当前位置:网站首页>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
边栏推荐
- Some features of ECMAScript
- Nmap: network detection tool and security / port scanner
- FFT 学习笔记(自认为详细)
- The growth path of test / development programmers, the problem of thinking about the overall situation
- SAP Spartacus home 页面读取 product 数据的请求的 population 逻辑
- Programmer growth Chapter 9: precautions in real projects
- Is chaozhaojin safe? Will it lose its principal
- [day 30] given an integer n, find the sum of its factors
- BiShe - College Student Association Management System Based on SSM
- Distributed base theory
猜你喜欢

ubantu 查看cudnn和cuda的版本

ORA-00030

Convert binary search tree into cumulative tree (reverse middle order traversal)

Study diary: February 13, 2022

电气数据|IEEE118(含风能太阳能)

Cve-2017-11882 reappearance

MATLB|实时机会约束决策及其在电力系统中的应用

可恢复保险丝特性测试

VMware Tools installation error: unable to automatically install vsock driver

Blue Bridge Cup embedded stm32g431 - the real topic and code of the eighth provincial competition
随机推荐
Illustrated network: the principle behind TCP three-time handshake, why can't two-time handshake?
Kotlin basics 1
关于softmax函数的见解
Netease smart enterprises enter the market against the trend, and there is a new possibility for game industrialization
Four commonly used techniques for anti aliasing
Cglib dynamic agent -- example / principle
Hcip---ipv6 experiment
面试必刷算法TOP101之回溯篇 TOP34
JVM_ 15_ Concepts related to garbage collection
【第30天】给定一个整数 n ,求它的因数之和
Live broadcast system code, custom soft keyboard style: three kinds of switching: letters, numbers and punctuation
基於DVWA的文件上傳漏洞測試
Obstacle detection
Dynamic programming -- linear DP
Study diary: February 13, 2022
MIT doctoral thesis | robust and reliable intelligent system using neural symbol learning
Mysql--- query the top 5 students
Cf:d. insert a progression [about the insert in the array + the nature of absolute value + greedy top-down]
Who knows how to modify the data type accuracy of the columns in the database table of Damon
3D模型格式汇总