mysql开启skip-name-resolve 导致[email protected](localhost)访问引发的ERROR 1045 (28000)错误解决方案

为什么配置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)无法本地访问:

[[email protected] ~]#  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)却可以访问。

[[email protected] ~]#   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密码:

[[email protected] ~]#   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
[[email protected] ~]# 

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

[[email protected] ~]# 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!

时间: 2024-10-26 11:46:25

mysql开启skip-name-resolve 导致[email protected](localhost)访问引发的ERROR 1045 (28000)错误解决方案的相关文章

mysql登录时,ERROR 1045 (28000): 错误解决办法

错误问题的描述: ERROR 1045 (28000): Access denied for user 'ODBC'@'localhost' (using password: NO) ERROR 1045 (28000): Access denied for user 'ODBC'@'localhost' (using password: YES) windows下,以上两个错误的解决方法 解决方法: 1.找到配置文件my.ini  ,然后将其打开,可以选择用NotePadd++打开 2.打开后

关于mysql ERROR 1045 (28000)错误的解决办法

错误情景: 使用Navicat打开mysql的时候弹出错误框 错误代码: ERROR 1045 (28000): Access denied for user 'ODBC'@'localhost' (using password: NO) ERROR 1045 (28000): Access denied for user 'ODBC'@'localhost' (using password: YES) 解决步骤: 1.找到配置文件my.ini  ,然后将其打开,可以选择用记事本打开 2. 打开

mysql ERROR 1045 (28000): 错误解决办法

ERROR 1045 (28000): Access denied for user 'ODBC'@'localhost' (using password: NO) ERROR 1045 (28000): Access denied for user 'ODBC'@'localhost' (using password: YES) windows下,以上两个错误的解决方法 1.找到配置文件my.ini  ,然后将其打开,可以选择用记事本打开 2.打开后,搜索mysqld关键字找到后,在mysql

mysql出现ERROR 1045 (28000) 错误

第一步: 用这位的方法进行实验,发现不是这样的因为我的没有空的user: 一.现象: 公司linux系统的mysql数据库root用户设置过密码,但常常用命令'mysql -u root -p'登录报错,有时又能登录.登录报错信息为:[[email protected] ~]# mysql -u root -p Enter password: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password

mysql ERROR 1045 (28000): Access denied for user 可能解决方法分析

在实际登录redmine的过程中,我们遇到了如下的error ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) ERROR 1045 (28000): Access denied for user 'redmine'@'localhost' (using password: YES) Solution 1---空用户error. Solution 2---Windows 重置mys

安装mysql因为/tmp权限不足而导致ERROR 1045 (28000): Access denied for user [email protected] (using password: NO)的解决方案

本机是centos 6.5  安装的mysql是5.1的版本. 在安装mysql之后,第一次启动mysql服务的时候,需要/tmp有777(rwxrwxrwx)的权限,然而楼主的/tmp是755(rwxr-xr-x)的,[其实默认的是777,我因为之前误删过tmp,然后自己建的tmp,而权限没跟着改,小白的悲伤,说多了都是泪= =]所以如果不知道这个坑的话,第一次基本会出错.这个时候再修改/tmp已经迟了, 所以只能重新安装mysql了 由于上述原因报的错误是:ERROR 1045 (28000

关于mysql修改密码 set password for [email protected] = password('xxx');报错解决方法

当你安装好mysql后,发现mysql -u root -p直接按俩次enter竟然不用密码就能登录进去,可是navicat连接mysql需要密码啊.怎么办? 于是我通过百度寻觅良久发现多数都是通过下面的命令修改.但是自己执行时报下面的错. mysql> set password for [email protected] = password('123456'); ERROR 1064 (42000): You have an error in your SQL syntax; check t

【转载】 ERROR 1045 (28000): Access denied for user [email protected] (using password: NO)

来自:http://www.jb51.net/LINUXjishu/10981.html 错误描述: Mysql中添加用户之后可能出现登录时提示ERROR 1045 (28000): Access denied for user的错误.删除user.user中值为NULL的,或更新NULL为test 1)delete from user where user is NULL 2)update user set user='test' where user is NULL.意外的情况: 如果上述方

Access denied for user [email protected]’localhost’(using password:NO)

Accessdenied for user [email protected]'localhost'(using password:NO) 1.错误描述: 2.找到下面这个文件: 3.修改权限: 4.拷贝password 密码: 5.输入下面命令: 6.把拷贝的密码输进去: 并且修改密码,我修改的密码为baozi: 7.必须输入这个: 效果. 8.登陆,并输入修改后的密码: 9.显示全部数据库,并创建一个数据库: 这只是 一种方法,还有别的解决方法.