Centos7.4 安装MySQL 5.7.21 (通用二进制包)

CentOS 7.4 使用yum源安装MySQL 5.7.21 环境:CentOS 7.4 1708从CentOS 7.0发布以来,yum源中开始使用mariadb来代替MySQL的安装。即使你输入的是yum install mysql , 显示的也是mariadb的安装内容。输入yum install mysql-server,提示yum没有可用的安装包。因此,如果使用yum安装MySQL的话,就需要去下载官方指定的yum源。网址为: https://dev... 阅读详情

1.下载安装包

MySQL 官方下载地址:https://dev.mysql.com/downloads/mysql/
MySQL 5.7官方安装文档:https://dev.mysql.com/doc/refman/5.7/en/binary-installation.html

本文完全按照官方步骤配置安装

选择Linux - generic 64位安装包
这里写图片描述
MySQL 5.7.21 二进制包下载地址:https://dev.mysql.com//Downloads/MySQL-5.7/mysql-5.7.21-linux-glibc2.12-x86_64.tar.gz

wget --no-check-certificate https://dev.mysql.com//Downloads/MySQL-5.7/mysql-5.7.21-linux-glibc2.12-x86_64.tar.gz

2.安装依赖包

MySQL依赖于libaio 库。如果这个库没有在本地安装,数据目录初始化和后续的服务器启动步骤将会失败。请使用适当的软件包管理器进行安装。例如,在基于Yum的系统上:

shell> yum search libaio  
shell> yum install libaio 

注意
SLES 11:从MySQL 5.7.19开始,Linux通用tar包的格式是EL6而不是EL5。以致于MySQL客户端bin / mysql需要libtinfo.so.5。

解决方法是创建软链接,例如64位系统上的ln -s libncurses.so.5.6 /lib64/libtinfo.so.5或32 位系统上的ln -s libncurses.so.5.6 /lib/libtinfo.so.5。

3.创建一个mysql用户和组

shell> groupadd mysql
shell> useradd -r -g mysql -s /bin/false mysql

注意
此用户仅用于运行mysql服务,而不是登录,因此使用useradd -r和-s /bin/false命令选项来创建对服务器主机没有登录权限的用户。

4.解压到指定目录

shell> tar -zxvf mysql-5.7.21-linux-glibc2.12-x86_64.tar.gz -C /opt
shell> cd /opt
shell> mv mysql-5.7.21-linux-glibc2.12-x86_64 mysql-5.7.21

5.配置环境变量

echo "export PATH=$PATH:/opt/mysql-5.7.21/bin" >> /etc/profile

6.配置数据库目录

数据目录:/opt/mysql-5.7.21/data
参数文件my.cnf:/opt/mysql-5.7.21/etc/my.cnf
错误日志log-error:/opt/mysql-5.7.21/log/mysql_error.log
二进制日志log-bin:/opt/mysql-5.7.21/log/mysql_bin.log
慢查询日志slow_query_log_file:/opt/mysql-5.7.21/log/mysql_slow_query.log
套接字socket文件:/opt/mysql-5.7.21/run/mysql.sock
pid文件:/opt/mysql-5.7.21/run/mysql.pid
创建目录:

shell> mkdir -p /opt/mysql-5.7.21/{data,log,etc,run}
shell> chown -R mysql:mysql /opt/mysql-5.7.21
shell> chmod 750 /opt/mysql-5.7.21/{data,log,etc,run}

7.配置my.cnf文件

在/opt/mysql-5.7.21/etc/下创建my.cnf文件,加入如下参数,其他参数根据需要配置

shell> touch /opt/mysql-5.7.21/etc/my.cnf
shell> chown mysql:mysql /opt/mysql-5.7.21/etc/my.cnf
[client]
port = 3306
socket = /opt/mysql-5.7.21/run/mysql.sock

[mysqld]
port = 3306
socket = /opt/mysql-5.7.21/run/mysql.sock
pid_file = /opt/mysql-5.7.21/run/mysql.pid
datadir = /opt/mysql-5.7.21/data
default_storage_engine = InnoDB
max_allowed_packet = 128M
max_connections = 2048
open_files_limit = 65535

skip-name-resolve
lower_case_table_names=1

character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
init_connect='SET NAMES utf8mb4'


innodb_buffer_pool_size = 128M
innodb_log_file_size = 128M
innodb_file_per_table = 1
innodb_flush_log_at_trx_commit = 0


key_buffer_size = 16M

log-error = /opt/mysql-5.7.21/log/mysql_error.log
log-bin = /opt/mysql-5.7.21/log/mysql_bin.log
slow_query_log = 1
slow_query_log_file = /opt/mysql-5.7.21/log/mysql_slow_query.log
long_query_time = 5


