Reset default MySQL root pass in Centos 7

This post is mainly for my own benefit since I lost track of the steps I followed to change the mysql default password in a Centos 7 environment.

I am going to assume that you can use yum to install the mysql-community sever just fine.

The default root password is actually stored in the mysql log.

Follow the steps below:

[abasu@localhost Documents]$ grep root@localhost /var/log/mysqld.log
2018-01-16T02:56:47.029538Z 1 [Note] A temporary password is generated for root@localhost: C9*=ntep#SPk
[abasu@localhost Documents]$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 5.7.21

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

mysql> alter user ‘root’@’localhost’ identified by ‘Passw0rd!’;
Query OK, 0 rows affected (0.10 sec)


 1,485 total views,  1 views today