用户'root'@'localhost'拒绝访问(使用密码:YES)

时间:2016-07-13 15:45:49

标签: php mysql phpmyadmin

我正在使用WAMP Server进行android注册页面开发。我收到了这个错误:

  

拒绝访问用户'root'@'localhost'(使用密码:YES)

请帮我解决这个问题。

这是我的Config.inc.php文件:

<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
 * phpMyAdmin sample configuration, you can use it as base for
 * manual configuration. For easier setup you can use setup/
 *
 * All directives are explained in documentation in the doc/ folder
 * or at <http://docs.phpmyadmin.net/>.
 *
 * @package PhpMyAdmin
 */

/*
 * This is needed for cookie based authentication to encrypt password in
 * cookie
 */
$cfg['blowfish_secret'] = 'a8b7c6d'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */

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

/*
 * First server
 */
$i++;
/* Authentication type */
$cfg['Servers'][$i]['verbose'] = 'mysql wampserver';
//$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = '';
/* Server parameters */
$cfg['Servers'][$i]['host'] = '127.0.0.1';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = false;
/* Select mysql if your server does not have mysqli */
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['AllowNoPassword'] = true;



/*
 * phpMyAdmin configuration storage settings.
 */

// No warning on  pmadb tables
$cfg['PmaNoRelation_DisableWarning'] = true;


?>

这是Config.php文件:

<?php

/**
 * Database config variables
 */
define("DB_HOST", "localhost");
define("DB_USER", "root");
define("DB_PASSWORD", "root");
define("DB_DATABASE", "android_api");
?>

这是我的确切问题: enter image description here

1 个答案:

答案 0 :(得分:1)

除非您为root用户ID添加了密码,否则默认情况下它是开箱即用的,没有密码。

所以只需加上

define("DB_USER", "root");
define("DB_PASSWORD", "");

或者只是将phpMyAdmin中的密码字段留空并按下GO按钮

RE:您的评论:我使用的是phpMyAdmin

然后屏幕看起来应该是这样的

enter image description here

在用户名中输入root,并将password:字段留空

然后按下GO按钮