tmp_table_size = 16M
max_heap_table_size = 16M
query_cache_type = 0
query_cache_size = 0

server-id=1

8.初始化

shell> mysqld --initialize --user=mysql --basedir=/opt/mysql-5.7.21 --datadir=/opt/mysql-5.7.21/data

此时会生成一个临时密码,可以在mysql_error.log文件找到

shell> grep 'temporary password' /opt/mysql-5.7.21/log/mysql_error.log 

生成ssl

shell> mysql_ssl_rsa_setup --basedir=/opt/mysql-5.7.21 --datadir=/opt/mysql-5.7.21/data/

9.配置服务,使用systemctl管理

shell> cd /usr/lib/systemd/system
shell> touch mysqld.service 

文件内容如下

# Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
#
# systemd service file for MySQL forking server
#

[Unit]
Description=MySQL Server
Documentation=man:mysqld(8)
Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html
After=network.target
After=syslog.target

[Install]
WantedBy=multi-user.target

[Service]
User=mysql
Group=mysql

Type=forking

PIDFile=/opt/mysql-5.7.21/run/mysql.pid

# Disable service start and stop timeout logic of systemd for mysqld service.
TimeoutSec=0

# Execute pre and post scripts as root
PermissionsStartOnly=true

# Needed to create system tables
#ExecStartPre=/usr/bin/mysqld_pre_systemd

# Start main service
ExecStart=/opt/mysql-5.7.21/bin/mysqld --daemonize --pid-file=/opt/mysql-5.7.21/run/mysql.pid $MYSQLD_OPTS

# Use this to switch malloc implementation
EnvironmentFile=-/etc/sysconfig/mysql

# Sets open_files_limit
LimitNOFILE = 65535

Restart=on-failure

RestartPreventExitStatus=1

PrivateTmp=false

让systemctl加载配置服务

shell> systemctl daemon-reload
shell> systemctl enable mysqld.service
shell> systemctl is-enabled mysqld

10.启动MySQL服务

shell> systemctl start mysqld.service 

11.MySQL用户初始化

重置密码(上一步已经重置过了 这次可以忽略)
删除匿名用户
关闭root用户的远程登录
删除测试数据库

shell> /usr/local/mysql/bin/mysql_secure_installation

Securing the MySQL server deployment.

Enter password for user root: 

The existing password for the user account root has expired. Please set a new password.

New password: 

Re-enter new password: 

VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?

Press y|Y for Yes, any other key for No: Y

There are three levels of password validation policy:

LOW    Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary                  file

Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 2
Using existing password for root.

