当前位置:网站首页>Docker compose configures MySQL and realizes remote connection
Docker compose configures MySQL and realizes remote connection
2022-07-06 01:20:00 【PHP's gossip girlfriend】
You need to ensure that your operating environment meets the following requirements :
- 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" # Set up root password
MYSQL_DATABASE: "library_manager" # Set up the database
MYSQL_USER: "library_manager" # The following items are connected Mysql When , Use this user name
MYSQL_PASSWORD: "123456"
ports:
- "33065:3306" # mapping , If you need a remote connection Docker Database in , This is an important step
volumes:
- mysql-data:/var/lib/mysql
- ./.github/init.sql:/docker-entrypoint-initdb.d/init.sql
restart: "always"
container_name: "mysql"
The effect of remote connection is as follows :
docker The configuration of the project in connecting to the database
environment:
APP_ENV: "${APP_ENV:-prod}"
DB_HOST: "mysql"
DB_PORT: "3306" # Because in the same environment , So just use 3306 Just port
DB_USERNAME: "library_manager"
DB_PASSWORD: "password"
DB_DATABASE: "database
边栏推荐
- 记一个 @nestjs/typeorm^8.1.4 版本不能获取.env选项问题
- Convert binary search tree into cumulative tree (reverse middle order traversal)
- The basic usage of JMeter BeanShell. The following syntax can only be used in BeanShell
- 在产业互联网时代,将会凭借大的产业范畴,实现足够多的发展
- Leetcode 208. 实现 Trie (前缀树)
- Leetcode daily question solution: 1189 Maximum number of "balloons"
- Yii console method call, Yii console scheduled task
- WordPress collection plug-in automatically collects fake original free plug-ins
- Remember that a version of @nestjs/typeorm^8.1.4 cannot be obtained Env option problem
- Paging of a scratch (page turning processing)
猜你喜欢
Mobilenet series (5): use pytorch to build mobilenetv3 and learn and train based on migration
yii中console方法调用,yii console定时任务
Dedecms plug-in free SEO plug-in summary
SSH login is stuck and disconnected
Vulhub vulnerability recurrence 75_ XStream
A picture to understand! Why did the school teach you coding but still not
Condition and AQS principle
About error 2003 (HY000): can't connect to MySQL server on 'localhost' (10061)
What is the most suitable book for programmers to engage in open source?
BiShe - College Student Association Management System Based on SSM
随机推荐
ThreeDPoseTracker项目解析
Huawei converged VLAN principle and configuration
基於DVWA的文件上傳漏洞測試
【第30天】给定一个整数 n ,求它的因数之和
Zhuhai's waste gas treatment scheme was exposed
关于softmax函数的见解
Idea sets the default line break for global newly created files
Introduction to robotics I. spatial transformation (1) posture, transformation
Mysql--- query the top 5 students
The basic usage of JMeter BeanShell. The following syntax can only be used in BeanShell
Leetcode sword finger offer 59 - ii Maximum value of queue
SCM Chinese data distribution
程序员搞开源,读什么书最合适?
Building core knowledge points
c#网页打开winform exe
A glimpse of spir-v
3D model format summary
Paging of a scratch (page turning processing)
Dede collection plug-in free collection release push plug-in
Vulhub vulnerability recurrence 74_ Wordpress