密码设置为数据库后无法访问phpMyAdmin

时间:2011-05-13 15:04:38

标签: php mysql phpmyadmin

我设置密码到MySQL后,phpMyAdmin拒绝访问数据库并显示以下错误:

  MySQL说:

     

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

我用Google搜索并试图弄乱配置文件,我尝试了一切,但无法提出解决方案。我甚至已经完成了Stack Overflow之前的问题,但那里的答案也没有改变这种情况。

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

<?php
/*
 * This is needed for cookie based authentication to encrypt password in
 * cookie
 */
$cfg['blowfish_secret'] = 'xampp'; /* YOU SHOULD CHANGE THIS FOR A MORE SECURE COOKIE AUTH! */

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

/*
 * First server
 */
$i++;

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

/* Server parameters */
$cfg['Servers'][$i]['host']             = 'localhost';
$cfg['Servers'][$i]['connect_type']     = 'tcp';
$cfg['Servers'][$i]['compress']         = false;
$cfg['Servers'][$i]['extension'] = 'mysql';
$cfg['Servers'][$i]['AllowNoPassword'] = false;

/* Select mysqli if your server has it */
$cfg['Servers'][$i]['extension'] = 'mysqli';

/* User for advanced features */
$cfg['Servers'][$i]['controluser'] = 'pma';
$cfg['Servers'][$i]['controlpass'] = 'root';

/* 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';
$cfg['Servers'][$i]['designer_coords']  = 'pma_designer_coords';

/*
 * End of servers configuration
 */

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

$cfg['AllowAnywhereRecoding']       = true;
$cfg['DefaultCharset']              = 'utf-8';
$cfg['DefaultLang']                 = 'en-utf-8';
$cfg['DefaultConnectionCollation']  = 'utf8_general_ci';

$cfg['MySQLManualBase'] = 'http://dev.mysql.com/doc/refman/5.1/en';
$cfg['MySQLManualType'] = 'searchable';

?>

4 个答案:

答案 0 :(得分:7)

以下是phpmyadmin config.inc.php文件的代码:

   <?php

          $i = 0;
          $i++;
          $cfg['Servers'][$i]['host'] = 'localhost';
          $cfg['Servers'][$i]['connect_type'] = 'tcp';
          $cfg['Servers'][$i]['auth_type'] = 'http';
          $cfg['Servers'][$i]['compress'] = false;
          $cfg['Servers'][$i]['extension'] = 'mysql';
          $cfg['Servers'][$i]['AllowNoPassword'] = false;

   ?>

如果您在主机配置方面遇到问题,则应使用:

         $cfg['Servers'][$i]['host'] = '127.0.0.1';

如果这不起作用,这是另一种不需要任何编码的解决方法:

  • 在PHPMyAdmin文件夹下的浏览器中打开/scripts/signon.php页面
  • 输入登录详细信息
  • 然后弹出另一个登录界面,输入mysql详细信息

答案 1 :(得分:4)

1)转到目录C:\ xampp \ phpMyAdmin并打开文件config.inc.php

2)然后找到第21行并将其更改为(123456是我的mysql root密码)

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

3)然后找到第34行并将其更改为

$cfg['Servers'][$i]['controlpass'] = '123456';

4)保存文件。然后尝试刷新mysql页面。这在大多数情况下都必须有效。

答案 2 :(得分:0)

你可以尝试这个.. 将密码字段留空

<?php
/*
* This is needed for cookie based authentication to encrypt password in
* cookie
*/
$cfg['blowfish_secret'] = 'xampp'; /* YOU SHOULD CHANGE THIS FOR A MORE     SECURE COOKIE AUTH! */

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

/*
* First server
*/
$i++;

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

/* Bind to the localhost ipv4 address and tcp */
$cfg['Servers'][$i]['host'] = '127.0.0.1';
$cfg['Servers'][$i]['connect_type'] = 'tcp';

/* User for advanced features */
$cfg['Servers'][$i]['controluser'] = 'pma';
$cfg['Servers'][$i]['controlpass'] = '';

/* 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';
$cfg['Servers'][$i]['designer_coords'] = 'pma_designer_coords';
$cfg['Servers'][$i]['tracking'] = 'pma_tracking';
$cfg['Servers'][$i]['userconfig'] = 'pma_userconfig';
$cfg['Servers'][$i]['recent'] = 'pma_recent';
$cfg['Servers'][$i]['table_uiprefs'] = 'pma_table_uiprefs';
$cfg['Servers'][$i]['users'] = 'pma_users';
$cfg['Servers'][$i]['usergroups'] = 'pma_usergroups';
$cfg['Servers'][$i]['navigationhiding'] = 'pma_navigationhiding';
$cfg['Servers'][$i]['savedsearches'] = 'pma_savedsearches';

/*
* End of servers configuration
*/
?>

答案 3 :(得分:0)

另一个选择是,在config.inc.php中,将auth_type更改为'cookie'

$cfg['Servers'][$i]['auth_type'] = 'cookie';

或者,您也可以将auth_type设置为“http”

$cfg['Servers'][$i]['auth_type'] = 'http';

使用任何一种方法,下次登录phpmyadmin时,都会提示您输入用户名和密码。

来源= https://wiki.phpmyadmin.net/pma/Auth_types