Published December 22, 2017 by

Reset MySQL root password

Step 1: Stop mysql service

# service mysqld stop                             (Centos or Fedora)

#service mysql stop                               (Ubuntu or Debian)

Step 2:


Restart the MySQL server with the —skip-grant-tables option. Using the following command:


# mysqld_safe --skip-grant-tables &

Step 3:

Log into MySQL using the following command:

mysql

Step 4:

At the mysql> prompt, reset the password. Using following command, replacing NEW-PASSWORD with the new root password:

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

Step 5:

Type following command:

FLUSH PRIVILEGES;

exit;

Step 6: Stop mysql server

# mysqladmin -u root -p shutdown

Step 7: Start mysql service


# service mysqld start                             (Centos or Fedora)

# service mysql start                               (Ubuntu or Debian)