在WAMP中的phpmyadmin错误#1045 - 需要重置密码

时间:2014-03-28 23:18:03

标签: php mysql phpmyadmin wamp wampserver

我最近在我的电脑上重新安装了WAMP,并从我备份的备份中复制了文件。我能够毫无问题地访问localhost并且我现有的网站运行正常。

问题是我似乎无法通过http://localhost/phpmyadmin/index.php登录。我收到#1045无法登录MySQL服务器响应。

执行some reading后,我一直认为我可以编辑phpmyadmin的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'] = '';
$cfg['Servers'][$i]['AllowNoPasswordRoot'] = true;

/* 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';

/*
 * End of servers configuration
 */

?>

有人可以指出我可以采取哪些措施来解决问题吗?

我使用PHP 5.4.12和mySQL 5.6.12运行WAMP 2。我也试图在WAMP中登录mySQL控制台,但我无法通过密码请求...

3 个答案:

答案 0 :(得分:18)

如果问题只是一个忘记的密码,这将允许您重置它。但是,如果您将不兼容的数据库与MySQL Server版本混合在一起,则在重置密码后会出现其他问题。

停止mysql服务

wampmanager -> MySQL -> Service -> Stop Service

编辑my.ini文件

wampmanager -> MySQL -> my.ini

在ini文件中找到[wampmysqld]部分。在[wampmysqld]

部分后直接添加此行
skip-grant-tables

重启mysql服务。 wampmanager -> MySQL -> Service -> Start/Resume Service

打开MySQL控制台 wampmanager -> MySQL -> MySQL Console

现在我们要重置root用户的密码,当然这可以用来重置任何用户密码。 在mysql>命令提示符处输入以下两个命令,每个命令在一行的末尾都有一个分号,并在每行后按Enter键向mysql发出命令。

对于5.7.0之前的MySQL版本

UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root';
FLUSH PRIVILEGES;

对于5.7.0之后的MySQL版本

UPDATE mysql.user SET authentication_string = PASSWORD('MyNewPass'), 
                      password_expired = 'N' 
WHERE User = 'root';
FLUSH PRIVILEGES;

注意,更新应报告已更新多行,这是因为实际上有3个用户帐户的用户ID为“root”,每个用户帐户具有不同的域

即。 127.0.0.1,localhost和:: 1 *

现在在mysql命令promt中输入'quit'以存在mysql。

停止mysql服务 wampmanager -> MySQL -> Service -> Stop Service

编辑my.ini文件 wampmanager -> MySQL -> my.ini

找到ini文件中的[wampmysqld]部分 删除我们之前添加的skip-grant-tables参数。

请勿将此参数留在ini文件中作为HUGH安全漏洞。

重启mysql服务。 wampmanager -> MySQL -> Service -> Start/Resume Service

答案 1 :(得分:2)

我遇到了这个问题。不幸的是,我的用户名root和密码=''无效。 我使用以下解决方案,它适用于我。你可以试试运气..

1)点击wamp图标(靠近笔记本电脑的右下角)

2)转到“MySQL”并单击“MySQL Console”。

enter image description here

终端打开后,输入以下三个命令。

mysql> SET PASSWORD for 'root'@'localhost' = '';
mysql> SET PASSWORD for 'root'@'127.0.0.1' = '';
mysql> SET PASSWORD for 'root'@'::1' = '';

注意:您不需要编写mysql&gt; ..它已经存在了。 :)

现在重新启动你的wamp。 转到localhost / phpmyadmin,输入用户名“root”并将密码保留为空..

如果答案适合您,请不要忘记投票。

最好的运气。

答案 2 :(得分:1)

对于上面的MySQL 5.7

UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root';

必须更改为 -

update user set authentication_string=password('MyNewPass') where user='root';