当前位置:网站首页>Docker compose配置MySQL并实现远程连接
Docker compose配置MySQL并实现远程连接
2022-07-06 01:15:00 【php的绯闻女友】
您需要确保您的运行环境达到了以下的要求:
- Docker Engine
- Docker CLI
- Docker Compose
docker-compose.yml
version: '3.7'
services:
mysql:
image: "mysql/mysql-server:8.0"
environment:
TZ: "Asia/Shanghai"
MYSQL_ROOT_PASSWORD: "123456" # 设置root密码
MYSQL_DATABASE: "library_manager" # 设置数据库
MYSQL_USER: "library_manager" # 下面的项目连接Mysql的时候,使用这个用户名
MYSQL_PASSWORD: "123456"
ports:
- "33065:3306" # 映射,如果需要远程连接Docker中的数据库,这一步很重要
volumes:
- mysql-data:/var/lib/mysql
- ./.github/init.sql:/docker-entrypoint-initdb.d/init.sql
restart: "always"
container_name: "mysql"
远程连接效果如下:
docker内的项目连接数据库时的配置
environment:
APP_ENV: "${APP_ENV:-prod}"
DB_HOST: "mysql"
DB_PORT: "3306" # 因为在同一个环境,所以直接用3306端口就行
DB_USERNAME: "library_manager"
DB_PASSWORD: "password"
DB_DATABASE: "database
边栏推荐
- Cf:c. the third problem
- 伦敦银走势中的假突破
- Ubantu check cudnn and CUDA versions
- logstash清除sincedb_path上传记录,重传日志数据
- 282. Stone consolidation (interval DP)
- I'm interested in watching Tiktok live beyond concert
- FFT learning notes (I think it is detailed)
- MATLB|实时机会约束决策及其在电力系统中的应用
- Kotlin basics 1
- General operation method of spot Silver
猜你喜欢
关于softmax函数的见解
黄金价格走势k线图如何看?
Recursive method to realize the insertion operation in binary search tree
How to extract MP3 audio from MP4 video files?
Xunrui CMS plug-in automatically collects fake original free plug-ins
Mobilenet series (5): use pytorch to build mobilenetv3 and learn and train based on migration
Introduction to robotics I. spatial transformation (1) posture, transformation
WordPress collection plug-in automatically collects fake original free plug-ins
关于#数据库#的问题:(5)查询库存表中每本书的条码、位置和借阅的读者编号
ORA-00030
随机推荐
Who knows how to modify the data type accuracy of the columns in the database table of Damon
在产业互联网时代,将会凭借大的产业范畴,实现足够多的发展
esxi的安装和使用
面试必刷算法TOP101之回溯篇 TOP34
可恢复保险丝特性测试
Mysql--- query the top 5 students
Overview of Zhuhai purification laboratory construction details
Recursive method to realize the insertion operation in binary search tree
MATLB|实时机会约束决策及其在电力系统中的应用
SAP Spartacus home 页面读取 product 数据的请求的 population 逻辑
Blue Bridge Cup embedded stm32g431 - the real topic and code of the eighth provincial competition
95后CV工程师晒出工资单,狠补了这个,真香...
视频直播源码,实现本地存储搜索历史记录
MCU realizes OTA online upgrade process through UART
Use of crawler manual 02 requests
Five challenges of ads-npu chip architecture design
About error 2003 (HY000): can't connect to MySQL server on 'localhost' (10061)
cf:C. The Third Problem【关于排列这件事】
FFT 学习笔记(自认为详细)
JMeter BeanShell的基本用法 一下语法只能在beanshell中使用