How to Reset Mysql Root Password on Linux Hosting Server

Mysql Database plays very important role in displaying the dynamic contents of your website. If you have forgotten the root password of your Mysql database, you can reset it very easily.

It is important to make sure that the current user and its password are limited to administrator use only. This is not the user or password you should use for everyday use.

Mysql Root Password Reset Steps using safe mode:

  1. Mysql safe mode is preferred to make system settings changes without using the root password. So lets Start up safe mode command and press enter twice.

sudo mysqld_safe --skip-grant-tables

  1. Next Login to mysql as a root user.

mysql -u root

  1. Select mysql database to make further changes.


use mysql;

  1. Now update the new password.


update user set password=PASSWORD(" new password") where


  1. Once update is done, you need to refresh the mysql user privileges.

flush privileges;

  1. Final step is to get exit from the mysql database.

Exit or \q

How to Start and Stop Mysql Service:

Since you have changed the mysql root password so now you need to stop the mysql and need to start it again and check whether new password is working or not.

service mysqld stop

service mysqld start

Make mysql connection again with your root user:

mysql -u root -p

It will ask to enter the password.

Once you enter the new password which you have been created it will take you to the mysql console.

Note:  If your sites or application that depends on MySQL to function, then it will stop working until you turn MySQL on.