Once in a while, you may need to know the database details of your WordPress website. I remember when I started using WordPress in 2012, and there wasn't a possible way to find out such information.
It's because many web hosting companies weren't offering cPanel with their starter plans. But nowadays, almost every company provides full access to cPanel with numerous options.
Even for the non-techie WordPress users, it's vital to have an idea to find the perfect spot to know the database credentials.
If you have ever tried to migrate your website from one web hosting to another, you might already know such a thing, but if you're a newbie, you need to follow this tutorial.
I would also like to mention, even if you transfer your website from its root directory to another folder, you need to handle the database correctly.
In this tutorial, you're going to learn the easiest way to find out and edit the database credentials, which usually helps in solving an error related to a database connection.
Use the wp-config.php File
Most of the newbies have no idea about wp-config.php and other WordPress core files.
Let me make you aware that .htaccess and wp-config.php are the two most vital files for a WordPress website; you may in need to use them now and then.
Whenever you get "Error Establishing a Database Connection," it's because of the database credentials don't match with the database you upload.
While migrating or moving a site, database error happens to be most common. The problem occurs when you have multiple databases.
For which, you require to open the wp-config.php file for each domain or subdomain.
Let's start the process.
Like always, you need to login to your cPanel account and search for the file manager to open, it happens to be under Files' section.
I remember when I was using Bluehost, and the layout of cPanel looked different than the official cPanel. It's because a few companies have their Account Management Panel.
So, don't be scared to see a different layout, make sure you find the file manager, where you will find your website's data.
Even if you host multiple websites on the same server, you can easily find your domain.
It's possible to see a blank page or the home directory, but you need to open public_html from the vertical left navigation menu.
I am sure; it can be easy to aim the root directory.
The wp-config.php file resides in the central area, where all the files and folders of a WordPress website are available.
Scroll down, and you can easily find the file. Right-click to edit. If you have used cPanel before, you may already know that it has the main navigation menu with an Edit option.
It's important to notice that you need to authenticate before accessing the wp-config.php file, for which, you need to click Edit when a popup appears in front of you.
A new tab appears on the browser, and you can see a lot of coding lines. You need to find out something related to the database name, database password, etc.
Let me show you a demo.
/** MySQL database username */ define('DB_USER', 'Username'); /** MySQL database password */ define('DB_PASSWORD', 'password'); /** MySQL hostname */ define('DB_HOST', 'localhost');
In this example, you can see "Username", which is the database username. For your website's database, the username may be "sss_11" or something else.
The same goes for the database password. You can easily spot all the database details for your domain.
As mentioned earlier, when you run multiple websites having multiple databases, you might need to find those databases.
You can either go to phpMyAdmin or use the database records, for which, click on the MySQL® Databases icon residing in the Databases' section.
A new page opens, and you can see all the available databases on your web hosting server, it's helpful when you're not sure about the database of your primary website.
I Hope You Find the wp-config.php File Helpful
Every time we ask our clients to send the database details to fix their website's issue, they give a blank look. Well, it's obvious for a newbie.
I can understand how hard it can be for a non-techie person to deal with all these technical terms. But if you decide to use WordPress, you should follow such basic terms.
The wp-config.php file is going to help you throughout your WordPress journey.
If you're techie person, you may also use phpMyAdmin to find out the database details, but it's not possible when you have multiple databases.
You should know the name of the database to edit. It's better to check the wp-config.php file of your WordPress site to grab the information.
I hope you can easily accomplish it.