Dealing with “Error establishing a database connection” is one toughest situation which many webmasters and webpage owners find themselves in. Due to the nature of the problem, with its cause being a guess other than a known one in many cases, understanding how to fix this error is a must for every webmaster.
This problem occurs on the different sites using the different content management systems for example; WordPress, Joomla, etc which support databases. For inexperienced or the less knowledgeable users, such a time is a hard one to go through since it involves many head scratches in a bid to find out the possible cause, and looking forward for a solution which can help in having the problem solved.
Error Establishing A Database Connection is a one situation which I experienced on this very website a few days day back, and thanks to my hosting provider who was able to deal with it although it took a few additional hours more than was expected. Having your website or blog visitors welcomed by Error Establishing A Database Connection is one thing which not only hurts, but too makes the reader think twice whenever he or she comes across your webpage link in search results.
If you hate seeing thesame just like I do, it may take some weeks before eventually coming back to such a site even if it pops up on every search query made and which is a bad and negative effect on the site. Remember, when a site goes off for a few hours or even a half day, there is a big impact which is experienced as a result although you may not see it right away for example on my side, I lost a good number of visitors, my revenues were impacted.
Somehow somewhere, my relationship with my host and who doubles as a friend was also shaken due to the fact that I seemed over pressurizing him to have my site up yet that is the same thing he was trying – thanks, we were able to solve that.
And if you happen to be experiencing the same problem and not knowing the cause and how to solve it, below are the suggestions you must try before everything else.
6 ways to fix error establishing database connection
- Use control panel to detect the problem
- Contact your hosting provider
- Revert all changes you had previously made
- Check out your config.Php file
- Try to add a default port number
- Consider an upgrade
Use Control Panel To Detect The Problem
If you have access to your cPanel, that is a good way to start. Try to log in to your dashboard and click on the view status link. On the next page, you will be able to see the different statuses of your website for example Server Load, Memory Used, cpanellogd and others. Put more emphasis on the MySQL since the problem you have concerns it and if you see a failure notice or contact your provider.
Contact Your Hosting Provider
The next thing you need to do and which I suggest basing on my own experience is contacting your service provider immediately you get to see such. If you have their phone contact, use that option since it appears to be the best one.
Let your provider try to troubleshoot the problem and possibly identify the cause and the solution at the same time. In so many cases, the problem is originating from your providers end which means that you can do nothing totally. Remember, its a database connection error. And basing on what you discover, consider doing the following below.
Revert all changes you had previously made
If the problem came after a change of something on your site for example installing a plugin, try to delete it first and retry to see if it helps. You can do such changes basing on when the problem happened and when the changes had occurred.
Check out your config.php file
This is a file which contains your database name and password. You need to access your site using FTP or File Manager so as to make sure that there is nothing like any change in them. If by any mistake you changes either the username or password, you will need to revert them or correct the File.
Try to add a default port number
Check out your PHP.INI file and add 127.0.0.1:3306 or 127.0.0.1:3307 next to your host Address field.
Consider an upgrade
This problem is very common on most free hosting services with exception of a few which offer a high class service. If you are on a free host, it may be time for you to upgrade to a better plan since in many cases, it involves some shifts.
Note : For which ever step you attempt, you need to ensure that you do a back of that very file you want to edit to avoid more confusion.
Liked this article or found it helpful? Share it with your friends using the social share buttons below and or post a comment to let us know your feedback or any addition using the comment form below..