修改docker中mysql配置文件,在mysqld项目下新增port=3307
配置
[mysqld]
port=3307
federated
max_connections = 200
max_allowed_packet = 64M
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
#限制mysql内存占用
#performance_schema_max_table_instances=400
#table_definition_cache=400
#table_open_cache=256
character-set-server=utf8
collation-server=utf8_general_ci
skip-character-set-client-handshake
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
[mysql.server]
default-character-set=utf8
[mysqld_safe]
default-character-set=utf8
之后执行mysql.sh脚本
#!/usr/bin/env bash
config_dir=`pwd`
PASSWORD=123456
docker run -d --net host --name solo_mysql\
-p 3307:3307 \
-e MYSQL_ROOT_PASSWORD=$PASSWORD \
-e TZ=Asia/Shanghai \
--restart=always \
-v ${config_dir}/mysqld.cnf:/etc/mysql/mysql.conf.d/mysqld.cnf \
mysql:5.7
exit
若容器已经生成,则先停止宿主机mysql服务,之后启动容器,通过docker exec命令进入容器中,修改/etc/mysql/mysql.conf.d/mysqld.cnf
配置文件即可
“The first 90% of the code accounts for the first 90% of the development time. The remaining 10% of the code accounts for the other 90% of the development time.” – Tom Cargill
标 题:如何修改docker容器中mysql的端口号