From 92217f572fa9c9cf648f6e44e81f0adb338e43a1 Mon Sep 17 00:00:00 2001 From: ZacharyZcR <2903735704@qq.com> Date: Fri, 20 Dec 2024 19:12:46 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0MySQL=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E9=9D=B6=E5=9C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TestDocker/MySQL/Dockerfile | 17 +++++++++++++++++ TestDocker/MySQL/README.txt | 5 +++++ TestDocker/MySQL/my.cnf | 2 ++ 3 files changed, 24 insertions(+) create mode 100644 TestDocker/MySQL/Dockerfile create mode 100644 TestDocker/MySQL/README.txt create mode 100644 TestDocker/MySQL/my.cnf diff --git a/TestDocker/MySQL/Dockerfile b/TestDocker/MySQL/Dockerfile new file mode 100644 index 0000000..5b14e00 --- /dev/null +++ b/TestDocker/MySQL/Dockerfile @@ -0,0 +1,17 @@ +# 使用MySQL官方镜像 +FROM mysql:latest + +# 设置环境变量 +ENV MYSQL_ROOT_PASSWORD=123456 +ENV MYSQL_DATABASE=mydb + +# 开放3306端口 +EXPOSE 3306 + +# MySQL配置 +# 允许远程访问 +COPY my.cnf /etc/mysql/conf.d/my.cnf + +# 健康检查 +HEALTHCHECK --interval=30s --timeout=3s \ + CMD mysql -uroot -p"${MYSQL_ROOT_PASSWORD}" -e "SELECT 1" || exit 1 \ No newline at end of file diff --git a/TestDocker/MySQL/README.txt b/TestDocker/MySQL/README.txt new file mode 100644 index 0000000..e0a25fd --- /dev/null +++ b/TestDocker/MySQL/README.txt @@ -0,0 +1,5 @@ +docker build -t mysql-server . +docker run -d \ + -p 3306:3306 \ + --name mysql-container \ + mysql-server \ No newline at end of file diff --git a/TestDocker/MySQL/my.cnf b/TestDocker/MySQL/my.cnf new file mode 100644 index 0000000..ff1b64f --- /dev/null +++ b/TestDocker/MySQL/my.cnf @@ -0,0 +1,2 @@ +[mysqld] +bind-address = 0.0.0.0 \ No newline at end of file