【mysql】mysql8.0进入mysql后修改密码
mysql5.7.9版本之后的user表中取消了password这个字段,改成了authentication_string
所以用update user set password=password(“123”) where user="root"
或者 set password for [email protected] = password(‘123’) 等含有password的命令都会报1064语法错误,试过在navicat里直接改也会报1064语法错误(也许是我版本不匹配?)
如图↓
正确的做法是:
- 进入mysql
- 切换数据库
输入use mysql - 查看user表的信息(查看要修改的user对应的host,不一定是localhost)
输入select user,host from user; (别忘了打 ; 分号) - 修改密码
输入alter user ‘你的user名’@‘你的host’ identified with mysql_native_password by “新密码”;
比如:alter user ‘root’@‘localhost’ identified with mysql_native_password by “123”;
修改成功