由于做了资源限制, 并且没有使用 swarm, 所以要加上–compatibility 参数, 不然会报错
WARNING: Some services (web) use the 'deploy' key, which will be ignored. Compose does not support 'deploy' configuration - use docker stack deploy to deploy to a swarm.
注意:
⚠️ 注意:启动 mysql 报如下错误,那是因为 MYSQL 新特性 secure_file_priv 对读写文件的影响。
ERROR: mysqld failed while attempting to check config
command was: “mysqld –verbose –help”
mysqld: Error on realpath() on ‘/var/lib/mysql-files’ (Error 2 - No such file or directory)
2019-09-14T09:52:51.015937Z 0 [ERROR] [MY-010095] [Server] Failed to access directory for –secure-file-priv. Please make sure that directory exists and is accessible by MySQL Server. Supplied value : /var/lib/mysql-files
2019-09-14T09:52:51.018328Z 0 [ERROR] [MY-010119] [Server] Aborting
解决问题:
windows 下:修改 my.ini 在[mysqld]内加入 secure_file_priv=/var/lib/mysql
linux 下:修改 my.cnf 在[mysqld]内加入 secure_file_priv=/var/lib/mysql
三、连接 MySQL
1、进入 mysql 容器
docker exec -it my_mysql /bin/bash
2、登陆 mysql
mysql -u root -p
3、mysql 8 设置允许远程用户访问
update user set host = ‘%’ where user = ‘root’ and host=‘localhost’; # 更新 root - localhost 为 root - %
GRANT ALL ON . TO ‘root’@’%’; # 设置允许远程用户访问
flush privileges;# 刷新权限
ALTER USER ‘root’@’%’ IDENTIFIED WITH mysql_native_password BY ‘密码’;#更新用户加密方式,mysql8 默认的加密方式为 caching_sha2_password 与 mysql5 的加密方式 mysql_native_password 不同