How to change your mysql root user password?
Aspirant Programmer

How can we update mysql root user password in command line using putty or command shell?

  • Total 1 Answer
  • 368
Can You answer this question?
Aspirant Programmer

To update the mysql root user password you will need to follow below steps and it will be updated without any problem.

1- First stop the mysql server 

sudo /etc/init.d/mysql stop

2- Now run command to start mysqld configuration

sudo mysqld --skip-grant-tables &  

Don't forget & sign at the end

In some cases you will need to create /var/run/mysqld  first

sudo mkdir -v /var/run/mysqld && sudo chown mysql /var/run/mysqld

3- Start mysql service

sudo service mysql start

4- Login to mysql as a root user

mysql -u root mysql

5- Run below commands

UPDATE mysql.user SET Password = PASSWORD('yourpassword') WHERE User = 'root';

In some cases you will get 'password' unknown column then try below:

UPDATE user SET authentication_string=password('yourpassword') WHERE user='root';


After going through all the above steps root user's password will get updated and you can test by login to mysql as root user with the updated password.