Wednesday, September 12, 2007

MySQL : root password reset

Here's what you need to do in case you forget the root user password of mysql.

# stop mysql service
/etc/init.d/mysql stop

# Start to MySQL server w/o password
mysqld_safe --skip-grant-tables &

# Connect to mysql server using mysql client
mysql -u root

# Setup new MySQL root user password
mysql> use mysql;
mysql> update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root';
mysql> flush privileges;
mysql> quit

# Stop MySQL Server
/etc/init.d/mysql stop

# Start MySQL server and test it
/etc/init.d/mysql start
mysql -u root -h localhost -p

1 comment:

Ketan said...

Glad to know you found the post useful !

Ketan