一、二话不说,先更改my.ini,位置在 C:\ProgramData\MySQL\MySQL Server 5.7,再【mysqld】节点下,增加 skip-grant-tables
这一步切记切记,不要用windows自带的notepad编辑,否则将导致mysql5.7服务无法启动,哭都来不及...
二、更改过后,就有登录权限了,再 C:\Program Files\MySQL\MySQL Server 5.7\bin下,进入cmd
三、直接输入mysql即可,因为已经跳过了验证
四、执行sql,创建一个新的账号,并赋予权限
grant all on *.* to 'root'@'localhost' identified by '123456' with grant option;
这种方式,再skip-grant-tables下,是不能完成用户创建的,所以需要换种方式,即:
INSERT INTO `mysql`.`user` (`Host`, `User`, `Select_priv`, `Insert_priv`, `Update_priv`, `Delete_priv`, `Create_priv`, `Drop_priv`, `Reload_priv`, `Shutdown_priv`, `Process_priv`, `File_priv`, `Grant_priv`, `References_priv`, `Index_priv`, `Alter_priv`, `Show_db_priv`, `Super_priv`, `Create_tmp_table_priv`, `Lock_tables_priv`, `Execute_priv`, `Repl_slave_priv`, `Repl_client_priv`, `Create_view_priv`, `Show_view_priv`, `Create_routine_priv`, `Alter_routine_priv`, `Create_user_priv`, `Event_priv`, `Trigger_priv`, `Create_tablespace_priv`, `ssl_type`, `ssl_cipher`, `x509_issuer`, `x509_subject`, `max_questions`, `max_updates`, `max_connections`, `max_user_connections`, `plugin`, `authentication_string`, `password_expired`, `password_last_changed`, `password_lifetime`, `account_locked`) VALUES ('%', 'root3', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', '', '', '', '', '0', '0', '0', '0', 'mysql_native_password', '*EFD4F9D35F94FA540CE669527225A4AAB7509965', 'N', '2023-02-14 14:23:46', NULL, 'N');
五、更改密码
update mysql.user set authentication_string=password('gyl@123456') where user='root3' ;
六、注释 skip-grant-tables,重启mysql服务
标签:更改,windows,mysql5.7,user,mysql,password,Create,priv From: https://www.cnblogs.com/lovezilv/p/17119509.html