centos7.8最小化安装离线安装mysql5.7,先参考如下文章安装基本网络工具。
获取安装包及依赖
首先准备一个与目标系统相同的联网系统
安装必要依赖
yum install -y yum-utils
下载mysql安装包和相关依赖
安装mysql需要首先安装perl、perl-Data-Dumper和perl-JSON
wget http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.32-1.el7.x86_64.rpm-bundle.tar
yumdownloader --resolve perl
yumdownloader --resolve perl-Data-Dumper
yumdownloader --resolve perl-JSON
打包依赖
tar czf perl.offline.tar.gz *.rpm
此时在目录下生成一个文件,perl.offline.ta.gz 就是离线安装mysql所需的全部依赖了
离线部署
将刚刚生成的perl.offline.tar.gz 和mysql-5.7.32-1.el7.x86_64.rpm-bundle.tar复制到离线部署的机器
安装 mysql所需依赖
# 安装
tar zxf perl.offline.tar.gz
rpm -ivh --replacefiles --replacepkgs *.rpm
rm -rf *.rpm
安装 mysql
# 安装前先删除mariadb-libs
yum remove mariadb-libs
# 安装
tar -xf mysql-5.7.32-1.el7.x86_64.rpm-bundle.tar
rpm -ivh --replacefiles --replacepkgs *.rpm
启动mysql
[root@localhost opt]# systemctl start mysqld
查看mysql启动服务情况
[root@localhost opt]# netstat -anpt|grep LISTEN|grep 3306
tcp6 0 0 :::3306 :::* LISTEN 2717/mysqld
访问mysql
访问之前需要关闭防火墙如下
systemctl stop firewalld
#查找临时密码
grep "password" /var/log/mysqld.log
2021-07-02T02:33:45.757334Z 1 [Note] A temporary password is generated for root@localhost: <c.V=Ti+T4TQ
#登录
mysql -uroot -p
Enter password:
#输入密码<c.V=Ti+T4TQ
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.32
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
#首次登录需要修改密码后才能使用
mysql> set password=password("[email protected]");
评论区