If your website is experiencing a MySQL database connection error, it's often because your website's configuration file has the wrong password listed, and you simply need to update the details. This guide shows you how to find this configuration file in various CMS's/Web Builders. Once you've found your MySQL password and user details, click on this guide for instructions on updating them.
NOTE: Your main website's root folder will always be the public_html folder. However, if the domain in question is an add-on domain or subdomain it will have its own root folder inside the main public_html folder. For example, the "public_html" folder of the subdomain testing.yourdomain.net.au will be public_html/testing/ (click here for a guide on finding the correct folder in this case)
Wordpress

wp-config.php this file is located in your public_html folder. The information you need will look like this:

findmysqlpasswordpic1.png

Prestashop

settings.inc.php this file is located in the public_html/config/ folder. The information you need will look like this:

findmysqlpassword45pic2.png

Joomla

configuration.php this file is located in the public_html folder. The information you need will look like this:

findmysqlpassword45pic3.png

Drupal

settings.php this file is located in the public_html/sites/default/ folder. The information you need will look like this:

findmysqlpassword45pic4.png

Magento

local.xml this file is located in the public_html/app/etc/ folder. The information you need will look like this:

findmysqlpassword45pic5.png

Other
If your CMS isn't listed here (or your site is custom made) and you can't find the config file name by doing a Google search for cms name config file (eg: magento config file), alternatively you can log into your website via SSH and search for part of the database using the below command:

egrep -r DBNAME *

This will find a list of text documents which contain your database name in them. With cPanel for example, the database name will start with the username. So if your cPanel username is yourdom then you would use the command: egrep -r yourdom *

Of course, if you have multiple CMS's installed in different sub/add-on directories, it will find them all and you will have to check the files to find the correct one.


Did you find this article useful?