Menu Close

MySQL 5.7 auto-generated root password

Hi There.

You may have noticed something different when you install a fresh copy of MySQL 5.7 either via yum or using binary source. The root password is auto-generated.
Ok and where can I find it ?

Centos
cat /var/log/mysqld.log | grep "A temporary password is generated for" | awk '{print $NF}'
Example:

[root@master ~]# cat /var/log/mysqld.log | grep "A temporary password is generated for" | awk '{print $NF}'
a3BGf#TY.pBj

Binary distribution
Once you initialization the datadir mysqld --initialize you will see the bellow log printed on screen:

. . .
2016-01-13T21:05:03.070322Z 1 [Note] A temporary password is generated for root@localhost: vL8n>Hs%kr>s
. . .

You will be required to change the password on the first login. You can do it following step 2 of this article.

That’s it.
Now you guys know how to find the auto generated root password for MySQL 5.7.

See you next time.

Liked? Help and Share!