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:
- Follow the path: <DocumentRoot>/app/etc/
- Locate the local.xml file
- Open the local.xml file with your editor
You will see the code like this:
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:
- Follow the path: /<Magento Install Dir>/app/etc/
- Locate the env.php file
- Open the env.php file with your editor
You will find a code like this:
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.