linux中mysql安装与修改密码报错记录及解决

1、安装时执行语句:sudo rpm -ivh mysql80-community-release-el7-6.noarch.rpm

报错:Couldn't open file /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql-2022

解决:rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022

2、安装完成后,无法登录

解决:vi /etc/my.cnf,在文件最后加入:skip-grant-tables,跳过校验,此时密码为空,回车即可登录。

3、修改密码

 网上常见的方法如下,我这里不可行

        登录mysql后执行

        use mysql;

        update user set password=password('1234') where user='root';

        新版本password字段改为authentication_string

        update user set authentication_string=password('1234') where user='root';

        使用均报错:ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '('新密码') where user='root'' at line 1


之后执行

flush privileges;

ALTER USER 'root'@'localhost' IDENTIFIED BY '1234';
此时报错: Your password does not satisfy the current policy requirements,意为密码过于简单,不符合密码策略。

此时输入语句 " SHOW VARIABLES LIKE 'validate_password%'; "进行查看

 可见策略等级为medium中级,长度为8,

此时执行修改: set global validate_password_policy=LOW;

报错:

 因此需要先设置一个符合条件的代码,执行语句:

 alter user 'root'@'%' identified with mysql_native_password by 'Root_1234';

之后再修改策略

set global validate_password.policy=0;
set global validate_password.length=1;

修改成功如图

 此时可将密码改回

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值