{"id":1740,"date":"2021-05-07T10:16:12","date_gmt":"2021-05-07T10:16:12","guid":{"rendered":"https:\/\/meetanshi.com\/blog\/change-database-name-in-magento-2\/"},"modified":"2025-05-22T10:32:41","modified_gmt":"2025-05-22T05:02:41","slug":"change-database-name-in-magento-2","status":"publish","type":"post","link":"https:\/\/meetanshi.com\/blog\/change-database-name-in-magento-2\/","title":{"rendered":"How to Change Database Name in Magento 2"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">The&nbsp;<a href=\"https:\/\/meetanshi.com\/blog\/magento-2-4-8\/\">latest Magento 2.4.8<\/a>&nbsp;comes with not only improved security, performance, and ease of use but also some changes in the file structure.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The configuration file differs from the one in Magento 1. For example:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">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<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">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.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This blog post will guide you on how to&nbsp;<strong><em>change database name in Magento 2<\/em><\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Use the below solution when you have FTP access, but you don\u2019t know database credentials while working with a live site.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Method to Change Database Name in Magento 2<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">1. In your Magento 2 folder structure, open&nbsp;<strong>env.php<\/strong>&nbsp;file from&nbsp;<strong>app\/code\/<\/strong><br>2. Change the database name by modifying name of \u2018<strong>dbname<\/strong>\u2018.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">'db' => [\n  'table_prefix' => '',\n  'connection' => [\n    'default' => [\n      'host' => 'localhost',\n      'dbname' => 'magento_db',\n      'username' => 'root',\n      'password' => 'admin123',\n      'model' => 'mysql4',\n      'engine' => 'innodb',\n      'initStatements' => 'SET NAMES utf8;',\n      'active' => '1'\n    ]\n  ]\n]<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Here, database name is magento_db. Now change the name of database to your selected name in the dbname.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">That\u2019s it<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Feel free to share the method with Magento Community via social media.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thank You.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The&nbsp;latest Magento 2.4.8&nbsp;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 [&hellip;]<\/p>\n","protected":false},"author":13,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[34],"tags":[],"class_list":["post-1740","post","type-post","status-publish","format-standard","hentry","category-magento"],"_links":{"self":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1740","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/comments?post=1740"}],"version-history":[{"count":3,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1740\/revisions"}],"predecessor-version":[{"id":14339,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1740\/revisions\/14339"}],"wp:attachment":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/media?parent=1740"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/categories?post=1740"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/tags?post=1740"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}