博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
MySQL 8.0 Docker使用注解
阅读量:4322 次
发布时间:2019-06-06

本文共 3799 字,大约阅读时间需要 12 分钟。

PUBLIC | AUTOMATED BUILD
/
Last pushed: 8 months ago
Short Description
MySQL 8.0 on CentOS 7
Full Description

MySQL 8.0 Docker

<small>Latest build: 2017-08-30</small>

   

 |  |  | mysql 8.0 |  |  |  |  |  |  |  | 


MySQL 8.0 Docker on CentOS 7

<sub>This docker image is part of the </sub>


Options

Environmental variables

Required environmental variables

Variable Type Description
MYSQL_ROOT_PASSWORD string MySQL root user password of either existing database or in case it does not exist it will initialize the new database with the given password.

Optional environmental variables

Variable Type Default Description
DEBUG_COMPOSE_ENTRYPOINT bool 0 Show shell commands executed during start.<br/>Value: 0 or 1
TIMEZONE string UTC Set docker OS timezone.<br/>Example: Europe/Berlin
MYSQL_SOCKET_DIR string /var/sock/mysqld Path inside the docker to the socket directory.<br/><br/>Used to separate socket directory from data directory in order to mount it to the docker host or other docker containers.<br/><br/>Mount this directory to a PHP container and be able to use mysqli_connect with localhost.
MYSQL_GENERAL_LOG bool 0 Turn on or off general logging<br/>Corresponds to mysql config: general-log<br/>Value: 0 or 1

Default mount points

Docker Description
/var/lib/mysql MySQL data dir
/var/log/mysql MySQL log dir
/var/sock/mysqld MySQL socket dir
/etc/mysql/conf.d MySQL configuration directory (used to overwrite MySQL config)
/etc/mysql/docker-default.d MySQL configuration directory (used to overwrite MySQL config)

Default ports

Docker Description
3306 MySQL listening Port

Usage

1. Listen on loopback interface only

$ docker run -i \    -p 127.0.0.1:3306:3306 \    -e MYSQL_ROOT_PASSWORD=my-secret-pw \    -t cytopia/mysql-8.0# Access MySQL from your host computer$ mysql --user=root --password=my-secret-pw --host=127.0.0.1 -e 'show databases;'

2. Enable logging

Enable logging and mount the log directory to your host to ~tmp/mysql-log

$ docker run -i \    -p 127.0.0.1:3306:3306 \    -v ~tmp/mysql-log:/var/log/mysql \    -e MYSQL_ROOT_PASSWORD=my-secret-pw \    -e MYSQL_GENERAL_LOG=1 \    -t cytopia/mysql-8.0# Access MySQL from your host computer$ mysql --user=root --password=my-secret-pw --host=127.0.0.1 -e 'show databases;'

3. Mount MySQL socket to the host

Use MySQL socket for localhost connections through the socket. No need to expose the MySQL port to the host in this case.

$ docker run -i \    -v ~tmp/mysql-sock:/var/sock/mysqld \    -e MYSQL_ROOT_PASSWORD=my-secret-pw \    -t cytopia/mysql-8.0# Access MySQL from your host computer via socket$ mysql --user=root --password=my-secret-pw --socket=/var/sock/mysqld/mysqld.sock -e 'show databases;'

4. Overwrite configuration

You can also add any configuration settings prior startup to MySQL.

# Create local config with buffer overwrite$ printf "[mysqld]\n%s\n" "key_buffer = 500M" > ~/tmp/mysqld_config/buffer.cnf$ docker run -i \    -p 127.0.0.1:3306:3306 \    -v ~/tmp/mysqld_config:/etc/mysql/conf.d \    -e MYSQL_ROOT_PASSWORD=my-secret-pw \    -t cytopia/mysql-8.0

MySQL Configuration overview

Configuration files inside this docker are read in the following order:

Order File Description
1 /etc/my.cnf Operating system default
2 /etc/mysql/conf.d/ Custom configuration (level 1). Can be mounted to provide custom *.cnf files which can overwrite anything of the above. (used by the devilbox for its base configuration)
3 /etc/mysql/docker-default.d/*.cnf Custom configuration (level 2). Can be mounted to provide custom *.cnf files which can overwrite anything of the above. (used by the devilbox to allow custom user-defined configuration overwriting the default devilbox settings.

Modules

[Version]

/usr/sbin/mysqld Ver 8.0.2-dmr for Linux on x86_64 (MySQL Community Server (GPL))

转载于:https://www.cnblogs.com/it-tsz/p/8973635.html

你可能感兴趣的文章
python接口自动化--get请求
查看>>
ajax 上传文件
查看>>
lintcode-easy-Flatten Binary Tree to Linked List
查看>>
从远程队列中读取消息
查看>>
typescript 接口的新认识
查看>>
java常见面试题及三大框架面试
查看>>
懒惰的肥兔博文导读
查看>>
[db] mongodb 存取修改简单小实例
查看>>
面试百题003——求子数组的最大和
查看>>
jq.validate 自定义验证两个日期
查看>>
公布一个以前写的随机数生成的方法
查看>>
AtCoder Regular Contest 077 被虐记&题解
查看>>
禁止ios10双指缩放
查看>>
LUOGU P1505 [国家集训队]旅游 (树链剖分+线段树)
查看>>
BZOJ 3509: [CodeChef] COUNTARI(fft+分块)
查看>>
flask源码解读05: Context(AppContext, RequestContext)
查看>>
css实现弹出层显示阻止滚动条滚动
查看>>
ping IP 带时间戳循环显示并写入日志(windos版+linux版)
查看>>
自学MVC看这里——全网最全ASP.NET MVC 教程汇总
查看>>
mediaxyz访谈录:ffmpeg的码率控制
查看>>