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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22724808/
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-25 16:12:39  来源:igfitidea点击:

phpmyadmin in WAMP error #1045 - Need to reset password

phpmysqlphpmyadminwampwampserver

提问by Sheixt

I have recently reinstalled WAMP on my PC and copied over files from a back-up I had. I am able to access localhostwithout any problem and my existing sites function fine.

我最近在我的 PC 上重新安装了 WAMP,并从我拥有的备份中复制了文件。我可以localhost毫无问题地访问,并且我现有的网站运行良好。

The problem is that I cannot seem to log-in via http://localhost/phpmyadmin/index.php. I receive a #1045 Cannot log in to the MySQL serverresponse.

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

After doing some readingI have been lead to believe that I can edit phpmyadmin's config.inc.phpfile to adjust the settings. After setting my files (as outlined below), I just get a Cannot connect: invalid settings.error.

在做了一些阅读之后,我相信我可以编辑 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
 */

?>

Can someone point out what I can do to resolve the problem?

有人可以指出我可以做些什么来解决问题吗?

I am running WAMP 2 using PHP 5.4.12 and mySQL 5.6.12. I've also attempted to log into the mySQL Console in WAMP but I cannot get past the password request...

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

回答by RiggsFolly

If the problem is just a forgotten password this will allow you to reset it. However if you have mixed incompatible databases with MySQL Server versions there will be other problems later once you have reset the password.

如果问题只是忘记密码,这将允许您重置密码。但是,如果您将不兼容的数据库与 MySQL Server 版本混合使用,那么一旦您重置密码,就会出现其他问题。

Stop the mysql service

停止mysql服务

wampmanager -> MySQL -> Service -> Stop Service

wampmanager -> MySQL -> Service -> Stop Service

Edit the my.ini file

编辑 my.ini 文件

wampmanager -> MySQL -> my.ini

wampmanager -> MySQL -> my.ini

Find the [wampmysqld]section in the ini file. Add this line directly after the section [wampmysqld]

[wampmysqld]在 ini 文件中找到该部分。在该部分之后直接添加此行[wampmysqld]

skip-grant-tables

Restart the mysql service. wampmanager -> MySQL -> Service -> Start/Resume Service

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

Open the MySQL console wampmanager -> MySQL -> MySQL Console

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

Now we are going to reset the password for the root user, of course this could be used to reset any users password. Enter the following 2 commands at the mysql>command prompt, each with a semi colon at the end of a line, and press ENTER after each line to issue the command to mysql.

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

For MySQL versions prior 5.7.0

对于 5.7.0 之前的 MySQL 版本

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

For MySQL versions after 5.7.0

对于 5.7.0 之后的 MySQL 版本

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

Notethat the update should report that it has updated more than one row, that is because there are actually 3 user accounts with the userid of 'root' each with a different domain

请注意,更新应该报告它已经更新了不止一行,这是因为实际上有 3 个用户帐户的用户 ID 为“root”,每个帐户都具有不同的域

i.e. 127.0.0.1, localhost and ::1*

即 127.0.0.1、本地主机和 ::1*

Now enter 'quit' at the mysql command promt to exist mysql.

现在在 mysql 命令提示符处输入 'quit' 以存在 mysql。

Stop the mysql service wampmanager -> MySQL -> Service -> Stop Service

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

Edit the my.ini file wampmanager -> MySQL -> my.ini

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

Find the [wampmysqld] section in the ini file Remove the skip-grant-tablesparameter we added earlier.

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

DO NOT Leave this parameter in the ini file its a HUGH security hole.

不要将此参数保留在 ini 文件中,因为这是一个巨大的安全漏洞。

Restart the mysql service. wampmanager -> MySQL -> Service -> Start/Resume Service

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

回答by Adnan Ahmad

I was facing the problem. Unfortunetly my user name root and password = '' was not working. I use following solution and its works for me. You can try your luck..

我正面临这个问题。不幸的是,我的用户名 root 和密码 = '' 不起作用。我使用以下解决方案,它对我有用。你可以试试你的运气..

1) Click on wamp icon (Near the time, Bottom right on your laptop)

1) 单击 wamp 图标(时间附近,笔记本电脑右下角)

2) Go to "MySQL" and click on "MySQL Console".

2) 转到“MySQL”并单击“MySQL 控制台”。

enter image description here

在此处输入图片说明

Once terminal opens, enter these three commands.

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

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

NOTE: You don't need to write mysql> .. It will already there. :)

注意:你不需要写 mysql> .. 它已经在那里了。:)

Now restart your wamp. go to localhost/phpmyadmin , enter username "root" and leave password empty ..

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

If answer works for you, Don't forget to vote it.

如果答案对您有用,请不要忘记投票。

BEST OF LUCK.

祝你好运。

回答by santosh hegde

For above MySQL 5.7

对于 MySQL 5.7 以上

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

has to be changed to -

必须改为 -

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