Get Magento’s database configuration

On Linux, make a php file anywhere in your filesystem while including the magento Mage file.


require_once "/home/cliper/magento/app/Mage.php";


$config  = Mage::getConfig()->getResourceConnectionConfig("default_setup");

$dbinfo = array(“host” => $config->host,
                “user” => $config->username,
                “pass” => $config->password,
                “dbname” => $config->dbname



where /home/cliper/magento/ is your magento absolute path.

In windows, change the directory like:

require_once “C:\magento\path\app\Mage.php”;

You can then use the array like:

echo $dbinfo[“host”];


Leave a Reply

Close Menu