网站维护
2023-11-09
次
wordpress翻译插件
网站搬家转移服务器是一件很正常的事,平时分分钟的事,就因为一个小小的大小写问题没注意,折腾了好半天光阴,大致流程为:
将程序及数据库转移到新服务器后,修改了数据库连接的地址及密码,程序使终显示错误,提示

CodeIgniter\Database\Exceptions\DatabaseException #8 Unable to connect to the database. Main connection [MySQLi]: Access denied for user '****'@'localhost' to database '****' 无法连接到数据库,检查数据库是否启动或者数据库配置文件不对,config/database.php
然后再次检查了数据库的权限配置包括服务器防火墙也都添加了端口,同样不会忘记端也要在云端添加,在宝塔页面都可以正常管理数据库及用Navicat连接也都显示正常,继续检查服务器

一切正常后还是无法连接,这就有点头疼了,查了很多资料还是一样,表示数据库出错。
[lighthouse@VM-12-16-centos ~]$ netstat -ntulp |grep 3306 (No info could be read for "-p": geteuid()=1001 but you should be root.) tcp6 0 0 :::3306 :::* LISTEN - [lighthouse@VM-12-16-centos ~]$ sudo systemctl status firewalld ● firewalld.service - firewalld - dynamic firewall daemon Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled) Active: active (running) since Thu 2023-11-09 10:00:01 CST; 15min ago Docs: man:firewalld(1) Main PID: 16371 (firewalld) CGroup: /system.slice/firewalld.service └─16371 /usr/bin/python2 -Es /usr/sbin/firewalld --nofork --nopid Nov 09 10:00:01 VM-12-16-centos systemd[1]: Starting firewalld - dynamic firewall daemon... Nov 09 10:00:01 VM-12-16-centos systemd[1]: Started firewalld - dynamic firewall daemon. Nov 09 10:00:01 VM-12-16-centos firewalld[16371]: WARNING: AllowZoneDrifting is enabled. This is considered an insecure configuration option. It will be removed in a future release. Please consider disabling it now. Nov 09 10:00:02 VM-12-16-centos firewalld[16371]: WARNING: AllowZoneDrifting is enabled. This is considered an insecure configuration option. It will be removed in a future release. Please consider disabling it now. [lighthouse@VM-12-16-centos ~]$ sudo firewall-cmd --zone=public --add-port=3306/tcp --permanent Warning: ALREADY_ENABLED: 3306:tcp success [lighthouse@VM-12-16-centos ~]$ sudo firewall-cmd --reload success [lighthouse@VM-12-16-centos ~]$
没办法在经常多次折磨后,只能老老实实一次次查找原因,功失不负有心人,当我把账户,密码及数据名一个一个全部复制写入的时候突然就一切OK了,再仔细一看原来是数据库名与用户名不同,在创建数据库时,数据库名和用户名都是一样的,所以没想太多,直接用的用户名,结果就因为数据库名是小写的,而用户名里有大写,导致始终无法连接数据库
【版权声明】:本站内容来自于与互联网(注明原创稿件除外),供访客免费学习需要。如文章或图像侵犯到您的权益,请及时告知,我们第一时间删除处理!谢谢!