MySQL password generator

You can easily generate the MySQL password.





Step 1: Finding MySQL Version

Find out the version of MySQL database server you’re running by running the commands below:

mysql --version

When you run the commands above, it will show you the version of MySQL installed…

mysql Ver 14.14 Distrib 5.7.22

Take notes of the version of either database you’re running… You will need it below.

Step 2: Reset User Password

Now that you know the version of the database server you running, run the commands below to logon to the database…

sudo mysql -u root -p

Type in the root password and logon..

Then type the following commands if you are running MySQL 5.7.6 and later to reset or change a user password:

ALTER USER 'username'@'localhost' IDENTIFIED BY 'NEWPASSWORD';
FLUSH PRIVILEGES;

Replace username and NEWPASSWORD with the username and new password you want to use for the user…

If the ALTER statement doesn’t work, you can run the commands below to change it…

UPDATE mysql.user SET authentication_string = PASSWORD('NEWPASSWORD')
WHERE User = 'username' AND Host = 'localhost';
FLUSH PRIVILEGES;
exit;

Exit and that should do it.

For MySQL 5.7.5 and earlier, use the commands below to change the user password

SET PASSWORD FOR 'username'@'localhost' = PASSWORD('NEWPASSWORD');
FLUSH PRIVILEGES;
exit;

Close out and you’re done.

If the commands were executed successfully, you should get a Query OK responses..

That should do it for you…

Congratulations! You have successfully change MySQL user password… This should apply to all modern Linux systems running the databases mentioned above…