I've been installing a MySQL database on my computer (just for fun, or whatever ^^). I've noticed that if you try to connect to it with any username but with no password it still accepts the connection, whether the username exists or not. Can this be prevented in some way?

Another thing I noticed is if you try to connect to it (through PHP's mysql_connect() ) and supply a username with an invalid password you get an error message saying somethign about "Access denied for user" but it STILL connects to the database and does its query. Obviously some setting must be wrong but every setup instructions I've read mentions nothing about it.

I know this aint a MySQL forum, but I don't know of any good ones.
Code:
$user="testuser";
$password="testpass";
$database="test";
mysql_connect("localhost", $user, $password);
@mysql_select_db($database) or die( "Unable to select database");
$query= " ... "; //Some query, not important
mysql_query($query);
mysql_close();
"testuser" with the password "testpass" is a valid one. If I change the password to something else I get the error message in the generated file, but the query is still done in the database. Why can it still connect even with an invalid password?