管理员用户密码忘记了?

2019-07-18  本文已影响0人  蔺蔺蔺赫赫

          1 关闭数据库

            /etc/init.d/mysqld stop

            systemctl stop mysqld

          2 启动数据库到维护模式

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

          3 登录并修改密码  这时登录是不要密码的

            mysql  就可以直接启动

            mysql> alter user root@'localhost' identified by '1';

            ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement

            这时会报错  因为这个模式不支持 修改密码

          4 执行如下语句

            mysql> flush privileges;#刷新权限

            可以正常修改密码了 修改密码为数字1

            mysql> alter user root@'localhost' identified by '1';

            Query OK, 0 rows affected (0.01 sec)

          5.关闭数据库,正常启动验证

            mysql -uroot -p1

上一篇 下一篇

猜你喜欢

热点阅读