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 ...
随机推荐
- 阶段5 3.微服务项目【学成在线】_day17 用户认证 Zuul_12-用户退出-服务端
实现退出 用户退出要以下动作: 1.删除redis中的token 2.删除cookie中的token controller内定义 spring securety config内放行 对这个url放行 ...
- linux下nginx结合keepalived实现主从切换的配置
linux下nginx结合keepalived实现主从切换的配置 解决方法: 实现一个主nginx宕机,请求转到另一个nginx中. 1.确保两台nginx已启动,假如端口分别是192.168.0 ...
- pycharm重命名文件
先右键要重命名的文件,然后按照下图操作:
- charles 白名单
本文参考:charles 白名单 charles 白名单 白名单工具,允许您阻止除选定位置之外的所有请求. 注意:如果一个请求与"黑名单"和"白名单"同时匹配成 ...
- 前端添加视频流rtmp格式
要求:rtmp格式, 在线直播 url地址 效果: 代码:初次打开时间较长, <!DOCTYPE html> <html> <head> <script ty ...
- VS2017.常量中有换行符
1.VS中加入 “/utf-8” Qt中 也是加入“/utf-8”,加的地方注意下:在 pro文件中 ,这个位置加入: win32-msvc*:QMAKE_CXXFLAGS += /wd"4 ...
- PL/SQL链接Oracle数据库 导出表结构和表数据
打开pl/sql客户端(导出数据表结构) 在左侧 点击tabales 2 Tools-->Export User Objects,导出sql格式的文件 3 红色1 是你要选择导出的表,红色2 是 ...
- Ext 默认时间
Ext js 设置默认时间 实例效果: 实现代码:
- 批量添加删除Windows server DNS服务 恶意域名 * A记录 指向 127.0.0.1(2019年6月5日更新)
下载链接:https://pan.baidu.com/s/1OUHyvnIfXYF0PdiT-VRyHw 密码:7gjj 注意!本解决方案在本地的Windows server服务器上把恶意域名指向1 ...
- php-fpm,cgi,fast-cgi,nginx,php.ini,php-fpm.conf,nginx.conf
php-fpm.conf 是PHP-FPM特有的配置文件. php.ini 是所以php模式中必须的配置文件. 两者的区别是,php-fpm.conf 是PHP-FPM进程管理器的配置文件,php.i ...