您好,应该在 Ubuntu 20.04 上的 Docker 上直接安装 Wordpress 和 PHPMyadmin 会在 STDOUT 中引发错误,随后尝试在浏览器中查看 WordPress 时出现非特定数据库错误。
首先我的yaml文件:
version: '3'
services:
db:
image: mysql:8
container_name: mysql
restart: always
command: '--default-authentication-plugin=mysql_native_password'
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: wpdb
MYSQL_USER: user
MYSQL_PASSWORD: password
wordpress:
image: wordpress:5.4.1
container_name: wordpress
restart: always
volumes:
- ./wp-content:/var/www/html/wp-content
depends_on:
- db
environment:
WORDPRESS_DB_HOST: db
WORDPRESS_NAME: wpdb
WORDPRESS_USER: user
WORDPRESS_PASSWORD: password
ports:
- 8080:80
- 443:443
phpmyadmin:
image: phpmyadmin/phpmyadmin
restart: always
ports:
- 3333:80
environment:
PMA_HOST: db
MYSQL_ROOT_PASSWORD: password
And Now the output from **docker-compose up**
Starting mysql ... done
Starting test2_phpmyadmin_1 ... done
Starting wordpress ... done
Attaching to mysql, test2_phpmyadmin_1, wordpress
mysql | 2020-05-13 08:25:52+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.20-1debian10 started.
mysql | 2020-05-13 08:25:52+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
phpmyadmin_1 | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.26.0.3. Set the 'ServerName' directive globally to suppress this message
mysql | 2020-05-13 08:25:52+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.20-1debian10 started.
mysql | 2020-05-13T08:25:52.527362Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.
mysql | 2020-05-13T08:25:52.527443Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.20) starting as process 1
phpmyadmin_1 | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.26.0.3. Set the 'ServerName' directive globally to suppress this message
mysql | 2020-05-13T08:25:52.534595Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
phpmyadmin_1 | [Wed May 13 08:25:52.250991 2020] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.38 (Debian) PHP/7.4.5 configured -- resuming normal operations
phpmyadmin_1 | [Wed May 13 08:25:52.251029 2020] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'
mysql | 2020-05-13T08:25:52.671334Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
mysql | 2020-05-13T08:25:52.773825Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: '/var/run/mysqld/mysqlx.sock' bind-address: '::' port: 33060
wordpress | [13-May-2020 08:25:52 UTC] PHP Warning: mysqli::__construct(): (HY000/2002): Connection refused in Standard input code on line 22
wordpress |
wordpress | MySQL Connection Error: (2002) Connection refused
mysql | 2020-05-13T08:25:52.864314Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
mysql | 2020-05-13T08:25:52.871773Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
mysql | 2020-05-13T08:25:52.908753Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.20' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server - GPL.
wordpress | [13-May-2020 08:25:55 UTC] PHP Warning: mysqli::__construct(): (HY000/1045): Access denied for user 'root'@'172.26.0.4' (using password: NO) in Standard input code on line 22
wordpress |
wordpress | MySQL Connection Error: (1045) Access denied for user 'root'@'172.26.0.4' (using password: NO)
wordpress |
wordpress | MySQL Connection Error: (1045) Access denied for user 'root'@'172.26.0.4' (using password: NO)
wordpress |
wordpress | MySQL Connection Error: (1045) Access denied for user 'root'@'172.26.0.4' (using password: NO)
wordpress |
wordpress | MySQL Connection Error: (1045) Access denied for user 'root'@'172.26.0.4' (using password: NO)
wordpress |
wordpress | MySQL Connection Error: (1045) Access denied for user 'root'@'172.26.0.4' (using password: NO)
wordpress |
wordpress | MySQL Connection Error: (1045) Access denied for user 'root'@'172.26.0.4' (using password: NO)
wordpress |
wordpress | MySQL Connection Error: (1045) Access denied for user 'root'@'172.26.0.4' (using password: NO)
wordpress |
wordpress | MySQL Connection Error: (1045) Access denied for user 'root'@'172.26.0.4' (using password: NO)
wordpress |
wordpress | MySQL Connection Error: (1045) Access denied for user 'root'@'172.26.0.4' (using password: NO)
wordpress |
wordpress | WARNING: unable to establish a database connection to 'db'
wordpress | continuing anyways (which might have unexpected results)
wordpress |
wordpress | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.26.0.4. Set the 'ServerName' directive globally to suppress this message
wordpress | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.26.0.4. Set the 'ServerName' directive globally to suppress this message
wordpress | [Wed May 13 08:26:19.911848 2020] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.38 (Debian) PHP/7.3.17 configured -- resuming normal operations
wordpress | [Wed May 13 08:26:19.911906 2020] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'
正如我在尝试访问 上的 WordPress 时所说的那样本地主机:8080 我明白了
建立数据库连接时出错
PhpMyadmin 在 上运行良好本地主机:3333
有任何想法吗???????
哦,是的,我一直在关注本教程:https://www.youtube.com/watch?v=BfrVWwJv8ls
谢谢 : )
最佳答案
该错误表明 WordPress 无法连接到您的数据库容器。原因可能是由于 WordPress 不知道凭据,因为传递给 WP 容器的 ENV 变量没有使用它期望的 key 。
如果您调整用于 WP 容器的键以匹配您在此处看到的键:https://docs.docker.com/compose/wordpress/它应该运行。试试这样:
version: '3'
services:
db:
image: mysql:8
container_name: mysql
restart: always
command: '--default-authentication-plugin=mysql_native_password'
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: wpdb
MYSQL_USER: user
MYSQL_PASSWORD: password
wordpress:
image: wordpress:5.4.1
container_name: wordpress
restart: always
volumes:
- ./wp-content:/var/www/html/wp-content
depends_on:
- db
environment:
WORDPRESS_DB_HOST: db
WORDPRESS_DB_NAME: wpdb
WORDPRESS_DB_USER: user
WORDPRESS_DB_PASSWORD: password
ports:
- 8080:80
- 443:443
phpmyadmin:
image: phpmyadmin/phpmyadmin
restart: always
ports:
- 3333:80
environment:
PMA_HOST: db
MYSQL_ROOT_PASSWORD: password
关于wordpress - 在 Ubuntu 20.04 上安装 Docker wordpress,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61769995/