美文网首页
MySQL远程无法连接(1130)

MySQL远程无法连接(1130)

作者: 欧阳晓 | 来源:发表于2018-09-18 16:19 被阅读0次

事情背景

最近琢磨着迁移数据库,想通过自己的电脑连接服务器,遇到两个问题,一是在这台WindowServer 2008上根本找不到Mysql,二是自己的电脑连接不上,提示:
1130-host ... is not allowed to connect to this MySql server

解决

这个提示就证明这台服务器上是有Mysql的。费劲周折,终于找到了一个命令行运行

Enter password: *******
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2695
Server version: 5.5.45 MySQL Community Server (GPL)


Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases
    -> ;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| obs                |
| performance_schema |
| test               |
+--------------------+

解决这个连接问题
改表法
帐号不允许从远程登陆,只能在localhost。这个时候只要在localhost的那台电脑,登入mysql后,更改 "mysql" 数据库里的 "user" 表里的 "host" 项,从"localhost"改称"%"
mysql>update user set host = '%' where user = 'root';
mysql>select host, user from user;
最后还有一步很重要的不能落下:
mysql>flush privileges;
作用在网上查了一下

flush privileges 命令本质上的作用是将当前user和privilige表中的用户信息/权限设置从mysql库(MySQL数据库的内置库)中提取到内存里。MySQL用户数据和权限有修改后,希望在"不重启MySQL服务"的情况下直接生效,那么就需要执行这个命令。通常是在修改ROOT帐号的设置后,怕重启后无法再登录进来,那么直接flush之后就可以看权限设置是否生效。而不必冒太大风险。

相关文章

网友评论

      本文标题:MySQL远程无法连接(1130)

      本文链接:https://www.haomeiwen.com/subject/brqynftx.html