解决mysql不需要密码就可以登陆问题
1.use mysql;
2.update user set authentication_string=password("你的密码") where user='root'; #(无password字段的版本,也就是版本<=5.7的)
3.update user set password=password('你的密码') where user='root'; #(有password字段的版本,版本>5.7的)
4.update user set plugin="mysql_native_password";
5.flush privileges;
6.exit;
忘记mysql密码的时候,重置mysql密码
1.cd /etc/my.cnf
2.在[mysqld]后面任意一行添加“skip-grant-tables”
3.保存文档并退出
4.重启mysql
/etc/init.d/mysql restart
5.重启之后输入#mysql即可进入mysql
6.接下来就是用sql来修改root的密码
mysql> use mysql;
mysql> update mysql.user set authentication_string=password('新密码') where user='root' ;
mysql> flush privileges;
mysql> quit
到这里root账户就已经重置成新的密码了。