Note: This post was written for a very old version of Drupal and may only be relevant for a few people but I’m leaving it here for posterity.

If your installing Drupal (even on localhost) if you get stuck on the Database Configuration page open ./sites/default/settings.php and change the $db_url variable to your database settings.

Depending on the type of database your using this is what your variable will look like.
$db_url = ‘mysql://username:[email protected]/databasename’;
$db_url = ‘mysqli://username:[email protected]/databasename’;
$db_url = ‘pgsql://username:[email protected]/databasename’;

In the case of my localhost install that line would be:
$db_url = ‘mysql://root:[email protected]/drupal’;

Drupal being the name of my database. Username and password are always root with mamp.