Mysql 8 docker return 不允许主机“172.xx.x.x”连接到此 MySQL 服务器
Mysql 8 with docker return Host '172.xx.x.x' is not allowed to connect to this MySQL server
我的问题有点奇怪。
当我启动我的容器时,我无法通过任何数据库管理器连接到我的数据库。
我得到
mysql | 2020-05-11T15:48:56.348312Z 8 [Warning] [MY-010055] [Server] IP address '172.21.0.1' could not be resolved: Name or service not known
但是在我使用上面的命令通过终端执行迁移后,我可以通过任何数据库管理器正常访问我的数据库。
$ docker-compose exec php-fpm php artisan migrate
我的docker-compose.yml
#MySQL Service
mysql:
image: mysql:8
container_name: mysql
restart: unless-stopped
tty: true
ports:
- "3306:3306"
environment:
MYSQL_DATABASE: database
MYSQL_ROOT_PASSWORD: root
SERVICE_TAGS: dev
SERVICE_NAME: mysql
volumes:
- ./mysql/dbdata:/var/lib/mysql/
- ./mysql/my.cnf:/etc/mysql/my.cnf
networks:
- app-network
和我的'my.cnf'
[mysqld]
general_log = 1
general_log_file = /var/lib/mysql/general.log
secure-file-priv= NULL
#Accept connections from any IP address
bind-address = 0.0.0.0
我修复了它,将 mysql 版本更新到 8.0.20 并将以下行添加到我的 "my.cnf" 文件中。
sql-mode="STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION"
character-set-server=utf8
default-authentication-plugin=mysql_native_password
所以我的文件现在就是这样
[mysqld]
general_log = 1
general_log_file = /var/lib/mysql/general.log
secure-file-priv= NULL
sql-mode="STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION"
character-set-server=utf8
default-authentication-plugin=mysql_native_password
我的问题有点奇怪。
当我启动我的容器时,我无法通过任何数据库管理器连接到我的数据库。 我得到
mysql | 2020-05-11T15:48:56.348312Z 8 [Warning] [MY-010055] [Server] IP address '172.21.0.1' could not be resolved: Name or service not known
但是在我使用上面的命令通过终端执行迁移后,我可以通过任何数据库管理器正常访问我的数据库。
$ docker-compose exec php-fpm php artisan migrate
我的docker-compose.yml
#MySQL Service
mysql:
image: mysql:8
container_name: mysql
restart: unless-stopped
tty: true
ports:
- "3306:3306"
environment:
MYSQL_DATABASE: database
MYSQL_ROOT_PASSWORD: root
SERVICE_TAGS: dev
SERVICE_NAME: mysql
volumes:
- ./mysql/dbdata:/var/lib/mysql/
- ./mysql/my.cnf:/etc/mysql/my.cnf
networks:
- app-network
和我的'my.cnf'
[mysqld]
general_log = 1
general_log_file = /var/lib/mysql/general.log
secure-file-priv= NULL
#Accept connections from any IP address
bind-address = 0.0.0.0
我修复了它,将 mysql 版本更新到 8.0.20 并将以下行添加到我的 "my.cnf" 文件中。
sql-mode="STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION"
character-set-server=utf8
default-authentication-plugin=mysql_native_password
所以我的文件现在就是这样
[mysqld]
general_log = 1
general_log_file = /var/lib/mysql/general.log
secure-file-priv= NULL
sql-mode="STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION"
character-set-server=utf8
default-authentication-plugin=mysql_native_password