我实际上丢失了 root 密码,我需要更改它。我按照以下步骤操作:
我们可以在这些网站上找到:https://www.howtoforge.com/setting-changing-resetting-mysql-root-passwords#recover-mysql-root-password https://www.howtoforge.com/setting-changing-resetting-mysql-root-passwords#recover-mysql-root-password
mysql> use mysql;
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD("TOOR");
mysql> flush privileges;
mysql> quit
第一个错误,所以我尝试:
mysql> use mysql;
mysql> update user set password=PASSWORD("TOOR") where User='root';
mysql> flush privileges;
mysql> quit
总是同样的错误说:
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near '("TOO
R") WHERE User='root'' at line 1
我该如何解决这个问题?
as here https://dev.mysql.com/doc/refman/8.0/en/encryption-functions.html#function_password says:
该函数在 MySQL 8.0.11 中被删除
1.如果您处于skip-grant-tables模式
在 mysqld_safe 中:
UPDATE mysql.user SET authentication_string=null WHERE User='root';
FLUSH PRIVILEGES;
exit;
然后,在终端中:
mysql -u root
在mysql中:
ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'yourpasswd';
2.不在skip-grant-tables模式下
就在mysql中:
ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'yourpasswd';
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)