

網(wǎng)站搬家轉移服務器是一件很正常的事,平時分分鐘的事,就因為一個小小的大小寫問題沒注意,折騰了好半天光陰,大致流程為:
將程序及數(shù)據(jù)庫轉移到新服務器后,修改了數(shù)據(jù)庫連接的地址及密碼,程序使終顯示錯誤,提示
CodeIgniter\Database\Exceptions\DatabaseException #8 Unable to connect to the database. Main connection [MySQLi]: Access denied for user '****'@'localhost' to database '****' 無法連接到數(shù)據(jù)庫,檢查數(shù)據(jù)庫是否啟動或者數(shù)據(jù)庫配置文件不對,config/database.php
然后再次檢查了數(shù)據(jù)庫的權限配置包括服務器防火墻也都添加了端口,同樣不會忘記端也要在云端添加,在寶塔頁面都可以正常管理數(shù)據(jù)庫及用Navicat連接也都顯示正常,繼續(xù)檢查服務器
一切正常后還是無法連接,這就有點頭疼了,查了很多資料還是一樣,表示數(shù)據(jù)庫出錯。
[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 ~]$
沒辦法在經(jīng)常多次折磨后,只能老老實實一次次查找原因,功失不負有心人,當我把賬戶,密碼及數(shù)據(jù)名一個一個全部復制寫入的時候突然就一切OK了,再仔細一看原來是數(shù)據(jù)庫名與用戶名不同,在創(chuàng)建數(shù)據(jù)庫時,數(shù)據(jù)庫名和用戶名都是一樣的,所以沒想太多,直接用的用戶名,結果就因為數(shù)據(jù)庫名是小寫的,而用戶名里有大寫,導致始終無法連接數(shù)據(jù)庫
【版權聲明】:本站內(nèi)容來自于與互聯(lián)網(wǎng)(注明原創(chuàng)稿件除外),供訪客免費學習需要。如文章或圖像侵犯到您的權益,請及時告知,我們第一時間刪除處理!謝謝!
售后服務:13534259410 (7×24小時)
在線 Q Q:253849310 (售前咨詢)
深圳無雙科技,專注于深圳網(wǎng)站建設、深圳網(wǎng)站設計、深圳網(wǎng)站制作。
服務客戶超3000家,一站式網(wǎng)站建設及推廣營銷解決方案提供商。
我們的價值觀:誠信、坦誠、盡責、創(chuàng)新。期待與您合作!