更新:在V8.0.15(可能是这个版本)上,password()函数不起作用
你必须:
-
请确保已先停止mysql。
-
以安全模式运行服务器,并绕过权限:
sudo mysqld_safe --skip-grant-tables
-
登录:
mysql -u root
-
MySQL>
UPDATE mysql.user SET authentication_string=null WHERE User='root';
-
FLUSH PRIVILEGES;
-
MySQL>
exit;
-
然后再次登录:
mysql-u根
8个。MySQL>
ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'yourpasswd';
快乐:)!