Hızlı yanıt: kod örneği
stackoverflow.com what-is-the-default-root-pasword-for-mysql-5-7
There's so many answers out there saying to reinstall mysql or use some combo ofand / orand / or something else ...... None of it was working for meHere's what worked for me, on Ubuntu 18.04, from the topWith special credit to this answer for digging me out of the frustration on this ...Note the lines which read:Then:Either:Or:Then:
mysqld_safe --skip-grant-tables
UPDATE mysql.user SET Password=PASSWORD('password')
$ sudo apt install mysql-server$ sudo cat /etc/mysql/debian.cnf
user = debian-sys-maintpassword = blahblahblah
$ mysql -u debian-sys-maint -pEnter password: // type 'blahblahblah', ie. password from debian.cnfmysql> USE mysqlmysql> 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
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';
// For MySQL 5.7+UPDATE mysql.user SET authentication_string=PASSWORD('new_password') where user='root';
mysql> FLUSH PRIVILEGES;mysql> COMMIT; // When you don't have auto-commit switched onmysql> EXIT$ sudo service mysql restart$ mysql -u root -pEnter password: // Yay! 'new_password' now works!