Windows forgot mysql password

1. Password-free login, leave the password blank

net stop mysql
# 窗口1
mysqld --console --skip-grant-tables --shared-memory 
# 窗口2
mysql -u root -p (直接回车)
use mysql;
# 修改密码为空
update user set authentication_string='' where user='root';
FLUSH PRIVILEGES;
exit;

2. Change password

# 关闭窗口1
# 关闭mysql
net stop mysql
# 启动
net start mysql
# 直接回车
mysql -u root -p
# 修改密码
alter user 'root'@'localhost' identified with mysql_native_password by '123456';
# 退出
exit;
mysql -uroot -proot

Mysql installation and uninstallation during the following operations

Install mysql

Download the zip file, unzip it and
enter the bin folder

//安装mysql  安装完成后Mysql会有一个随机密码
mysqld --initialize --console
//安装mysql服务并启动   
mysqld --install mysql

Then, go to services and start the mysql service

Delete mysql

stop mysql

net stop mysql
sc delete MySQL

Guess you like

Origin blog.csdn.net/qq_46110497/article/details/130650278