以下的文章主要讲述的是远程登入MySQL数据库经常出现错误问题的原因的详细分析与具体的解决方案(无法远程登入MySQL数据库),以下就是对在实际操作中无法正常远程登入MySQL数据库的解决办法: 尝试用MySQL Adminstrator GUI Tool登入MySQL Server,Server却
以下的文章主要讲述的是远程登入MySQL数据库经常出现错误问题的原因的详细分析与具体的解决方案(无法远程登入MySQL数据库),以下就是对在实际操作中无法正常远程登入MySQL数据库的解决办法:
尝试用MySQL Adminstrator GUI Tool登入MySQL Server,Server却回复错误讯息:
Host ‘60-248-32-13.HINET-IP.hinet.net’ is not allowed to connect to this MySQL server
这个是因为权限的问题,处理方式如下:
shell>mysql –user=root -p
输入密码
<ol class="dp-xml"> <li class="alt"><span><span>mysql</span><span class="tag">></span><span>use mysql </span></span></li> <li> <span>mysql</span><span class="tag">></span><span>GRANT SELECT,INSERT,UPDATE,DELETE ON [db_name].* TO [username]@[ipadd] identified by ‘[password]‘; </span> </li> </ol>
[username]:远程登入的使用者代码
[db_name]:表示欲开放给使用者的数据库称
[password]:远程登入的使用者密码
[ipadd]:IP地址或者IP反查后的DNS Name,此例的内容需填入’60-248-32-13.HINET-IP.hinet.net’ ,包函上引号(‘)
(其实就是在远端服务器上执行,地址填写本地主机的ip地址。)
如果希望开放所有权限的话请执行:
<ol class="dp-xml"><li class="alt"><span><span>mysql</span><span class="tag">></span><span>update user set </span><span class="attribute">select_priv</span><span>=’Y’ , </span><span class="attribute">Insert_priv</span><span>=’Y', </span><span class="attribute">Update_priv</span><span>=’Y', <br></span><span class="attribute">delete_priv</span><span>=’Y', </span><span class="attribute">Create_priv</span><span>=’Y', </span><span class="attribute">Drop_priv</span><span>=’Y',</span><span class="attribute">Reload_priv</span><span>=’Y', <br></span><span class="attribute">shutdown_priv</span><span>=’Y', </span><span class="attribute">Process_priv</span><span>=’Y', </span><span class="attribute">File_priv</span><span>=’Y', </span><span class="attribute">Grant_priv</span><span>=’Y', <br></span><span class="attribute">references_priv</span><span>=’Y',</span><span class="attribute">Index_priv</span><span>=’Y', </span><span class="attribute">Alter_priv</span><span>=’Y', </span><span class="attribute">Show_db_priv</span><span>=’Y', <br></span><span class="attribute">Super_priv</span><span>=’Y',</span><span class="attribute">Create_tmp_table_priv</span><span>=’Y',</span><span class="attribute">Lock_tables_priv</span><span>=’Y', <br></span><span class="attribute">Execute_priv</span><span>=’Y',</span><span class="attribute">Repl_slave_priv</span><span>=’Y',</span><span class="attribute">Repl_client_priv</span><span>=’Y’ where </span><span class="attribute">user</span><span>=’[username]‘; </span></span></li></ol>
无法远程登入MySQL数据库的解决办法二:
如何解决客户端与服务器端的连接(mysql) :xxx.xxx.xxx.xxx is not allowed to connect to this mysql serv
1、进入mysql,创建一个新用户xuys:
格式:grant 权限 on 数据库名.表名 用户@登录主机 identified by “用户密码”;
grant select,update,insert,delete on *.* to xuys@192.168.88.234identified by “xuys1234″;
查看结果,执行:
<ol class="dp-xml"> <li class="alt"><span><span>use mysql; </span></span></li> <li><span>select host,user,password from user; </span></li> </ol>
可以看到在user表中已有刚才创建的xuys用户。host字段表示登录的主机,其值可以用IP,也可用主机名,
将host字段的值改为%就表示在任何客户端机器上能以xuys用户登录到mysql服务器,建议在开发时设为%。
3、./mysqld_safe –user-root &
记住:对授权表的任何修改都需要重新reload,即执行第3步。
如果经过以上3个步骤还是无法从客户端连接,请执行以下操作,在mysql数据库的db表中插入一条记录:
<ol class="dp-xml"> <li class="alt"><span><span>use mysql; </span></span></li> <li><span>insert into db values(‘192.168.88.234′,’%',’xuys’,'Y’,'Y’,'Y’,'Y’,'Y’,'Y’,'Y’,'Y’,'Y’,'Y’,'Y’,'Y’); </span></li> <li class="alt"> <span>update db set </span><span class="attribute">host</span><span> = ‘%’ where </span><span class="attribute">user</span><span> = ‘xuys’; </span> </li> </ol>
重复执行上面的第2、3步。
无法远程登入MySQL数据库的解决办法三:
附加fbysss解决phpMyAdmin连接远程用户的方法:
1.用root账户登录远程Mysql服务器,
<ol class="dp-xml"> <li class="alt"><span><span>grant select,update,insert,delete on *.* to sss@192.168.0.114identified by “sss”; </span></span></li> <li> <span>update user set </span><span class="attribute">host</span><span> = ‘%’ where </span><span class="attribute">user</span><span> = ’sss’; </span> </li> </ol>
退出mysql,在shell下执行
<ol class="dp-xml"> <li class="alt"><span><span>#mysqladmin -u root -p [password] reload </span></span></li> <li><span>#mysqladmin -u root -p [password] shutdown </span></li> <li class="alt"><span>#/etc/rc.d/init.d/mysqld start </span></li> </ol>
2.修改phpMyAdmin目录下的config.inc.php文件,找到
$cfg['Servers'][$i]['host'] 修改为远程服务器地址
$cfg['Servers'][$i]['user'] 修改为sss
$cfg['Servers'][$i]['password']修改为sss的密码
要注意的是:grant all privilege并不能把“grant” 的权限赋给用户,如果要加,可以直接在mysql数据库中使用use mysql; update user set Grant_priv =’Y'来达到要求。