<img src="https://letscodepare.com/assets/blog/how-to-reset-mysql-57-root-password-in-centos-or-ubuntu/banner.png" alt="How to reset MySQL
5.7 root password on Centos or Ubuntu” />
Forgot your MySQL root password? (I know, I know 😂😂😂 it’s a secret.)
If you do, and
trying to figure out how to do it, then you’re on the right track, my friend
Let’s get started and let’s code stop
if you’re doing this on your live server
with a live user, congratulations you’re a PRO developer. If you ever have no choice, make sure to change it late at night or when there isn’t much traffic on your server. 😂 😂 😂
The first thing we need to do is log in to your server and stop the MySQL service
. If you are logged in as root, type this code
in case you are not a root user but have privileges as root, just add sudo to the beginning of the command.
Once you run
, You will stop your MySQL services and no one will be able to connect to your database temporarily.
( Be sure to notify your co-developer and the other teams involved or else you will receive a new ticket error 😂)
We need to start our mysql in a safe mode. What does mysqld_safe command mean?
is the recommended way to start a mysqld server on Unix. mysqld_safe adds some security features, such as restarting the server when an error occurs and logging run-time information in an error log. A description of the error log is provided later in this section.
Run this code then when running mysqld_safe with -skip-grant-tables allows anyone to connect without a password and with full privileges. Along with the “&” symbol to run the command in the background.
We’re almost there stop, just keep going
Log in to our mysql When you run this command, you should see the mysql monitor welcome screen.
In this step, we will change the password of your mysql root user.
Type this code, to
use the mysql table and press enter
code to change your root password is the following command. Make sure to change “EnterYourSuperCoolPasswordHere” before running it.
Please note that the authentication_string is for mysql 5.7 higher version… In case you have a lower version of MySQL, you can use the password column instead.
Reload the grant tables to take effect
using the following command. Then exit the mysql
Start your mysql
AND log in to your mysql as root user with your new password
If everything works, you will see a welcome message on the command screen of the mysql monitor.
1). Access denied; you need (at least one of) SHOW DATABASES privileges for this operation.
SOLUTION: Log in as root mysql and then type this command:
2). mysqld_safe directory ‘/var/run/mysqld’ for the UNIX socket file does not exist.
SOLUTION: Then try stopping
or starting mysql again
3) ERROR 1524 (HY000): The plugin ‘auth_socket’ is not loaded. Basically, we need to reconfigure the authorization plugin on mysql_native_password.
Log in as root mysql and then type this command:4) ERROR 1054 (42S22): Unknown column ‘password’ in ‘field list’RESOLUTION:
It means that you are using a low version of code for mysql 5.6 below. The password column was removed from previous MySQL 5.7, As I mentioned in the previous tutorial, you should use authentication_string
I hope to help you solve your problem. Let me know in case you find a different error.
Explore our security tips for the server and security process
. 👊 👊 👊
Explore our security tips for server security and
the Voila process!!!
I hope you enjoy our tutorial, let me know in case you find any bugs, I’d love to answer that. Don’t forget to subscribe to my Youtube channel at Let’s Code Pare – Youtube Channel