1、找到my.ini,去掉skip-grant-tables,然后重启mysql服务,如无,可忽略
skip-grant-tables:数据库启动的时候 跳跃权限表的限制,不用验证密码,直接登录。
不去掉skip-grant-tables,直接修改密码会出现错误:
2、mysql5.7版本,user表没有password字段,改成了authentication_string字段,所以输入update mysql.user set password=password('root') where user='root'时提示ERROR 1054 (42S22): Unknown column 'password' in 'field list'
正确语句应该为:
update mysql.user set authentication_string=password('root') where user='root';
修改成功重启mysql服务,重新登录,mysql -u root -p
输入密码,不输入密码会出错
使用工具登录mysql
1、有可能会出现 1862的错误。解决办法
以root权限登录mysql:(这里我的账户是root,密码也是root)
mysql -uroot -proot
然后更改密码:
SET PASSWORD = PASSWORD('root');
然后,重新登录成功。