



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