本文介紹訪問WordPress管理員登入地址顯示“Error establishing a database connection”的問題描述、問題原因和解決方案。
問題描述
訪問WordPress管理員登入地址http://8.219.XX.XX/wp-login.php顯示Error establishing a database connection。
問題原因
可能原因為伺服器的記憶體資源不足。
解決方案
-
遠端連線Simple Application Server。具體操作,請參見遠端連線Linux伺服器。
-
執行以下命令,查看包含
mysql的進程。ps -ef | grep mysql回顯資訊如下所示,表示不存在
mysql的進程。[root@iZt4n8 bbnn3Z ~]# ps -ef | grep mysql root 2872 2812 0 14:19 pts/2 00:00:00 grep --color mysql -
執行以下命令,啟動資料庫。
sudo /etc/init.d/mysqld start -
執行以下命令,查看是否因為記憶體資源不足導致進程被終止。
sudo grep "Out of memory" /var/log/messages回顯資訊表示執行個體記憶體資源不足導致資料庫的進程被終止。
root@iZt4n:~# grep "Out of memory" /var/log/messages Jul 15 02:2 n3Z kernel: Out of memory: Killed process 14177 (mysqld) total-vm:491852kB, anon-rss:145516kB, file-rss:0kB, shmem-rss:0kB, UID:1000 pgtables:516kB oom_score_adj:0 Jul 16 09:2 n3Z kernel: Out of memory: Killed process 2000 (mysqld) total-vm:487756kB, anon-rss:168724kB, file-rss:0kB, shmem-rss:0kB, UID:1000 pgtables:544kB oom_score_adj:0 Binary file /var/log/messages matches -
升級伺服器的記憶體配置。具體操作,請參見升級配置。
說明建議伺服器的記憶體大於等於4 GB。