Linux(CentOS7.5):通过docker安装mysql8.0

一、预创建存储券映射

mkdir -p /opt/docker_mysql/conf/conf.d;
mkdir -p /opt/docker_mysql/data;
mkdir -p /opt/docker_mysql/logs;
mkdir -p /opt/docker_mysql/mysql-files;

chmod -R 755 /opt/docker_mysql;

二、编辑配置文件

vim /opt/docker_mysql/conf/conf.d/my.cnf
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/8.0/en/server-configuration-defaults.html

[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M

# Remove leading # to revert to previous value for default_authentication_plugin,
# this will increase compatibility with older clients. For background, see:
# https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_default_authentication_plugin
# default-authentication-plugin=mysql_native_password
skip-host-cache
skip-name-resolve
datadir=/var/lib/mysql
socket=/var/run/mysqld/mysqld.sock
secure-file-priv=/var/lib/mysql-files
user=mysql

pid-file=/var/run/mysqld/mysqld.pid
[client]
socket=/var/run/mysqld/mysqld.sock

!includedir /etc/mysql/conf.d/

# 此处必须把配置文件的权限给改小,否则,容器内部会忽略该配置文件
chmod 644 /opt/docker_mysql/conf/conf.d/my.cnf 

三、安装

docker run \
--restart=always \
--name mysql8.0 \
--privileged=true \
-v /opt/docker_mysql/conf/:/etc/mysql \
-v /opt/docker_mysql/data:/var/lib/mysql \
-v /opt/docker_mysql/logs:/var/log \
-v /opt/docker_mysql/mysql-files:/var/lib/mysql-files \
-p 3306:3306 \
-e MYSQL_ROOT_PASSWORD='yourPasswd' \
-d mysql:8.0 \
--lower_case_table_names=1

相关推荐

  1. Linux(CentOS7.5):通过docker安装mysql8.0

    2024-03-11 17:38:01       19 阅读
  2. MySQL商城数据表(80-88

    2024-03-11 17:38:01       12 阅读
  3. MySQL商城数据表(80-84

    2024-03-11 17:38:01       9 阅读
  4. dockerdocker安装Mysql

    2024-03-11 17:38:01       33 阅读
  5. 商城数据库(77-80

    2024-03-11 17:38:01       13 阅读
  6. 商城数据库88章表72~75

    2024-03-11 17:38:01       11 阅读
  7. docker安装mysql8

    2024-03-11 17:38:01       32 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-03-11 17:38:01       19 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-03-11 17:38:01       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-03-11 17:38:01       20 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-03-11 17:38:01       20 阅读

热门阅读

  1. cudnn下载国内满速下载地址长期有效更新

    2024-03-11 17:38:01       19 阅读
  2. Redis info - 内存

    2024-03-11 17:38:01       19 阅读
  3. Apache拦截不安全漏洞

    2024-03-11 17:38:01       21 阅读
  4. python基础练习 序列求和

    2024-03-11 17:38:01       20 阅读
  5. 阿尔巴尼亚借助ChatGPT加快欧盟入会进程

    2024-03-11 17:38:01       22 阅读
  6. 3.最长连续序列

    2024-03-11 17:38:01       18 阅读
  7. _note_01

    2024-03-11 17:38:01       17 阅读
  8. TypeScript 5.4 正式发布

    2024-03-11 17:38:01       22 阅读
  9. Spring MVC面试系列-01

    2024-03-11 17:38:01       17 阅读
  10. numpy和pytorch的tensor哪个效率更高?

    2024-03-11 17:38:01       22 阅读