Change database name in Magento 2

Magento 2 versions have had a lot of changes compared to Magento 1, not only improving performance, security, functionality, but also some changes in file structure. With Magento 1, the database configuration file is located in app/etc/local.xml. As for Magento 2, this file has been converted to app/etc/env.php. In this article, I will show you how to change the database name in Magento 2.

Steps to change database name in Magento 2

Step 1: Find the database configuration file env.php I mentioned above, it is located in app/etc

Step 2: Next, you will only pay attention to the ‘db’ which contains the information about the data


This is the line of code to help you change the database name. To change just enter the new db name in the following:

‘dbname’ => ‘new-name-database’,

After that, remember to save it