1. Mysql连接问题

远程访问mysql或者通过docker访问宿主机mysql经常会碰到下面的问题:

Can’t connect to MySQL server on (111 “Connection refused”)

解决

找到自己MySQL数据库配置文件的位置,编辑

/etc/mysql/mysql.conf.d# vi mysqld.cnf

bind_address 127.0.0.1 注释掉

2. 开放远程连接后,会出现第二个问题:

"Host 'x.x.x.x' is not allowed to connect to this MySQL server"

解决办法

root 进入数据库

$ mysql -uroot -p

执行下方两行命令:

grant all privileges on *.* to 'root'@'%' identified by '12345678' with grant option;

开放所有权限给root,当root以12345678密码从任意IP登入的时候,允许其操作所有数据库下的所有表

flush privileges;

刷新,使上述命令生效

3. 重启数据库

$ /etc/init.d/mysql stop
$ /etc/init.d/mysql start

再从docker或者远程主机访问数据库的时候就可以了

$ telnet 172.17.0.1 3306
Trying 172.17.0.1...
Connected to 172.17.0.1.
Escape character is '^]'.

注意: grant all privileges on *.* to 'root'@'%' identified by '12345678' with grant option; 给root用户(mysql用户里面的root,不是主机)

所有数据库的最高权限,可能会有安全隐患。可以根据具体需求限制对具体的数据库,甚至是表格进行授权

MySQL: Can’t connect to MySQL server on (111 “Connection refused”)的更多相关文章

  1. 如何解决远程连接mysql出现Can’t connect to MySQL server on (111 “Connection refused”)的问题

    如何解决远程连接mysql出现Can’t connect to MySQL server on (111 “Connection refused”)的问题 开放Mysql的远程连接 在服务器上登录my ...

  2. [nginx] connect() failed (111: Connection refused) while connecting to upstream, client: 101.18.123.107, server: localhost,

    nginx一直报错, 2016/12/02 10:23:19 [error] 1472#0: *31 connect() failed (111: Connection refused)while c ...

  3. nginx访问502 gateway,*1 connect() failed (111: Connection refused) while connecting to upstream

    安装好nginx,php环境后,配置虚拟主机,结果访问后就报502 gateway,查看日志文件后,显示错误如下: 2019/04/29 16:24:39 [error] 19433#19433: * ...

  4. nginx 报错 connect() failed (111: Connection refused) while connecting to upstream

    公司网站搬迁到新服务器后,发现站点访问不了,network里面提示502,查看相关的server配置,感觉没有什么问题,经过测试发现txt.html.等非php文件能够直接访问,也就是php访问不了, ...

  5. zabbix-Get value from agent failed: cannot connect to [[127.0.0.1]:10050]: [111] Connection refused

    监控zabbix服务端这台服务器,然后显示Get value from agent failed: cannot connect to [[127.0.0.1]:10050]: [111] Conne ...

  6. Ubuntu下 ssh : connect to host localhost port 22:Connection refused

    Ubuntu下测试ssh时使用ssh localhost 命令,出现错误提示connect to host localhost port 22:Connection refused 造成这个错误的原因 ...

  7. 运行Hadoop start-all.sh遇到的错误ssh: connect to host localhost port 22: Connection refused

    ssh: connect to host localhost port 22: Connection refused 我的情况是ssh server没装,查看方法: ps -e |grep ssh 1 ...

  8. nginx 解决 connect() failed (111: Connection refused) while connecting to upstream,

    嗯哼,刚装了个ubuntu的lnmp,我的天啊,踩的坑比我脂肪还多了 比如刚装完的时候访问显示502, 也不知道什么问题,就去看了一下nginx日志  /var/log/nginx/error.log ...

  9. 解决connect() failed (111: Connection refused) while connecting to upstream

    使用nginx时, 有可能遇到connect() failed (111: Connection refused) while connecting to upstream的问题. 如果upstrea ...

随机推荐

  1. Qt编写自定义控件50-迷你仪表盘

    一.前言 这个控件取名叫迷你仪表盘,是以为该控件可以缩小到很小很小的区域显示,非常适合小面积区域展示仪表数据使用,还可以手动触摸调节进度,是我个人觉得最漂亮小巧的一个控件.初次看到类似的控件是在一个音 ...

  2. Node中使用MySQL报错:TypeError: Cannot read property 'query' of undefined

    Node中使用MySQL报错: TypeError: Cannot read property 'query' of undefined at /Users/sipeng/Desktop/彭思/201 ...

  3. 偶尔在网上看到的,相对比较好的c#端订单号生成规则

    偶尔在网上看到的,相对比较好的c#端订单号生成规则 public class BillNumberBuilder{     private static object locker = new obj ...

  4. DLT(Direct Linear Transform)算法

    1.DLT定义            DLT是一个 用于解决包含尺度问题的最小二乘问题 的算法.           DLT解决问题的标准形式为:                            ...

  5. 【c# 学习笔记】接口与抽象类

    抽象类经常与接口一起使用,共同服务于面向对象的编程,这里简单地分析一下接口与抽象类的区别,如下: 1.抽象类使用abstract关键字进行定义,而接口使用interface进行定义:它们都不能进行实例 ...

  6. 利用socket编程在ESP32上搭建一个TCP客户端

    通过之前http://www.cnblogs.com/noticeable/p/7636582.html中对socket的编程,已经可以知道如何通过socket编程搭建服务器和客户端了,现在,就在ES ...

  7. 使用Vulcan工具构建真实的业务负载进行网络压力测试,满足SD-WAN,White-box Switch的Performance,QoE,SLA测试要求

    工具链接#  https://xenanetworks.com/vulcan/ 使用Vulcan工具,可构建真实的业务负载进行网络压力测试 满足Performance,QoE,SLA等测试要求 硬件指 ...

  8. 游戏协议模拟测试工具(TcpEngine)使用简介

    功能介绍 在有的网络开发需要走二进制流协议场景,比如网络游戏开发,在开发阶段,前端和后端协商好协议后就分别开发.在开发写代码的时候,有时需要对端发送一条完整的协议过来触发一下自己的代码,进行单步调试或 ...

  9. Bandicam录制三大神器之一

    链接: http://pan.baidu.com/s/1bnDIUOv 密码: etge

  10. Oracle 计算时间格式平均值

    select to_char((to_date('2019-07-01', 'yyyy-mm-dd') + numtodsinterval(avg(begin_time_second), 'secon ...