Java自学者论坛

 找回密码
 立即注册

手机号码,快捷登录

恭喜Java自学者论坛(https://www.javazxz.com)已经为数万Java学习者服务超过8年了!积累会员资料超过10000G+
成为本站VIP会员,下载本站10000G+会员资源,会员资料板块,购买链接:点击进入购买VIP会员

JAVA高级面试进阶训练营视频教程

Java架构师系统进阶VIP课程

分布式高可用全栈开发微服务教程Go语言视频零基础入门到精通Java架构师3期(课件+源码)
Java开发全终端实战租房项目视频教程SpringBoot2.X入门到高级使用教程大数据培训第六期全套视频教程深度学习(CNN RNN GAN)算法原理Java亿级流量电商系统视频教程
互联网架构师视频教程年薪50万Spark2.0从入门到精通年薪50万!人工智能学习路线教程年薪50万大数据入门到精通学习路线年薪50万机器学习入门到精通教程
仿小米商城类app和小程序视频教程深度学习数据分析基础到实战最新黑马javaEE2.1就业课程从 0到JVM实战高手教程MySQL入门到精通教程
查看: 542|回复: 0

mysql开启skip-name-resolve 导致root@127.0.0.1(localhost)访问引发的ERROR 1045 (28000)错误解决方案

[复制链接]
  • TA的每日心情
    奋斗
    2024-11-24 15:47
  • 签到天数: 804 天

    [LV.10]以坛为家III

    2053

    主题

    2111

    帖子

    72万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    积分
    726782
    发表于 2021-4-23 12:53:07 | 显示全部楼层 |阅读模式

    为什么配置skip-name-resolve?

    由于mysql -h${ip} 远程访问速度过慢,

    mysql -h172.16.66.171 -uroot -p123456

     根据网友经验(https://www.cnblogs.com/yjf512/p/3803762.html),

    vi /etc/my.cnf

    [mysqld] skip
    -name-resolve

    重启mysql,发现远程访问msyql速度上来了,解决问题。

     然而引发了新的问题:

    但是却发现msyql(mysql -h127.0.0.1 -uroot -p123456)无法本地访问:

    [root@localhost ~]#  mysql -h127.0.0.1 -uroot -p123456
    Warning: Using a password on the command line interface can be insecure.
    ERROR 1045 (28000): Access denied for user 'root'@'127.0.0.1' (using password: YES)

    而不输入密码(mysql -h127.0.0.1 -uroot)却可以访问。

    [root@localhost ~]#   mysql -h127.0.0.1 -uroot 
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 91114
    Server version: 5.6.35-log 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>

     

    解决方法:

    参考(http://blog.sina.com.cn/s/blog_759a5a7c01017dj0.html),重置root密码:

    [root@localhost ~]#   mysql -h127.0.0.1 -uroot 
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 91114
    Server version: 5.6.35-log 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;
    Database changed
    mysql> update user set password=password("123456") where user="root";
    Query OK, 3 rows affected (0.06 sec)
    Rows matched: 5  Changed: 3  Warnings: 0
    
    mysql> flush privileges;
    Query OK, 0 rows affected (0.13 sec)
    
    mysql> quit
    Bye
    [root@localhost ~]# 

     用 mysql -h127.0.0.1 -uroot -p123456 访问,问题解决。

    [root@localhost ~]# mysql -h127.0.0.1 -uroot -p123456
    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 2487
    Server version: 5.6.35-log 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>

     由于开启skip-name-resolve引发的ERROR 1045 (28000)网上资料不详,解决这个问题花了大半天,所以发布这篇文章。

    My first blog on cnblogs!

    哎...今天够累的,签到来了1...
    回复

    使用道具 举报

    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    QQ|手机版|小黑屋|Java自学者论坛 ( 声明:本站文章及资料整理自互联网,用于Java自学者交流学习使用,对资料版权不负任何法律责任,若有侵权请及时联系客服屏蔽删除 )

    GMT+8, 2024-12-23 05:03 , Processed in 0.056521 second(s), 28 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2021, Tencent Cloud.

    快速回复 返回顶部 返回列表