---
title: "mysql报错处理: could not be resolved: getnameinfo() returned error (code: -3)"
author: "dynamiclu"
date: "2011-01-10T15:33:32Z"
tags: []
categories: ["数据库"]
slug: "mysql-could-not-be-resolved-getnameinfo-returned-error-code-3"
draft: false
lastmod: "2011-01-11T11:20:51Z"
id: 867226
url: "https://dynamiclu.iteye.com/blog/867226"
---

\[文章作者：狂奔的鹿 本文版本：v1.0  转载请注明原文链接：[http://dynamiclu.iteye.com/](/)]

 

近期, 用mysqld\_multi开了几个mysql实例，mysql版本5.5.8; 

然后授权：

```
GRANT ALL PRIVILEGES ON *.* TO 'lsl'@192.168.0.1 IDENTIFIED BY 'lusonglin' WITH GRANT OPTION;
```

 

客户端连接报错

could not be resolved: getnameinfo() returned error (code: -3).

如下图：

![](http://dl.iteye.com/upload/attachment/386464/5ae78b65-1357-3ee8-afa5-39a5862e7517.jpg)

google里baidu了很久，没找到相关的中文解释原因。

在老外的坛子里发现如下方式：

Try the followng in that order to resolve:

1&gt; At the console of the box on which mysql server is running type mysql -uroot -p  
2&gt; It will prompt you for root pasword is it was set. Once insidew mysql command shell type  
user mysql;  
3&gt; now type the following command:  
grant all privileges on \*.* to '&lt;username&gt;'@'&lt;IP&gt;' identified by '&lt;password&gt;';  
In above command replace &lt;username&gt; with the username you want for connection.&lt;IP&gt; with the IP of the host from where you want the permission to connect to this mysql server(in you case this shall be 192.168.1.2) You can also use 192.168.% to allow connection from all IP that begin eith 192.168. Similarly replacing &lt;IP&gt; with just % will allow connection from all hosts for this username. Replace &lt;password&gt; with the password you want.  
4&gt; type this command:  
flush privileges;

大概意思是也要授权192.168.%   操作：

 

```
GRANT ALL PRIVILEGES ON *.* TO 'lsl'@'192.168.%' IDENTIFIED BY 'lusonglin' WITH GRANT OPTION;
```

 

 

客户端再连一下，果真OK了。

 

 注:配置文件上需加skip-name-resolve参数，不然也会出现同样错误

 

\[文章作者：狂奔的鹿 本文版本：v1.0  转载请注明原文链接：[http://dynamiclu.iteye.com/](/)]