mysql 修改密码

一、以下是Windows操作系统的操作步骤:

1. 关闭正在运行的MySQL服务-->net stop mysql

2. 打开DOS窗口,转到mysqlin目录。

3. 输入mysqld --console --skip-grant-tables --shared-memory 回车。--skip-grant-tables 的意思是启动MySQL服务的时候跳过权限表认证,注意skip前面是两个“-” ,此时DOS窗口无法输入

4. 再开一个DOS窗口,转到mysqlin目录。

5. 输入mysql回车,如果成功,将出现MySQL提示符 >。

6. 连接权限数据库: use mysql; 。

7. 改密码:

update mysql.user set authentication_string=("root") where user='root';

出现如下信息表示修改成功;

mysql> update mysql.user set authentication_string='root' where user='root';
Query OK, 1 row affected (0.52 sec)
Rows matched: 1 Changed: 1 Warnings: 0

8. 刷新权限(必须步骤):flush privileges; 

---修改密码MySQL版本大于8.0时候(错误号码2059 )

将用户的加密方式改为mysql_native_password。并修改密码

alter user 'root'@'localhost' identified with mysql_native_password by '1q2w3e';      -

原文地址:https://www.cnblogs.com/-hao/p/11099852.html