[分享]ERROR 1042 (00000): Can't get hostname for your address解决方案 _MySQL, Oracle及数据库讨论区_Weblogic技术|Tuxedo技术|中间件技术|Oracle论坛|JAVA论坛|Linux/Unix技术|hadoop论坛_联动北方技术论坛  
网站首页 | 关于我们 | 服务中心 | 经验交流 | 公司荣誉 | 成功案例 | 合作伙伴 | 联系我们 |
联动北方-国内领先的云技术服务提供商
»  游客             当前位置:  论坛首页 »  自由讨论区 »  MySQL, Oracle及数据库讨论区 »
总帖数
1
每页帖数
101/1页1
返回列表
0
发起投票  发起投票 发新帖子
查看: 2730 | 回复: 0   主题: [分享]ERROR 1042 (00000): Can't get hostname for your address解决方案         下一篇 
guoqiang
注册用户
等级:上士
经验:252
发帖:26
精华:0
注册:2012-4-12
状态:离线
发送短消息息给guoqiang 加好友    发送短消息息给guoqiang 发消息
发表于: IP:您无权察看 2014-11-7 14:57:31 | [全部帖] [楼主帖] 楼主

第一步:
.安装完 mysql

[root@sv245 tmp]# mysqladmin -hlocalhost -uroot password '123456'
[root@sv245 tmp]# mysql -uroot -p123456
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.41-ndb-7.0.13-cluster-gpl MySQL Cluster Server (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> select user,host,password from user;
+------+-----------+-------------------------------------------+
| user | host      | password                                  |
+------+-----------+-------------------------------------------+
| root | localhost | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| root | sv245     |                                           |
| root | 127.0.0.1 |                                           |
| root | ::1       |                                           |
|      | localhost |                                           |
|      | sv245     |                                           |
+------+-----------+-------------------------------------------+
6 rows in set (0.00 sec)
mysql> update user set host='%' where host='localhost';
Query OK, 2 rows affected (0.02 sec)
Rows matched: 2  Changed: 2  Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> select user,host,password from user;
+------+-----------+-------------------------------------------+
| user | host      | password                                  |
+------+-----------+-------------------------------------------+
| root | %         | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| root | sv245     |                                           |
| root | 127.0.0.1 |                                           |
| root | ::1       |                                           |
|      | %         |                                           |
|      | sv245     |                                           |
+------+-----------+-------------------------------------------+
6 rows in set (0.00 sec)
mysql> exit
Bye
[root@sv245 tmp]# service mysql restart


第二步:

[root@sv245 mysql]# cp my-huge.cnf /etc/my.cnf
[root@sv245 mysql]# vi /etc/my.cnf


在配置文件中增加:
[mysqld]下增加下面一句话:

skip-name-resolve
[root@sv245 mysql]# service mysql restart


ok,可以通过外部工具测试连接了
windows系统下测试如下:

C:\Documents and Settings\lidw>mysql -h 192.168.0.245 -uroot -p123456
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 5.1.41-ndb-7.0.13-cluster-gpl-l
og
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>


ok,连接成功:

注释:

#1:去掉mysql启动参数中的skip-name-resolve ,然后jdbc连接串用ip地址和主机名均可。
#2:如果保留启动参数skip-name-resolve 的话,在jdbc连接串中只能使用IP地址的方式连接数据库。


--转自 北京联动北方科技有限公司




赞(0)    操作        顶端 
总帖数
1
每页帖数
101/1页1
返回列表
发新帖子
请输入验证码: 点击刷新验证码
您需要登录后才可以回帖 登录 | 注册
技术讨论