How to Change Database Name in Magento 2

How to Change Database Name in Magento 2

The latest Magento 2 comes with not only improved security, performance, and ease of use but also some changes in the file structure.

The configuration file differs from the one in Magento 1. For example:

In the previous version of Magento, the database configuration file was located in app/etc/local.xml, whereas, in Magento 2, the file address is app/etc/env.php

The database configuration file holds information like server hostname, username, password, database name, view of backups, database edits, and every alteration you need to work with MySQL.

This blog post will guide you on how to change database name in Magento 2.

Use the below solution when you have FTP access, but you don’t know database credentials while working with a live site.

Method to Change Database Name in Magento 2

  1. In your Magento 2 folder structure, open env.php file from app/code/
  2. Change the database name by modifying name of ‘dbname‘.

Here, database name is magento_db. Now change the name of database to your selected name in the dbname.

That’s it

If you have any doubt regarding the above solution, do mention them in the Comments section below.

I would be happy to help.

Feel free to share the method with Magento Community via social media.

Thank You.

Get Weekly Updates

Never miss Magento tips, tricks, tutorials, and news.

Thank you for subscribing.

Something went wrong.

5
(based on 11 Reviews)

An expert in his field, Jignesh is the team leader at Meetanshi and a certified Magento developer. His passion for Magento has inspired others in the team too. Apart from work, he is a cricket lover.

Leave a reply:

Your email address will not be published.