getting Error establishing a database connection

taker18

Verified User
Joined
Oct 18, 2021
Messages
141
Location
USA

Hello Everyone thank you for helping in advance. but sometimes I get this message Below not sure why. in the beginning, it was I had an extra wp-config.sample.php that comes originally with fresh WP download. I remove it but I still getting this message sometimes and I got access to the site. I am able to access the site fine but it happens sometimes and goes away after a few seconds or another refresh.​

anyone has an idea about that
Thank you

Error establishing a database connection​

This either means that the username and password information in your wp-config.php file is incorrect or we can’t contact the database server at localhost. This could mean your host’s database server is down.

  • Are you sure you have the correct username and password?
  • Are you sure you have typed the correct hostname?
  • Are you sure the database server is running?
If you’re unsure what these terms mean you should probably contact your host. If you still need help you can always visit the WordPress Support Forums.
 
Seems sometimes it looses contact with the database if the credentials are correct. Might be something like too little memory for the mysql/mariadb server or too much connections are made at the server, hard to say.

Is it your server? If yes, did you check the mysql error log?
 
thanks again. yes it's very possible scenario that my server needs an update,

System load: 0.16 Processes: 243
Usage of /: 43.2% of 74.82GB Users logged in: 0
Memory usage: 47%
Swap usage: 0%
I am not sure how to check mySQL Error logs
on direct panel front end I found this

022:03:13-00:10:01: Unable to find the pid file: /var/run/httpd.pid
2022:03:13-00:10:01: Unable to find the webalizer binary: /usr/bin/webalizer. Download a new binary: http://files.directadmin.com/services/
2022:03:13-00:10:02: Unable to find the webalizer binary: /usr/bin/webalizer. Download a new binary: http://files.directadmin.com/services/
2022:03:13-00:10:03: Unable to find the webalizer binary: /usr/bin/webalizer. Download a new binary: http://files.directadmin.com/services/
2022:03:13-00:10:03: Unable to find the webalizer binary: /usr/bin/webalizer. Download a new binary: http://files.directadmin.com/services/
2022:03:13-00:10:05: Unable to find the webalizer binary: /usr/bin/webalizer. Download a new binary: http://files.directadmin.com/services/
2022:03:13-23:45:01: service mysqld wasn't running, starting mysqld
2022:03:14-00:10:02: Unable to find the pid file: /var/run/httpd.pid
2022:03:14-00:10:02: Unable to find the webalizer binary: /usr/bin/webalizer. Download a new binary: http://files.directadmin.com/services/
2022:03:14-00:10:02: Unable to find the webalizer binary: /usr/bin/webalizer. Download a new binary: http://files.directadmin.com/services/
2022:03:14-00:10:04: Unable to find the webalizer binary: /usr/bin/webalizer. Download a new binary: http://files.directadmin.com/services/
2022:03:14-00:10:04: Unable to find the webalizer binary: /usr/bin/webalizer. Download a new binary: http://files.directadmin.com/services/
2022:03:14-00:10:05: Unable to find the webalizer binary: /usr/bin/webalizer. Download a new binary: http://files.directadmin.com/services/
2022:03:15-00:10:01: Unable to find the pid file: /var/run/httpd.pid
2022:03:15-00:10:01: Unable to find the webalizer binary: /usr/bin/webalizer. Download a new binary: http://files.directadmin.com/services/
2022:03:15-00:10:02: Unable to find the webalizer binary: /usr/bin/webalizer. Download a new binary: http://files.directadmin.com/services/
2022:03:15-00:10:04: Unable to find the webalizer binary: /usr/bin/webalizer. Download a new binary: http://files.directadmin.com/services/
2022:03:15-00:10:04: Unable to find the webalizer binary: /usr/bin/webalizer. Download a new binary: http://files.directadmin.com/services/
2022:03:15-00:10:05: Unable to find the webalizer binary: /usr/bin/webalizer. Download a new binary: http://files.directadmin.com/services/



logfiles .jpg
 
Yes that is for webalizer.

I might have customized it, but I have my mysql log in the /var/log/mysql/ directory. You can check there.

However, seems it might be good to update things first.
 
Yes that is for webalizer.

I might have customized it, but I have my mysql log in the /var/log/mysql/ directory. You can check there.

