gpt4 book ai didi

mysql - WordPress docker "Error establishing a database connection"

转载 作者:行者123 更新时间:2023-12-05 09:11:14 30 4
gpt4 key购买 nike

我已经根据本教程设置了一个服务器来托管多个网站:https://blog.ssdnodes.com/blog/host-multiple-ssl-websites-docker-nginx/

我还为 wordpress 配置了一个 docker-compose.yml,就像他们在同一教程的示例 2 中所做的那样。但是当我打开网站时,出现“建立数据库连接时出错”的错误。我记得几个月前做这件事时一切正常,但我不记得我做了什么不同的事情。

这是我在输入 docker-compose up 后(多次)收到的错误消息

wp_test           | MySQL Connection Error: (1045) Access denied for user 'wordpress'@'172.20.0.9' (using password: YES)
wp_test_db | 2020-02-23T21:00:45.772510Z 11 [Note] Access denied for user 'wordpress'@'172.20.0.9' (using password: YES)

我的 docker-compose.yml 文件如下所示:

version: "3"

services:
db_node_domain:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: somewordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
container_name: wp_test_db

wordpress:
depends_on:
- db_node_domain
image: wordpress:latest
expose:
- 80
restart: always
environment:
VIRTUAL_HOST: blog.example.com
LETSENCRYPT_HOST: blog.example.com
LETSENCRYPT_EMAIL: foo@example.com
WORDPRESS_DB_HOST: db_node_domain:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
container_name: wp_test
volumes:
db_data:

networks:
default:
external:
name: nginx-proxy

我已尝试停止和启动图像,如此处所建议:https://www.reddit.com/r/docker/comments/ahzv5d/wordpress_cant_connect_to_mysql/

我也尝试了另一个 wordpress docker-config.yml 并自己添加了 nginx 参数,但得到了相同的错误消息 https://docs.docker.com/compose/wordpress/

编辑我收到了新的错误消息

