mysql8.0.19忘记密码处理方法详解

吾爱主题 阅读:121 2024-04-01 23:19:49 评论:0

1在配置文件中添加skip-grant-tables后重启mysql,然后直接登录

?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 [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更新密码

?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 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:

?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 [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 #去掉
?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 [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>

到此这篇关于mysql8.0.19忘记密码处理方法详解的文章就介绍到这了,更多相关mysq忘记密码处理内容请搜索服务器之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持服务器之家!

原文链接:https://blog.51cto.com/tyjs09/5462080

可以去百度分享获取分享代码输入这里。
声明

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

【腾讯云】云服务器产品特惠热卖中
搜索
标签列表
    关注我们

    了解等多精彩内容