Host 'HostName' is not allowed to connect to this MySQL server
2007-12-26 21:22
633 查看
导读:
应用程序采用ODBC方式从本机登陆MySQL数据库,出现下面的提示:
[MySQL][ODBC 3.51 Driver]Host 'HostName' is not allowed to connect to this MySQL server
(注:HostName为本机主机名称,在/etc/hosts文件中有设置。)
很明显,应该是权限设置问题,查看一下权限设置信息:
$ mysql -uroot -Dmysql
mysql> select Host, User, Password from user;
+-----------+------+----------+
| Host????? | User | Password |
+-----------+------+----------+
| localhost | root |????????? |
| localhost |????? |????????? |
+-----------+------+----------+
4 rows in set (0.00 sec)
上述结果也很明显,root用户可以从localhost登陆MySQL数据库,且无需口令。
这可怪了!?
不过,有些莫名其妙的是,MySQL服务器为什么提示是:Host 'HostName',而不是localhost呢?
服务器是如何获取这个“HostName”信息的?难道是/etc/hosts文件的问题?
是不是MySQL获取客户端(SHELL命令行下执行mysql时就等于起了一个客户端)IP地址信息后,又根据hosts文件做了一个转换?
查看一下文件/etc/hosts,看看有没有什么问题。
$ grep HostName /etc/hosts
10.10.10.10???? HostName
问题似乎有些眉目了,MySQL数据库里面root用户的权限是针对地址localhost的,而非HostName
所以,只需要添加别名localhost给10.10.10.10即可 ^_^
$ grep HostName /etc/hosts
10.10.10.10???? localhost HostName
重启MySQL服务器,重新执行程序,可以顺利登陆数据库,问题解决。
评论
feeling
Host "xxx.xxx.xxx.xxx" is not allowed to connect to this mysql server.
关键字 ?? 如何解决客户端与服务器端的连接(mysql) :"xxx.xxx.xxx.xxx" is not allowed to connect to this mysql server.
出处 ?
1、进入mysql,创建一个新用户user:
格式:grant 权限 on 数据库名.表名 用户@登录主机 identified by "用户密码";
grant select,update,insert,delete on *.* to user@10.10.10.10identified by "user";
查看结果,执行:
use mysql;
select host,user,password from user;
可以看到在user表中已有刚才创建的user用户。host字段表示登录的主机,其值可以用IP,也可用主机名,
将host字段的值改为%就表示在任何客户端机器上能以user用户登录到mysql服务器,建议在开发时设为%。?? ??
update user set host = '%' where user = 'user';
2、?./mysqladmin -uroot -p21century reload
./mysqladmin -uroot -p21century shutdown
3、./mysqld_safe --user-root &
记住:对授权表的任何修改都需要重新reload,即执行第3步。
如果经过以上3个步骤还是无法从客户端连接,请执行以下操作,在mysql数据库的db表中插入一条记录:
use mysql;
insert into db values('192.168.88.234','%','user','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y');
update db set host = '%' where user = 'user';
重复执行上面的第2、3步。
本文转自
http://ym1977.spaces.live.com/blog/cns!e45a3dfc50f22053!272.entry
应用程序采用ODBC方式从本机登陆MySQL数据库,出现下面的提示:
[MySQL][ODBC 3.51 Driver]Host 'HostName' is not allowed to connect to this MySQL server
(注:HostName为本机主机名称,在/etc/hosts文件中有设置。)
很明显,应该是权限设置问题,查看一下权限设置信息:
$ mysql -uroot -Dmysql
mysql> select Host, User, Password from user;
+-----------+------+----------+
| Host????? | User | Password |
+-----------+------+----------+
| localhost | root |????????? |
| localhost |????? |????????? |
+-----------+------+----------+
4 rows in set (0.00 sec)
上述结果也很明显,root用户可以从localhost登陆MySQL数据库,且无需口令。
这可怪了!?
不过,有些莫名其妙的是,MySQL服务器为什么提示是:Host 'HostName',而不是localhost呢?
服务器是如何获取这个“HostName”信息的?难道是/etc/hosts文件的问题?
是不是MySQL获取客户端(SHELL命令行下执行mysql时就等于起了一个客户端)IP地址信息后,又根据hosts文件做了一个转换?
查看一下文件/etc/hosts,看看有没有什么问题。
$ grep HostName /etc/hosts
10.10.10.10???? HostName
问题似乎有些眉目了,MySQL数据库里面root用户的权限是针对地址localhost的,而非HostName
所以,只需要添加别名localhost给10.10.10.10即可 ^_^
$ grep HostName /etc/hosts
10.10.10.10???? localhost HostName
重启MySQL服务器,重新执行程序,可以顺利登陆数据库,问题解决。
评论
feeling
Host "xxx.xxx.xxx.xxx" is not allowed to connect to this mysql server.
关键字 ?? 如何解决客户端与服务器端的连接(mysql) :"xxx.xxx.xxx.xxx" is not allowed to connect to this mysql server.
出处 ?
1、进入mysql,创建一个新用户user:
格式:grant 权限 on 数据库名.表名 用户@登录主机 identified by "用户密码";
grant select,update,insert,delete on *.* to user@10.10.10.10identified by "user";
查看结果,执行:
use mysql;
select host,user,password from user;
可以看到在user表中已有刚才创建的user用户。host字段表示登录的主机,其值可以用IP,也可用主机名,
将host字段的值改为%就表示在任何客户端机器上能以user用户登录到mysql服务器,建议在开发时设为%。?? ??
update user set host = '%' where user = 'user';
2、?./mysqladmin -uroot -p21century reload
./mysqladmin -uroot -p21century shutdown
3、./mysqld_safe --user-root &
记住:对授权表的任何修改都需要重新reload,即执行第3步。
如果经过以上3个步骤还是无法从客户端连接,请执行以下操作,在mysql数据库的db表中插入一条记录:
use mysql;
insert into db values('192.168.88.234','%','user','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y');
update db set host = '%' where user = 'user';
重复执行上面的第2、3步。
本文转自
http://ym1977.spaces.live.com/blog/cns!e45a3dfc50f22053!272.entry
相关文章推荐
- Host 'name' is not allowed to connect to this MySQL server
- Host 'HostName' is not allowed to connect to this MySQL server
- 1130 - Host ‘' is not allowed to connect to this mysql server
- Host 'heChengjian' is not allowed to connect to this MySQL server
- Error No. 1130 Host '*.*.*.*' is not allowed to connect to this MySQL server解决方法
- Host 'aeolus-PC2' is not allowed to connect to this MySQL server
- message from server: "Host 'xxx' is not allowed to connect to this MySQL server"
- Host 'A'is not allowed to connect to this MySQL server
- SQL Error (1130): Host '192.168.1.100' is not allowed to connect to this MySQL server
- "Host 'localhost' is not allowed to connect to this MySQL server" 的原因及解决办法
- mysql不支持远程连接的解决办法(#1130 - Host 'localhost' is not allowed to connect to this MySQL server)
- 服务器连接错误Host 'XXX' is not allowed to connect to this MySQL server
- mysql本地訪问linuxserver,出现SQLSTATE[HY000] [1130] Host '127.0.0.1' is not allowed to connect to this
- java数据库连接(mysql)java.sql.SQLExcept "Host 'Lenovo-PC' is not allowed to connect to this MySQL server"
- Discuzx2.5 数据库连接问题 Host '***.***.***.***' is not allowed to connect to this MySQL server
- mysql Host 'microsof-80f25e' is not allowed to connect to this MySQL server
- ERROR 1130: Host 'A'is not allowed to connect to this MySQL server
- ERROR 1130 (HY000): Host 'localhost' is not allowed to connect to this MySQL server
- MySQL: Host '127.0.0.1' is not allowed to connect to this MySQL server
- Host 'admin-PC' is not allowed to connect to this MySQL server