However, seems it might be good to update things first.
HI @Richard G thank you for your help
I am sorry when I ran the command /var/log/mysql/ on my Terminal it says no directory
root@server:~# /var/log/mysql/
-bash: /var/log/mysql/: No such file or directory

last night I search about how log to mySQL log error and i found the same answer that you sent me /var/log/mysql/ but I couldn't log in

is that somewhere on my phpadmin
- "However, seems it might be good to update things first."
I updated the server unless you are asking to upadte anything else....

do I need to update any of those things on the custom update below on attachment Custom build .jpg
 
I am sorry when I ran the command /var/log/mysql/ on my Terminal it says no directory
it's not a command, you have to go to that directory, so it's:
cd /var/log/mysql
if it exists, then use ls -all to see then contents.

This requires some basic linux command knowledge.

As for your screenshot, I don't know, if you have used the "update software" part you probably will be fine. I never use that plugin myself. I always update everything via command line.
 
it's not a command, you have to go to that directory, so it's:
cd /var/log/mysql
if it exists, then use ls -all to see then contents.

This requires some basic linux command knowledge.

As for your screenshot, I don't know, if you have used the "update software" part you probably will be fine. I never use that plugin myself. I always update everything via command line.
here we go



total 76


drwx------ 7 root root 4096 Feb 3 02:13 .


drwxr-xr-x 19 root root 4096 Mar 15 15:18 ..


-rw------- 1 root root 3546 Mar 15 15:18 .bash_history


-rw-r--r-- 1 root root 3106 Dec 5 2019 .bashrc


drwx------ 2 root root 4096 Nov 29 11:33 .cache


-rw-r--r-- 1 root root 0 Nov 29 11:40 .cloud-locale-test.skip


drwx------ 3 root root 4096 Feb 3 02:13 .config


drwxr-xr-x 3 root root 4096 Jan 6 03:17 .local


-rw-r--r-- 1 root root 0 Jan 2 17:34 .mysql_secret


-rw-r--r-- 1 root root 161 Dec 5 2019 .profile


-rwxr-xr-x 1 root root 30611 Dec 30 22:19 setup.sh


drwxr-xr-x 3 root root 4096 Nov 29 11:33 snap


drwx------ 2 root root 4096 Jan 2 17:31 .ssh


-rw------- 1 root root 797 Jan 12 03:15 .viminfo

Untitled.jpg


agree I used the command to update linux :
sudo apt-get update && sudo apt-get upgrade && sudo apt-get dist-upgrade
 
You're looking at the /root directory, not at the /var/log/mysql directory. If even present there on Debian, I don't know.

You might best ask somebody else or hire somebody to check and fix, because you don't have any basic linux console knowledge, and most of us will not give you a commandline by commandline help for searching, editing and viewing logs and other stuff.

Maybe the issue is gone after upgrading the system, because since normally it works, it's either connection amounts or too little resources if it happens just sometimes.
 
You're looking at the /root directory, not at the /var/log/mysql directory. If even present there on Debian, I don't know.

You might best ask somebody else or hire somebody to check and fix, because you don't have any basic linux console knowledge, and most of us will not give you a commandline by commandline help for searching, editing and viewing logs and other stuff.

Maybe the issue is gone after upgrading the system, because since normally it works, it's either connection amounts or too little resources if it happens just sometimes.
agree with you, I need to upgrade my knowledge about Linux much better than this. the other option, where can I hire someone for help? any recommendation where to find someone good to help will really appreciate it
 
There are several people here on the forums who might be able to help you.
You can also visit this page where also are companie's.
MC2 name does maybe not ring a bell, but is owned by smtalk which is also doing some development of DA.

You can also look here or post a request there:
 
There are several people here on the forums who might be able to help you.
You can also visit this page where also are companie's.
MC2 name does maybe not ring a bell, but is owned by smtalk which is also doing some development of DA.

You can also look here or post a request there:
Thank you much @Richard G for the help.
 
What is your server specs, looks like your server is too light for your applications
 
108.162.237.165 -> this is Cloudflare IP. I wonder why they need so many connections. However, as Active8 said... seems server is a bit too light.
I'm not into databases anyway, maybe Active8 can help you better.
 
