Heim  >  Artikel  >  Datenbank  >  IT忍者神龟之mysql远程连接:ERROR1130(HY000):Host'*.*

IT忍者神龟之mysql远程连接:ERROR1130(HY000):Host'*.*

WBOY
WBOYOriginal
2016-06-07 16:02:40889Durchsuche

安装完MySQL后,远程连接数据库的时候,出现 ERROR 1130 (HY000): Host '192.168.0.1' is not allowed to connect to this MySQL server提示信息,不能远程连接数据库。考虑可能是因为系统数据库mysql中user表中的host是localhost的原因,于是,我尝试把这个

安装完MySQL后,远程连接数据库的时候,出现 ERROR 1130 (HY000): Host '192.168.0.1' is not allowed to connect to this MySQL server提示信息,不能远程连接数据库。考虑可能是因为系统数据库mysql中user表中的host是localhost的原因,于是,我尝试把这个值改为自己服务器的ip,果然就好用了,不过用 mysql -u root -p命令就连不上数据库了,需要用mysql -h 服务器ip -u root -p因为默认的连接mysql数据库user表中host的值,而这个命令的默认host是localhost,就连不上了。

具体操作方法:

用localhost连接上mysql后,
use mysql;
update user set host='123.456.789.254';(IP为你想要远程连接数据库的本地机器的IP)
\q;

退出mysql,然后重新启动mysql就可以了。

其他解决方案

2. 改表法。可能是你的帐号不允许从远程登陆,只能在localhost。这个时候只要在localhost的那台电脑,登入mysql后,更改 "mysql" 数据库里的 "user" 表里的 "host" 项,从"localhost"改称"%"
mysql -u root -pvmware
mysql>use mysql;
mysql>update user set host = '%' where user = 'root';
mysql>flush privileges;
mysql>select host, user from user;

3. 授权法。例如,你想myuser使用mypassword从任何主机连接到mysql服务器的话。
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
如果你想允许用户myuser从ip为192.168.1.3的主机连接到mysql服务器,并使用mypassword作为密码
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'192.168.0.1' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;


***********************************************************************
phpMyAdmin说是用户名密码的问题,这就奇怪了,root用户名密码肯定没有问题,而且通过命令行连接没有问题。又仔细查看配置文件,还是没有问题。于是去搜了一下,找到这个解决方法.

先用root登录MYSQL服务器,执行
mysql>set password for 你要用的用户名@"localhost"=old_password('这个用户的密码');

原因是因为你使用的mysql服务器版本中使用了新的密码验证机制,这需要客户端的版本要在4.0以上,原来的密码函数被改为old_password();,这样使用password()生成的密码在旧的版本上就可以解决这个问题了.

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn