最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
mysql8.0.19忘记密码处理方法代码解析
时间:2022-07-13 编辑:袖梨 来源:一聚教程网
本篇文章小编给大家分享一下mysql8.0.19忘记密码处理方法代码解析,文章代码介绍的很详细,小编觉得挺不错的,现在分享给大家供大家参考,有需要的小伙伴们可以来看看。
1、在配置文件中添加skip-grant-tables后重启mysql,然后直接登录
[root@tyjs09 ~]# cat /etc/my.cnf [mysqld] user=mysql basedir=/application/mysql datadir=/data/mysql/data socket=/tmp/mysql.sock server_id=6 port=3306 gtid-mode=on enforce-gtid-consistency=true log_error=/data/mysql/data/mysql.log log_bin=/data/binlog/mysql-bin secure-file-priv=/tmp innodb_flush_method=O_DIRECT lower_case_table_names=1 skip-grant-tables
2、更新密码
mysql> flush privileges; Query OK, 0 rows affected (0.00 sec) mysql> alter user "root"@"localhost" identified by "123456"; ERROR 1396 (HY000): Operation ALTER USER failed for 'root'@'localhost' mysql> use mysql;select user,host from user;root | % | | mysql.infoschema | localhost | | mysql.session | localhost | | mysql.sys | localhost | +------------------+-----------+ 4 rows in set (0.00 sec) mysql> ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456'; Query OK, 0 rows affected (0.00 sec) mysql> flush privileges;
3、在配置文件中去掉免登录然后重启mysql:
[root@tyjs09 ~]# vim /etc/my.cnf [mysqld] user=mysql basedir=/application/mysql datadir=/data/mysql/data socket=/tmp/mysql.sock server_id=6 port=3306 gtid-mode=on enforce-gtid-consistency=true log_error=/data/mysql/data/mysql.log log_bin=/data/binlog/mysql-bin secure-file-priv=/tmp innodb_flush_method=O_DIRECT lower_case_table_names=1 skip-grant-tables #去掉
[root@tyjs09 ~]# service mysql restart Shutting down MySQL.. SUCCESS! Starting MySQL. SUCCESS! [root@tyjs09 ~]# mysql -uroot -p123456 mysql: [Warning] Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or g. Your MySQL connection id is 8 Server version: 8.0.19 MySQL Community Server - GPL Copyright (c) 2000, 2020, 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>
-
下一个: MySQL读写分离原理解析
相关文章
- MySQL登录、访问及退出操作解析 10-18
- sql语句 update字段null不能用is null问题解析 09-28
- SQL Server ISNULL 不生效原因及解决分析 09-28
- 关于if exists的用法及说明分析 09-28
- Mysql删除某个字段的最后四个字符 09-26
- mysql多个字段最大最小值介绍 09-26