docker安装的mysql修改配置文件方式
一、先看一下容器绑定的配置文件目录在哪
docker inspect 347
如图:
mysql容器的配置文件映射在服务器 /opt/mysql_docker/conf目录下。
所以想修改容器的配置文件内容,只需要修改 /opt/mysql_docker/conf中的配置文件。

二、发现 /opt/mysql_docker/conf
目录下没有文件
三、进入mysql容器
复制mysql的配置文件内容
docker exec -it 347 /bin/bash cd /etc/mysql/conf.d cat mysqld.cnf
复制内容如下:
# Copyright (c) 2014, 2021, Oracle and/or its affiliates. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License, version 2.0, # as published by the Free Software Foundation. # # This program is also distributed with certain software (including # but not limited to OpenSSL) that is licensed under separate terms, # as designated in a particular file or component or in included license # documentation. The authors of MySQL hereby grant you an additional # permission to link the program and your derivative works with the # separately licensed software that they have included with MySQL. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License, version 2.0, for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # # The MySQL Server configuration file. # # For explanations see # http://dev.mysql.com/doc/mysql/en/server-system-variables.html [mysqld] pid-file = /var/run/mysqld/mysqld.pid socket = /var/run/mysqld/mysqld.sock datadir = /var/lib/mysql #log-error = /var/log/mysql/error.log # By default we only accept connections from localhost #bind-address = 127.0.0.1 # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTIONroot@347e69759ec4:/etc/mysql/conf.d# cat mysqld.cnf
四、在服务器/opt/mysql_docker/conf 下
新建配置文件mysqld.cnf,内容来自第三步复制内容。
五、重启容器
docker start 347
发现报出异常如下:
Error response from daemon: driver failed programming external connectivity on endpoint mysqlserver (c97a49898a84bdfaadaa8510a81f99d3eb7b19fd3eb4451dba7f6d70f9516409): (iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dport 3306 -j DNAT --to-destination 172.18.0.5:3306 ! -i docker0: iptables: No chain/target/match by that name.
(exit status 1))
Error: failed to start containers: 347
解决方法:
重启docker,再启动mysql容器。
service docker restart
六、总结
以上为个人经验,希望能给大家一个参考,也希望大家多多支持脚本之家。
相关文章
CentOS8上用Docker部署开源项目Tcloud的教程
这篇文章主要介绍了CentOS8上用Docker部署开源项目Tcloud,本文给大家介绍的非常详细,具有一定的参考借鉴价值,需要的朋友可以参考下2020-01-01
解读Dockerfile中CMD和ENTRYPOINT是否可以混着用
在Dockerfile中,CMD和ENTRYPOINT可以混着用,CMD指定默认命令,ENTRYPOINT指定启动命令,CMD可以被docker run命令的参数覆盖2025-03-03
docker部署xxl-job-admin出现数据库拒绝问题及解决方法
这篇文章主要介绍了docker部署xxl-job-admin出现数据库拒绝问题,本文给大家分享正确的解决思路,对docker部署xxl-job-admin相关知识感兴趣的朋友一起看看吧2023-02-02


最新评论