Home  >  Article  >  Database  >  安装mysql后,开启远程登录_MySQL

安装mysql后,开启远程登录_MySQL

WBOY
WBOYOriginal
2016-06-01 13:13:31789browse

       在内部测试服务器上新安装了mysql,在服务器本地登录数据库没问题,但是远程不能登录,试着用telnet命令连接mysql服务器,结果命令行给出如下提示:

 telnet 192.168.41.191 3306
Trying 192.168.41.191...
Connected to 192.168.41.191.
Escape character is '^]'.
GHost '192.168.41.186' is not allowed to connect to this MySQL serverConnection closed by foreign host.

        刚开始怀疑是防火墙的端口没有打开,直接把防火墙关掉,还是不行。

然后琢磨是不是路由器对服务器的访问设置了什么规则。了解到路由器没有添加任何过滤规则,问题应该不在路由器。

后来发现,mysql默认是没有打开远程登录的,好尴尬,太无知了。

然后就找到了打开远程登录的方法。如下:

  1. 修改mysql数据库的表user 的 host 字段的localhost 数据改为:“%”
  2. 在mysql的Console 控制台 输入 flush privileges
  3. Commit 

做完这三步操作,再次使用远程机器登录mysql,已经可以连接了。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn