MySQL 更改 root 密码后 PHPMyAdmin 无法连接

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13010268/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 15:15:24  来源:igfitidea点击:

PHPMyAdmin doesn't connect after root password change

mysqlconfigurationphpmyadminxamppchange-password

提问by hkBattousai

I installed Xampp (for Windows). I was happily using it with its all features.

我安装了 Xampp(适用于 Windows)。我很高兴使用它的所有功能。

Then I wanted to change MySql password. I set a randomly generated password (rCZ4Xnz78zbLY2Vh). Then PHPMyAdmin stopped logging in. It started to give the following error message, and it is the same ever since:

然后我想更改MySql密码。我设置了一个随机生成的密码 (rCZ4Xnz78zbLY2Vh)。然后 PHPMyAdmin 停止登录。它开始给出以下错误消息,此后一直是这样:

Error

MySQL said:
Cannot connect: invalid settings.

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.

Then I edited the `config.inc.php" file of PHPMyAdmin, and made its contents exactly as below:

然后我编辑了 PHPMyAdmin 的 `config.inc.php" 文件,并将其内容完全如下:

<?php

/* Servers configuration */
$i = 1;
$cfg['Servers'][$i]['host']         = '127.0.0.1';
$cfg['Servers'][$i]['port']         = '3306';
$cfg['Servers'][$i]['ssl']          = FALSE;
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['extension']    = 'mysql';
$cfg['Servers'][$i]['compress']     = FALSE;
$cfg['Servers'][$i]['controluser']  = 'root';   
$cfg['Servers'][$i]['controlpass']  = 'rCZ4Xnz78zbLY2Vh';
$cfg['Servers'][$i]['auth_type']    = 'config';
$cfg['Servers'][$i]['user']         = 'root';
$cfg['Servers'][$i]['password']     = 'rCZ4Xnz78zbLY2Vh';
$cfg['Servers'][$i]['nopassword']   = TRUE;

/* rajk - for blobstreaming */
$cfg['Servers'][$i]['bs_garbage_threshold']     = 50;
$cfg['Servers'][$i]['bs_repository_threshold']  = '32M';
$cfg['Servers'][$i]['bs_temp_blob_timeout']     = 600;
$cfg['Servers'][$i]['bs_temp_log_threshold']    = '32M';

/* Other settings */
$cfg['blowfish_secret'] = '';
$cfg['DefaultCharset']  = 'utf-8';
$cfg['UploadDir']       = '';
$cfg['SaveDir']         = '';

?>

But I was able to connect to the MySql servier via command line by the same password .

但是我能够通过命令行使用相同的密码连接到 MySql 服务器。

C:\Users\hkBattousai>mysql.exe --user=root --password=rCZ4Xnz78zbLY2Vh
mysql.exe: Unknown OS character set 'cp857'.
mysql.exe: Switching to the default character set 'latin1'.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 21
Server version: 5.5.27 MySQL Community Server (GPL)

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

Then I removed the password via the command line interface:

然后我通过命令行界面删除了密码:

user-password-removed

用户密码已删除

I also removed password from the config.inc.phpfile. The relevant lines in that file are now:

我还从config.inc.php文件中删除了密码。该文件中的相关行现在是:

$cfg['Servers'][$i]['controluser']  = 'root';
$cfg['Servers'][$i]['controlpass']  = '';
$cfg['Servers'][$i]['user']         = 'root';
$cfg['Servers'][$i]['password']     = '';

Currently, it is strange but, I can connect with the password I deleted, but I cannot connect with empty password:

目前,这很奇怪,但是,我可以使用我删除的密码连接,但无法使用空密码连接:

C:\Users\hkBattousai>mysql.exe --user=root --password=rCZ4Xnz78zbLY2Vh  // Connects
C:\Users\hkBattousai>mysql.exe --user=root --password=                  // Error given

I want to assign another random password to this user, and I want to access my database via PHPMyAdmin, as I did within the fresh Xampp installation before. What should I do? I'm really confused and I need your help.

我想为这个用户分配另一个随机密码,我想通过 PHPMyAdmin 访问我的数据库,就像我之前在全新的 Xampp 安装中所做的那样。我该怎么办?我真的很困惑,我需要你的帮助。

It is like the config.inc.phpfile contents are ignored. I copied it from the template file config.sample.inc.phpand altered its contents. It is now located in the directory \Xampp\phpmyadmin\.

就像config.inc.php文件内容被忽略一样。我从模板文件中复制了它config.sample.inc.php并更改了它的内容。它现在位于目录中\Xampp\phpmyadmin\



Versions:

版本:

Xampp   : 3.1.0
MySQL   : 5.5.27
PHP     : 5.4.7
Apache  : 2.4
Windows : 7 Ultimate x64 SP1

回答by Nick

You need to edit the config.inc file in the phpMyAdmin directory (probably C:\xampp\phpMyAdmin) and change this line to match the password you entered for root in phpMyAdmin.

您需要编辑 phpMyAdmin 目录(可能是 C:\xampp\phpMyAdmin)中的 config.inc 文件并更改此行以匹配您在 phpMyAdmin 中为 root 输入的密码。

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

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

回答by ChannaB

If you have installed WAMP, go to the [wamp root]\apps[phpmyadmin installation] and find the file config.inc.php. Then you have the change the following entry to the new password of the root user.

如果您已经安装了 WAMP,请转到 [wamp root]\apps[phpmyadmin 安装] 并找到文件 config.inc.php。然后您将以下条目更改为 root 用户的新密码。

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

$cfg['服务器'][$i]['密码']

save the file and don't forget to restart WAMP services. Now it should work as a charm :)

保存文件,不要忘记重新启动 WAMP 服务。现在它应该可以作为一个魅力:)

回答by Om Sao

Here is the solution for Windows machine: When you changed the root passord to let's say adminand now when you access http://localhost/phpmyadminyou see following screen enter image description here

这是 Windows 机器的解决方案:当您更改根密码admin时,现在当您访问http://localhost/phpmyadmin 时,您会看到以下屏幕 在此处输入图片说明

Open XAMPP_SETUP/phpMyAdmin/config.inc.phpfile change configto cookieand add the password. enter image description hereenter image description hereAnd again access the http://localhost/phpmyadmin!!

打开XAMPP_SETUP / phpMyAdmin的/ config.inc.php文件文件更改configcookie并添加密码。 再次访问 http://localhost/phpmyadmin!!在此处输入图片说明在此处输入图片说明

回答by Pardeep Kumar

You need to specify the actual password. Not encrypted password in config file

您需要指定实际密码。配置文件中未加密密码