Saturday, September 01, 2012

Reset MySQL's root Password

Here's how to reset the root's password of MySQL:

Step 1) Stop MySQL: /etc/init.d/mysql stop
Step 2) Start mysqld skipping grant tables: mysqld --skip-grant-tables
Step 3) Start mysql client with root user: mysql -u root
Step 4) Now you're logged in at MySQL as root, run this to set a new password for root:
UPDATE mysql.user SET PASSWORD=PASSWORD('newpassword') WHERE User='root';
FLUSH PRIVILEGES;
quit;
Step 5) Stop MySQL: /etc/init.d/mysql stop
Step 6) Start MySQL: /etc/init.d/mysql start

That's it, you've reseted root's password of your MySQL server!