获取源

sudo rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm

安装mysql 8.0

sudo yum --enablerepo=mysql80-community install mysql-community-server

  • 启动服务service mysqld start
  • 查看状态service mysqld status

centos7安装mysql8.0

  • 查看临时密码grep "A temporary password" /var/log/mysqld.log
  • 登陆mysql后输入临时密码即可mysql -u root -p

centos7安装mysql8.0

  • 修改密码
    alter user 'root'@'localhost' identified by 'zxcv1234'

    • 这个@和两侧的单引号直接不要有空格,否则会报错语法有误

      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 ‘‘localhost’ identified by ‘zxcv1234’’ at line 1

    • 这个单引号也要注意,不要打成 Esc键下面的那个小点,否则报错语法有误

      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 ’localhost identified by zxcv1234’ at line 1

    • 疯狂提示我不符合规则,也执行不了其他的命令

      ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
      centos7安装mysql8.0

    • 查询资料得知默认的政策要求是 为 1
策略 规则
0 or LOW Length
1 or MEDIUM Length; numeric, lowercase/uppercase, and special characters
2 or STRONG Length; numeric, lowercase/uppercase, and special characters; dictionary file
  • 0 or LOW Length:密码任意,长度8位及以上
  • 1 or MEDIUM Length; numeric, lowercase/uppercase, and special characters:表示的是数字、大小写字母、特殊字符,长度任意
  • 2 or STRONG Length; numeric, lowercase/uppercase, and special characters; dictionary file:限制与 1 差不多,但是密码会通过字典检查,通俗的说太简单的密码无法通过
修改策略(这个为可选)
  • 查询策略 show variables like 'validate_password.%';
  • 修改策略 set global validate_password.policy=0,令密码任意,长度大于等于8
    centos7安装mysql8.0

相关文章:

  • 2021-07-10
  • 2021-11-10
  • 2021-04-05
  • 2022-03-08
  • 2021-06-14
  • 2021-10-13
  • 2022-12-23
猜你喜欢
  • 2021-04-27
  • 2021-11-08
  • 2021-05-26
  • 2021-10-30
  • 2021-06-08
  • 2022-12-23
相关资源
相似解决方案