docker wordpress 连接数据库失败

将wordpress.tar.gz解压直/usr/local/nginx/html/下, 使用浏览器访问121.37.166.201:8081/wp-admin/install.php,输入数据库信息,报错:

docker wordpress 连接数据库失败插图

问题排查步骤:

1、查看数据库IP地址

[root@master-1 ~]# docker inspect zabbix-mysql | grep "IPAddress" "SecondaryIPAddresses": null, "IPAddress": "", "IPAddress": "172.17.201.1",

进入 /usr/local/nginx/html/wp_config.php配置文件,修改数据库信息:

/** WordPress数据库的名称 */ define('DB_NAME', 'wordpress'); /** MySQL数据库用户名 */ define('DB_USER', 'wordpress'); /** MySQL数据库密码 */ define('DB_PASSWORD', 'wordpress'); /** MySQL主机 */ define('DB_HOST', '172.17.0.1'); 

重新在浏览器打开wordpress, 问题还是没有解决,依然提示数据库连接失败,,,

2、登录容器数据库,查看密码账号是否正确, ——-没有报错信息,继续排查

[root@master-1 ~]# docker exec -it zabbix-mysql /bin/bash root@0bffe1016a51:/# mysql -uwordpress -pwordpress mysql: [Warning] Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 465 Server version: 8.0.28 MySQL Community Server - GPL Copyright (c) 2000, 2022, Oracle and/or its affiliates. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> 

3、在宿主机登录数据库看是否登录成功 ——–宿主机无法连接数据库容器

[root@master-1 ~]# mysql -h 121.37.166.201 -P 3306 -uwordpress -pwordpress ERROR 2059 (HY000): Authentication plugin 'caching_sha2_password' cannot be loaded: The specified module could not be found.(this error comes when I try to lo...

原因:此为8.0新版本的MySQL新特性导致,老版本里机密方式为mysql_native_password,导致认证方式有问题。

解决方法: 登录容器数据库,修改加密方式

1>进入数据库容器: docker exec -it zabbix-mysql /bin/bash

2>登录数据库: mysql -uwordpress -pwordpress

3>修改加密方式:alter user wordpress@'%' identified with mysql_native_password by 'wordpress';

4> 刷新: flush privileges;

5> 退出数据库容器

重新打开wordpress 验证, 可以连到数据库,问题解决。

docker wordpress 连接数据库失败插图1

原文链接:https://blog.csdn.net/weixin_70661795/article/details/130970403?ops_request_misc=&request_id=6a5d8b60969247fc8f7e0711a2c2827d&biz_id=&utm_medium=distribute.pc_search_result.none-task-blog-2~blog~koosearch~default-19-130970403-null-null.268%5Ev1%5Econtrol&utm_term=docker%E3%80%81wordpress%E3%80%81wordpress%E5%BB%BA%E7%AB%99%E3%80%81wordpress%E4%B8%BB%E9%A2%98%E3%80%81%E5%AE%B9%E5%99%A8%E9%95%9C%E5%83%8F%E3%80%81

© 版权声明
THE END
喜欢就支持一下吧
点赞6 分享