问题描述
我实际上丢失了我的 root 密码,我需要更改它.我遵循以下步骤:
I have actually lost my root password and I need to change it. I follow these steps :
第 1 步:停止 MySQL 服务器进程.
Step # 1: Stop the MySQL server process.
第 2 步:使用以下命令启动 MySQL (mysqld) 服务器/守护进程--skip-grant-tables 选项,这样它就不会提示输入密码.
Step # 2: Start the MySQL (mysqld) server/daemon process with the --skip-grant-tables option so that it will not prompt for a password.
第 3 步:以 root 用户身份连接到 MySQL 服务器.
Step # 3: Connect to the MySQL server as the root user.
我们可以在这些网站上找到:https://www.howtoforge.com/setting-changeing-resetting-mysql-root-passwords#recover-mysql-root-password
that we can found on these website : 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
第一个错误,所以我尝试了:
First error, so I tried :
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
我该如何解决这个问题?
How can I resolve this?
推荐答案
as 这里 说:
这个函数在 MySQL 8.0.11 中被移除了
This function was removed in MySQL 8.0.11
1.如果您处于跳过授权表模式
在 mysqld_safe 中:
1.if you in skip-grant-tables mode
in 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.不在跳过授权表模式
就在mysql中:
2.not in skip-grant-tables mode
just in mysql:
ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'yourpasswd';
这篇关于如何在 MySQL 8.0.11 中重置 root 密码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!