1.停止mysql資料庫服務
2.Win+R;輸入cmd;cd 至資料庫資料夾
3.輸入mysqld -nt –skip-grant-tables;
4.最小化窗口,再新開壹個cmd窗口,輸入mysql -h localhost -u root -p
5.輸入空密碼
6.選擇庫名:use mysql;
7.修改庫表密碼:update mysql.user set password=password(‘新密碼’) where user=”root”;
8.刷新權限:flush privileges
9.授權grant 權限[all privileges] on 庫名.表名 to 帳號@ip或’帳護’@”%”  identified by ‘密碼’ with grant option
如果是Linux  则在my.cnf 添加   skip-grant-tables保存
mysql -u root -p空密码登录
再次修改密码
UPDATE user SET Password = password ( '新密码' ) WHERE User = 'root' ;
mysql 5.7是: update mysql.user set authentication_string=password(‘123qaz’) where user =’root’;
也可以事先停止mysql
service mysqld stop
进入mysql的bin目录
mysqld_safe –skip-grant-tables –skip-networking &
mysql -u root -p
直接回车
提示输入密码,继续为空
mysql 5.6:  UPDATE user SET Password = password ( '新密码' ) WHERE User = 'root' ;
mysql5.7: update mysql.user set authentication_string=password(‘123qaz’) where user =’root’;
打赏