mysql5.7.27离线安装(基于centos7 ,通过rpm
一、下载mysql 5.7 安装包
-
下载地址
(1)选择Looking for previous GA versions
image.png
(2)选择 Red Hat Enterprise Linux / Orical Linux
(3)进行下载
image.png
二、 删除原有的mariadb,不然装不进msyql
(1)查询:rpm -qa | grep mariadb
(2)卸载mariadb:rpm -e --nodeps mariadb-libs-5.5.60-1.el7_5.x86_64
三、开始安装
(1)检查安装libaio环境:
rpm -qa|grep libaio
(2)没有则安装,上传后安装命令:
rpm -ivh libaio-0.3.107-10.el6.x86_64.rpm
(3)下载mysql5.7的tar压缩包
mysql-5.7.27-1.el7.x86_64.rpm-bundle.tar
(4)将安装包上传到centos7系统,测试地址为:
/root/tools/mysql_tools
(5)解压:
tar -xvf mysql-5.7.27-1.el7.x86_64.rpm-bundle.tar
(6)安装mysql-community-common-5.7.27-1.el7.x86_64.rpm
rpm -ivh mysql-community-common-5.7.27-1.el7.x86_64.rpm --force --nodeps
(7)安装mysql-community-libs-5.7.27-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.27-1.el7.x86_64.rpm --force --nodeps
(8)安装mysql-community-devel-5.7.27-1.el7.x86_64.rpm
rpm -ivh mysql-community-devel-5.7.27-1.el7.x86_64.rpm --force --nodeps
(9)安装mysql-community-libs-compat-5.7.27-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-compat-5.7.27-1.el7.x86_64.rpm --force --nodeps
(10)安装mysql-community-client-5.7.27-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.27-1.el7.x86_64.rpm --force --nodeps
(11)安装mysql-community-server-5.7.27-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.27-1.el7.x86_64.rpm --force --nodeps
(12)关闭mysql服务:
service mysqld stop
(13)修改配置文件:
vim /etc/my.cnf
(14)设置免密码登录:在mysqld标签内添加skip-grant-tables
(15)修改/var/lib/mysql权限,不然会打开服务不成功:
chown mysql:mysql -R /var/lib/mysql
(16)打开服务:service mysqld start
(17)空密码登录:mysql -u root
(18)修改密码:依次执行
flush privileges; # 更新权限
set password for root@localhost = password('123456'); # 设置root密码为123456;
use mysql;
update user set host = '%' where user ='root'; # 配置可远程登录
flush privileges; # 更新权限
exit; # 退出
(19)测试登录:mysql -u root -p
输入密码:123456
(20)设置mysql开机自启:systemctl enable mysqld