309: Locating your database name in Drupal 8
There may come a time where you will need to know your specific database name for your Drupal 8 website. Perhaps you need to connect to it via a remote MySQL program to take a look at some tables, or maybe you are in the middle of transferring a site and need to know what database to move.
If you used an autoinstaller such as Softaculous or Fantastico to install Drupal you may have used the default database name and not paid much attention to it. You may also not have been the person to initially set up the site and have never seen the database name.
If your hosting account has only one database in it, finding the name will not be an issue, but if you have multiple databases installed on the account, narrowing down which one is in use for your specific Drupal site can be more difficult. In this article, we will describe how to find the name of the database that your Drupal 8 site is using.
How to find your Drupal 8 database name
- Log into your cPanel dashboard.
- From the main cPanel page, locate the File Manager tool under the Files category and click on it.
- Now that you are in the File Manager, you will need to access the root folder for your Drupal site. This can be different depending on whether your Drupal is installed as your main domain, an addon domani, or a sub domain. Below is a table to give you the format of the folder you will need to look for. The vast majority will be using the main domain, followed by addon, and the least likely subdomain.
main site public_html addon domain public_html/example.com subdomain public_html/folder
- Once you have found your root folder and opened it, you will need to look for the configuration file. This is located under the sites and then default folders. Assuming that Drupal is installed on your main site, you would need to look under the "public_html/sites/default" folder path. Once you have opened the default folder, look for a file named settings.php. Open the file in edit mode.
Once in the editor you will need to find the actual lines that have the database settings. The vast majority of the lines are commented out, so look towards the bottom of the file. In Drupal 8 (as of Alpha 7) the settings appear around line 670. You will see a line of code that appears like this:
'database' => 'userna5_testdb',The database name itself has two portions. The first portion 'userna5' is your cPanel username and the second part 'testdb' is the actual database name.
- Once you find the database name, be sure to notate it in a safe place so it is easily found when you need it. This will be most commonly useful when working with database admin programs such as phpMyAdmin or remote database connection managers.
›Section 2: 310: Changing the Maintenance Mode Message in Drupal 8
We value your feedback!
There is a step or detail missing from the instructions.
The information is incorrect or out-of-date.
It does not resolve the question/problem I have.
new! - Enter your name and email address above and we will post your feedback in the comments on this page!