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. python2,socket多进程的错误pickle.PicklingError: Can't pickle

    python2,socket多进程的错误pickle.PicklingError: Can't pickle 源码: #coding:utf-8 import socket import pickle ...

  2. java获取两个日期之间的所有日期

    java获取两个日期之间的所有日期   解决方法: 1.核心方法 private List<String> getBetweenDates(String start, String end ...

  3. Vue+MySQL实现购物车的增删改查

    1,创建简单数据库数据表 2,创建Mapper文件 <!--查询商品--> <select id="selectcommodity" resultType=&qu ...

  4. 重新认识Java 8的HashMap

    [转自]美团技术博客 HashMap是Java程序员使用频率最高的用于映射(键值对)处理的数据类型.随着JDK(Java Developmet Kit)版本的更新,JDK1.8对HashMap底层的实 ...

  5. git 平时遇到的问题记录

    1.git warning: LF will be replaced by CRLF in 解决办法 git config core.autocrlf false 2.git提交时如何忽略一些文件 h ...

  6. json 格式化输出

    C#格式化JSON字符串 很多时候我们需要将json字符串以 {     "status": 1,     "sum": 9 }这种方式显示,而从服务端取回来的 ...

  7. 股票PE的应用

    投资股票前,需要先分析公司,然后做估值.最后拿这估值对比现在它的现价,如果现价远低于估值,那就买入,因为这时候相当于打折价. 分析要怎么分析,估值要怎么估值 就像拿不同的旋头去维修不同的电器是一样的原 ...

  8. 最新 翔通动漫java校招面经 (含整理过的面试题大全)

    从6月到10月,经过4个月努力和坚持,自己有幸拿到了网易雷火.京东.去哪儿.翔通动漫等10家互联网公司的校招Offer,因为某些自身原因最终选择了翔通动漫.6.7月主要是做系统复习.项目复盘.Leet ...

  9. vector iterators incompatible

    字面翻译迭代器类型不兼容 今天同事遇到的这个问题算是一个习惯性写法的问题.描述一下代码: struct Track{}; class BaseTrack { - std::vector<Trac ...

  10. [转帖]阿里云VS腾讯云 谁才是中国未来的云计算之王?

    阿里云VS腾讯云 谁才是中国未来的云计算之王? https://www.qianzhan.com/analyst/detail/220/191008-f05009f6.html 吴小燕• 2019-1 ...