美文网首页
Docker容器连接外部Mysql

Docker容器连接外部Mysql

作者: 小丸子的呆地 | 来源:发表于2021-11-10 17:30 被阅读0次

容器内部程序连接外部mysql,需要以远程连接的方式进行访问

  1. 开启mysql 远程连接
  • 找到my.cnf配置文件
  • 注释掉 bind-address = 127.0.0.1,
  • 重启mysql
  1. 授权root用户可以在任何地址发起连接
    create user 'root'@'%' identified by 'root';
    grant all privileges on . to "root"@'%';
  2. 修改内部程序jdbc连接,不能使用回环地址,需要使用主机IP地址,通过ifconfig查询

相关文章

网友评论

      本文标题:Docker容器连接外部Mysql

      本文链接:https://www.haomeiwen.com/subject/selizltx.html