标签:
也欢迎大家转载本篇文章。分享知识,造福人民,实现我们中华民族伟大复兴!
[Comment 1] 前同事企鹅上面说他安装的mysql 5.5,发现用mysql客户端远程连接的时候,报1042-Can’t get hostname for your address错误,但是权限已经grant了并且grant成功了。
这个报错的意思是“您的地址无法获得主机名”,我就想到了skip-name-resolve参数。
官方文档:
Use IP addresses rather than host names when creating grant table entries. This option can be useful if your DNS does not work.
Do not resolve host names when checking client connections. Use only IP numbers. If you use this option, allHost column values in the grant tables must be IP numbers orlocalhost. SeeSection 7.7.11, “How MySQL Uses DNS”.
mysql> show variables like '%skip_name_resolve%';
+-------------------+-------+
| Variable_name | Value |
+-------------------+-------+
| skip_name_resolve | ON |
+-------------------+-------+
1 row in set (0.00 sec)
mysql> set global skip_name_resolve=0;
ERROR 1238 (HY000): Variable 'skip_name_resolve' is a read only variable
mysql>
失败了,看来是只有修改my.cnf了
在[mysqld]节点下修改
skip-name-resolve
#忽略主机名的方式访问
lower_case_table_names=1
#忽略数据库表名大小写
重启MySQLD process即可。
[Comment 2]前同事企鹅留言:
mysql -h 192.168.1.101 -u root -p
访问不了,我本地的mysql.192.168.1.101是本地ip地址。
grant all privileges on *.* to
标签:
来源: https://blog.csdn.net/hfdchhu/article/details/83995970