Magento database settings are stored at the xml file:
app/etc/local.xml
In this file you will find around line 37:
<resources>
<db>
<table_prefix><![CDATA[mage_]]></table_prefix>
</db>
<default_setup>
<connection>
<host><![CDATA[localhost]]></host>
<username><![CDATA[your_database_username]]></username>
<password><![CDATA[your_database_password]]></password>
<dbname><![CDATA[your_database_name]]></dbname>
<active>1</active>
</connection>
</default_setup>
</resources>
Change the database settings between the xml tags.