Magento : Get Database Configuration

You can get the Magento database configuration by using custom PHP script in Magento given below:
<?php
define('MAGENTO_ROOT', getcwd());
require_once MAGENTO_ROOT . '/app/Mage.php';
$app = Mage::app('default');
$config  = Mage::getConfig()->getResourceConnectionConfig("default_setup");
$dbInfo = array("host" => $config->host,
            "user" => $config->username,
            "pass" => $config->password,
            "dbname" => $config->dbname
);

$host = $dbInfo["host"]; // will provide host name
$user = $dbInfo["user"]; // will provide user name
$password = $dbInfo["pass"]; // will provide database password
$dbName = $dbInfo["dbname"]; // will provide database name
?>
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s