mysql8.0.19忘记密码处理方法详解
时间:2025-12-04 20:00:02|栏目:其它数据库|点击: 次
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>
您可能感兴趣的文章
- 12-22使用mysql记录从url返回的http GET请求数据操作
- 12-22详解sql中exists和in的语法与区别
- 12-22hive从mysql导入数据量变多的解决方案
- 12-22如何为PostgreSQL的表自动添加分区
- 12-22postgresql 实现得到时间对应周的周一案例
- 12-22sqoop export导出 map100% reduce0% 卡住的多种原因及解决
- 12-22mysql查询条件not in 和 in的区别及原因说明
- 12-22解决mysql使用not in 包含null值的问题
- 12-22解决从集合运算到mysql的not like找不出NULL的问题
- 12-22postgresql 实现多表关联删除


阅读排行
推荐教程
- 12-11mysql代码执行结构实例分析【顺序、分支、循环结构】
- 12-08添加mysql的用户名和密码是什么语句?
- 12-20PhpMyAdmin出现错误数据无法导出怎么办?
- 12-19Redis中实现查找某个值的范围
- 12-15浅析mysql迁移到clickhouse的5种方法
- 12-15CentOS7 64位下MySQL5.7安装与配置教程
- 12-14Mysql大型SQL文件快速恢复方案分享
- 12-14mysql 5.7.27 安装配置方法图文教程
- 12-13MySQL给新建用户并赋予权限最简单的方法
- 12-13关于MySQL索引的深入解析





