前言
打卡学习第一天,先立个flag在这,丛今天开始每天写一篇当天学习内容相关的记录文章,打这个卡之前,其实这个flag已经在心里立了半个月了,但是一直没有真正去动手,不愧是我,一天天走着躺着坐着没事就立个flag,立完就忘了,是时候逼迫一下自己了。
正文
最近使用的都是oracle太长时间没有用mysql,上来就是各种问题,不愧是我。直接就连不上了,查了一下服务也起不起来了。


管理员身份运行 mysqld install

查了相关错误,发现确实缺少data文件,不用由发问,以前是怎么能用的?神奇

解决方式:管理员身份运行 mysqld --initialize-insecure --user=mysql

非常开心,已经有data文件了

服务终于启动,太感动了

不愧是我,步步是坎

怎么办?继续查,问题原因:mysql8.0之前的版本加密规则是mysql_native_password,mysql8.0之后,加密规则是caching_sha2_password
解决方式:见图14下面
但是我把密码也忘了。。。。。。先解决密码忘了的情况

新开cmd,关闭mysql服务:net stop mysql

在mysql的bin目录下输入:mysqld --console --skip-grant-tables --shared-memory 这样可以跳过密码登录

新开cmd切到bin目录下输入 mysql -u root -p 会显示输入密码,此时不用输入,直接回车可以登录mysql

现将密码设置为空:
use mysql; (使用mysql数据表)
update user set authentication_string='' where user='root';(将密码置为空)
quit; (然后退出Mysql)

关闭其他cmd窗口,在最后一个cmd里输入:
net stop mysql(关闭服务)
net start mysql(启动服务)
bin目录下输入:mysql -u root -p (连接数据库)此时密码已经被置空,可以直接回车
输入:ALTER USER 'root'@'localhost' IDENTIFIED BY 'root';(更改密码为:root)
quit;(退出mysql)
mysql -u root -p (连接数据库)输入新密码,验证密码是否被修改成功,我这里修改成功了。

密码问题终于解决,解决加密规则不同的问题
use mysql;
select user,plugin from user where user ='root';
结果显示加密规则是caching_sha2_password
修改加密方式:ALTER USER'root'@'localhost' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER;
修改用户密码:ALTER USER'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';

刷新权限:FLUSH PRIVILEGES;

去navicat看一下是否可以了

诶呀,不容易啊,还没开始正文内容,我觉得已经够了。。。。。。
网友评论