xshell中数据库忘记密码后重新设置密码的解决办法!
2020-07-22 22:42
411 查看
数据库忘记密码后重新设置:
1.修改主配置文件,添加 skip-grant-tables,跳过授权表
vim /etc/my.cnf
[root@zhai ~]# vim /etc/my.cnf
[mysqld]
skip-grant-tables
如下图
2.重启mysqld
systemctl restart mysqld
[root@zhai ~]# systemctl restart mysqld
3.无需输入密码进入mysql,执行修改密码的命令,刷新并退出
mysql -u root -p
直接回车进入数据库,无需输入密码
mysql> use mysql;
mysql> update user set authentication_string=password(“123456”) where User=“root”;
mysql> flush privileges;
mysql> quit;
[root@zhai ~]# mysql -u root -pEnter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3 Server version: 5.7.17 MySQL Community Server (GPL) Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> use mysql; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> update user set authentication_string=password("123456") where User="root"; Query OK, 1 row affected, 1 warning (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 1 mysql> flush privileges; Query OK, 0 rows affected (0.00 sec) mysql> quit; Bye
4.恢复主配置文件,即进入 vim /etc/my.cnf,然后把skip-grant-tables注释掉,最后重启mysqld
systemctl restart mysqld![在这里插入图片描述](https://img-blog.csdnimg.cn/20200722223022258.PNG)
[root@zhai ~]# systemctl restart mysqld[root@zhai ~]# vim /etc/my.cnf[root@zhai ~]# mysql -u root -pEnter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3 Server version: 5.7.17 MySQL Community Server (GPL) Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
相关文章推荐
- 安装Oracle 10g sys,system 密码忘记设置解决办法
- system 密码忘记设置解决办法
- 腾讯云mysql重新设置密码解决办法
- 百度软件中心安装的Appserv首次登录数据库输入设置密码时不能登录的解决办法
- Oracle 11g sys,system 密码忘记设置解决办法
- oracle安装时忘记设置账号密码解决办法
- Mysql8.0数据库忘记root密码解决办法
- 腾讯云mysql重新设置密码解决办法
- 数据库之mac上mysql root密码忘记或权限错误的解决办法
- Oracle 11g sys,system 密码忘记设置解决办法
- root用户密码忘记的解决办法|设置grub密码
- 数据库之mac上mysql root密码忘记或权限错误的解决办法
- Oracle 11g sys,system 密码忘记设置解决办法 .
- mac忘记MySQL本地数据库密码解决办法
- 数据库之mac上mysql root密码忘记或权限错误的解决办法
- 数据库之mac上mysql root密码忘记或权限错误的解决办法
- 数据库之mac上mysql root密码忘记或权限错误的解决办法
- Oracle 10g&11g sys,system 密码忘记设置解决办法
- Linux忘记了数据库root用户密码的解决办法
- Oracle 11g sys,system 密码忘记设置解决办法