安装后MySQL后 去查看日志并未查到初始密码,那怎么办尼,解决呗,不解决登录不上去啊 哈哈哈
在MySQL 配置文件中 【mysqld】模块里添加 skip-grant-tables ##(服务器不在加载权限判断)
vim /etc/my.cnf

重启服务
systemctl restart mysqld
再次尝试登录
mysql -uroot 回车

现在已经进入了mysql 里面 就可以开始修改密码了
修改语句
use mysql
alter user 'root'@'localhost' identified by '123456'; ##123456是设置的密码

看报错提示The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement ##运行的时候加入了--skip-grant-tables 选项 所以不能运行该条语句
这时候我们只需要刷新一下权限就可以了
flush privileges;
再次执行修改语句
alter user 'root'@'localhost' identified by '123456';

现在已经修改成功了 退出数据库,去配置文件注释刚刚添加的--skip-grant-tables

重启数据库
systemctl restart mysqld
使用刚刚修改的密码登录
mysql -uroot -p123456
可以用了,快去干活吧!
本文介绍了安装MySQL后未查到初始密码的解决办法。通过在配置文件中添加skip - grant - tables,重启服务登录数据库,修改密码时遇权限问题,刷新权限后再次修改,最后注释配置文件中添加项,重启数据库,用新密码登录。
1018

被折叠的 条评论
为什么被折叠?



