How to Reset the MySQL Root Password

Leave reply

mysqlThis tutorial will show you how to reset your MySQL root password on your VPS in case you forgot it.

 

 

1.Login as root via ssh and stop the mysql server.

debian-ubuntu#  /etc/init.d/mysql stop
centos-fedora#  /etc/init.d/mysqld stop

2. Start the MySQL server with “skip-grant-tables” option.

# mysqld_safe --skip-grant-tables &

This will disable the MySQL authentication and run the process in the background.

3. Login to MySQL as root.

# mysql -u root mysql

4. Reset the MySQL password.

UPDATE user SET Password=PASSWORD('NEW_PASSWORD') WHERE User='root';
FLUSH PRIVILEGES;
exit;

Replace NEW_PASSWORD with your new password!

5. After the password has been reset, start the MySQL server in normal mode.

debian-ubuntu#  /etc/init.d/mysql restart
centos-fedora#  /etc/init.d/mysqld restart

Now you can connect to MySQL as a root user using the new password.

Type “mysql -u root -p” in the terminal, and enter the password when prompted.

PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.

 


50% OFF Coupon

EXCLUSIVE EMAIL UPDATES AND “MEMBERS-ONLY” CONTENT


Leave a Reply