Edit Magento 1 and Magento 2 Database Configuration File

Magento Database Configuration File

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.

Also Read

Latest Magento Tips, Guides, & News

Stay updated with new stuff in the Magento ecosystem including exclusive deals, how-to articles, new modules, and more. 100% Magento Goodness, a promise!

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top

We can help you. Right now.

Fast growing merchants depend ServerGuy for high-performance hosting. Experience counts. Let's get started.

Talk to a sales representative

USA / Worldwide




Core Web Vitals Book COver

Is your website ready for Core Web Vitals?

Take this FREE book with you and optimize your store for speed.

Learn all about new Google new ranking factors and get that top ranking.