1. Can you log in to MySQL from the command line?
2. If you're using MySQL 4.1 with the mysql extension (the only one available in PHP 4), then you need to run MySQL using the --old-passwords option enabled because the mysql extension does not support the new authentication used in MySQL 4.1.1 and newer.
Try running this simple PHP script, using appropriate values for $hostname, $username, and $password:
<?php
$link = mysql_connect($hostname, $username, $password)
or die( mysql_error() );
echo "Connected to $host as $username with connection ID $link.";
?>
If you're running the webserver and MySQL on the same machine, then the correct value for $hostname is almost certainly "localhost" or "127.0.0.1". If you get an error message that looks something like "Client does not support authentication protocol requested by server; consider upgrading MySQL client", then see
http://dev.mysql.com/doc/mysql/en/old-client.html
and for background info
http://dev.mysql.com/doc/mysql/en/password-hashing.html
If you get a different error message, post it here.
Jon Stephens
MySQL Documentation Team @ Oracle
MySQL Dev Zone
MySQL Server Documentation
Oracle