Estimated strength of the password: 100 
Change the password for root ? ((Press y|Y for Yes, any other key for No) : N

 ... skipping.
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : Y
Success.


Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : Y
Success.

By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.


Remove test database and access to it? (Press y|Y for Yes, any other key for No) : Y
 - Dropping test database...
Success.

 - Removing privileges on test database...
Success.

Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y
Success.

All done!

12.导入时区

shell> mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root -p mysql

13.验证安装

shell> mysqladmin version -u root -p
参考

1.https://www.jianshu.com/p/0d628b2f7476
2.https://dev.mysql.com/doc/refman/5.7/en/binary-installation.html

Centos7.7安装mysql5.7.28二进制包方式部署 1、安装依赖包 yum -y install libaio 2、安装mysql软件 下载软件包:https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.28-linux-glibc2.12-x86_64.tar.gz tar -xzvf mysql-5.7.28-linux-glibc2.12-x86_64.tar.gz ... 阅读详情

相关推荐

Linux普通用户安装mysql-5.7.21

Linux普通用户安装mysql-5.7.21 工作中一直在用mysql,但是研究不够深入,由于现有MySQL数据库所在主机资源比较紧张,如果出现单点故障,对业务影响将会比较大。所以,一方面需要迁移到新的主机上,另一方面,希望通过mysql主从复制的方式,实现高可用的解决方案。 经过资源申请,平台架构部提供了两台主机,经过资源评估后,发现有两个问题:一个是两台主机已经安装了mysql数据库,另...

tianpy5的博客 1万+

CentOS7用二进制安装MySQL5.7

以上步骤即可完成在CentOS 7上通过二进制包安装MySQL 5.7。

高性价比服务器就选:蓝易云 697

mysql5.7.24安装,在centos7下,我已经整理好所有步骤和所有需要的包

我写好了安装脚本,在文件夹soft下,你把soft上传home下,对立里面nstall-full.sh给权限,直接./install-full.sh执行即可;对centos7系统我已经试过很多次,我把所有依赖包都下载了,不需要yum,因为有的项目实施没外网也没挂在镜像你就没法yum,所以我都整理好了。

mysql5.7二进制安装(centos7)

本文演示centos7下二进制安装mysql。 下载 建议百度网盘下载,或者:https://www.cnblogs.com/uncleyong/p/13785675.html 解压 tar -zxvf mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz 移动并改名 移动到/usr/local下,并改名为mysql:mv mysql-5.7.26-linux-...

全栈测试笔记 911

CentOS7安装mysql5.7.19&mysql5;.7.19主从配置(CentOS7)

CentOS7安装mysql5.7.19 & mysql5.7.19主从配置(CentOS7)

CentOS7下安装MySQL5.7安装与配置

安装环境:CentOS7 64位 MINI版,安装MySQL5.7 同一个主机、不同显示器、连接多个键盘鼠标、多用户、多桌面同时操作

CentOs 7 安装mysql5.7(二进制版本)

1、下载二进制版本安装包。这里以 5.7.11 版本为例。 2、我装在/var/local目录下面,把下载的mysql包放在这个文件夹下面,执行以下命令,期间建立一个mysql的软连接。# tar -zxvf mysql-5.7.12-linux-glibc2.5-x86_64.tar.gz # ln -s mysql-5.7.12-linux-glibc2.5-x86_64 mysql # c

fengabner的专栏 3663

mysql二进制包

Mysql二进制包文件,包含三种配置内容。适用于LINUX系统

test markdown

1.下载安装包 下载地址 https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz 安装文档 https://dev.mysql.com/doc/refman/5.7/en/binary-installation.html 2.创建用户和组 groupadd mysql user...

weixin_33877885的博客 163

Linux中安装MySql 5.7.21的详细操作步骤

主要给大家介绍了关于在Linux中安装MySql 5.7.21的详细操作步骤,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧。

CANOE仿真someip报文配置说明

利用canoe测试车辆控制器someip报文收发的步骤

AUTOSAR架构汽车软件开发 1万+

二进制安装 MySQL8.0(v2.0)

时隔几个月后,又重新装了一遍 MySQL 思路比之前清晰多了。虽然还有不足之处,但比之前好多了,写个教程备忘一下。此教程已经写的尽量详细了,但读者最好还是有一点点 Linux 基础。如果想省事情,可以直接选择用包管理器一键安装。

vatebur的博客 688

极验滑块验证码破解与研究(一):AST还原混淆JS

极验滑块验证码破解与研究(一):AST还原混淆JS声明一、环境安装1. node安装1.1. node下载1.2. 配置环境变量1.3. node安装检测1.4. pycharm配置node环境2. babel库安装2.1. babel库安装命令2.2. babel库安装检测二、AST还原混淆JS1. 模块导入2. AST还原流程3. 复制还原需要用到的js源码4. AST还原函数详解4.1. replace_unicode4.2. replace_unicode, replace_name_array,

帯泪的鱼的博客 1万+

mysql 5.7.21 二进制_Centos7.4 安装MySQL 5.7.21 (通用二进制包)

1.下载安装包本文完全按照官方步骤配置安装wget --no-check-certificate https://dev.mysql.com//Downloads/MySQL-5.7/mysql-5.7.21-linux-glibc2.12-x86_64.tar.gz2.安装依赖包MySQL依赖于libaio 库。如果这个库没有在本地安装,数据目录初始化和后续的服务器启动步骤将会失败。请使用适当的...

weixin_34684706的博客 225

更多 LSTM 变种——应用于 CMAPSS 数据集

本文并模型介绍,只是把一些比较火的技术,像双向注意力机制,自注意力机制这样的比较火的内容,简单的和LSTM堆叠,结果发现效果都不如最基础的,这里作者将本人代码及实现结果,进行展示,给各位想更改LSTM的朋友一些。

2301_77491330的博客 1817

(12)单相降压自耦变压器的等效电路和仿真模型

本文根据电机学基本原理,从单相双绕组变压器的接线方式出发,建立基本方程并导出T型等效电路。然后将双绕组变压器演变成一种降压自耦变压器,详细地建立起单相降压自耦变压器的数学模型以及导出相对应的等效电路,最后用Matlab/simulink的simscape元件库元件建立了基于单相自耦变压器的T型等效电路的仿真模型。用实例仿真验证了本文工作的正确性。

weixin_45670943的博客 1052

centos7上如何安装Mysql5.5数据库?

centos7上如何安装Mysql5.5数据库?

2409_89014517的博客 1959

【ESP32CAM+Android+OpenCV】自定义目标数据集、训练自己的OpenCV模型部署到手机APP并对ESP32CAM无线图传显示并实时检测识别目标_资料编号30

本项目实现自定义目标数据集(想检测什么就检测什么,按照本文教程自己来更换目标)、训练自己的OpenCV模型实时检测识别(pycharm工程)。手机APP(Android studio工程)部署OpenCV模型实现对ESP32CAM(arduino工程)无线WIFI图传过来的图像实时检测识别。 本文以火焰检测识别为例进行演示,通过该过程,结合本文可自定义尝试更换为其它目标的检测,例如更换为车辆、车牌、手势、人脸面部活动、人脸表情、火焰烟雾、行人、口罩、行为、水果、植物、农作物、建筑、损伤等等部署进行检测。

嵌入式阿齐Archie 3501

Linux二进制包安装MySQL 5.7的步骤

原文地址:https://zhangnq.com/3018.html MySQL 5.7提供二进制包的安装,相比yum安装麻烦点,但相比编译安装还是会方便很多。二进制包不需要自行编译mysql源码,瞎下载后可直接使用,绿色版安装。二进制包安装也和编译一样,可以灵活指定需要的MySQL版本。下面就以centos系统为例安装。 一、下载MySQL 5.7二进制包 下载页面:https://dev...

章郎虫的专栏 3809

Linux驱动学习--HCI框架及源码分析

目录 一、引言 二、HCI框架 三、pcm_read简要分析 一、引言 最近一直在分析蓝牙驱动,发现在底层驱动与上层协议栈间还有一层HCI,主机控制层,两者之间通过HCI协议通讯 而Linux也将HCI协议抽象层了一个框架。 为上层提供一个统一的接口,让上层协议不依赖于具体硬件的实现。HCI在硬件中的固件与HCI在主机端的驱动通信方式有多种,比如像 UART、USB和PC Card等等。hci_core.c相当于一个框架,用于把各种具体通信方式绞合起来,并提供一些公共函数的实现。 今天就来简单的分析一下 二

文艺小少年的博客 2012

机器学习实战4-教育领域:学生成绩的可视化分析与成绩预测-详细分析

大家好,我是微学AI,今天给大家带来机器学习实战4-学生成绩的可视化分析与成绩预测,机器学习在教育中的应用具有很大的潜力,特别是在学生成绩的可视化分析与成绩预测方面。机器学习可以通过对学生的父母教育情况和学校表现等数据进行分析和挖掘,从而揭示潜在的学习模式和趋势。

微学AI的博客 7695

centos7通用二进制包安装mysql5.7

**从5.7.18开始support-files就没有my.cnf的模板了,所以要自己写了**1、删除mariadb和以前安装的mysql1.1卸载系统自带的Mariadb:rpm -qa | grep mariadbrpm -e --nodeps  查到的mariadb文件名1.2卸载已安装的mysql:rpm -qa | grep -i mysqlrpm -e --nodeps 查到的mysq...

vzdong1的博客 1795

【ARM CoreLink 系列 7 -- TZC-400控制器简介】

为了确保内存能够正确识别总线的信号控制位,新增一个TrustZone地址空间控制器(TrustZone Address Space Controller,TZASC)组件来实现对内存地址的安全扩展,将内存区域划分为安全内存区域和非安全内存区域,安全世界可以访问安全内存和非安全内存,而普通世界只能访问非安全内存,如下图所示:图 1-1内存区域的划分是在系统启动时通过配置 TZASC 组件(TZC-400/TZC-380)来实现的。TZC-400由和使能情况;安全访问权限;Base地址;

CodingCos的博客 1643

在CentOS7上二进制包安装MySQL5.6

文章目录CentOS7上二进制包安装MySQL5.6一、下载MySQL5.6二进制包二、主机方面的优化MySQL安装三、安装MySQL5.6二进制安装包 CentOS7上二进制包安装MySQL5.6 平时工作中都会用到MySQL,所以本次分享通过二进制包的形式安装MySQL5.6的方法 一、下载MySQL5.6二进制包 打开mysql的官网www.mysql.com,点击"DOWNLOADS...

sonoface的专栏 715

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

蓝牙模块HM-10手册

蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。

centos7下MySQL的安装(通用二进制安装)

本篇博客是为下面安装hive做准备 MySQL安装的方法有三种(这里采用通用二进制安装) (29条消息) CentOS7安装MySQL的几种方法_神圣罗马帝国的博客-CSDN博客_centos7安装mysql的步骤和方法 下载MySQL在官网下载太慢了 MySQL官网下载太慢的解决方法_thm的博客-CSDN博客_mysql下载很慢 下载后通过xftp传至虚拟机(这里我还是跟之前一样传至/usr/local/tmp下) tar -zxf mysql-5.7.27-linux-glibc2.12.

qq_45672631的博客 2325

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

上一篇: nginx服务器安装启动及配置文件详解
菜团886
博客等级 码龄16年 2粉丝 3原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值