Skip to content

Magento 2 Database Configuration File

Magento2 db settings. Magento 2 Database Configuration File. Magento database configuration file. Magento db settings file. Magento2 database file.

Category
Databases
Covers
Magento
Versions & support
About Magento →
On this page

Magento 2 is latest version available of the popular eCommerce software Magento. In previous tutorial you got details about Magento2 installation on Linux.

This tutorial will help you to update Magento 2 database configuration file. The previous Magento versions’ uses app/etc/local.xml database configuration file. The Magento2 keep database configuration under app/etc/env.php file.

Magento 2 Database Configuration File

To change your Magento 2 database server hostname, database username, password or database name, you need to edit below file.

/Magento2 Install Dir/app/etc/env.php

Navigate to your Magento 2 installation directory and edit app/etc/env.php configuration file in your favorite editor and search for following settings and do necessary changes.


  'db' =>
  array (
    'table_prefix' => '',
    'connection' =>
    array (
      'default' =>
      array (
        'host' => 'localhost',
        'dbname' => 'database_name',
        'username' => 'database_username',
        'password' => 'database_password',
        'active' => '1',
      ),
    ),
  ),

Now update the orange highlighted values as following

  • localhost : MySQL server hostname.
  • database_username : MySQL user to connect database server.
  • database_password : MySQL user password .
  • database_name : MySQL database name of magento.

Conclusion

In this tutorial, you have learned to update database configuration on Magento2 application.

Rahul

Rahul Kumar is the founder and chief editor of TecAdmin.net. A Red Hat Certified Engineer (RHCE), he has worked in IT since 2009, with hands-on experience in Linux system administration, DevOps, web hosting, cloud platforms and automation. He started TecAdmin in 2013 to share practical, step-by-step guides, and leads its editorial work with one aim: making technical learning clear and useful for sysadmins, developers and beginners alike.

4 Comments

  1. Hello Rahul,

    Using same way, can we connect 3rd party SOAP API’s ? Where my credentials are stored in env.php file and using that I will create on connection class like AbstractDB in default Magento2

  2. Are the passwords in the file encrypted/hashed or are they just stored as plain text?

    I am trying to retrieve my password from the env.php file but it does not seem to be correct

Leave a Reply

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


Back to top