MySQL 5.7.34的多种安装方式
1 二进制–RPM安装方式
- MySQL Yum Repository(安装yun源repo仓库)
Linux在一些软件安装中出现的错误有时与yum源有关
yum,全称“Yellow dog Updater, Modified”,是一个专门为了解决包的依赖关系而存在的软件包管理器。
yum源仓库下载地址 将repo的rpm包上传到linux
![image-20210911160029920](https://gitee.com/torohui/typora/raw/master/20210914153716.png)
1、安装yum源
yum localinstall mysql80-community-release-el7-3.noarch.rpm
2、修改repo仓库配置打开5.7版本
查看有哪些仓库:yum repolist(默认是没有5.7的库,因此需要关闭8.0,开启5.7)
编辑配置文件:vim /etc/yum.repos.d/mysql-community.repo
![image-20210914091603684](https://gitee.com/torohui/typora/raw/master/20210914153755.png)
3、centos7 修改为阿里的yum源
- 备份本地yum源
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo_bak
- 获取阿里yum源配置文件
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
- 更新cache
yum makecache
- 安装
yum -y update
- MySQL Community Server(安装MySQL服务端)
1、卸载 centos 中预安装的 mysql
rpm -qa | grep -i mysql
rpm -e mysql-xxx --nodeps
2、centos7.6自带的类mysql数据库是mariadb,会跟mysql冲突,要先删除
rpm -qa|grep mari
rpm -e --nodeps mariadb-libs
3、仓库安装mysql服务端
yum install mysql-server
- MySQL相关初始化设置
1、启动mysql服务
systemctl start mysqld
2、修改mysql初始密码
#查看初始密码
grep 'temporary password' /var/log/mysqld.log
-- 登录mysql
mysql -u root -p
-- 修改密码
alter user root@localhost identified by '1zxcasd..';
**3、授权远程访问 **
grant all privileges on *.* to 'root' @'%' identified by '123456';
flush privileges;
4、关闭防火墙
systemctl stop firewalld
2 二进制–通用包安装方式(已编译好的二级制包)
MySQL通用包下载地址 (Archived Versions)
-- 创建系统用户mysql
useradd -r -s /bin/false mysql
-- 解压通用安装包
tar zxf mysql-5.7.34-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
-- 修改软件目录权限
ln -s /usr/local/mysql-5.7.34-linux-glibc2.12-x86_64/ /usr/local/mysql
chown -R mysql:mysql /usr/local/mysql/
-- 创建依赖目录
cd /usr/local/mysql
mkdir mysql-files
chown mysql:mysql mysql-files
chmod 750 mysql-file
-- 初始化数据库实例
bin/mysqld --initialize --user=mysql
bin/mysql_ssl_rsa_setup
bin/mysqld_safe --user=mysql &
-- 创建数据库服务
cp support-files/mysql.server /etc/init.d/mysqld