如何在 WAMP 2.5 中更改 MySQL 控制台的密码
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25971703/
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
How to change password for MySQL Console in WAMP 2.5
提问by sdfgg45
I'm currently running WAMP under Windows 7, I changed my username and password for phpmyadmin.
我目前在 Windows 7 下运行 WAMP,我更改了 phpmyadmin 的用户名和密码。
I cant get my Mysql console working after changing password in phpmyadmin
在 phpmyadmin 中更改密码后,我的 Mysql 控制台无法正常工作
After the change I get:
更改后我得到:
access denied for user 'root'@'localhost' (using password yes)
用户 'root'@'localhost' 访问被拒绝(使用密码是)
I have tryed to navigate to the mysql folder manual and tryed:
我尝试导航到 mysql 文件夹手册并尝试:
mysql -u username password newpassword
mysql -u 用户名密码新密码
This with no luck of entering the comand line.
这没有进入命令行的运气。
Anyone have an good awnser to actually set new password for the command line?
任何人都有一个很好的 awnser 来实际为命令行设置新密码?
采纳答案by ???
This is a straight copy/paste from the manual.
- Log on to your system as Administrator.
- Stop the MySQL server if it is running.
Create a text file containing the following statements. Replace the password with the password that you want to use.
UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root'; FLUSH PRIVILEGES;
Save the file. For this example, the file will be named C:\mysql-init.txt.
- Open a console window to get to the command prompt:
run cmd
Start the MySQL server with the special --init-file option (notice that the backslash in the option value is doubled):
C:> C:\mysql\bin\mysqld --init-file=C:\mysql-init.txt
After the server has started successfully, delete C:\mysql-init.txt.
- 以管理员身份登录您的系统。
- 如果 MySQL 服务器正在运行,请停止它。
创建一个包含以下语句的文本文件。将密码替换为您要使用的密码。
更新 mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root'; 同花顺特权;
保存文件。对于此示例,文件将命名为 C:\mysql-init.txt。
- 打开控制台窗口以进入命令提示符:
run cmd
使用特殊的 --init-file 选项启动 MySQL 服务器(注意选项值中的反斜杠是双倍的):
C:> C:\mysql\bin\mysqld --init-file=C:\mysql-init.txt
服务器启动成功后,删除C:\mysql-init.txt。
回答by Darkcoder
wamp server mysql user id and password
Images Also Available
Hit enter as there is no password. Enter the following commands:
图像也可用按
回车键,因为没有密码。输入以下命令:
[mysql> SET PASSWORD for 'root'@'localhost' = password('enteryourpassword');
mysql> SET PASSWORD for 'root'@'127.0.0.1' = password('enteryourpassword');
mysql> SET PASSWORD for 'root'@'::1' = password('enteryourpassword');][2]
That's it, I keep the passwords the same to keep things simple. If you want to check the user's table to see that the info has been updated just enter the additional commands as shown below. This is a good option to check that you have indeed entered the same password for all hosts.
就是这样,我保持密码相同以保持简单。如果您想检查用户的表以查看信息是否已更新,只需输入如下所示的附加命令。这是检查您是否确实为所有主机输入了相同密码的好选择。
回答by Philip D.
Alternatively to your solution you could click the Wamp icon near the clock, Mysql -> service -> remove service
, then Mysql -> service -> install service
and after this restart all services.
作为您的解决方案的替代方案,您可以单击时钟附近的 Wamp 图标Mysql -> service -> remove service
,然后Mysql -> service -> install service
重新启动所有服务。
回答by Nalan Dayarathna
In WAMP server 3 you might need to change the query to
在 WAMP 服务器 3 中,您可能需要将查询更改为
UPDATE mysql.user
SET authentication_string =PASSWORD('MyNewPass')
WHERE User='root';
FLUSH PRIVILEGES;