Monday, August 22, 2011

Reset MySQL root password

Forgot root-password database to MySQL? It does not matter. It can be easily restored.

Stop the service:

# /etc/init.d/mysql stop

and restart it manually with ignoring privileges:

# mysqld_safe –skip-grant-tables &

Now we can create a new password:

# mysql -u root 
   
mysql> use mysql; 
mysql> update user set password=PASSWORD(”new_password”) where User=’root’; 
mysql> flush privileges;
mysql> quit

And restart MySQL in normal mode:

# /etc/init.d/mysql restart

This is that what I did in my Mac OS.

in terminal:
cd /usr/local/mysql/bin/mysql

mysql> use mysql; 
mysql> update user set password=PASSWORD(”new_password”) where User=’root’; 

the end  

No comments:

Post a Comment