centOS7离线安装mysql5.6(RPM方式)-v1


title: centOS7离线安装mysql5.6(RPM方式)-v1
date: 2020-05-21 13:14:00
comments:
description:
keywords: “PUSDN,JaneYork,平行宇宙开发者网,P站,破该仔统一软件开发者网,破该仔联盟,破该仔俱乐部,离线安装MySQL”
top_img:
cover:
mathjax:
katex:
aplayer:
tags: [PUSDN,MySQL]
categories: MySQL


一说

前情提示

系统:CentOS7
mysql5.6社区版

下载安装包
https://dev.mysql.com/downloads/mysql/5.6.html#downloads

https://dev.mysql.com/get/Downloads/MySQL-5.6/MySQL-5.6.50-1.el7.x86_64.rpm-bundle.tar


各个包介绍:

注意

以后为适配部分shell,密码尽量去除特殊符,除下划线

软件备份上传

先建立好相关目录
内网环境部署软件位置:/server/backup/software_centos7

scp -P 22 -r -v /server/backup/software_centos7/* root@115.29.201.42:/server/backup/software
ssh-keygen -R 115.29.201.42

卸载自带的mariadb

rpm -qa | grep mariadb
# rpm -e --nodeps 返回的文件名
rpm -e --nodeps mariadb-libs-5.5.60-1.el7_5.x86_64
# rpm -e --nodeps mariadb-libs-*
rpm -qa | grep mariadb
rpm -qa | grep mysql

提前安装依赖(离线)

不建议,如果有网,尽可能yum在线安装,省时省力,离线安装适合内网,且需考虑各个依赖版本。
RPM网站:
http://rpmfind.net/
https://pkgs.org/download/libaio
http://rpm.pbone.net/
I386—I686都是32位
x86_64是64位

#########安装 start #########

rpm -qa | grep unzip
rpm -qa | grep libaio
cd /server/backup/software
#rpm -ivh perl-5.16.3-297.el7.x86_64.rpm
#rpm -ivh perl-devel-5.16.3-297.el7.x86_64.rpm
rpm -ivh perl-Data-Dumper-2.145-3.el7.x86_64.rpm
rpm -ivh autoconf-2.69-11.el7.noarch.rpm
rpm -ivh libaio-0.3.109-13.el7.x86_64.rpm

#########安装 end #########

https://centos.pkgs.org/7/centos-x86_64/libaio-0.3.109-13.el7.x86_64.rpm.html
http://mirror.centos.org/centos/7/os/x86_64/Packages/libaio-0.3.109-13.el7.x86_64.rpm

cd /server/backup/software
rpm -ivh libaio-0.3.109-13.el7.x86_64.rpm

备用:安装依赖(在线)

如果上面离线安装过依赖(一般内网部署),就不要执行此步骤了

yum install kernel-headers
yum -y install gcc gcc-c++ zlib zlib-devel libaio-devel perl perl-devel perl-Data-Dumper openssl openssl-devel pcre pcre-devel zip unzip autoconf

解压并安装

cd /server/backup/software
tar -xvf MySQL-5.6.50-1.el7.x86_64.rpm-bundle.tar
# 以下建议一条一条执行
rpm -ivh MySQL-client-5.6.50-1.el7.x86_64.rpm
rpm -ivh MySQL-devel-5.6.50-1.el7.x86_64.rpm
rpm -ivh MySQL-embedded-5.6.50-1.el7.x86_64.rpm
rpm -ivh MySQL-shared-5.6.50-1.el7.x86_64.rpm
rpm -ivh MySQL-shared-compat-5.6.50-1.el7.x86_64.rpm
rpm -ivh MySQL-test-5.6.50-1.el7.x86_64.rpm
rpm -ivh MySQL-server-5.6.50-1.el7.x86_64.rpm

#不依赖,强制安装
#rpm -ivh MySQL-test-5.6.50-1.el7.x86_64.rpm --force --nodeps

执行成功截图:
在这里插入图片描述

用户和密码

查看初始密码

cat /root/.mysql_secret | grep 'password'
Bx4WmLZrfEaj6bpQ

在这里插入图片描述

启动mysql服务,安装完成(强荐)

systemctl restart mysql.service
systemctl start mysql
systemctl restart mysql
systemctl stop mysql
systemctl status mysql

登录

mysql -u root -p
Bx4WmLZrfEaj6bpQ
Www_pusdn_com

在这里插入图片描述

修改root默认密码

set password for 'root'@'localhost'=password('Www_pusdn_com');

flush privileges;
exit;

将MySQL加入系统服务,并设置开机启动(默认已是)
#chkconfig --add mysql

chkconfig mysql on

chkconfig --list2345都为on
在这里插入图片描述

配置root远程访问(不建议设置)

mysql -u root -p
Www_pusdn_com
# 加了WITH GRANT OPTION将拥有全部权限
#use mysql;将无其他库权限
grant all privileges on *.* to 'root'@'%' identified by 'Www_pusdn_com' WITH GRANT OPTION;
flush privileges;
exit;

修改某用户密码或root(备用)

update mysql.user set Password=password('密码') where User='root';

update mysql.user set Password=password('Www_pusdn_com') where User='root';
flush privileges;
exit;

创建开发用户

mysql -u root -p
Www_pusdn_com

超级
dev-super
Www_pusdn_com

CREATE USER 'dev-super'@'%' IDENTIFIED BY 'Www_pusdn_com';
GRANT ALL PRIVILEGES ON *.* TO 'dev-super'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;

所有主机
dev-hnnm-all
Www_pusdn_com

CREATE USER 'dev-hnnm-all'@'%' IDENTIFIED BY 'Www_pusdn_com';
GRANT ALL PRIVILEGES ON hnnm.* TO 'dev-hnnm-all'@'%';
GRANT Process ON *.* TO `dev-hnnm-all`@`%`;
FLUSH PRIVILEGES;
exit;

远程连接测试

使用navicat等工具测试链接

移动数据目录修改配置文件

配置参数可能还需要优化

systemctl stop mysql.service
cp /usr/my.cnf /etc/my.cnf
mv /var/lib/mysql /server
# mv /server/mysql /var/lib

配置文件内容详见:
https://www.yuque.com/pusdn/mpdkgr/ogk4d1

systemctl start mysql.service

配置文件含义参考:
https://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
https://www.cnblogs.com/marixh/p/12952654.html
https://blog.imdst.com/mysql-5-6-pei-zhi-you-hua/

防火墙

CentOS7.x移步:https://blog.csdn.net/qq_31708763/article/details/86514366

[root@localhost ~]# firewall-cmd --zone=public --add-port=3306/tcp --permanent    #添加防火墙开放端口
[root@localhost ~]# systemctl restart firewalld.service    #重新启动防火墙

远程连接测试

至此,安装结束!

其他说明

文件默认位置

https://dev.mysql.com/doc/refman/5.6/en/linux-installation-rpm.html
/var/lib/mysql/  #数据库目录
/usr/share/mysql #配置文件目录
/usr/bin   #相关命令目录
/etc/init.d/mysql #启动脚本
可酌情参考以下翻译:

相关推荐
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页