When you are working on Magento, you may have to make changes in Magento database configuration file, now and then.

Editing Magento DB Config files are important when:

  • Installing a fresh Magento site
  • Changing DB or Magento site
  • Migrating the store to a new server

This article will guide you to change the Magento 1 and Magento 2 db config files.

Magento Database Configuration File

In Magento, edit the db:

  1. Follow the path: <DocumentRoot>/app/etc/
  2. Locate the local.xml file
  3. Open the local.xml file with your editor

You will see the code like this:

Magento Database Configuration File

This file is editable. And you can edit all the values needed such as:

  • Host: Host address
  • Username/Password: Account information that has access to Database
  • Database Name: the Name of Magento website database.

After making the changes, save the file.

For Magento 2 db Config File

In Magento 2, edit the db:

  1. Follow the path: /<Magento Install Dir>/app/etc/
  2. Locate the env.php file
  3. Open the env.php file with your editor

You will find a code like this:

Magento 2 Db Config File

From here, change the values.

  • Host: Change the Host Address
  • Username/Password: Changing the account info of the Magento 2
  • Database Name: Name of the Magento DB

After making the change, save the updates.

Maintenance of the database file is important for Magento store.

I hope this small tutorial helped you in configuring the Magento database files. if any doubt, leave it in the comments.

Posted by Editor