我遇到了这个连接的问题。我也为这个用户做了“全部授权”
Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'kristian'@'localhost' (using password: YES) in connection.php on line 8
Failed to connect to MySQL: Access denied for user 'kristian'@'localhost' (using password: YES)
connection.php
<?php
define('DB_HOST', 'localhost');
define('DB_NAME', 'email');
define('DB_USER', 'kristian');
define('DB_PASSWORD', 'password');
$con=mysql_connect(DB_HOST,DB_USER,DB_PASSWORD) or die("Failed to connect to MySQL: " . mysql_error());
$db=mysql_select_db(DB_NAME,$con) or die("Failed to connect to MySQL: " . mysql_error());
?>
答案 0 :(得分:1)
首先,使用mysqli而不是mysql。也可以尝试运行
GRANT ALL PRIVILEGES ON email.* TO kristian@localhost IDENTIFIED BY 'password';
确保您拥有正确的访问权限。