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 ...
随机推荐
- ubuntu下编译和使用libxml2
安装: #sudo apt-get install libxml2 #sudo apt-get install libxml2-dev sudo apt-get install libxml2-dev ...
- 32Flutter仿京东商城项目 用户中心页面布局
import 'package:flutter/material.dart'; import 'package:flutter_jdshop/services/ScreenAdapter.dart'; ...
- webpack——Modules && Hot Module Replacement
blog:JavaScript Module Systems Showdown: CommonJS vs AMD vs ES2015 官网链接: Modules 官网链接:Hot Module Rep ...
- Qt编写自定义控件42-开关按钮
一.前言 从2010年进入互联网+智能手机时代以来,各种各样的APP大行其道,手机上面的APP有很多流行的元素,开关按钮个人非常喜欢,手机QQ.360卫士.金山毒霸等,都有很多开关控制一些操作,在Qt ...
- Mac更新npm和node版本
npm: 查看当前版本: npm --version 更新到最新版: sodu npm install npm@latest -g node: 1.查看当前版本: node -v 2.清除npm当前缓 ...
- linux计划任务以某个用户身份执行
# Example of job definition: # .---------------- minute (0 - 59) # | .------------- hour (0 - 23) # ...
- C#关于DateTime得到的当前时间的格式和用法
DateTime.Now.ToShortTimeString() DateTime dt = DateTime.Now; dt.ToString();//2005-11-5 13:21:25 dt.T ...
- react 打印页面怎么实现?
2017-11-10 react 打印页面怎么实现?
- 解决访问github等网站慢或下载失败的问题
最近老大push项目,正常的git clone每次都是下载一部分就断掉了.下面介绍网上找到的两种方法: 方法一: 1.打开网站https://www.ipaddress.com/: 2.分别在上面打开 ...
- 安卓 adb命令
获取包名 aapt d badging C:\Users\600844\Desktop\beijingtoon.apk "package launchable-activity" ...