[Resolved] resetting mysql server password

Hello, If you maybe forget your root MySQL server password, do not panic it can be flushed and then reset very easily

  1. Stop the current MySQL server instance, then restart it with an option to not ask for a password.
    1
    2
     sudo /etc/init.d/mysqld stop
     sudo mysqld_safe --skip-grant-tables &
    
  2. Reconnect to the MySQL server with the MySQL root account.
    1
     mysql -u root
    
  3. Use the following commands to reset root’s password. Replace password with a strong password.
    1
    2
    3
    4
     use mysql;
     update user SET PASSWORD=PASSWORD("yorsnewpassword") WHERE USER='root';
     flush privileges
     exit
    
  4. Then restart MySQL.
    1
     sudo service mysqld restart
    

You’ll now be able to log in again using mysql -u root -p.

 

proved to be very easy? I hope this helps 😀

Be Sociable, Share!

Leave a Reply

Your email address will not be published. Required fields are marked *