synchronization
This commit is contained in:
20
Docker/Dockerfile/Mysql/Dockerfile
Normal file
20
Docker/Dockerfile/Mysql/Dockerfile
Normal file
@@ -0,0 +1,20 @@
|
||||
FROM mysql:5.7
|
||||
# FROM mysql:8
|
||||
|
||||
ENV MYSQL_USER=demo \
|
||||
MYSQL_PASSWORD=demo \
|
||||
MYSQL_DATABASE=demo \
|
||||
MYSQL_ROOT_PASSWORD=root
|
||||
|
||||
COPY ./sql/* /docker-entrypoint-initdb.d/
|
||||
|
||||
# 更改配置文件
|
||||
#COPY ./my.cnf /etc/my.cnf
|
||||
|
||||
CMD ["mysqld", "--character-set-server=utf8mb4", "--collation-server=utf8mb4_unicode_ci"]
|
||||
|
||||
# 旧加密方式
|
||||
# --default-authentication-plugin=mysql_native_password
|
||||
# 是一种基本的身份验证插件,它使用经典的 MySQL 加密方法来存储和验证用户的密码。这意味着用户的密码以散列形式存储在数据库中,而在用户登录时,其密码将与存储的散列进行比较。
|
||||
# 新加密方式
|
||||
# --default-authentication-plugin=caching_sha2_password
|
14
Docker/Dockerfile/Mysql/Dockerfile-secrets
Normal file
14
Docker/Dockerfile/Mysql/Dockerfile-secrets
Normal file
@@ -0,0 +1,14 @@
|
||||
FROM mysql:5.7
|
||||
# FROM mysql:8
|
||||
|
||||
ENV MYSQL_ROOT_PASSWORD_FILE=/run/secrets/mysql-root-pass \
|
||||
MYSQL_USER=demo \
|
||||
MYSQL_DATABASE=demo \
|
||||
MYSQL_PASSWORD_FILE=/run/secrets/mysql-demo-pass
|
||||
|
||||
COPY ./sql/* /docker-entrypoint-initdb.d/
|
||||
|
||||
# 更改配置文件
|
||||
#COPY ./my.cnf /etc/my.cnf
|
||||
|
||||
CMD ["mysqld", "--character-set-server=utf8mb4", "--collation-server=utf8mb4_unicode_ci"]
|
21
Docker/Dockerfile/Mysql/README.md
Normal file
21
Docker/Dockerfile/Mysql/README.md
Normal file
@@ -0,0 +1,21 @@
|
||||
*
|
||||
|
||||
> 本文作者:丁辉
|
||||
|
||||
# Mysql 镜像构建
|
||||
|
||||
- 自动初始化 Mysql 数据库, 构建示例
|
||||
|
||||
```bash
|
||||
docker build -t <镜像名:标签> .
|
||||
```
|
||||
|
||||
- Mysql 通过 Secrets 隐藏构建账户密码, 示例
|
||||
|
||||
[Mysql-Secrets 使用](https://gitee.com/offends/Kubernetes/tree/main/Docker/Docker%E4%BD%BF%E7%94%A8%E6%96%87%E6%A1%A3/Mysql-secrets%E4%BD%BF%E7%94%A8.md)
|
||||
|
||||
```bash
|
||||
docker build -t <镜像名:标签> --file=./Dockerfile-secrets .
|
||||
```
|
||||
|
||||
|
1
Docker/Dockerfile/Mysql/my.cnf
Normal file
1
Docker/Dockerfile/Mysql/my.cnf
Normal file
@@ -0,0 +1 @@
|
||||
# 写入配置文件指定内容
|
1
Docker/Dockerfile/Mysql/sql/01_init_offends.sql
Normal file
1
Docker/Dockerfile/Mysql/sql/01_init_offends.sql
Normal file
@@ -0,0 +1 @@
|
||||
-- 初始化基础 sql
|
Reference in New Issue
Block a user