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'

 

  •  
  • 150 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...

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...

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...

Change permissions using find command

On a Linux server, if you are in need of changing the permissions of a bulk amount of files or...

Change the time of your vps/dedi

It's very easy, you first need to remove the current time file rm /etc/localtime and replace it...