给自己一点时间,别害怕重新开始。——威尔·鲍温
我们参考
https://github.com/docker-library/docs/tree/master/mysql
编写一个docker-compose.yml
来安装mysql
# Use root/example as user/password credentials
version: '3.1'
services:
db:
image: mysql
# NOTE: use of "mysql_native_password" is not recommended: https://dev.mysql.com/doc/refman/8.0/en/upgrading-from-previous-series.html#upgrade-caching-sha2-password
# (this is just an example, not intended to be a production configuration)
command: --default-authentication-plugin=mysql_native_password
restart: always
environment:
MYSQL_ROOT_PASSWORD: root
SQL_MODE: STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
CHARACTER_SET_SERVER: utf8mb4
LOWER_CASE_TABLE_NAME: 1
ports:
- 3306:3306
然后运行
代码语言:javascript复制achaodeMacBook-Pro:DockerCompose achao$ cd /Library/DockerCompose/
achaodeMacBook-Pro:DockerCompose achao$ docker-compose -f mysql-compose.yml up -d
[ ] Running 12/12
✔ db 11 layers [⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿] 0B/0B Pulled 34.7s
✔ 29e800056b7e Pull complete 11.7s
✔ 69da292eb326 Pull complete 11.7s
✔ 8850ef02dd58 Pull complete 11.7s
✔ 86a76caa9e20 Pull complete 11.8s
✔ 881324b10832 Pull complete 11.8s
✔ 1f5d1a8fa489 Pull complete 11.8s
✔ 5efbe9eacf59 Pull complete 25.7s
✔ 80db22f26c0f Pull complete 25.7s
✔ e5595b935c31 Pull complete 30.0s
✔ c391d4efe159 Pull complete 30.0s
✔ e5527cf2eb5f Pull complete 30.0s
[ ] Running 2/2
✔ Network dockercompose_default Creat... 0.0s
✔ Container dockercompose-db-1 Starte... 0.6s
然后使用idea
进行连接
成功!