mysql yum 离线源拉取。

来源:互联网 发布:大话西游男鬼加点数据 编辑:程序博客网 时间:2024/06/11 21:24

需要一台可以连接外网的centos7服务器

1.安装 createrepo,用于制作源。

yum -y install createrepo

2.安装拉取离线源插件。

yum -y install yum-utils

3.到mysql官网下载所需版本mysql的repo源 注:(mysql-5.7-repo源包含旧版本如需要下载其他版本源只需要安装文档第(11)条处更改配置文件即可。)

mysql5.7版本:wget http://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm

4.安装 mysql57-community-release-el7-9.noarch.rpm

rpm -ivh mysql57-community-release-el7-9.noarch.rpm  --nodeps --force  

5.安装这个包后,在/etc/yum.repos.d/下会获得两个mysql的yum repo源。

mysql-community-source.repomysql-community.repo

6.执行命令 “yum repolist” 查看mysql-repo源 列表

yum repolist#mysql-connectors-community    MySQL Connectors Community       24#mysql-tools-community         MySQL Tools Community            36#mysql57-community             MySQL 5.7 Community Server       146

7.同步mysql-repo到本地。注:同步下载源时名字为“源标识”名字。

reposync -r   mysql-connectors-communityreposync -r   mysql-tools-communityreposync -r   mysql57-community

8.所以数据同步下载完成将所同步下载下来的文件cp到同一目录下。并创建子的repo仓库。

mkdir /var/www/html/mysql5.7cp -r mysql-connectors-community /var/www/html/mysql5.7/cp -r mysql-tools-community /var/www/html/mysql5.7/cp -r mysql57-community /var/www/html/mysql5.7/cd /var/www/html/mysql-5.7/createrepo .

9.拷贝myslq-KEY到/var/www/html/mysql5.7

cp /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql /var/www/html/mysql5.7/

10.用apache共享本地mysql离线源。共享/var/www/html/mysql5.7/目录 让客户端可通过“http://hostname/mysql5.7/”访问。
注:如访问时提示没有该目录访问权限可执行如下命令。

chcon -R -h -t httpd_sys_content_t /var/www/html/mysql5.7/chcon -R -h -t httpd_sys_content_t /var/www/html/mysql5.7

11.如需设置repo版本 修改mysql-community.repo文件

vim /etc/yum.repos.d/mysql-community.repo 

找到标注版本如下配置:

enabled=0    (0为关闭 1为打开)。yum repolist enabled | grep mysql   设置完成后刷新mysql源然后查看同步源即可 :**

mysql5.7本地离线源设置完成。

客户端设置mysql离线源安装。


1.配置修改yum源文件。

cd /etc/yum.repos.d/ #进入到该目录下。cp CentOS-Base.repo CentOS-Base.repo.BAK  #备份原始数据。vim CentOS-Base.repo #打开编辑yum源改文件

新添加如下命令:

[mysql-connectors-community]name=MySQL Connectors Communitybaseurl=http://hostname/mysql5.7/enabled=1gpgcheck=1gpgkey=http://hostname/mysql5.7/RPM-GPG-KEY-mysql[mysql-tools-community]name=MySQL Tools Communitybaseurl=http://hostname/mysql5.7/enabled=1gpgcheck=1gpgkey=http://hostname/mysql5.7/RPM-GPG-KEY-mysql[mysql57-community]name=MySQL 5.7 Community Serverbaseurl=http://hostname/mysql5.7/enabled=1gpgcheck=1gpgkey=http://hostname/mysql5.7/RPM-GPG-KEY-mysql

4.安装mysql :

yum -y install mysql-community-server   

注:mysql5.7安装会随机生成一段初始密码在mysql日志文件里。

原创粉丝点击