Red Hat 8.1 部署MySQL 5.7
文章目录
- Red Hat 8.1 部署MySQL 5.7
- 一、关闭防火墙和Selinux
- 二 、配置 YUM 源
- 三、安装依赖包
- 四、安装 MySQL
- 4.1 创建安装目录并解压文件到目录中
- 4.2 创建快捷方式
- 4.3 创建用户组
- 4.4 初始化
- 4.5 配置环境变量
- 五、 启动数据库
- 5.1 后台启动,并登陆数据库
- 5.2 新增远程用户
- 5.3 修改本地用户密码
- 5.4 关闭数据库
一、关闭防火墙和Selinux
systemctl stop firewalld
systemctl disable firewalld
## 关闭 SELINUX=disabled
vim /etc/sysconfig/selinux# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these three values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted修改配置文件需要重启生效, 为了提高效率不重启系统 setenforce 0 临时挂壁
[root@localhost ~]# setenforce 0
[root@localhost ~]# getenforce
Permissive
二 、配置 YUM 源
根据情况,选择本地源或者网络源
三、安装依赖包
yum install libaio
yum -y install perl perl-devel
yum install libncurses*
yum -y install autoconf
yum -y install numactl.x86_64
四、安装 MySQL
通过网盘分享的文件:mysql-5.7.30-linux-glibc2.12-x86_64.tar.gz
链接: https://pan.baidu.com/s/1Cx0gJXj0a37_F2a8Jdh73A 提取码: vg45
rz mysql-5.7.30-linux-glibc2.12-x86_64.tar.gz
4.1 创建安装目录并解压文件到目录中
mkdir -p /usr/local/mysqlsoft
tar -zxvf mysql-5.7.30-linux-glibc2.12-x86_64.tar.gz -C /usr/local/mysqlsoft
4.2 创建快捷方式
mkdir -p /usr/local/mysql57ln -s /usr/local/mysqlsoft/mysql-5.7.30-linux-glibc2.12-x86_64 /usr/local/mysql57/mysql5730
4.3 创建用户组
groupadd mysql
useradd -r -g mysql mysql
chown -R mysql:mysql /usr/local/mysqlsoft
echo “mysql” | passwd --stdin mysql
4.4 初始化
chown -R mysql.mysql /usr/local/mysql57
/usr/local/mysql57/mysql5730/bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql57/mysql5730 --datadir=/usr/local/mysql57/mysql5730/data
4.5 配置环境变量
echo "export PATH=$PATH:/usr/local/mysql57/mysql5730/bin" >> /root/.bashrc
source /root/.bashrc
五、 启动数据库
5.1 后台启动,并登陆数据库
mysqld_safe &
mysql -uroot -p
5.2 新增远程用户
select user,host,authentication_string from mysql.user;
grant all on *.* to mysql@'%' identified by 'mysql' with grant option;
flush privileges;
5.3 修改本地用户密码
set password for root@'localhost'=password('root');
flush privileges;
5.4 关闭数据库
mysqladmin -uroot -proot shutdown