How To Reset Root Password MySQL Server

Reset Root Password MySQL Server

In this tutorial, we will show you how to reset the root password MySQL server. By default, the MySQL server will be installed with the root account and the password is blank. Have you ever forgotten the root password on one of your MySQL servers? If you have set the password for root and forget it, then you will need to reset the root password for MySQL. To reset your MySQL password just follow these instructions and we assume that you already have a small amount of knowledge of MySQL.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The reset password MySQL is quite simple. I will show you through the step-by-step reset root password MySQL server.

Prerequisites

  • A server running one of the following operating systems: Ubuntu or CentOS Linux.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • A non-root sudo useror access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Reset Root Password MySQL Server

Step 1. The first thing to do is stop MySQL.

### CentOS 6 ###
sudo service mysqld stop

### CentOS 7 ###
sudo systemctl stop mysqld

Step 2. Next, we need to start MySQL in safe mode with the --skip-grant-tables option so that it will not prompt for a password.

mysqld_safe --skip-grant-tables &

Step 3. Start the MySQL client process using this command with a root account and a blank password.

mysql -u root

 Step 4. Change the password for the root account.

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

 Step 5. Restart MySQL.

Once complete, you can restart MySQL is installed by running the below command:

### CentOS 6 ###
service mysqld restart

### CentOS 7 ###
systemctl restart mysqld

Congratulations! You have successfully reset your password MySQL. Thanks for using this tutorial to reset the root password MySQL on the Linux system. For additional help or useful information, we recommend you check the official MySQL website.

MySQL Fix Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “MySQL Fix”, starting from $10 (Paypal payment). Please contact us to get a best deal!

Save