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

发布于 2024-11-07 05:57:31 字数 2328 浏览 1 评论 0原文

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

MySQL 说:

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

我已经用谷歌搜索并试图弄乱配置文件,我尝试了一切,但无法想出解决方案。我什至浏览了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';

?>

After I set password to MySQL, phpMyAdmin is denying access to the database and is showing the following error:

MySQL said:

1045 - Access denied for user 'root'@'localhost' (using password: NO)

I have googled it and tried to mess with the config file, I tried everything, but couldn't come up with a solution. I even went through the previous questions of Stack Overflow, but the answers there also didn't change the situation.

Here is my config.inc.php file:

<?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';

?>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

oО清风挽发oО 2024-11-14 05:57:31

以下是您应该为 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 详细信息

Here's the code you should have for the phpmyadmin config.inc.php file:

   <?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;

   ?>

If you are having issues w the host configuration, you should use:

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

If that doesn't work, here's another work-around that doesn't require any coding:

  • open /scripts/signon.php page in your browser under PHPMyAdmin folder
  • enter the the login details
  • Then another login screen pops-up, enter the mysql details
玩心态 2024-11-14 05:57:31

1)进入目录C:\xampp\phpMyAdmin,打开文件config.inc.php

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

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

3)然后找到第34行,并将其更改 4)保存

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

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

1) Go to the directory C:\xampp\phpMyAdmin and open the file config.inc.php

2) Then find the line 21 and change it to (123456 is my mysql root password)

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

3) Then find the line 34 and change it to

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

4) Save the file. Then try to refresh the mysql page. This must work in most cases..

毁梦 2024-11-14 05:57:31

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

<?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
*/
?>

You Can Try This Too..
Leave Your Password Field Blank

<?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
*/
?>
檐上三寸雪 2024-11-14 05:57:31

另一种选择是,在 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

Another option is, inside config.inc.php, change the auth_type to 'cookie'

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

Or, you can also set auth_type to 'http'

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

With either method, next time you login to phpmyadmin, it should prompt you for a username and password.

Source = https://wiki.phpmyadmin.net/pma/Auth_types

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文