Centos7使用rpm安装mysql 5.7.43

Centos7使用rpm安装mysql 5.7.43

1、下载rpm包

bash 复制代码
wget
https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.43-1.el7.x86_64.rpm-bundle.tar

2、解压并安装

bash 复制代码
tar xf mysql-5.7.43-1.el7.x86_64.rpm-bundle.tar
yum -y install mysql-*

3、按需修改mysql配置

#注意:自定义datadir目录要给mysql用户授权

bash 复制代码
vim /etc/my.cnf

chown -R mysql.mysql /opt/mysql

4、启动mysql并添加开机自启动

bash 复制代码
systemctl start mysqld
systemctl enable mysql

5、查看初始密码并登录mysql验证

bash 复制代码
grep password /opt/mysql/mysqld.log
mysql -uroot -p
#输入上面查到的密码

6、修改密码

如果设置的密码过于简单,上面执行会报错

sql 复制代码
mysql> alter user  user() identified by 'root';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

mysql> alter user  user() identified by 'root!Passwrd';
Query OK, 0 rows affected (0.00 sec)
#刷新权限使生效
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

简单密码报错解决方法1(推荐):

设置8位及以上密码来保证安全性

解决方法2:

降低密码复杂度及修改密码过期策略

sql 复制代码
#设置密码不过期
mysql> set global validate_password_policy=0;
Query OK, 0 rows affected (0.00 sec)
#设置密码长度为1
mysql> set global validate_password_length=1;
Query OK, 0 rows affected (0.00 sec)
#修改密码
mysql> alter user  user() identified by 'root';
Query OK, 0 rows affected (0.00 sec)
#刷新权限使生效
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

退出重新登录验证

相关推荐
Wiktok11 分钟前
MySQL的常用数据类型
数据库·mysql
曹牧27 分钟前
Oracle 表闪回(Flashback Table)
数据库·oracle
J_liaty32 分钟前
Redis 超详细入门教程:从零基础到实战精通
数据库·redis·缓存
m0_706653231 小时前
用Python批量处理Excel和CSV文件
jvm·数据库·python
山岚的运维笔记1 小时前
SQL Server笔记 -- 第15章:INSERT INTO
java·数据库·笔记·sql·microsoft·sqlserver
夹锌饼干2 小时前
mysql死锁排查流程--(处理mysql阻塞问题)
java·mysql
Lw老王要学习2 小时前
CentOS 7.9达梦数据库安装全流程解析
linux·运维·数据库·centos·达梦
qq_423233902 小时前
Python深度学习入门:TensorFlow 2.0/Keras实战
jvm·数据库·python
无限码力2 小时前
华为OD技术面真题 - Mysql相关 - 4
mysql·华为od·华为od技术面真题·华为od技术面八股·华为od技术面八股文·华为od技术面mysql相关
Wasim4042 小时前
【渗透测试】SQL注入
网络·数据库·sql