wp_test_db        | 2020-02-23T22:09:40.654580Z 0 [Note] mysqld (mysqld 5.7.29) starting as process 1 ...
wp_test_db | 2020-02-23T22:09:40.659627Z 0 [Note] InnoDB: PUNCH HOLE support available
wp_test_db | 2020-02-23T22:09:40.659883Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
wp_test_db | 2020-02-23T22:09:40.659958Z 0 [Note] InnoDB: Uses event mutexes
wp_test_db | 2020-02-23T22:09:40.660412Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
wp_test_db | 2020-02-23T22:09:40.660451Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
wp_test_db | 2020-02-23T22:09:40.660811Z 0 [Note] InnoDB: Using Linux native AIO
wp_test_db | 2020-02-23T22:09:40.661814Z 0 [Note] InnoDB: Number of pools: 1
wp_test_db | 2020-02-23T22:09:40.662418Z 0 [Note] InnoDB: Using CPU crc32 instructions
wp_test_db | 2020-02-23T22:09:40.667522Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
wp_test_db | 2020-02-23T22:09:40.681674Z 0 [Note] InnoDB: Completed initialization of buffer pool
wp_test_db | 2020-02-23T22:09:40.687033Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
wp_test_db | 2020-02-23T22:09:40.701423Z 0 [ERROR] [FATAL] InnoDB: Table flags are 0 in the data dictionary but the flags in file ./ibdata1 are 0x4000!
wp_test_db | 2020-02-23 22:09:40 0x7f7ce62ee740 InnoDB: Assertion failure in thread 140174414505792 in file ut0ut.cc line 918
wp_test_db | InnoDB: We intentionally generate a memory trap.
wp_test_db | InnoDB: Submit a detailed bug report to http://bugs.mysql.com.
wp_test_db | InnoDB: If you get repeated assertion failures or crashes, even
wp_test_db | InnoDB: immediately after the mysqld startup, there may be
wp_test_db | InnoDB: corruption in the InnoDB tablespace. Please refer to
wp_test_db | InnoDB: http://dev.mysql.com/doc/refman/5.7/en/forcing-innodb-recovery.html
wp_test_db | InnoDB: about forcing recovery.
wp_test_db | 22:09:40 UTC - mysqld got signal 6 ;
wp_test_db | This could be because you hit a bug. It is also possible that this binary
wp_test_db | or one of the libraries it was linked against is corrupt, improperly built,
wp_test_db | or misconfigured. This error can also be caused by malfunctioning hardware.
wp_test_db | Attempting to collect some information that could help diagnose the problem.
wp_test_db | As this is a crash and something is definitely wrong, the information
wp_test_db | collection process might fail.
wp_test_db |
wp_test_db | key_buffer_size=8388608
wp_test_db | read_buffer_size=131072
wp_test_db | max_used_connections=0
wp_test_db | max_threads=151
wp_test_db | thread_count=0
wp_test_db | connection_count=0
wp_test_db | It is possible that mysqld could use up to
wp_test_db | key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 68196 K bytes of memory
wp_test_db | Hope that's ok; if not, decrease some variables in the equation.
wp_test_db |
wp_test_db | Thread pointer: 0x0
wp_test_db | Attempting backtrace. You can use the following information to find out
wp_test_db | where mysqld died. If you see no messages after this, something went
wp_test_db | terribly wrong...
wp_test_db | stack_bottom = 0 thread_stack 0x40000
wp_test_db | mysqld(my_print_stacktrace+0x2c)[0x5643574c60cc]
wp_test_db | mysqld(handle_fatal_signal+0x479)[0x564356de87b9]
wp_test_db | /lib/x86_64-linux-gnu/libpthread.so.0(+0x110e0)[0x7f7ce5ecb0e0]
wp_test_db | /lib/x86_64-linux-gnu/libc.so.6(gsignal+0xcf)[0x7f7ce4657fff]
wp_test_db | /lib/x86_64-linux-gnu/libc.so.6(abort+0x16a)[0x7f7ce465942a]
wp_test_db | mysqld(+0x699b25)[0x564356dbeb25]
wp_test_db | mysqld(_ZN2ib5fatalD1Ev+0x12d)[0x56435782ed8d]
wp_test_db | mysqld(+0x11b68f1)[0x5643578db8f1]
wp_test_db | mysqld(+0x11b6f28)[0x5643578dbf28]
wp_test_db | mysqld(_Z6fil_ioRK9IORequestbRK9page_id_tRK11page_size_tmmPvS8_+0x2b0)[0x5643578e5110]
wp_test_db | mysqld(_Z13buf_read_pageRK9page_id_tRK11page_size_t+0xce)[0x56435789a33e]
wp_test_db | mysqld(_Z16buf_page_get_genRK9page_id_tRK11page_size_tmP11buf_block_tmPKcmP5mtr_tb+0x4aa)[0x56435786957a]
wp_test_db | mysqld(_Z31trx_rseg_get_n_undo_tablespacesPm+0x143)[0x56435780d1f3]
wp_test_db | mysqld(+0x698c99)[0x564356dbdc99]
wp_test_db | mysqld(_Z34innobase_start_or_create_for_mysqlv+0x2f3d)[0x5643577da06d]
wp_test_db | mysqld(+0xf80438)[0x5643576a5438]
wp_test_db | mysqld(_Z24ha_initialize_handlertonP13st_plugin_int+0x4f)[0x564356e390ff]
wp_test_db | mysqld(+0xb8c0f6)[0x5643572b10f6]
wp_test_db | mysqld(_Z40plugin_register_builtin_and_init_core_sePiPPc+0x2f0)[0x5643572b4300]
wp_test_db | mysqld(+0x6bbece)[0x564356de0ece]
wp_test_db | mysqld(_Z11mysqld_mainiPPc+0xc71)[0x564356de2a71]
wp_test_db | /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf1)[0x7f7ce46452e1]
wp_test_db | mysqld(_start+0x2a)[0x564356dd8eaa]
wp_test_db | The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains
wp_test_db | information that should help you find out what is causing the crash.

最佳答案

你的 yaml 文件对我来说工作正常。我唯一注意到的是 wordpress.environment (WORDPRESS_DB_NAME=wordpress) 中缺少数据库名称变量,但如果找不到,则默认为 wordpress。我指出这一点是为了防止您的实际副本具有 wordpress 以外的数据库名称。

这是适合我的撰写文件:

version: "3"

services:
db_node_domain:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: somewordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
container_name: wp_test_db

wordpress:
depends_on:
- db_node_domain
image: wordpress:latest
ports:
- '8000:80'
expose:
- 80
restart: always
environment:
VIRTUAL_HOST: blog.example.com
LETSENCRYPT_HOST: blog.example.com
LETSENCRYPT_EMAIL: foo@example.com
WORDPRESS_DB_HOST: db_node_domain:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
WORDPRESS_DB_NAME: wordpress # THIS WAS MISSING?
container_name: wp_test
volumes:
db_data:

networks:
default:
external:
name: nginx-proxy

如果您想重新开始并重试,您可以运行 docker-compose down 然后运行 ​​docker-compose up这会破坏一切所以要小心 :)

关于mysql - WordPress docker "Error establishing a database connection",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60366969/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com