在 WAMP 上重新获得对 PHPMyAdmin 丢失的 MySQL 密码的访问权限
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29070501/
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
Regaining access to lost MySQL password for PHPMyAdmin on WAMP
提问by Eamon Bohan
I changed the password for my 'root'@'localhost'account in PHPMyAdmin and like (this person asking here) and locked myself out of PHPMyAdmin on my browser. I am using WAMP 2.5.
我在 PHPMyAdmin 中更改了我的'root'@'localhost'帐户的密码(此人在这里问),并在浏览器上将自己锁定在 PHPMyAdmin 之外。我正在使用 WAMP 2.5。
The solutions offered on that question don't work for me because unfortunately I have lost the password that I reassigned rootto.
在该问题上提供的解决方案对我不起作用,因为不幸的是我丢失了重新分配root的密码。
Some solutions ask one to reset the password via command line (including this source), and I have tried that through the Windows command line without success because I now have no privileges:
一些解决方案要求通过命令行(包括此源)重置密码,我已经通过 Windows 命令行尝试过但没有成功,因为我现在没有权限:
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('mynewpassword');
ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'mysql'
WAMP comes with a MySQL Console but I am unable to use it since it prompts me for a password which as I stated, no longer have.
WAMP 附带一个 MySQL 控制台,但我无法使用它,因为它提示我输入密码,正如我所说,不再有。
This video explains how to change passwords, and it agrees with the answers in the StackExchange answer above, but evidently, I need another method to do this now since I did not know I would lose access as the guy warns.
这个视频解释了如何更改密码,它与上面 StackExchange 答案中的答案一致,但显然,我现在需要另一种方法来做到这一点,因为我不知道我会像那个人警告的那样失去访问权限。
I would appreciate any advice and apologise if this is a newbie type of thing to ask. I am just getting the hang of using a stack for web development, and configuring access to a LAN site through WAMP was quite an adventure, so if possible, I would prefer something that does not require reinstalling everything again.
如果这是新手要问的问题,我将不胜感激。我刚刚掌握了使用堆栈进行 Web 开发的窍门,并且通过 WAMP 配置对 LAN 站点的访问是一次冒险,所以如果可能的话,我更喜欢不需要重新安装所有东西的东西。
Edit 1: Went ahead and tried @RiggsFolly 's solution. While I can access the my.ini
file, make changes without problem, and restart MySQL without issue through WAMP or otherwise, the line skip-grant-tables
is not taking effect, leaving me with a password prompt or no access to do anything. (I wrote a new question here to troubleshoot this since I feel like this is a different issue.)
编辑 1:继续尝试@RiggsFolly 的解决方案。虽然我可以访问该my.ini
文件,毫无问题地进行更改,并通过 WAMP 或其他方式毫无问题地重新启动 MySQL,但该行skip-grant-tables
没有生效,让我得到密码提示或无法执行任何操作。(我在这里写了一个新问题来解决这个问题,因为我觉得这是一个不同的问题。)
Edit 2: I tried the instructions in the link provided by @t.niese in the comments and when I set the console to return feedback on the instructions, it reported this, and failed to change anything:
编辑 2:我尝试了@t.niese 在评论中提供的链接中的说明,当我将控制台设置为返回对说明的反馈时,它报告了这一点,但没有更改任何内容:
C:\wamp\bin\mysql\mysql5.6.17\bin>mysqld --skip-grant-tables --console
[Note] Plugin 'FEDERATED' is disabled.
[Note] InnoDB: Using atomics to ref count buffer pool pages
[Note] InnoDB: The InnoDB memory heap is disabled
[Note] InnoDB: Mutexes and rw_locks use Windows interlocked functions
[Note] InnoDB: Compressed tables use zlib 1.2.3
[Note] InnoDB: Not using CPU crc32 instructions
[Note] InnoDB: Initializing buffer pool, size = 128.0M
[Note] InnoDB: Completed initialization of buffer pool
[ERROR] InnoDB: .\ibdatai can't be opened in read-write mode
[ERROR] InnoDB: The system tablespace must be writabe!
[ERROR] Plugin 'InnoDB' init function returned error.
[ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
[ERROR] Unknown/unsupported storage engine: InnoDB
[ERROR] Aborting
[Note] /* List of plugins shutting down */
回答by RiggsFolly
Here is a method that will allow you to reset the MYSQL 'root' password quite simply.
这是一种允许您非常简单地重置MYSQL“root”密码的方法。
Stop the mysql service
停止mysql服务
wampmanager -> MySQL -> Service -> Stop Service
Edit the my.ini file
编辑 my.ini 文件
wampmanager -> MySQL -> my.ini
Find the [wampmysqld]
(32bit) or [wampmysqld64]
(64bit) section in the ini file
在ini文件中找到[wampmysqld]
(32bit)或[wampmysqld64]
(64bit)部分
Add this line directly after that section heading
在该部分标题之后直接添加此行
skip-grant-tables
Restart the mysql service.
重启mysql服务。
wampmanager -> MySQL -> Service -> Start/Resume Service
Open the 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.
现在我们要重置 root 用户的密码,当然这可以用来重置任何用户的密码。
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.
在mysql>
命令提示符下输入以下2条命令,每条命令在一行末尾有一个分号,每行后按回车向mysql发出命令。
Pre MYSQL version 5.7
MYSQL 5.7 之前的版本
UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root';
FLUSH PRIVILEGES;
Post MYSQL version 5.7 the column name changed
发布 MYSQL 5.7 版的列名已更改
UPDATE mysql.user SET authentication_string=PASSWORD('MyNewPass') WHERE User='root';
ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;
FLUSH PRIVILEGES;
Note that the update may report that it has updated more than one row, that because there may be more than one user accounts with the userid of 'root' each with a different domain i.e. 127.0.0.1, localhost and ::1
请注意,更新可能会报告它更新了不止一行,因为可能有多个用户帐户为“root”,每个帐户都具有不同的域,即 127.0.0.1、localhost 和 ::1
Now enter 'quit' at the mysql command promt to exist mysql.
现在在 mysql 命令提示符处输入 'quit' 以存在 mysql。
Stop the mysql service
停止mysql服务
wampmanager -> MySQL -> Service -> Stop Service
Edit the my.ini file
编辑 my.ini 文件
wampmanager -> MySQL -> my.ini
Find the [wampmysqld]
(32bit) or [wampmysqld64]
(64bit) section in the ini file
在ini文件中找到[wampmysqld]
(32bit)或[wampmysqld64]
(64bit)部分
Remove the skip-grant-tables
parameter we added earlier.
删除skip-grant-tables
我们之前添加的参数。
DO NOT Leave this parameter in the ini file its a HUGH security hole.
不要将此参数保留在 ini 文件中,因为这是一个巨大的安全漏洞。
Restart the mysql service.
重启mysql服务。
wampmanager -> MySQL -> Service -> Start/Resume Service
You should now be able to login with phpmyadmin using the userid 'root' and the new password you have just set for that user.
您现在应该可以使用用户 ID 'root' 和您刚刚为该用户设置的新密码通过 phpmyadmin 登录。
回答by Ljubomir Luki?
This has worked for my Wampserver64 - 3.1.9. Thanx.
这对我的Wampserver64-3.1.9 有效。谢谢。
UPDATE mysql.user SET authentication_string=PASSWORD('MyNewPass') WHERE User='root';
ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;
FLUSH PRIVILEGES;
回答by Mario Orozco
Previous answers didn't work for me, since MySQL Console keep me out after pressing intro. Try this:
以前的答案对我不起作用,因为 MySQL 控制台在按介绍后让我离开。尝试这个:
Create a file C:\wamp64\mysql-init.txtwith this content:
使用以下内容创建文件C:\wamp64\mysql-init.txt:
UPDATE mysql.user SET Password=PASSWORD('1234') WHERE User='root';
FLUSH PRIVILEGES;
This will reset password to 1234for user root. Then, run the next command on Windows Command Line:
这会将用户root 的密码重置为1234。然后,在 Windows 命令行上运行下一个命令:
C:\wamp64\bin\mysql\mysql5.7.21\bin\mysqld.exe wampmysqld --init-file=C:\wamp64\mysql-init.txt
Change paths depending on where is installed WAMP on your file system.
根据文件系统上安装 WAMP 的位置更改路径。
Finally, restart WAMP services.
最后,重启 WAMP 服务。