For MySQL 5.7.6 and newer, use the following command in the MySQL command prompt.
For MySQL 5.7.5 and older users in the MySQL command prompt:
Restart the MySQL Server
If you would like to reset the password for the root user's MySQL password, this guide will help you through that process.
Reset MySQL Password
Stop the MySQL Server
You will want to have the correct version before continuing with this guide and can get it using this command:
Before continuing with the following, you will want to know that these steps are intended to be run by the root user using su or sudo commands. Logging in as your root user is not recommended.
To change the MySQL password, you will need first to stop the MySQL service.
service mysql stop
If you know your password, you can change it using the MySQL command line with the following for the root user in this example
mysql -u root -p
Replace the new_password above with your new password.
By running MySQL without loading any information about the user privileges, you can access the command line without using root privileges which would require a password. You can do this by not allowing the database to load the grant tables. You'll also want to skip networking to avoid any security risks.
It is important to note that using --skip-networking below is very insecure and should only be run while resetting the root user's password if you have forgotten it.
Start the MySQL command prompt using this command: