Reset MySQL root password

Here are the steps to reset the MySQL root password from the server command line:

Log in to the server via  command line as 'root' user and run the following commands:

  1. Stop the currently running MySQL process:

    #/etc/init.d/mysql stop
  2. Now start the MySQL process with the –skip-grant-tables option so that it will not prompt for the password:

    #mysqld_safe --skip-grant-tables &
  3. Once done, log in as root user without password using the following command:

    #mysql -u root
  4. Once logged in, set a new root password:

    #mysql> use mysql;
    #mysql> update user set password=PASSWORD("NEW PASSWORD") where User='root';
    #flush privileges;

    Need to replace "NEW PASSWORD" with the new password.
  5. Exit from MySQL and then restart the service:

    #service mysql stop
    #service mysql start
  6. Try to login using the new password:

    #mysql -u root -p'NEW-PASSWORD'


  • mysql root, reset mysql root password
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How To Install and Use Docker on Ubuntu 16.04

Introduction Docker is an application that makes it simple and easy to run application processes...

Adding Server Credentials from Client Area

The exchange of passwords in plain text format is not at all a safer way nowadays.  In case if we...

Backup and Restore cPanel Accounts via SSH

a. How to create a backup of a cPanel Account via SSH?   1. Log-in to the SSH as the Root user....

Change Main IP of the server :: Vesta Panel

If we are changing the main IP of a server installed with Vesta panel, we can use the following...

cPanel: Apache-FastCGI Data Timeout Error

If you are using a cPanel server and have FastCGI enabled in Apache, you might be facing the...