1.安装相关的软件源
yum -y install epel-release
yum install -y wget
2.安装mysql
wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
rpm -ivh mysql57-community-release-el7-8.noarch.rpm ls /etc/yum.repos.d/
yum install -y mysql-community-server
安装失败,如图
需要公钥则输入下面命令用mardb进行替代
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022 yum -y install mysql-community-server
3.配置mysql
重载配置文件
systemctl daemon-reload
启动mysql服务
systemctl start mysqld
设置开机自启
systemctl enable mysqld
获取初始密码
grep password /var/log/mysqld.log
登陆MySQL
mysql -uroot -p'初始密码'
如下图:
4.更改数据库安全策略
密码强度设置为低级
set global validate_password_policy=0;
设置密码长度(最低)
set global validate_password_length=4;
修改本地密码
set password=password('123456');
退出
\q
利用修改的密码,登陆数据库
mysql -uroot -p123456
创建用户
create user 'root'@'%' identified by '123456';
允许远程登陆
grant all privileges on *.* to 'root'@'%' with grant option;
刷新权限
flush privileges;
退出
\q
感谢大家的支持,关注,评论,点赞!