The 01/05/2017

How to reset your password on Mysql 5.7 after installation?

When installing its mysql 5.7 database, mysql create a user with a temporary password. You can retrieve its password at the end of the logs:

2017-01-04T21:19:27.581996Z 1 [Note] A temporary password is generated for root@localhost: R1qrG:dnarxk

Then connect with:

root@3b40abb8e364:/var/lib/mysql# mysql -u root -pR1qrG:dnarxk 
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
You have a mistake! In fact it is necessary to restart the server to avoid this error:

root@3b40abb8e364:/var/lib/mysql# service mysql restart
 * Stopping MySQL database server mysqld
 * Starting MySQL database server mysqld
No directory, logging in with HOME=/

You can then log in:

root@3b40abb8e364:/var/lib/mysql# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.

and it works ! And redefine the user's password like this:

ALTER USER 'root'@'localhost' IDENTIFIED BY 'pfaymdp';

I can now log in with my credentials: root / pfaymdp
Comments on this article
No comments yet for this article. Be the first !

You must be logged in to comment an article.