MYSQL +无法从PHP连接

I am using nginx, PHP and MYSQL. I setup a database and a user and I can select it via the MySQL CLI client:

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 52
Server version: 5.1.61-0+squeeze1 (Debian)
mysql> use cinema
Database changed

However, it seems not to work when I try to connect to it from my php script:

<?php
$link = mysql_connect('localhost', 'root', '************');
if (!$link) {
    die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($link);
?>

The output is:

Could not connect: Access denied for user 'root'@'localhost' `(using password: NO)`

(**** is of course my real password...).

Does anyone have an idea why it says (using password: NO) although I clearly use one in my code?

It could be that mysql safe mode is on, and then the password field is ignored.