Você está na página 1de 1

linux - What is the default root pasword for My... https://stackoverflow.com/questions/33991228/...

What is the default root pasword for MySQL 5.7 Ask Question

Cannot login to MySQL database after fresh install with root ID and empty/no password like other older MySQL versions do

mysql linux passwords password-recovery mysql-5.7

asked Nov 30 '15 at 3:57


Ryan
1,204 2 14 23

root no longer has one because it does not use one. By default the auth method is auth socket. use sudo to access with root access, change the auth method to password and
set a password if you need a root lmysql oogin without root system access. – G.Martin Nov 13 '16 at 3:50

1 @G.Martin would you mind expanding this comment into an answer with more detailed steps? I think this is the solution I want to use but don't know how to change the auth
method. ( sudo mysql -u root does work for me - I want to change it so I can just do mysql -u root with no password) – Max Williams Dec 7 '16 at 13:08

Sorry You probably already figured this out but I found out my post only applies to debian distros. If its still an issue (doubt it) I can provide more detail. – G.Martin Jul 9 '17 at
21:37

3 Answers

After you installed MySQL-community-server 5.7 from fresh on linux, you will need to find the
temporary password from /var/log/mysqld.log to login as root.

1. grep 'temporary password' /var/log/mysqld.log


2. Run mysql_secure_installation to change new password

ref: http://dev.mysql.com/doc/refman/5.7/en/linux-installation-yum-repo.html

answered Nov 30 '15 at 3:57


Ryan
1,204 2 14 23

4 Thank you! Kind of crazy to find this information here instead of the MySQL 5.7 doc from Oracle. – maddin2code
Feb 9 '16 at 18:12

7 This saves my life... been searching for solution everywhere and this solves all my problem. Even the document
from mysql website didn't mention about this. This is crazy man. Thanks! – nodeffect Mar 11 '16 at 6:33

1 Where would you look on a Windows machine? – rotaercz Dec 11 '16 at 19:04

1 @rotaercz try following this guide? dev.mysql.com/doc/refman/5.7/en/resetting-permissions.html – Ryan Dec 17


'16 at 8:11

7 /var/log/mysqld.log does not exist for me (mariadb on mint) – donquixote Mar 16 '17 at 18:06

In case you want to install mysql or percona unattended (like in my case ansible), you can use
following script:

# first part opens mysql log


# second part greps lines with temporary password
# third part picks last line (most recent one)
# last part removes all the line except the password
# the result goes into password variable

password=$(cat /var/log/mysqld.log | grep "A temporary password is generated for"


| tail -1 | sed -n 's/.*root@localhost: //p')

# setting new password, you can use $1 and run this script as a file and pass the
argument through the script

newPassword="wh@teverYouLikE"

# resetting temporary password

This site uses cookies to deliver our services and to show you relevant ads and job listings. By using our site, you acknowledge that you have read and understand our
Cookie Policy, Privacy Policy, and our Terms of Service. Your use of Stack Overflow’s Products and Services, including the Stack Overflow Network, is subject to these
policies and terms.

1 of 1 6/1/18, 5:09 AM