My server
3VCPU, 4 GB RAM, 80 GB DISK LOCAL
I have 4 sites WP press on it
basically, only one site might be heavy and has small traffic, and another I use it as a stage for the original site.
all the other 2 are just small blogging static sites not heavy.
if this is the reason that would be an easy one to do. I just didn't want spend more money while I still have more RAM available


total used free shared buff/cache available


Mem: 3835 1574 196 129 2064 1872


Swap: 0 0 0

MY VCPU

Architecture: x86_64


CPU op-mode(s): 32-bit, 64-bit


Byte Order: Little Endian


Address sizes: 40 bits physical, 48 bits virtual


CPU(s): 3


On-line CPU(s) list: 0-2


Thread(s) per core: 1


Core(s) per socket: 3


Socket(s): 1


NUMA node(s): 1


Vendor ID: AuthenticAMD


CPU family: 23


Model: 49


Model name: AMD EPYC Processor


Stepping: 0


CPU MHz: 2445.404


BogoMIPS: 4890.80


Hypervisor vendor: KVM


Virtualization type: full


L1d cache: 96 KiB


L1i cache: 96 KiB


L2 cache: 1.5 MiB


L3 cache: 16 MiB


NUMA node0 CPU(s): 0-2
 
looks like an VPS from Hetzner, with SSD or NVMe ?
Try to stress your server with YABS test suite and share your results:
Thank you @Active8

here we go


# ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## #


# Yet-Another-Bench-Script #


# v2022-02-18 #


# https://github.com/masonr/yet-another-bench-script #


# ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## #





Fri 18 Mar 2022 04:14:00 PM UTC





Basic System Information:


---------------------------------


Processor : AMD EPYC Processor


CPU cores : 3 @ 2445.404 MHz


AES-NI : ✔ Enabled


VM-x/AMD-V : ❌ Disabled


RAM : 3.7 GiB


Swap : 0.0 KiB


Disk : 75.1 GiB





fio Disk Speed Tests (Mixed R/W 50/50):


---------------------------------


Block Size | 4k (IOPS) | 64k (IOPS)


------ | --- ---- | ---- ----


Read | 138.86 MB/s (34.7k) | 1.39 GB/s (21.7k)


Write | 139.23 MB/s (34.8k) | 1.39 GB/s (21.8k)


Total | 278.09 MB/s (69.5k) | 2.78 GB/s (43.5k)


| |


Block Size | 512k (IOPS) | 1m (IOPS)


------ | --- ---- | ---- ----


Read | 1.66 GB/s (3.2k) | 1.57 GB/s (1.5k)


Write | 1.75 GB/s (3.4k) | 1.68 GB/s (1.6k)


Total | 3.42 GB/s (6.6k) | 3.25 GB/s (3.1k)





iperf3 Network Speed Tests (IPv4):


---------------------------------


Provider | Location (Link) | Send Speed | Recv Speed


| | |


Clouvider | London, UK (10G) | busy | busy


Online.net | Paris, FR (10G) | busy | busy


WorldStream | The Netherlands (10G) | busy | busy


WebHorizon | Singapore (400M) | busy | busy


Clouvider | NYC, NY, US (10G) | busy | busy


Velocity Online | Tallahassee, FL, US (10G) | busy | busy


Clouvider | Los Angeles, CA, US (10G) | busy | busy


Iveloz Telecom | Sao Paulo, BR (2G) | busy | busy





iperf3 Network Speed Tests (IPv6):


---------------------------------


Provider | Location (Link) | Send Speed | Recv Speed


| | |


Clouvider | London, UK (10G) | busy | busy


Online.net | Paris, FR (10G) | busy | busy


WorldStream | The Netherlands (10G) | busy | busy


WebHorizon | Singapore (400M) | busy | busy


Clouvider | NYC, NY, US (10G) | busy | busy


Clouvider | Los Angeles, CA, US (10G) | busy | busy





Geekbench 5 Benchmark Test:


---------------------------------


Test | Value


|


Single Core | 1051


Multi Core | 2725


Full Test | https://browser.geekbench.com/v5/cpu/13641529
 
Good on cpu power and hd speed , but pity I don't see any speed test, maybe some firewall issues.
I advise you to install some kind of WAF like Wordfence to deal with some bots/sites what to make lot of connections.
If you throttle this way maybe then the issue will solve it self
 
Back
Top