一、my.ini 的mysqld下添加
skip-grant-tables
二、重启mysql服务
net start mysqld
三、打开cmd
cd C:\Program Files\MySQL\MySQL Server 5.7\bin
mysql
use mysql
设置新密码
update mysql.user set authentication_string=password('mima****') where user='root' and Host='localhost';
UPDATE user SET authentication_string=password('1234') where user='root' and Host='localhost';
alter user 'root'@'localhost' identified by '123'; 改密码?
flush privileges;
5.7以前版本可用UPDATE user SET Password=PASSWORD('newpassword') where USER='root';更新密码
四、恢复my.ini 重启mysql服务
五、本地计算机上的MySQL服务启动后停止。某些服务在未由其他服务或程序使用时将自动停止
我也一样的问题, 执行了一下初始化 mysqld --initialize, 就解决了
my.ini示例
[client]
port=3306
default-character-set=utf8
[mysqld]
port=3306
character_set_server=utf8
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES