mysql数据库远程授权

如果mysql不支持远程连接,会出现提示:错误代码是1130,ERROR 1130: Host 192.168.0.10 is not allowed to connect to this MySQL server ,解决此问题有以下2个方法:

1、改表法:在本机登入mysql后,更改“mysql”数据库里的“user”表里的“host”项,从”localhost”改为' % '。

mysql>
mysql>use mysql;
mysql>select 'host' from user where user='root';<wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr>#查看mysql库中的user表的host值(即可进行连接访问的主机/IP名称)<br><br> mysql&gt;update<span style="color:rgb(77,109,243); word-wrap:normal; word-break:normal">user</span>set host = '<span style="color:rgb(237,28,36); word-wrap:normal; word-break:normal">%</span>'<wbr>where user ='<span style="color:rgb(77,109,243); word-wrap:normal; word-break:normal">root</span>'; #修改host值(以通配符%的内容增加主机/IP地址,当然也可以直接增加某个特定IP地址,如果执行update语句时出现<strong>ERROR 1062 (23000): Duplicate entry '%-root' for key 'PRIMARY'</strong>错误,需要<strong>select host from user where user = 'root';</strong><br> 查看一下<strong>host是否已经有了%这个值</strong>,如果有了直接执行下面的<strong>flush privileges;</strong>即可)<br> mysql&gt;flush privileges;<br> mysql&gt;select host,user from user where user='root';<br> mysql&gt;quit<br><br> 退出后会回到DOS正常的提示符状态,此时可以通过远程连接Mysql了!</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>

========================================<wbr><wbr></wbr></wbr>


2. 授权法。例如,你想myuser使用mypassword从任何主机连接到mysql服务器的话。
为mysql创建一个远程连接用户:
grant<wbr>all<wbr>privileges<wbr>on<wbr>*.*<wbr>to<wbr>remoteuser@remoteIPAddr<wbr>identified<wbr>by<wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>'password'; (remoteIPAddr是指远程客服端ip)
例如:grant<wbr>all<wbr>privileges<wbr>on<wbr>*.*<wbr>to<wbr><a target="_blank" href="mailto:myuser@192.168.0.10" style="color:rgb(27,113,155); text-decoration:none">myuser@192.168.0.10</a><wbr>identified<wbr>by<wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>'shihuan';

GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%'IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
如果你想允许用户myuser从ip为192.168.0.10的主机连接到mysql服务器,并使用mypassword作为密码
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'192.168.0.10'IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
<wbr><wbr><wbr><wbr>我的mysql.user里root用户的host果然是localhost,先用改表法给localhost改成“%”,还是不行,仍然报1130的错误,又按“从任何主机连接到mysql服务器”方法授权,还是报一样的错,最后给自己的ip授权之后,终于登录上了。</wbr></wbr></wbr></wbr>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值