In case of MySQL database server, if you type a wrong password, you may come across an error as shown:


So if you want to reset the password then follow these steps

Firstly you need to stop MySQL server process. Use the following command:

/etc/init.d/mysql stop

In case if you get an error like,


Then you have to stop the MySQL service and then try the above command.

sudo service mysql stop

/etc/init.d/mysql stop


Start the MySQL (mysqld) server/daemon process without prompting for password.

mysqld_safe –skip-grant-tables &


If you get the error:


Then try this command,

mysql -u root mysql

Now you can change the password by using the below command in mysql prompt.

update user set Password=PASSWORD(‘newpswd’) WHERE User=’root’;
Note: change/replace ‘newpswd’ with your New Root Password.

Type exit and logout from the mysql prompt.

Now bring back the running mysql instance into the foreground by typing:
fg and then press (Ctrl + C) to kill the mysql process.

Restart the mysql server
sudo /etc/init.d/mysql start


Else you can proceed with the below steps,

To Connect to mysql server using mysql client:

mysql -u root

Setup new MySQL root user password in the mysql prompt:

use mysql;

update user set password=PASSWORD(“newpswd “) where User=’root’;

flush privileges;


To Stop MySQL Server use the following commands:

/etc/init.d/mysql stop

Start MySQL service and server and test it

sudo service mysql start

/etc/init.d/mysql start

Again you can login to your MySQL using your new password:

mysql -u root –p



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s