mysql reset root user password Linux

Strongly recommended book
Hi Guys,

Well there are a couple of ways you can do this but I am going to highlight what I use.

This sort of stuff is rarely used so this post will end up being my reference as well.

Alright lets reset your mySQL Root user password.

Steps

  1. Login to your *IX server as super administrator, normally called “root”
  2. Now stop your mySQL server.
    I am using RedHat Linux so command will be

    1. shell>  /etc/init.d/mysqld stop
  3. No start your server in safe mode with –skip-grant-tables option as shown below
    1. shell>  mysqld_safe --skip-grant-tables

    The reason why we used –skip-grant-tables is because your passwords are stored in Grant tables so no need to load them

  4.  Now with another Terminal window open login to your mySQL database using the command below
    1. shell>  mysql -uroot mysql

    We are connecting to the mysql database here where your mysql users and their credential lives.

  5. Now that you are in Run these commands
    1. mysql>  update user set Password=PASSWORD('YOUR_NEW_PASSWORD') where user='root';
    2. mysql>  FLUSH PRIVILEGES;
  6. Now exit from your mysql shell
    1. mysql>  exit;
    2. shell>  
  7. Now stop your mysql server again (step 2).
  8. Start your mysql server
    1. shell>  /etc/init.d/mysqld start
  9. Your password is reset now. Test it by logging into your mysql  server using mysql client as below
    1. shell>  mysql -uroot -p
    2. Enter Password: ENTER YOUR NEW PASSWORD HERE
  10. You should be able to login with your new password.

 

 

I hope this helps.

Cheers

VN:F [1.9.22_1171]
Rating: 0.0/5 (0 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

Speak Your Mind

*

CommentLuv badge