MySQL 8.0 重置root密码_如何在MySQL 8.0.11中重置root密码?

bd96500e110b49cbb3cd949968f18be7.png

I have actually lost my root password and I need to change it. I follow these steps :

Step # 1: Stop the MySQL server process.

Step # 2: Start the MySQL (mysqld) server/daemon process with the

--skip-grant-tables option so that it will not prompt for a password.

Step # 3: Connect to the MySQL server as the root user.

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

Always the same error said :

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 here says:

This function was removed in MySQL 8.0.11

1.if you in skip-grant-tables mode

in mysqld_safe:

UPDATE mysql.user SET authentication_string=null WHERE User='root';

FLUSH PRIVILEGES;

exit;

and then, in terminal:

mysql -u root

in mysql:

ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'yourpasswd';

2.not in skip-grant-tables mode

just in mysql:

ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'yourpasswd';

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值