本文翻译自:How to allow remote connection to mysql

I have installed MySQL Community Edition 5.5 on my local machine and I want to allow remote connections so that I can connect from external source. 我已经在本地计算机上安装了MySQL Community Edition 5.5,并且希望允许远程连接,以便可以从外部源进行连接。

How can I do that? 我怎样才能做到这一点?


#1楼

参考:https://stackoom.com/question/100ie/如何允许远程连接到MySQL


#2楼

If your MySQL server process is listening on 127.0.0.1 or ::1 only then you will not be able to connect remotely. 如果您的MySQL服务器进程仅在127.0.0.1或:: 1上侦听,则您将无法远程连接。 If you have a bind-address setting in /etc/my.cnf this might be the source of the problem. 如果在/etc/my.cnf具有bind-address设置,则可能是问题的根源。

You will also have to add privileges for a non- localhost user as well. 您还必须为非localhost用户添加特权。


#3楼

That is allowed by default on MySQL. MySQL默认情况下允许这样做。

What is disabled by default is remote root access. 默认情况下禁用的是远程root访问。 If you want to enable that, run this SQL command locally: 如果要启用它,请在本地运行此SQL命令:

 GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;FLUSH PRIVILEGES;

And then find the following line and comment it out in your my.cnf file, which usually lives on /etc/mysql/my.cnf on Unix/OSX systems. 然后找到下面一行,在您的评论出来 my.cnf文件,通常生活在/etc/mysql/my.cnf在Unix / OSX系统。 In some cases the location for the file is /etc/mysql/mysql.conf.d/mysqld.cnf). 在某些情况下,文件的位置是/etc/mysql/mysql.conf.d/mysqld.cnf。

If it's a Windows system, you can find it in the MySQL installation directory, usually something like C:\\Program Files\\MySQL\\MySQL Server 5.5\\ and the filename will be my.ini . 如果是Windows系统,则可以在MySQL安装目录中找到它,通常类似于C:\\Program Files\\MySQL\\MySQL Server 5.5\\ ,文件名将为my.ini

Change line 换线

 bind-address = 127.0.0.1

to

 #bind-address = 127.0.0.1

And restart the MySQL server ( Unix/OSX , and Windows ) for the changes to take effect. 并重新启动MySQL服务器( Unix / OSX和Windows ),以使更改生效。


#4楼

In my case I was trying to connect to a remote mysql server on cent OS. 就我而言,我试图连接到cent OS上的远程mysql服务器。 After going through a lot of solutions (granting all privileges, removing ip bindings,enabling networking) problem was still not getting solved. 经过许多解决方案(授予所有特权,删除ip绑定,启用网络连接)之后,问题仍然没有得到解决。

As it turned out, while looking into various solutions,I came across iptables, which made me realize mysql port 3306 was not accepting connections. 事实证明,在研究各种解决方案时,我遇到了iptables,这使我意识到mysql端口3306不接受连接。

Here is a small note on how I checked and resolved this issue. 这是有关我如何检查和解决此问题的小注释。

  • Checking if port is accepting connections: 检查端口是否接受连接:
telnet (mysql server ip) [portNo]
  • Adding ip table rule to allow connections on the port: 添加ip表规则以允许端口上的连接:
iptables -A INPUT -i eth0 -p tcp -m tcp --dport 3306 -j ACCEPT
  • Would not recommend this for production environment, but if your iptables are not configured properly, adding the rules might not still solve the issue. 不建议在生产环境中使用此功能,但是如果您的iptables配置不正确,则添加规则可能仍无法解决问题。 In that case following should be done: 在这种情况下,应执行以下操作:
service iptables stop

Hope this helps. 希望这可以帮助。


#5楼

After doing all of above I still couldn't login as root remotely, but Telnetting to port 3306 confirmed that MySQL was accepting connections. 完成上述所有操作后,我仍然无法以root身份远程登录,但是Telnet到端口3306确认MySQL正在接受连接。

I started looking at the users in MySQL and noticed there were multiple root users with different passwords. 我开始查看MySQL中的用户,发现有多个root用户使用不同的密码。

select user, host, password from mysql.user;

So in MySQL I set all the passwords for root again and I could finally log in remotely as root . 因此,在MySQL我再次为root设置了所有密码,最终我可以以root身份远程登录。

