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. 阶段5 3.微服务项目【学成在线】_day18 用户授权_12-前端集成认证授权-携带JWT授权

    携带JWT授权 登陆后jwt已经存到了sessionStorage里面 当进行微服务的请求就要携带令牌.我们在拦截器里面做文章. 在axios的intercepters拦截器上 手工的给这个课程 造一 ...

  2. 阶段5 3.微服务项目【学成在线】_day16 Spring Security Oauth2_06-SpringSecurityOauth2研究-Oauth2授权码模式-申请令牌

    3.3 Oauth2授权码模式 3.3.1 Oauth2授权模式 Oauth2有以下授权模式: 授权码模式(Authorization Code) 隐式授权模式(Implicit) 密码模式(Reso ...

  3. Python - Django - 作者表多对多关联书籍表

    models.py 代码: from django.db import models # Create your models here. # 出版社 class Publisher(models.M ...

  4. c-lodop的三个进程和一个服务介绍

    在windows任务管理器里,最新版可以看到有三个进程,例如安32位c-lodop的时候,有CLodopPrint32.exe.CLodopPrint32_backup.exe.CLodopServi ...

  5. python 创建虚拟环境(virtualenv)

    原文地址:https://www.jianshu.com/p/2645d8f2e690 另附连接:Linux环境下虚拟环境virtualenv安装和使用 virtualenv 安装 1.Install ...

  6. linux服务器常用密令

    1. 什么是linux服务器load average? Load是用来度量服务器工作量的大小,即计算机cpu任务执行队列的长度,值越大,表明包括正在运行和待运行的进程数越多.参考资料:http://e ...

  7. [转载]Oracle中动态SQL详解

    1.静态SQLSQL与动态SQL Oracle编译PL/SQL程序块分为两个种:其一为前期联编(early binding),即SQL语句在程序编译期间就已经确定,大多数的编译情况属于这种类型:另外一 ...

  8. ROS学习(二)运行keyboard

    1.ssh连接机器人 ./dora*.sh 启动roscore,相当于启动ros系统 roscore 2.另启终端,也就意味着重新ssh连接机器人, ./dora*.sh 运行wheel驱动 rosr ...

  9. Jmeter做HTTP接口测试

    接口测试概述:https://www.cnblogs.com/mawenqiangios/p/7886115.html Jmeter接口测试教程:https://www.cnblogs.com/hou ...

  10. Demonstration(CodeForces-191B)【贪心】

    题目链接:https://vjudge.net/problem/CodeForces-191B 题意:过于繁琐,略 思路:真·神级贪心题 首先我们可以想到的是,为了在k天内选到最靠前的城市,我们要想办 ...