【问题标题】:xampp localhost phpmyadmin Access denied for user 'root'@'localhost' (using password: YES)xampp localhost phpmyadmin 用户'root'@'localhost'的访问被拒绝(使用密码:是)
【发布时间】:2012-10-31 14:57:09
【问题描述】:

当我尝试访问我的 phpmyadmin localhost 时遇到两个错误

Access denied for user 'root'@'localhost' (using password: YES)

phpMyAdmin tried to connect to the MySQL server, and the server rejected the connection. You should check the host, username and password in your configuration and make sure that they correspond to the information given by the administrator of the MySQL server.

我不知道我做错了什么...这是我的配置代码...

$cfg['blowfish_secret'] = ''; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */

/* 
 * Servers configuration
 */
$i = 0;

/* 
 * First server
 */
$i++;
/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'config';
/* Server parameters */
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'password';
$cfg['Servers'][$i]['connect_type'] = 'socket'; 
$cfg['Servers'][$i]['compress'] = false;
$cfg['Servers'][$i]['AllowNoPassword'] = false;
/* Select mysqli if your server has it */
$cfg['Servers'][$i]['extension'] = 'mysql';
/* User for advanced features */
//$cfg['Servers'][$i]['controluser'] = 'pmauser';
//$cfg['Servers'][$i]['controlpass'] = 'pmapass';
/* Advanced phpMyAdmin features */
//$cfg['Servers'][$i]['pmadb'] = 'phpmyadmin';
//$cfg['Servers'][$i]['bookmarktable'] = 'pma_bookmark';
//$cfg['Servers'][$i]['relation'] = 'pma_relation';
//$cfg['Servers'][$i]['table_info'] = 'pma_table_info';
//$cfg['Servers'][$i]['table_coords'] = 'pma_table_coords';
//$cfg['Servers'][$i]['pdf_pages'] = 'pma_pdf_pages';
//$cfg['Servers'][$i]['column_info'] = 'pma_column_info';
//$cfg['Servers'][$i]['history'] = 'pma_history';

/* 
 * End of servers configuration
 */

/*
 * Directories for saving/loading files from server
 */
$cfg['UploadDir'] = '';
$cfg['SaveDir'] = '';

?>

我注意到很多代码被注释掉了,我应该取消注释吗?

【问题讨论】:

  • 您确定需要密码才能连接数据库吗?如果您不需要密码,请执行此操作 $cfg['Servers'][$i]['password'] = '';
  • 连接数据库时出现此错误。因此,尝试回显连接字符串的详细信息以进行调试(以了解其连接所采用的值是否正确)。
  • 您是否进入了默认的 xampp 页面并通过了安全屏幕?

标签: php phpmyadmin xampp localhost


【解决方案1】:

如果 XAMPP->MySQL 端口已更改,(默认端口为 3306)必须将新端口添加到 phpMyAdmin 文件中:

xampp phpmyadmin access denied error(#2002)

C:\xampp\phpMyAdmin\config.inc.php

发件人:
$cfg['Servers'][$i]['host'] = '127.0.0.1';
至:
$cfg['Servers'][$i]['host'] = '127.0.0.1:3308';

【讨论】:

    【解决方案2】:

    不要改变任何东西,保持原样,打开你的 xampp 并尝试在写完之后从 shell cd c://xampp/mysql/bin 访问 mysql mysql 然后点击进入它会打开你的数据库

    【讨论】:

    • 这不只是从命令行访问吗? phpmyadmin 在哪里适合这个?
    【解决方案3】:

    花了这么多时间我才知道。

    只要使用这个设置->打开phpmyadmin目录下的config.inc.php文件

    /* Authentication type and info */
    $cfg['Servers'][$i]['auth_type'] = 'cookie';
    $cfg['Servers'][$i]['user'] = 'root';
    $cfg['Servers'][$i]['password'] = '';
    $cfg['Servers'][$i]['extension'] = 'mysqli';
    $cfg['Servers'][$i]['AllowNoPassword'] = true;  
    $cfg['Lang'] = '';
    

    您应该有一个具有@localhost 主机名的用户。现在 phpmyadmin 会要求你输入密码。如果您提供正确的密码,您将能够登录。

    【讨论】:

      【解决方案4】:

      在您的配置代码下更改以下行

      $cfg['Servers'][$i]['password'] = 'password';
      

      $cfg['Servers'][$i]['password'] = '';
      

      【讨论】:

        【解决方案5】:

        尝试使用相同的身份验证凭据从命令行登录数据库。通过这种方式,您可以验证您是否确实使用了正确的身份验证凭据,例如用户名和密码。如果您在命令行上失败,则问题不在于 phpmyadmin,而在于您的数据库引擎设置。

        【讨论】:

        • 你需要安装mysql客户端。它带有一个手册页。但一般用法是:mysql -u <our-user-name> -p [RETURN]。如果您想访问不同系统上的数据库服务器,您必须确保您可以通过网络访问服务器端口,通常是 mysql 的端口 3306。但如前所述:阅读手册页或 mysql 文档。里面都有解释。
        【解决方案6】:

        试试这些步骤

        1. 打开phpmyadmin目录下的config.inc.php文件

        2. 查找第 21 行:$cfg['Servers'][$i]['password'] = ''

        3. 改成:$cfg['Servers'][$i]['password'] = 'your_password';

        4. 重启 XAMPP

        here is full description with image

        【讨论】:

          猜你喜欢
          • 2017-12-20
          • 1970-01-01
          • 2016-05-05
          • 1970-01-01
          • 2014-09-10
          • 1970-01-01
          • 2013-06-11
          • 2013-11-03
          • 2016-08-21
          相关资源
          最近更新 更多