use mysql;
update user set password=PASSWORD('NEWPASSWORD') where User='root';
flush privileges;

#6楼

如果防火墙服务正在运行,请向谁需要它,请检查防火墙端口3306是否也已打开。

如何允许远程连接到MySQL相关推荐

  1. Linux远程连接到MySQL客户端

    第一步:安装docker yum install docker 第二步:使用docker快速部署MySQL服务 1.查找镜像  ----> docker search (MySQL)镜像名: 2 ...

  2. 测试远程连接mysql_让MYSQL服务支持远程连接(允许mysql远程登录)测试可行

    一般来说远程连接MYSQL数据库,除非两台服务器在同个机房的局域网内,不然访问速度肯定很慢,性价比不高,除非为了远程维护方便,不然一般不会有人这么设置,这里简单谈谈如何在WIN系统下设置MYSQL的远 ...

  3. mysql命令远程连接cmd命令行_如何从Windows命令提示符连接到mysql命令行

    如何从Windows命令提示符连接到mysql命令行 我正在尝试从Windows提示符下连接到mysql服务器命令行 我在cmd中写下一行,但出现错误. cd C:\MYSQL\bin\ 然后我执行 ...

  4. Navicat Report Viewer 如何连接到 MySQL 数据库

    Navicat Report Viewer 是一个容易使用的工具.有了用户友好的图形用户介面 (GUI),Navicat Report Viewer 让你浏览由 Navicat Report Buil ...

  5. 如何在SQL Server Management Studio中创建和配置链接服务器以连接到MySQL

    This article will guide you with all the necessary steps to successfully create a linked server in S ...

  6. mysql 远程虚拟主机_navicat 远程连接虚拟机MYSQL数据库

    1. secureCRT远程虚拟机,输入 netstat -anp| grep 3306 如上图结果中显示mysql 3306前面的ip不是0.0.0.0 2.修改/etc/mysql/mysql.c ...

  7. 电脑无法连接mysql_本地电脑无法连接到MySQL

    问题描述: ERROR 1130 (HY000): Host 'localhost' is not allowed to connect to this MySQL server 首先网上的问题大部分 ...

  8. 远程连接访问mysql数据库

    第一:更改 "mysql" 数据库里的 "user" 表里的 "host" 项,从"localhost"改称'%'. 或 ...

  9. linux登录远程mysql_实现MySQL远程登陆在linux下

    以下的文章主要介绍的是在linux操作系统下实现MySQL远程登陆的实际解决方案,其中包括改表法与授权法,如果你对这两种方案感兴趣的话,你就可以对以下的文章进行点击阅读,望你会对其有更深的了解. 解决 ...

最新文章

  1. 封装一个计时器,记录页面的停留时间
  2. 对比MySQL表数据内容方式汇总
  3. node 之 ... 扩展运算符报错
  4. DNS区域传送、子域授权
  5. 大剑无锋之大数据面试题第一套(选择题)
  6. 前端学习(2207):Vue-store文件夹的目录结构
  7. mysql bitmap index_[MySQL] mysql中bitmap的简单运用
  8. 面向对象、继承、多态、封装、匿名内部类的基本知识点复习总结
  9. python解决urllib发送请求报错:urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED].....>
  10. 计算机误删怎么恢复数据,电脑资料数据误删怎么恢复?
  11. Spring MVC (mvc框架)
  12. Buck_Boost电路分析 亲测
  13. 分位数回归(Quantile Regression)
  14. Android程序员简历
  15. UIkit框架之轮播特效
  16. 5G技术演进与核心技术一(笔记)
  17. Spring注解开发配置
  18. SQL执行计划--HIT、SQLPLAN
  19. 卫星ku波段为何优先使用垂直极化波
  20. 网站服务器采用CDN+专线 ,完美加速

热门文章

  1. 数值保留小数点两位,但同时去除小数点后多余0 的 javascript、java实现
  2. Django中的admin
  3. JEECG传统版问题分析
  4. 【转】Fiddler抓包教程
  5. 【学习笔记】一:JavaScript简介
  6. iphoneX的适配问题
  7. .NET 基础 一步步 一幕幕 [前言]
  8. 使用EasyUI的插件前需要引入的文件
  9. 鼠标右键快速连接wifi
  10. Linux下安装Python3.6(可用)