Error Establishing A Database Connection WordPress CentOS

Being novice to WordPress, but maintaining a Apache web server on CentOS 6.5 and maintaining a WordPress website.
Surprisingly it was not a database issue, but a DDoS attack!!!
After googling a lot related to MySQL database, i started monitoring my web server and found its CPU usage was becoming 100% by lot of Apache processes and after some time my server became unresponsive!!!

What I did…
Blocked HTTP access from 0.0.0.0/0
Allowed HTTP access to only my network Public IP.
Restarted the Server and found it was working like charm.

I again allowed access to 0.0.0.0/0 and it again became unresponsive and the CPU utilization was 100% or sometimes with “Error Establishing A Database Connection”

My next step was obviously to look at which public IP is bombarding http requests to my Server.

To check http access logs, use the following command
cat /var/log/httpd/access_log

My CentOS server is hosted on Amazon Web Services, so there is no provision to block any single IP address with AWS security group, I had to block this culprit IP on the CentOS itself.

Here are the commands to block the IP on the CentOS linux with it native firewall
sudo iptables -I INPUT -s x.x.x.x/32 -j DROP

After adding your rules you’ll need to save them, and ensure the iptables service starts at boot.
sudo iptables-save > /etc/sysconfig/iptables-config