I have come across this problem with Postgres as well as Oracle and DB2. DBI is a little qwerky for me, and sometimes I have to explicitly put single quotes around the username and the password in order for it to connect successfully. So you might try
$username="'user'";
$password="'password'";
type of thing.
hope this helps.