【问题标题】:getting an error message with a mysql_connect() statement使用 mysql_connect() 语句获取错误消息
【发布时间】:2011-11-29 14:40:38
【问题描述】:

mysql_connect 语句之前的一些 cmets 告诉我修改值/变量名称以适应我的安装。我现在正在使用 xamp 并查看 php.ini。真的不知道问题出在哪里。请指教。谢谢。

php:

$dbhost = 'localhost'; //unlikely to require changing.
$dbname ='publication'; //moify these
$dbuser = 'username'; //variables 
$dbpass = 'password'; //// to your installation
$appname = 'Robot City'; // and preference

mysql_connect($dbhost, $dbuser, $dbpass) or die(mysql_error());

错误信息:

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'username'@'localhost' (using password: YES) in C:\xampp\htdocs\ajaxpagination\testpage.php on line 10
Access denied for user 'username'@'localhost' (using password: YES)

【问题讨论】:

    标签: php xampp mysql-connect


    【解决方案1】:

    这与 php.ini 无关。您向 mysql 提供了错误的用户名/密码,或者您没有在 mysql 中正确配置该帐户。

    当你在 mysql 中运行 show grants for username@localhost; 时会显示什么?

    【讨论】:

    • ERROR 1044 (42000): Access denied for used ''@'localhost' to database 'mysql'.
    【解决方案2】:

    您必须查看 XAMPP 文档,而不是查看 php.ini。
    我确信它包含您必须使用的数据库凭据。

    作为一个疯狂的猜测尝试使用

    $dbname ='test'; //moify these
    $dbuser = 'root'; //variables 
    $dbpass = '';
    

    但同样 - 请参阅文档以获取实际值。

    也有可能是您在安装 XAMPP 的过程中自己输入的。

    请注意,我一生中从未见过此应用程序。我写的只是大多数应用程序如何工作的一般概念。

    【讨论】:

      【解决方案3】:

      用户名和密码错误。时期!!!试试

      $dbhost = 'localhost'; //unlikely to require changing.
      $dbname ='publication'; //moify these
      $dbuser = 'root'; //variables 
      $dbpass = ''; //// to your installation
      $appname = 'Robot City'; // and preference

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-09-13
        • 2012-11-02
        • 2013-04-28
        • 2011-06-12
        • 2018-11-09
        • 2015-07-13
        • 2019-12-24
        • 1970-01-01
        相关资源
        最近更新 更多