Home Linux How to change the root mySql password with mySql installed on Ubuntu/Linux?
 
 
 

How to change the root mySql password with mySql installed on Ubuntu/Linux?

PDF Print E-mail

Question: How to change the root mySql password with mySql installed on Ubuntu/Linux?

 

Solution 1: 

  1. Open a new Terminal Window. 
  2. Type in the commands below.
    mysqladmin -u root OLDPASSWORD NEWPASSWORD
  3. 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)'
  4. If you did not get the error above restart the mySql server by typing the following command:
    sudo service mysql restart


Solution 2:

  1. If Solution 1 did not work, this should work. 
  2. mySql stores usernames together with their passwords in the user table in the mySql database.
  3. Open a new Terminal Window and type in the command below to Login to the mySql server.
    mysql -u root -p
  4. Enter your password.
  5. Now you need to switch to the mysql database. Type the command below
    mysql> use mysql;
  6. Now we need to change the password. Type in the following command:
    mysql> update user set password=PASSWORD("NEW_PASSWORD") where User='USERNAME';
     
  7. Flush the privileges (Reloading them) using command below:
    mysql> flush privileges;
     
  8. Exit mySql
    mysql>quit

+/-
+/- Write comment
Your Contact Details:
Comment:
[b] [i] [u] [url] [quote] [code] [img]   
Security Please input the anti-spam code that you can read in the image.
 

Go Daddy $7.49 .com Sale!