Man*_*iff 14 mysql passwords root
我实际上丢失了我的root密码,我需要更改它.我按照以下步骤操作:
步骤#1:停止MySQL服务器进程.
步骤#2:使用--skip-grant-tables选项启动MySQL(mysqld)服务器/守护程序进程,以便它不会提示输入密码.
步骤#3:以root用户身份连接MySQL服务器.
我们可以在这些网站上找到: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
Run Code Online (Sandbox Code Playgroud)
第一个错误,所以我试过:
mysql> use mysql;
mysql> update user set password=PASSWORD("TOOR") where User='root';
mysql> flush privileges;
mysql> quit
Run Code Online (Sandbox Code Playgroud)
总是同样的错误说:
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
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个问题?
小智 28
因为在这里说:
在MySQL 8.0.11中删除了此功能
1.如果你
在mysqld_safe 中的skip-grant-tables模式:
UPDATE mysql.user SET authentication_string=null WHERE User='root';
FLUSH PRIVILEGES;
exit;
Run Code Online (Sandbox Code Playgroud)
然后,在终端:
mysql -u root
Run Code Online (Sandbox Code Playgroud)
在mysql中:
ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'yourpasswd';
Run Code Online (Sandbox Code Playgroud)
2.不在mysql中的skip-grant-tables模式
:
ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'yourpasswd';
Run Code Online (Sandbox Code Playgroud)
小智 22
用sudo登录mysql
Sudo mysql
Run Code Online (Sandbox Code Playgroud)
然后
ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'yourpasswd';
exit;
Run Code Online (Sandbox Code Playgroud)
测试一下
mysql -u root -p
Run Code Online (Sandbox Code Playgroud)
小智 6
尝试这个:
ALTER USER 'root'@'localhost' IDENTIFIED BY 'newPasswd';
Run Code Online (Sandbox Code Playgroud)
如果您使用的是 Windows,您可以尝试以下步骤
MySQL 8.0从服务中停止服务cmdmysqld --console --skip-grant-tables --shared-memorycmd在同一路径下打开新的mysql -u rootselect authentication_string,host from mysql.user where user='root';UPDATE mysql.user SET authentication_string='' WHERE user='root';cmd.在https://gist.github.com/pishangujeniya/0f839d11a7e692dadc49821c274a2394找到这个
| 归档时间: |
|
| 查看次数: |
20438 次 |
| 最近记录: |