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

Discount on all Ukrainian domains until 10/21/2022!
14.10.2022
Discount on all Ukrainian domains until 10/21/2022!
Dear users! For a whole week -15% discount for registration of all Ukrainian domains using the promo code defendersday22!
Increase in price of a number of Ukrainian domains UA ccTLD!
28.09.2022
Increase in price of a number of Ukrainian domains UA ccTLD!
Dear users! From October 1, 2022, we are waiting for a rise in price in a number of Ukrainian domains - in.ua, od.ua, mk.ua!
Important changes in some Ukrainian domains!
09.03.2022
Important changes in some Ukrainian domains!
Dear users! In some Ukrainian domain zones, the Redemption period for domains has been increased from 30 to 60 days.
Rise in price of dedicated IPv4 in Germany!
09.08.2021
Rise in price of dedicated IPv4 in Germany!
Dear users! In Germany, additional dedicated IP addresses (IPv4) and IP networks have risen significantly.

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.