1.安装wget
yum install -y wget
【资料图】
2、下载rpm安装包
[root@nifi1 home]# wget http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
2.1 yum安装mysql 5.7
yum -y install mysql57-community-release-el7-10.noarch.rpm
2.2yum安装mysql-community-server
yum -y install mysql-community-server
安装失败由于MySQL GPG 密钥已过期导致的需要运行命令, 以2022年为例
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
yum -y install mysql-community-server
至此yum安装MySQL服务结束!
3.MySQL数据库设置
3.1启动MySQL
systemctl start mysqld.service
3.2查看MySQL运行状态
systemctl status mysqld.service
4.在日志文件中找出密码
grep "password" /var/log/mysqld.log
5.进入数据库
mysql -uroot -p # 回车后会提示输入密码
6.在日志文件中找出密码
grep "password" /var/log/mysqld.log
7.进入数据库
mysql -uroot -p # 回车后会提示输入密码
8.设置mysql密码
8.1修改变更,便于修改简单密码
set global validate_password_policy=0;
set global validate_password_length=1;
8.2修改密码
ALTER USER "root"@"localhost" IDENTIFIED BY "root";
8.3远程授权,便于使用navicat等远程客户端连接
grant all on *.* to root@"%" identified by "root";
9.登录测试
mysql -uroot -p