简体   繁体   English

卸载旧版本的MySQL后,在Windows上全新安装MySQL 5.6.15时,访问被拒绝用户'root'@'localhost'“

[英]“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”帐户默认情况下,但这是我解决问题的方法:

  1. Stop the MySQL service (mysqld.exe) 停止MySQL服务(mysqld.exe)
  2. Start the MySQL service with the following parameter: --skip-grant-tables 使用以下参数启动MySQL服务: - --skip-grant-tables
  3. Log in to MySQL (mysql.exe) as root: mysql.exe -u root (it doesn't require a password, thanks to step 2) 以root mysql.exe -u root登录MySQL(mysql.exe): mysql.exe -u root (由于步骤2,它不需要密码)
  4. Execute the following queries: 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;
  5. Exit MySQL 退出MySQL
  6. Stop the MySQL service 停止MySQL服务
  7. Start the MySQL service without the --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.

相关问题 Windows 上的 MySQL - 全新安装后用户“root”@“localhost”的访问被拒绝 - MySQL on Windows - Access denied for user 'root'@'localhost' after fresh install 全新 MYSQL 安装,用户“root”拒绝访问 - Fresh MYSQL install, Access denied for user 'root' 执行代码时,对用户“ root” @“ localhost”的MySQL访问被拒绝(Windows 7) - MySQL Access denied for user 'root'@'localhost' when executing code (Windows 7) Windows 上的 MySQL:用户 'root'@'localhost' 的访问被拒绝(使用密码:YES) - MySQL on Windows: Access Denied for User 'root'@'localhost' (using password: YES) 如何解决“mysql工作台窗口中用户'root'@'localhost'的访问被拒绝” - How to resolve “access denied for user 'root'@'localhost' in mysql workbench windows” mySQL:“安装软件后,用户'root'@'localhost”拒绝访问 - mySQL: “Access denied for user 'root'@'localhost” after installing the software MySQL:拒绝访问用户 root@localhost - MySQL: Access denied for user root@localhost mysql docker 中的用户 'root'@'localhost' 的访问被拒绝 - Access denied for user 'root'@'localhost' in the mysql docker MySQL 错误::“用户'root'@'localhost'的访问被拒绝” - MySQL Error: : 'Access denied for user 'root'@'localhost' Mysql:在macOS上安装后用户'root'@'localhost'的访问被拒绝 - Mysql: Access denied for user 'root'@'localhost' right after installation on macOS
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM