Mysql default root password on Centos7

After you install Mysql community server on “Centos7” machine using yum, you might get the “access denied” error if you try to login to mysql with empty root password. 

See below

Unlike earlier versions, here mysql set a default password while starting it for first time.The new password will be printed in the logs also. Let us see how to recover mysql default root password  .

To recover the mysql root password, check the mysql logs. On a Centos machine you can find it at “/var/log/mysqld.log” by default. You will find a line similar to this, in the logs

As you can see in the logs, it set a temporary password which is “cUgI:,Ve;6qd”

Now we can login to mysql with mysql default root password  password

 

But mysql wont allow you to run any commands without reseting the temporary password. Now we have to reset the temporary password.

Now we reset the password for mysql root user. You can exit from the console and login again with new password.

As always, feel free to drop us a note if you have any queries or feedbacks using our comment form below. Always happy to help you 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *