Get your server issues fixed by our experts for a price starting at just 25 USD/Hour. Click here to register and open a ticket with us now!

Author Topic: Resetting a forgotten MySQL root password in Linux  (Read 4639 times)

0 Members and 1 Guest are viewing this topic.

akhilt

  • Guest
Resetting a forgotten MySQL root password in Linux
« on: September 08, 2018, 10:27:29 am »
Resetting a forgotten MySQL root password in Linux

If you forgot MySQL root password, it can be recovered by booting the database in failsafe mode and then reset it.

To reset the root password for MySQL, follow these steps:

   1. Log in to your account using SSH.

   2. Stop the MySQL server using the appropriate command for your Linux distribution:

For CentOS and Fedora, type:

Code: [Select]
service mysqld stop
For Debian and Ubuntu, type:

Code: [Select]
service mysql stop

   3. Restart the MySQL server with the —skip-grant-tables option. To do this, type the following command:

Code: [Select]
mysqld_safe --skip-grant-tables &

   4. Log into MySQL using the following command:

Code: [Select]
mysql
   5. At the mysql> prompt, reset the password. To do this, type the following command, replacing NEW-PASSWORD with the new root password:
Code: [Select]
UPDATE mysql.user SET Password=PASSWORD('NEW-PASSWORD') WHERE User='root';
   6. At the mysql> prompt, type the following commands:

Code: [Select]
FLUSH PRIVILEGES;
exit;

   7. 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:

Code: [Select]
mysqladmin -u root -p shutdown
   8. Start the MySQL server normally. To do this, type the appropriate command for your Linux distribution:

For CentOS and Fedora, type:

Code: [Select]
service mysqld start
For Debian and Ubuntu, type:

Code: [Select]
service mysql start

Hoping you find the article useful, Thank you!! ;D