MySQL: Can’t connect to MySQL server on (111 “Connection refused”)
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”)的更多相关文章
- 如何解决远程连接mysql出现Can’t connect to MySQL server on (111 “Connection refused”)的问题
如何解决远程连接mysql出现Can’t connect to MySQL server on (111 “Connection refused”)的问题 开放Mysql的远程连接 在服务器上登录my ...
- [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 ...
- 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: * ...
- nginx 报错 connect() failed (111: Connection refused) while connecting to upstream
公司网站搬迁到新服务器后,发现站点访问不了,network里面提示502,查看相关的server配置,感觉没有什么问题,经过测试发现txt.html.等非php文件能够直接访问,也就是php访问不了, ...
- 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 ...
- Ubuntu下 ssh : connect to host localhost port 22:Connection refused
Ubuntu下测试ssh时使用ssh localhost 命令,出现错误提示connect to host localhost port 22:Connection refused 造成这个错误的原因 ...
- 运行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 ...
- nginx 解决 connect() failed (111: Connection refused) while connecting to upstream,
嗯哼,刚装了个ubuntu的lnmp,我的天啊,踩的坑比我脂肪还多了 比如刚装完的时候访问显示502, 也不知道什么问题,就去看了一下nginx日志 /var/log/nginx/error.log ...
- 解决connect() failed (111: Connection refused) while connecting to upstream
使用nginx时, 有可能遇到connect() failed (111: Connection refused) while connecting to upstream的问题. 如果upstrea ...
随机推荐
- jsp中用java代码拼接下拉选备选项及默认值【我】
<th id="TD_N_CERTIFICATION_TYPE" >证件类型:</th> <td > <select id="C ...
- osgOcean编译
E:\Visual Studio 2015\install\VC>e: E:\Visual Studio 2015\install\VC>E:\Visual Studio 2015\ins ...
- std::wstring std::string w2m m2w
static std::wstring m2w(std::string ch, unsigned int CodePage = CP_ACP) { if (ch.empty())return L&qu ...
- PAT 甲级 1031 Hello World for U (20 分)(一开始没看懂题意)
1031 Hello World for U (20 分) Given any string of N (≥) characters, you are asked to form the char ...
- PPT做交互效果
1 做交互效果(点击一个按钮,弹出某个框或者跳转到某个页面)其实就是若干个PPT页面,利用给按钮增加超链接或者动作 达到点击一个按钮 跳转到另外一个PPT的效果. 2 选择一个形状组件(或者其他组件) ...
- 小程序 实现fadeIn 渐变的效果
const winHeight = wx.getSystemInfoSync().windowHeight Page({ data: { logs: [] }, onLoad: function () ...
- MySQL必知必会:组合查询(Union)
MySQL必知必会:组合查询(Union) php mysqlsql 阅读约 8 分钟 本篇文章主要介绍使用Union操作符将多个SELECT查询组合成一个结果集.本文参考<Mysql ...
- 页面被iframe与无刷新更换url方法
页面被iframe问题解决方法 if (window.top.location !== window.self.location) { const data = JSON.stringify({ if ...
- ElasticSearch文档删除字段
https://www.cnblogs.com/ljhdo/archive/2017/03/24/4885796.html
- iOS-CGAffineTransform相关函数
CGAffineTransform相关函数 CGAffineTransformMakeTranslation(width, 0.0);是改变位置的,CGAffineTransformRotate(tr ...