私はnginx、PHP、MYSQLを使用しています。データベースとユーザーをセットアップし、MySQLCLIクライアントを介してそれを選択できます。
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
ただし、phpスクリプトから接続しようとすると機能しないようです。
<?php
$link = mysql_connect('localhost', 'root', '************');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($link);
?>
出力は次のとおりです。
Could not connect: Access denied for user 'root'@'localhost' `(using password: NO)`
(* ** *はもちろん私の本当のパスワードです...)。
(using password: NO)
私がコードで明確に使用しているのに、なぜそれが表示されるのか誰かが知っていますか?