27.06.2016

Reset MySQL root password on Linux

Reset MySQL root password on Linux

Sometimes it becomes necessary to restore the password of the MySQL database administrator (the root of a user or another superuser, for example, if the superuser is not root or root has been deleted) on a server running Linux. Below, we will take a step-by-step look at how to reset the MySQL admin password.

How to reset MySQL root password on Linux

1. Stop MySQL by running the command below:

/etc/init.d/mysql stop

2. We start the MySQL server with special parameters (without privilege checking):

/usr/bin/mysqld_safe --skip-grant-tables --user=root &

3. Run the MySQL client:

mysql -u root

4. Set a new password for the root user to execute this SQL query below:

mysql>UPDATE mysql.user SET Password=PASSWORD('password_for_root') WHERE User='root';
Where password_for_root - this is the new password for the root MySQL user.

5. After that, reset the privileges with the command:

mysql>FLUSH PRIVILEGES;

6. And exit the MySQL client:

mysql>\q

7. After that need to restart the MySQL server in normal mode by running the command:

/etc/init.d/mysql restart

These are all the steps necessary to reset the root password in MySQL. After that, you can use the new root password to connect.

Latest news

HostingHutor.com is now in Telegram: chat with support, bot, channel
04.05.2020
HostingHutor.com is now in Telegram: chat with support, bot, channel
Dear users! Now we are in Telegram! Support chat, bot for sending notifications from your personal account and channel.
Schedule and payment processing for the May day holidays
29.04.2020
Schedule and payment processing for the May day holidays
Dear users! Check out the schedule for processing bank transfers during the May day holidays.
Google Chrome will soon blocking insecure HTTP downloads
03.03.2020
Google Chrome will soon blocking insecure HTTP downloads
At first, Chrome will warn, but in future releases it will already block unsafe HTTP downloads.
Starting January 13, only the new IBAN bank account standard is valid!
13.01.2020
Starting January 13, only the new IBAN bank account standard is valid!
Starting today, the bank code and current account in Ukraine will replace the bank account number according to the IBAN standard.

Latest Blog Posts

New virus Coronavirus (COVID-19) and cyber fraud on the Internet
02.03.2020
New virus Coronavirus (COVID-19) and cyber fraud on the Internet
The panic surrounding the coronavirus COVID-19 is used by cyber fraudsters on the Internet - phishing, selling masks, vaccines and tests.
Mail is not sent - check if the internet provider is blocking port 25
11.01.2020
Mail is not sent - check if the internet provider is blocking port 25
How to check if provider is blocking port 25 using the command line in Windows. How to send mail if port 25 is blocked.
How to install Clam AntiVirus (ClamAV) on a VPS or server with CentOS
11.11.2019
How to install Clam AntiVirus (ClamAV) on a VPS or server with CentOS
Install Clam AntiVirus (ClamAV) on VPS / VDS or a dedicated server with CentOS OS and configure daily server scan.
ISPmanager no longer supports backup to Yandex.Disk
20.10.2019
ISPmanager no longer supports backup to Yandex.Disk
Within a week, Yandex.Disk will disappear from the list of backup storage in the ISPmanager panel and other ISPsystem products.

Popular domains