[英]“Access denied for user 'root'@'localhost'” on a fresh install of MySQL 5.6.15 on Windows after uninstalling an older version of MySQL
So, I've just installed MySQL 5.6.15 on my Windows machine, but for some reason I can't log in using "root" with no password. 所以,我刚刚在我的Windows机器上安装了MySQL 5.6.15,但出于某种原因我无法使用没有密码的“root”登录。
C:\web\mysql-5.6.15-win32\bin>mysql.exe -u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
However I can login with "ODBC" and no password: 但是我可以使用“ODBC”登录而无需密码:
C:\web\mysql-5.6.15-win32\bin>mysql.exe
Welcome blah blah blah
mysql> SELECT USER();
+----------------+
| USER() |
+----------------+
| ODBC@localhost |
+----------------+
1 row in set (0.00 sec)
Why can't I log in with "root" with no password? 为什么我不能使用没有密码的“root”登录? I've tried uninstalling MySQL and installing it again, to no avail.
我已经尝试卸载MySQL并重新安装它,但无济于事。
I still don't know why there isn't a "root" account without password by default, but here's how I solved the problem: 我仍然不知道为什么没有密码的“root”帐户默认情况下,但这是我解决问题的方法:
--skip-grant-tables
--skip-grant-tables
mysql.exe -u root
(it doesn't require a password, thanks to step 2) mysql.exe -u root
登录MySQL(mysql.exe): mysql.exe -u root
(由于步骤2,它不需要密码) UPDATE mysql.user SET Password=PASSWORD('') WHERE User='root'; FLUSH PRIVILEGES;
UPDATE mysql.user SET Password=PASSWORD('') WHERE User='root'; FLUSH PRIVILEGES;
UPDATE mysql.user SET Password=PASSWORD('') WHERE User='root'; FLUSH PRIVILEGES;
--skip-grant-tables
parameter --skip-grant-tables
参数启动MySQL服务 OK, I think I found out what the problem was: 好的,我想我发现了问题所在:
I uninstalled MySQL 5.1.70 by doing: 我通过执行以下操作卸载了MySQL 5.1.70:
C:\web\mysql-5.1.70\bin>mysqld.exe --remove
It worked. 有效。
Then I installed MySQL 5.6.15 by doing 然后我做了安装MySQL 5.6.15
C:\web\mysql-5.6.15-win32\bin>mysqld.exe --install
It appeared to work. 它似乎工作。 In fact what it did was re-installing the old version.
实际上,它所做的是重新安装旧版本。
The solution is to rename or delete the old folder (C:\\web\\mysql-5.1.70) before running mysqld.exe --install
解决方法是在运行
mysqld.exe --install
之前重命名或删除旧文件夹(C:\\ web \\ mysql-5.1.70)--install
EDIT: Now I understand. 编辑:现在我明白了。
C:\\web\\mysql-5.1.70\\bin
was in my Path... C:\\web\\mysql-5.1.70\\bin
在我的路径中......
I had the same security issue when I had a fresh install of Mysql on windows after uninstalling the old version. 卸载旧版本后,当我在Windows上全新安装Mysql时,我遇到了同样的安全问题。 I figured out a way that could possiblely resolve the problem:
我想出了一种可以解决问题的方法:
After you have installed the new version of MySQL, go to MySQL\\MySQL Server 5.5\\bin and launch MySQLInstanceConfig.exe . 安装新版本的MySQL后,转到MySQL \\ MySQL Server 5.5 \\ bin并启动MySQLInstanceConfig.exe 。 This will help you to reset your password and config will work well
这将帮助您重置密码,配置将运行良好
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.