Mysql8.0采坑
密码无法使用
在服务器中安装mysql8.0数据库修改密码发现无法使用update语句修改,于是百度了一番参考了MYSQL8.0以上版本正确修改ROOT密码由此问题解决
解决方法:
- 使用
mysql初始生成的密码登录到数据库(密码在数据库产生的日志文件中, 可查看/etc/my.cnf中的log-error指向的文件) - 登录到数据库
mysql -uroot -p'首次初始化数据库产生的密码' - 登录执行
alter user 'root'@localhost identified by 'new password'; - 执行成功后刷新数据库
flush privileges;问题成功解决
连接出现 cryptography is required for sha256_password or caching_sha2_password**
解决方法:
首先查询一下数据库
user表中连接时报错的用户与主机mysql> select user,plugin,host from mysql.user; +------------------+-----------------------+-----------+ | user | plugin | host | +------------------+-----------------------+-----------+ | root | mysql_native_password | % | | mysql.infoschema | caching_sha2_password | localhost | | mysql.session | caching_sha2_password | localhost | | mysql.sys | caching_sha2_password | localhost | | root | mysql_native_password | localhost | +------------------+-----------------------+-----------+ 5 rows in set (0.00 sec)%表示通配符查询得出
plugin为caching_sha2_password就将它改为mysql_native_password执行如下命令:
alter user 'your account'@'your host' identified with mysql_native_password by 'your password'flush privileges#刷新权限重新连接, 问题解决 。参考了
msql8.0官方文档可插拔身份验证
不成功其他解决方法
- 参考 mysql报错RuntimeError: cryptography is required for sha256_password or caching_sha2_p
ALTER USER 'root'@'localhost' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER;#修改加密规则ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';#更新一下用户的密码FLUSH PRIVILEGES;#刷新权限alter user 'root'@'localhost' identified by '123456';# 再次重置密码- 重启服务,问题解决