咸鱼

咸鱼是以盐腌渍后,晒干的鱼

0%

10、Docker-部署Mysql

编写docker-compose.yml文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
version: '3.3'

services:
my_mysql:
environment:
TZ: Asia/Shanghai
MYSQL_ROOT_PASSWORD: 123456
MYSQL_DATABASE: test
MYSQL_USER: test
MYSQL_PASSWORD: 123456
image: mysql:5.7
restart: always
volumes:
- /opt/mysql/data:/var/lib/mysql
- /opt/mysql/conf:/etc/mysql/mysql.conf.d
ports:
- 3306:3306
container_name: my_mysql_container

启动容器

1
$ docker-compose up

phpmyadmin

phpmyadmin 是网页版MySQL客户端工具软件

1
2
3
4
5
6
7
8
9
10
11
12
13
version: '3.3'

services:
my_mysql:
#***********省略*****************
my_phpmyadmin:
environment:
- PMA_ARBITRARY=1
image: phpmyadmin/phpmyadmin:5.2
restart: always
ports:
- 8080:80
container_name: my_phpmyadmin_container

启动后,访问 http:{IP}:8080 填写mysql的服务器地址、用户名、密码,点击登录进入后,即可查看服务器上存储的数据库及相应的数据表。

PMA_ARBITRARY - when set to 1 connection to the arbitrary server will be allowed
PMA_HOST - define address/host name of the MySQL server
PMA_VERBOSE - define verbose name of the MySQL server
PMA_PORT - define port of the MySQL server

示例:仅允许连接本地的MySQL

1
2
3
4
5
6
7
8
9
10
11
12
13
14
version: '3.3'

services:
my_mysql:
#***********省略*****************
my_phpmyadmin:
environment:
- PMA_HOST=localhost
- PMA_PORT=3360
image: phpmyadmin/phpmyadmin:5.2
restart: always
ports:
- 8080:80
container_name: my_phpmyadmin_container

启动后,访问 http:{IP}:8080 就没有填写服务器地址的选项了。