Centos7使用rpm安装mysql 5.7.43
Centos7使用rpm安装mysql 5.7.43
1、下载rpm包
wget
https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.43-1.el7.x86_64.rpm-bundle.tar
2、解压并安装
tar xf mysql-5.7.43-1.el7.x86_64.rpm-bundle.tar
yum -y install mysql-*
3、按需修改mysql配置
#注意:自定义datadir目录要给mysql用户授权
vim /etc/my.cnf
chown -R mysql.mysql /opt/mysql
4、启动mysql并添加开机自启动
systemctl start mysqld
systemctl enable mysql
5、查看初始密码并登录mysql验证
grep password /opt/mysql/mysqld.log
mysql -uroot -p
#输入上面查到的密码
6、修改密码
如果设置的密码过于简单,上面执行会报错
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:
降低密码复杂度及修改密码过期策略
#设置密码不过期
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)
退出重新登录验证