MySQL修改密码

管理员用户密码忘记了

--skip-grant-tables  #跳过授权表
--skip-networking    #跳过远程登录

1、关闭数据库

/etc/init.d/mysqld stop

2、 启动数据库到维护模式

mysqld_safe --skip-grant-tables --skip-networking &

3、登陆并修改密码

mysqld_safe --skip-grant-tables --skip-networking &

msyql -uroot -p   # 不需要输入密码 直接回车登陆

mysql> alter user root@'localhost' identified by '123';
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> alter user root@'localhost' identified by '123'; Query OK, 0 rows affected (0.01 sec)

4、关闭数据库,正常登陆验证

posted @ 2022-07-08 11:11  荔枝的汁  阅读(26)  评论(0编辑  收藏  举报