- Open a new Terminal Window.
- Type in the commands below.
-u root OLDPASSWORD NEWPASSWORD
- If you get the error below follow solution 2
mysqladmin: connect to server at 'localhost' failed error: 'Access denied for user 'root'@'localhost' (using password: YES)'
- If you did not get the error above restart the mySql server by typing the following command:
sudo service mysql restart
- If Solution 1 did not work, this should work.
- mySql stores usernames together with their passwords in the user table in the mySql database.
- Open a new Terminal Window and type in the command below to Login to the mySql server.
mysql -u root -p
- Enter your password.
- Now you need to switch to the mysql database. Type the command below
mysql> use mysql;
- Now we need to change the password. Type in the following command:
mysql> update user set password=PASSWORD("NEW_PASSWORD") where User='USERNAME';
- Flush the privileges (Reloading them) using command below:
mysql> flush privileges;
Exit mySql mysql>quit
Image Credits: Photo by Isis França on Unsplash.