How to find the MySQL Database details for Wordpress, Joomla, Prestashop and Magento and others
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,
use this guide for instructions on updating them.
Note: Your main domain's document 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/.
Wordpress
Configuration file - wp-config.php
This file is located in your public_html folder. The information you need will look like this:
Prestashop
Configuration file - settings.inc.php
This file is located in the public_html/config/ folder. The information you need will look like this:
Joomla
Configuration file - configuration.php
This file is located in the public_html folder. The information you need will look like this:
Drupal
Configuration file - settings.php
This file is located in the public_html/sites/default/ folder. The information you need will look like this:
Magento
Configuration file - local.xml
This file is located in the public_html/app/etc/ folder. The information you need will look like this:
OpenCart
Configuration file - config.php
There are two config files: one is located in the public_html/ and the other in the public_html/admin/ folder. The information you need will look like this:
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 hosting 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 CMSs 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.
For more tutorials on website development and Content Management System troubleshooting, view our List of CMS Guides.