1、使用yum安装mysql后
2、初始密码在/var/log/mysqld.log这个文件里
3、输入命令:grep 'temporary password' /var/log/mysqld.log,可以直接获取密码。
(注:密码为冒号后面的所有字符!)
如果想要更换初始密码,可以按照下面的操作。
在/etc/my.cnf中加入如下内容:
在[mysqld]下添加skip-grant-tables,然后保存并退出
linux 下mysql忘记密码或者安装好linux后不知道mysql初始密码解决方案

然后重启mysql服务
systemctl restart mysqld
a、重启以后,执行mysql命令进入mysql命令行

b、修改root用户密码

MySQL> update mysql.user set authentication_string=password('123456') where user='root';
MySQL> flush privileges;
MySQL> exit

c、最后把/etc/my.cnf中的skip-grant-tables注释掉,然后重启mysql,即:service mysqld restart

OK,下面我们就可以使用root新的密码登录MySQL了。
linux 下mysql忘记密码或者安装好linux后不知道mysql初始密码解决方案
参考链接:
https://blog.csdn.net/wohiusdashi/article/details/89358071
https://www.cnblogs.com/whoyoung/p/10987005.html

相关文章:

  • 2022-02-20
  • 2022-12-23
  • 2021-05-05
  • 2021-08-27
  • 2021-07-22
  • 2021-12-15
  • 2021-07-05
猜你喜欢
  • 2022-12-23
  • 2021-08-14
  • 2021-11-12
  • 2021-12-11
  • 2021-07-08
  • 2021-07-06
相关资源
相似解决方案