• 欢迎访问VPS岛网站,国外VPS,国内VPS,国外服务器,国内服务器,服务器主机,测评及优惠码,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站 QQ群

centos7中 docker 安装mysql5.7

Centos技术 大酥酥 27次浏览 已收录 0个评论

1、 安装docker

 添加依赖

yum -y install yum-utils device-mapper-persistent-data lvm2

curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

yum-config-manager –add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

安装   yum -y install docker-ce   

添加镜像加速器

mkdir  /etc/docker && vim /etc/docker/daemon.json  添加下列东西

{  "registry-mirrors": ["https://9cpn8tt6.mirror.aliyuncs.com"]
}

启动 systemctl start docker  开机自动  systemctl enable docker 

 使用 mysql:5.7 镜像创建 mysql 容器

docker run -dit -v /root/mysql/conf:/etc/mysql/conf.d -v /root/mysql/logs:/logs -v /root/mysql/data:/var/lib/mysql -p 3306:3306 –restart=always  -e MYSQL_ROOT_PASSWORD=root –name mysql mysql:5.7

将 下列 mysql配置 放到/root/mysql/conf 目录下  vim /root/mysql/conf/mysl.cnf

[mysqld]

pid-file = /var/run/mysqld/mysqld.pid

socket = /var/run/mysqld/mysqld.sock

datadir = /var/lib/mysql

symbolic-links=0

character-set-server = utf8

#skip-networking

innodb_print_all_deadlocks = 1

max_connections = 2000

max_connect_errors = 6000

open_files_limit = 65535

table_open_cache = 128

max_allowed_packet = 16M

binlog_cache_size = 1M

max_heap_table_size = 80M

tmp_table_size = 16M

read_buffer_size = 20M

read_rnd_buffer_size = 8M

innodb_buffer_pool_size = 1G

sort_buffer_size = 8M

join_buffer_size = 128M

key_buffer_size = 4M

thread_cache_size = 8

query_cache_type = 1

query_cache_size = 24M

query_cache_limit = 2M

ft_min_word_len = 4

log-bin = mysql-bin

server-id = 1

binlog_format = mixed

performance_schema = 0

explicit_defaults_for_timestamp

lower_case_table_names = 1

interactive_timeout = 28800

wait_timeout = 28800

sql_mode=NO_ENGINE_SUBSTITUTION,NO_AUTO_CREATE_USER,STRICT_TRANS_TABLES

[mysqldump]

quick

max_allowed_packet = 16M

[myisamchk]

key_buffer_size = 8M

sort_buffer_size = 8M

read_buffer = 4M

write_buffer = 4M

docker ps 查看 mysql 正常运行 用户名和 密码均是 root

image.png


VPS岛 的文章和资源来自互联网,仅作为参考资料,如果有侵犯版权的资源请尽快联系站长,我们会在24h内删除有争议的资源。丨 转载请注明centos7中 docker 安装mysql5.7
喜欢 (0)
发表我的评论
取消评论
表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址