Connecting Civi to a previous install's database
You should edit the civicrm.settings.php file.  The location of this file depends on your content management system.

Drupal: sites/default/civicrm.settings.php

WordPress: wp-content/uploads/civicrm/civicrm.settings.php

Joomla: administrator/components/com_civicrm/civicrm.settings.php

You may find this related post helpful: How do I change the CiviCRM Database name