mysql修改root密码
1.首先停止mysql服务器
net stop mysql
2.开启两个cmd,使用管理员运行。
3.第一个窗口输入
mysqld --console --skip-grant-tables --shared-memory
4.使用第二个窗口输入,无需密码,敲回车键进入数据库
mysql -uroot -p
5.将密码置为空,就可以直接登录MySQL
UPDATE mysql.user SET authentication_string='' WHERE user='root' and host='localhost';
6.关闭所有窗口,启动MySQL:net start mysql,或者手动在任务管理器里面选择服务右击启动。
7.登录mysql,执行:
ALTER USER 'root'@'localhost' IDENTIFIED WITH 'mysql_native_password' BY '123456';
8.执行
FLUSH PRIVILEGES;
EXIT;
9.重新登录即可
mysql -u root -p