17.07.2005
Forgot MySQL Root Password ?
How many times it happened to you to forget root password for MySQL server ? Never !? Well, count your self lucky :)
Anyway, here is pretty good way to reset root password without a hasle of reinstalling of MySQL. Of course, I assume you have root privileges on your *nix os, this won’t work without it.
If MySQL server is up, let’s put it down:
/etc/rc.d/mysql stop
Then put it up in following way:
/usr/bin/mysqld_safe --skip-grant-tables &
–skip-grant-tables is crucial here. It turn off privileges system, so everyone is able to connect to your system, without password. Now, start your mysql client and set new root password:
# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 44 to server version: 4.0.15
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> use mysql;
Database changed
mysql>update user set password = password('novirootivpass') where user = 'root';
mysql>flush privileges;
Now, kill your mysql server by using mysql shutdown command, and then start it up with usual init script, usually something like: /etc/rc.d/mysql start.
