使用 Wordpress 从 docker 容器连接到 RDS Mysql
Connecting to RDS Mysql from docker container with Wordpress
使用 docker-compose 启动一个 wordpress 容器,但我想在该容器内连接到 AWS 上的 RDS mysql 实例。我能够设置 wordpress 但无法连接到数据库。我试过将 DB_NAME 变量更改为 _DATABASE。我还可以使用 mac 中的 mysql 命令行来建立有效的连接
version: '2'
services:
wordpress:
image: wordpress:latest
ports:
- "8000:80"
restart: always
environment:
MYSQL_HOST: "endpoint"
MYSQL_USER: "user"
MYSQL_PASSWORD: "pass"
MYSQL_DB_NAME: "wordpress_docker"
MYSQL_PORT: 3306
volumes:
- ${HOME}:/var/lib/mysql
根据 WordPress 的 documentation
环境名称应该是,
WORDPRESS_DB_HOST=... (defaults to the IP and port of the linked mysql container)
WORDPRESS_DB_USER=... (defaults to "root")
WORDPRESS_DB_PASSWORD=... (defaults to the value of the MYSQL_ROOT_PASSWORD environment variable from the linked mysql container)
WORDPRESS_DB_NAME=... (defaults to "wordpress")
WORDPRESS_TABLE_PREFIX=... (defaults to "", only set this when you need to override the default table prefix in wp-config.php)
使用 docker-compose 启动一个 wordpress 容器,但我想在该容器内连接到 AWS 上的 RDS mysql 实例。我能够设置 wordpress 但无法连接到数据库。我试过将 DB_NAME 变量更改为 _DATABASE。我还可以使用 mac 中的 mysql 命令行来建立有效的连接
version: '2'
services:
wordpress:
image: wordpress:latest
ports:
- "8000:80"
restart: always
environment:
MYSQL_HOST: "endpoint"
MYSQL_USER: "user"
MYSQL_PASSWORD: "pass"
MYSQL_DB_NAME: "wordpress_docker"
MYSQL_PORT: 3306
volumes:
- ${HOME}:/var/lib/mysql
根据 WordPress 的 documentation
环境名称应该是,
WORDPRESS_DB_HOST=... (defaults to the IP and port of the linked mysql container)
WORDPRESS_DB_USER=... (defaults to "root")
WORDPRESS_DB_PASSWORD=... (defaults to the value of the MYSQL_ROOT_PASSWORD environment variable from the linked mysql container)
WORDPRESS_DB_NAME=... (defaults to "wordpress")
WORDPRESS_TABLE_PREFIX=... (defaults to "", only set this when you need to override the default table prefix in wp-config.php)