How To Change Database Name In Magento 2
In this post, I will guide you on How To Change Database Name In Magento 2. The env file contains information about the database like dbname, username, and password, and you can change them to work with the MySQL server.
This should be done when you move host or change a new database. Here’s how you can get the job done quickly through our guide below:
Steps To Change Database Name In Magento 2
1. First, you need to connect to your server via SSH as the root user by command:
ssh root@<your-ip-address> -p <your-port-number>
2. Go to Magento 2 root folder.
3. Open env.php file with the below given path.
app/etc/env.php
4. Navigate to the db and check the “dbname” property. You can see it in env.php file like this:
'db' => [
'table_prefix' => '',
'connection' => [
'default' => [
'host' => 'localhost',
'dbname' => 'magento2',
'username' => 'root',
'password' => '',
'model' => 'mysql4',
'engine' => 'innodb',
'initStatements' => 'SET NAMES utf8;',
'active' => '1',
'driver_options' => [
1014 => false
]
]
]
],
5. Here, the database name is “magento2”. Now you can change the name of the database to the name you want to set.
For example the database name you want to change is “magento242”, it will look like below:
'dbname' => 'magento242',
So you have done it successfully!
This is the end of the post.
Follow us for the more helpful posts!
We hope this is a useful post for you on How To Change MySQL Password Policy Level.
Thank you for reading!