This article describes how to reset the MySQL root password. You may need to do this, for example, if you have forgotten the password.
To reset the root password for MySQL, follow these steps:
service mysqld stop
For Debian and Ubuntu, type:
service mysql stop
Restart the MySQL server with the —skip-grant-tables option. To do this, type the following command:
mysqld_safe --skip-grant-tables &
Log into MySQL using the following command:
mysql
At the mysql> prompt, reset the password. To do this, type the following command, replacing new-password with the new root password:
UPDATE mysql.user SET Password=PASSWORD('new-password') WHERE User='root';
At the mysql> prompt, type the following commands:
FLUSH PRIVILEGES; exit;
Stop the MySQL server using the following command. You will be prompted to enter the new MySQL root password before the MySQL server shuts down:
mysqladmin -u root -p shutdown
Start the MySQL server normally. To do this, type the appropriate command for your Linux distribution:
service mysqld start
For Debian and Ubuntu, type:
service mysql start
Subscribe to receive weekly cutting edge tips, strategies, and news you need to grow your web business.
No charge. Unsubscribe anytime.
Did you find this article helpful? Then you'll love our support. Experience the A2 Hosting difference today and get a pre-secured, pre-optimized website. Check out our web hosting plans today.
We use cookies to personalize the website for you and to analyze the use of our website. You consent to this by clicking on "I consent" or by continuing your use of this website. Further information about cookies can be found in our Privacy Policy.