如何在MySQL 8.0.11中重置root密码? [英] How to reset the root password in MySQL 8.0.11?

查看:505
本文介绍了如何在MySQL 8.0.11中重置root密码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我实际上已经丢失了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.

:

第一个错误,所以我尝试了:

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

我该如何解决?

推荐答案

这里说:

此功能已在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密码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