当前位置:网站首页>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
边栏推荐
- Exciting, 2022 open atom global open source summit registration is hot
- In the era of industrial Internet, we will achieve enough development by relying on large industrial categories
- Differences between standard library functions and operators
- SPIR-V初窥
- Leetcode1961. 检查字符串是否为数组前缀
- Four dimensional matrix, flip (including mirror image), rotation, world coordinates and local coordinates
- How does Huawei enable debug and how to make an image port
- WordPress collection plug-in automatically collects fake original free plug-ins
- DOM introduction
- VSphere implements virtual machine migration
猜你喜欢
False breakthroughs in the trend of London Silver
Mobilenet series (5): use pytorch to build mobilenetv3 and learn and train based on migration
Kotlin basics 1
WordPress collection plug-in automatically collects fake original free plug-ins
VSphere implements virtual machine migration
The growth path of test / development programmers, the problem of thinking about the overall situation
关于softmax函数的见解
Condition and AQS principle
Finding the nearest common ancestor of binary tree by recursion
3D model format summary
随机推荐
Kotlin core programming - algebraic data types and pattern matching (3)
JMeter BeanShell的基本用法 一下语法只能在beanshell中使用
How to get the PHP version- How to get the PHP Version?
朝招金安全吗 会不会亏损本金
网易智企逆势进场,游戏工业化有了新可能
VMware Tools installation error: unable to automatically install vsock driver
Une image! Pourquoi l'école t'a - t - elle appris à coder, mais pourquoi pas...
SCM Chinese data distribution
Gartner released the prediction of eight major network security trends from 2022 to 2023. Zero trust is the starting point and regulations cover a wider range
The basic usage of JMeter BeanShell. The following syntax can only be used in BeanShell
Distributed base theory
SSH login is stuck and disconnected
Building core knowledge points
ThreeDPoseTracker项目解析
Recoverable fuse characteristic test
什么是弱引用?es6中有哪些弱引用数据类型?js中的弱引用是什么?
IP storage and query in MySQL
Study diary: February 13, 2022
Mysql--- query the top 5 students
95后CV工程师晒出工资单,狠补了这个,真香...