mysqld --remove mysql57 HKEY_LOCAL_MACHINESYSTEMControlSet001ServicesEventlogApplicationMySQL目录删除; HKEY_LOCAL_MACHINESYSTEMControlSet002ServicesEventlogApplicationMySQL目录删除; HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesEventlogApplicationMySQL目录删除; 4.3 安装mysql服务,指定该mysql服务名为mysql2,并根据my.ini文件(用记事本改为ANSI的文件格式)进行安装,命令如下: C:mysql-5.7.22-winx64in>mysqld install mysql57 --default-file="D:Program FilesMySQLmysql-5.7.27-winx64my.ini" 4.4在bin目录下执行如下命令 C:mysql-5.7.22-winx64in>mysqld --initialize 4.5在bin目录下执行如下命令(必须) HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesmysql2,修改ImagePath参数 "D:Program FilesMySQLmysql-5.7.27-winx64inmysqld" --default-file="D:Program FilesMySQLmysql-5.7.27-winx64my.ini" mysql57 D:Program FilesMySQLmysql-5.7.27-winx64inmysqld mysql57 net start mysql57 mysql -uroot -p (放开my.ini中的 skip-grant-tables 重启后验证,改完密码后再注释掉skip-grant-tables) update user set password=password("新密码") where user="root"; flush privileges; // https://www.jianshu.com/p/a4c223793ee0 4.6修改密码 mysql> set password for root@localhost=password('root'); 其他查考:update mysql.user set authentication_string=password('newpassword') where user='root'; Query OK, 0 rows affected, 1 warning (0.00 sec) 使用 quit 退出,使用新密码登录。