Heim  >  Artikel  >  Datenbank  >  远程登录mysql,报错:message from server: "Host is not a

远程登录mysql,报错:message from server: "Host is not a

WBOY
WBOYOriginal
2016-06-07 15:47:051144Durchsuche

1. 改表法。 可能是你的帐号不允许从远程登陆,只能在localhost。这个时候只要在localhost的那台电脑,登入mysql后,更改 mysql 数据库里的 user 表里的 host 项,从localhost改称% 登录数据库:mysql -u root -pvmware mysqluse mysql; mysqlupdate user se

1. 改表法。

可能是你的帐号不允许从远程登陆,只能在localhost。这个时候只要在localhost的那台电脑,登入mysql后,更改 "mysql" 数据库里的 "user" 表里的 "host" 项,从"localhost"改称"%"

登录数据库:mysql -u root -pvmware

mysql>use mysql;

mysql>update user set host = '%' where user = 'root';

mysql>select host, user from user;

mysql>FLUSH RIVILEGES

2. 授权法。

(1)例如,你想myuser使用mypassword从任何主机连接到mysql服务器的话。

第一步:root用户登录;mysql>mysql -u root -p rootpassword;

第二步:赋予权限;mysql>GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;

第三步:mysql>FLUSH   PRIVILEGES;

(2)如果你想允许用户myuser从ip为192.168.1.3的主机连接到mysql服务器,并使用mypassword作为密码

mysql>GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'192.168.1.3' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;

mysql>FLUSH   PRIVILEGES;

(3)如果你想允许用户myuser从ip为192.168.1.3的主机连接到mysql服务器的dk数据库,并使用mypassword作为密码

mysql>GRANT ALL PRIVILEGES ON dk.* TO 'myuser'@'192.168.1.3' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;

mysql>FLUSH   PRIVILEGES;

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
Vorheriger Artikel:linux下配置mysqlNächster Artikel:MySQL安全相关启动选项