Mysql
 SQL >> Datenbank >  >> RDS >> Mysql

Was ist das Standard-Root-Passwort für MySQL 5.7?

Es gibt unzählige Antworten, die dir raten, MySQL neu zu installieren oder irgendeine Kombination aus

mysqld_safe --skip-grant-tables 

und/oder

UPDATE mysql.user SET Password=PASSWORD('password') 

und/oder irgendetwas ganz anderem zu probieren...

...nichts davon hat bei mir funktioniert.

Hier ist, was auf Ubuntu 18.04 schließlich geklappt hat, von Anfang an.

Besonderer Dank an diese Antwort, die mich aus dem Frust geholt hat...

$ sudo apt install mysql-server $ sudo cat /etc/mysql/debian.cnf 

Beachte die Zeilen:

user = debian-sys-maint password = blahblahblah 

Dann:

$ mysql -u debian-sys-maint -p Enter password: // type 'blahblahblah', ie. password from debian.cnf mysql> USE mysql mysql> SELECT User, Host, plugin FROM mysql.user; +------------------+-----------+-----------------------+ | User | Host | plugin | +------------------+-----------+-----------------------+ | root | localhost | auth_socket | | mysql.session | localhost | mysql_native_password | | mysql.sys | localhost | mysql_native_password | | debian-sys-maint | localhost | mysql_native_password | +------------------+-----------+-----------------------+ 4 rows in set (0.00 sec) mysql> UPDATE user SET plugin='mysql_native_password' WHERE User='root'; mysql> COMMIT; // When you don't have auto-commit switched on 

Entweder:

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password'; 

Oder:

// For MySQL 5.7+ UPDATE mysql.user SET authentication_string=PASSWORD('new_password') where user='root'; 

Dann:

mysql> FLUSH PRIVILEGES; mysql> COMMIT; // When you don't have auto-commit switched on mysql> EXIT $ sudo service mysql restart $ mysql -u root -p Enter password: // Yay! 'new_password' now works!