在win10下,MySQL5.7本来是运行的好好的;突然停止运行了;服务也无法启动。
在卸载之后,重新安装,依旧是无法启动。
度娘之后,在path环境变量里面添加了C:\Program Files\MySQL\MySQL Server 5.7\bin路径,还是依旧无法启动。
然后继续度娘,让:
服务依旧是启动不了。
说是在MySQL Server 5.7目录下面,没有找到data文件夹;不知道是不是win10下,这个版本的没有什么权限创建这个文件夹;手动创建一个吧。然后在命令 net start mysql启动,依旧报错,只不过是另一个错误:
[ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
[ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist
[ERROR] Fatal error: Failed to initialize ACL/grant/time zones structures or failed to remove temporary table files.
[ERROR] Aborting
第一个错误可以看到这里少了一个mysql.plugin的表;
第二个错误是少了mysql.user表;
解决方法:
1、去C:\Program Files\MySQL\MySQL Server 5.7\bin目录下创建my.ini文件,内容如下:
[mysqld] basedir=C:\Program Files\MySQL\MySQL Server 5.7 datadir=C:\Program Files\MySQL\MySQL Server 5.7\data2、清空C:\Program Files\MySQL\MySQL Server 5.7\data目录,里面的信息一会通过命令会自动生成的;
3、执行 mysqld --initialize --user=mysql --console
4、启动成功;
完成上面的操作之后,用navicat和CMD登录时,用密码都会报1045-access denied for user 'root'@错,直接输入MySQL反而登录成功;
解决方法
1.以管理员身份启动CMD,必须是管理员身份
2.执行命令:mysqld --skip-grant-tables
3.以管理员身份重开个命令窗口
4.执行如下命令:
update mysql.user set password=password('123456') where user='root';
又在报错,怀疑是password字段被改成其他的了;
我们去表里面查一下不就知道了;
执行mysql> select * from mysql.user;
真的是MySQL5.7换名字了,改成authentication_string了
那就执行这个吧:
update user set authentication_string=password('123456') where user='root';
成功!
工具也是连接OK: