Centos7.6 离线安装mysql-5.7.26

安装包下载

https://dev.mysql.com/downloads/mysql/ 
根据系统版本下载

下载安装包: mysql-5.7.26-1.el7.x86_64.rpm-bundle.tar
安装新版mysql前,需将系统自带的mariadb-lib卸载
[[email protected] ~]# rpm -qa|grep mariadb
mariadb-libs-5.5.56-2.el7.x86_64
[[email protected] ~]# rpm -e --nodeps mariadb-libs-5.5.56-2.el7.x86_64
[[email protected] ~]# rpm -qa|grep mariadb
或者yum remove mariadb

解压安装包
[[email protected] mysql-5.7]# tar -xvf mysql-5.7.26-1.el7.x86_64.rpm-bundle.tar
mysql-community-embedded-devel-5.7.26-1.el7.x86_64.rpm
mysql-community-libs-5.7.26-1.el7.x86_64.rpm
mysql-community-embedded-5.7.26-1.el7.x86_64.rpm
mysql-community-test-5.7.26-1.el7.x86_64.rpm
mysql-community-embedded-compat-5.7.26-1.el7.x86_64.rpm
mysql-community-common-5.7.26-1.el7.x86_64.rpm
mysql-community-devel-5.7.26-1.el7.x86_64.rpm
mysql-community-client-5.7.26-1.el7.x86_64.rpm
mysql-community-server-5.7.26-1.el7.x86_64.rpm
mysql-community-libs-compat-5.7.26-1.el7.x86_64.rpm

安装mysql-community-common-5.7.26-1.el7.x86_64.rpm
[[email protected] mysql-5.7]# rpm -ivh mysql-community-common-5.7.26-1.el7.x86_64.rpm
warning: mysql-community-common-5.7.26-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql-community-common-5.7.26-1.e################################# [100%]

安装mysql-community-libs-5.7.26-1.el7.x86_64.rpm
[[email protected] mysql-5.7]# rpm -ivh mysql-community-libs-5.7.26-1.el7.x86_64.rpm
warning: mysql-community-libs-5.7.26-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql-community-libs-5.7.26-1.el7################################# [100%]

安装mysql-community-client-5.7.26-1.el7.x86_64.rpm
[[email protected] mysql-5.7]# rpm -ivh mysql-community-client-5.7.26-1.el7.x86_64.rpm
warning: mysql-community-client-5.7.26-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql-community-client-5.7.26-1.e################################# [100%]

安装mysql-community-server-5.7.20-1.el7.x86_64.rpm
在安装之前需要安装libaio
[[email protected] mysql-5.7]# rpm -qa|grep libaio
libaio-0.3.109-13.el7.x86_64

或者 yum install -y libaio
如果不存需要下载离线包: 
http://mirror.centos.org/centos/6/os/x86_64/Packages/ 

安装libaio库:
rpm -ivh libaio-0.3.107-10.el6.x86_64.rpm(若在有网情况下可执行yum install libaio)

安装server,rpm -ivh mysql-community-server-5.7.26-1.el7.x86_64.rpm
[[email protected] mysql-5.7]# rpm -ivh mysql-community-server-5.7.26-1.el7.x86_64.rpm
warning: mysql-community-server-5.7.26-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql-community-server-5.7.26-1.e################################# [100%]如果提示没有 perl 则, 安装 yum install -y perl

初始化数据库
// 指定datadir, 执行后会生成~/.mysql_secret密码文件(5.7以后不在使用)
[[email protected] mysql-5.7]# mysql_install_db --datadir=/var/lib/mysql

// 初始化,执行生会在/var/log/mysqld.log生成随机密码
[[email protected] mysql-5.7]# mysqld --initialize

更改mysql数据库目录的所属用户及其所属组(没用创建mysql用户)
[[email protected] mysql-5.7]# chown mysql:mysql /var/lib/mysql -R
启动mysql
[[email protected] mysql-5.7]# systemctl start mysqld.service
授权
[[email protected] mysql-5.7]# chmod -R 777 mysql
查看效果
[[email protected] mysql-5.7]# systemctl status mysqld.service

修改MySQL的登录设置
[[email protected] mysql-5.7]# vim /etc/my.cnf
在[mysqld]的段中加上一句:skip-grant-tables 
重新启动mysqld 
[[email protected] mysql-5.7]# service mysqld restart
Redirecting to /bin/systemctl restart mysqld.service

查看初始密码

命令:cat /root/.mysql_secret

复制下来初始的密码,做登录使用

命令:bin/mysql -uroot -p

密码就是刚才复制的密码,粘贴进去回车即可。

登录并修改MySQL的root密码
[[email protected] mysql-5.7]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.26 MySQL Community Server (GPL)

Copyright (c) 2000, 2019, 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.

# 修改root用户的密码
mysql> update mysql.user set authentication_string=password(‘你要修改的密码‘) where user=‘root‘;
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 1

# 刷新该表
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

# 退出MySQL
mysql> quit;
Bye
将MySQL的登录设置修改回来 
重新启动mysqld
[[email protected] mysql-5.7]# service mysqld restart
Redirecting to /bin/systemctl restart mysqld.service
登录到mysql,更改root用户的密码 
命令可以查看初始密码

grep ‘temporary password‘ /var/log/mysqld.log

[[email protected] mysql-5.7]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.26 MySQL Community Server (GPL)

Copyright (c) 2000, 2019, 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.

# 修改root用户的密码
mysql> set password=password(‘你要修改的密码‘);
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 1

# 刷新该表
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

# 退出MySQL
mysql> quit;
Bye
 远程登陆授权
[[email protected] mysql-5.7]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.26 MySQL Community Server (GPL)

Copyright (c) 2000, 2019, 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.

# root用户远程登录
mysql> grant all privileges on *.* to ‘root‘@‘%‘ identified by ‘你的密码‘ with grant option;
Query OK, 0 rows affected, 1 warning (0.00 sec)

# 刷新表
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

# 退出MySQL
mysql> quit;
Bye
设置mysql开机启动 
// 检查是否已经是开机启动
[[email protected] mysql-5.7]# systemctl list-unit-files | grep mysqld

// 开机启动
[[email protected] mysql-5.7]# systemctl enable mysqld.service
默认配置文件路径:
配置文件:/etc/my.cnf
日志文件:/var/log/mysqld.log
服务启动脚本:/usr/lib/systemd/system/mysqld.service
socket文件:/var/run/mysqld/mysqld.pid
配置默认编码为utf8
修改/etc/my.cnf配置文件,在[mysqld]下添加编码配置,如下所示:
[mysqld]
character_set_server=utf8
init_connect=‘SET NAMES utf8‘

原文地址:https://www.cnblogs.com/chendian0/p/10929939.html

时间: 2024-10-14 08:21:41

Centos7.6 离线安装mysql-5.7.26的相关文章

内网环境下centos7.4离线安装oracle,及不同用户表空间迁移数据

初始环境为Centos7.4 Mini安装后的系统,最开始用镜像iso做为yum源,安装oracle,在静默安装的时候报错,后来用一台同样环境的系统,开启yum缓存,下载安装依赖环境,让rpm包离线下载后,传到这台服务器,在静默安装,还是失败,最后网上找了个离线安装依赖包,成功静默安装及建库,将源oracle下的用户及表空间数据迁移到新安装的oracle用户和表空间下.以后安装可以直接安装离线依赖包 安装前的准备: 1. 修改主机名 #sed -i "s/HOSTNAME=localhost.l

CentOS6 下编译安装 MySQL 5.6.26

CentOS6下通过yum安装的MySQL是5.1版的,比较老,所以就想通过源代码安装高版本的5.6.26. 一:卸载旧版本 使用下面的命令检查是否安装有MySQL Server rpm -qa | grep mysql 有的话通过下面的命令来卸载掉 rpm -e mysql // 普通删除模式 rpm -e --nodeps mysql // 强力删除模式,如果使用上面命令删除时,提示有依赖的其它文件,则用该命令可以对其进行强力删除 二.安装编译MySQL需要的工具 安装g++和gdb yum

centos7用rpm安装mysql总结

最近做一个项目,需要用centos做数据服务器,用mysql数据库,就需要安装mysql数据库,之前没接触过centos,因此什么也不懂,就从网上也查了很多资料,都觉得不是最好的方法.最后结合mysql官方资料和网友的资料,最后用rpm方式安装,并总结给其他人以参考. 首先打开mysql管网,找到“yum repository”打开页面或者直接打开如下链接 http://dev.mysql.com/downloads/repo/yum/ ,找到自己需要的,点击download,下载rpm文件,在

Centos7源码安装mysql

转子 http://www.linuxidc.com/Linux/2015-06/119354.htm 目录 准备工作 运行环境 确认你的安装版本 下载MySQL 安装MySQL 准备安装环境 编译和安装 配置MySQL 单实例配置 单实例配置方法 添加防火墙 启动MySQL 重启MySQL 多实例配置 什么是多实例 多实例配置方法 创建启动文件 初始化数据库 配置防火墙 启动MySQL 登陆MySQL 重启MySQL 准备工作 运行环境 本文的运行环境如下 系统版本 CentOS7最小化安装:

Centos7下yum安装mysql

Centos7 yum源没有Mysql,要到官网下载. 单击此处下载 下载完RPM安装 yum安装Mysqld 启动Mysqld 初次安装root没有密码 设置密码 #mysql -uroot mysql>set password for 'root'@'localhost'=password('密码'); mysql>exit

CentOS7的yum安装mysql

CentOS7的yum源中默认好像是没有mysql的.为了解决这个问题,我们要先下载mysql的repo源. 1. 下载mysql的repo源 $ wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm 2. 安装mysql-community-release-el7-5.noarch.rpm包 $ sudo rpm -ivh mysql-community-release-el7-5.noarch.rpm 安装这个

Centos7 开发环境安装mysql社区版本

1,Centos7安装 mysql 首先开发的服务器是centos7,上面默认安装的数据库是MariaDB. 还是有一点区别的.要安装mysql而且oracle提供的还是个社区版本. 无所谓,开发而已,装上就行. http://dbahire.com/how-to-install-mysql-5-6-on-centos-7/ yum install http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm yum inst

CentOS7虚拟机上安装Mysql

安装环境:系统是 CentOS7 1.下载 下载地址:http://dev.mysql.com/downloads/mysql/5.6.html#downloads 下载版本:我这里选择的5.6.33,通用版,linux下64位 也可以直接复制64位的下载地址,通过命令下载: wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz 2.安装依赖 #安装依赖 yum -y

centos7下如何安装mysql 亲测

因为centos7 自带mariadb,所以第一步需要卸载mariadb 1.rpm -qa | grep mariadb  查看mariadb版本, 2.rpm -e --nodeps +版本  卸载mariadb mysql官网下载需要的版本 3.将mysql安装包解压到指定目录,命令如下: tar -zxvf mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz -C /usr/local 4.进入/usr/local目录:cd /usr/local 5.为m

centos6.5离线安装mysql

1.查看是否已安装mysql rpm -qa | grep -i mysql 2.如果有,先卸载,没有直接跳到第3步 yum remove mysql mysql-server mysql-libs compat-mysql51 rm -rf /var/lib/mysql rm /etc/my.cnf 查看是否还有mysql软件: rpm -qa|grep mysql 有的话继续删除 3.下载mysql离线安装包 地址:http://cdn.mysql.com/Downloads/MySQL-5