docker-compose通过容器名连接mysql
这是Mysql的配置:
- version :'3'
- services:
- desneyMysql:
- container_name: app_mysql
- image: mysql:5.7
- build:
- context:./mysql
- ports:
- -"3307:3306"
- volumes:
- -./mysql/conf:/etc/mysql/conf.d
- -./mysql/logs:/logs
- -./mysql/data:/var/lib/mysql
- command:[
- 'mysqld',
- '--innodb-buffer-pool-size=80M',
- '--character-set-server=utf8mb4',
- '--collation-server=utf8mb4_unicode_ci',
- '--default-time-zone=+8:00',
- '--lower-case-table-names=1'
- ]
- environment:
- MYSQL_DATABASE:'desneytown'
- MYSQL_ROOT_PASSWORD: 'xxxxxxxx'
- restart: always
虽然Mysql暴露的是3307端口,但是连接Mysql时,要用3306.
- datasource:
- url: jdbc:mysql://app_mysql:3306/dbxxx?useUnicode=true>characterEncoding=UTF-8>useSSL=false
============ 欢迎各位老板打赏~ ===========
与本文相关的文章
- · docker-compose安装phpmyadmin
- · Amazon Linux 2023 安装Docker和Docker Compose
- · docker定时任务Mysql脚本
- · docker安装mysql8注意事项
- · .NET8 Mysql SSL error
- · 定时备份docker中的mysql
- · linux使用docker-compose安装和破解confluence 8.0.2
- · unity3d mysql error: The given key was not present in the dictionary.
- · MySQL 批量修改数据表编码及字符集
- · mac os m1可用的NACOS
- · Your database must use ‘READ-COMMITTED’ as the default isolation level.
- · MySQL-InnoDB存储引擎