CentOS7.4下MySQL5.7.28二进制方式安装的方法步骤

Linux系统版本:CentOS7.4

MySQL版本:5.7.28

在Linux平台有RPM包、二进制包、源码包3中安装方式,这一篇文章主要是以RPM包为例来介绍如何在Linux平台下进行MysqL的安装。

下载地址:

https://cdn.MysqL.com//Downloads/MysqL-5.7/MysqL-5.7.28-linux-glibc2.12-x86_64.tar.gz

CentOS7.4下MySQL5.7.28二进制方式安装的方法步骤


具体安装步骤如下:

(1)首先卸载mariadb,不然后面会和安装MysqL需要的库冲突:

[root@localhost ~]# rpm -qa | grep mariadb
mariadb-libs-5.5.56-2.el7.x86_64
[root@localhost ~]# rpm -e --nodeps mariadb-libs-5.5.56-2.el7.x86_64

(2)用root用户登录系统,增加MysqL用户和组,数据库安装在此用户下:

[root@localhost ~]# groupadd MysqL
[root@localhost ~]# useradd -r -g MysqL -s /bin/false MysqL

(3)准备数据目录

以/app/data为例,建议使用逻辑卷

[root@localhost ~]# mkdir -p /app/data
[root@localhost ~]# chown MysqL.MysqL /app/data/
[root@localhost ~]# chmod 750 /app/data

(4)准备二进制文件

[root@localhost ~]# tar xvf MysqL-5.7.28-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
root@localhost ~]# cd /usr/local
[root@localhost local]# ln -sv MysqL-5.7.28-linux-glibc2.12-x86_64 MysqLMysqL' -> ‘MysqL-5.7.28-linux-glibc2.12-x86_64'

(5)初始化MysqL

[root@localhost ~]# cd /usr/local/MysqL
[root@localhost MysqL]# bin/MysqLd --initialize --user=MysqL --basedir=/usr/local/MysqL --datadir=/app/data
2019-11-03T09:47:18.263716Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2019-11-03T09:47:19.059462Z 0 [Warning] InnoDB: New log files created, LSN=45790
2019-11-03T09:47:19.140866Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2019-11-03T09:47:19.207569Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: ed1cd8ec-fe1e-11e9-8c9c-000c29f8617a.
2019-11-03T09:47:19.209181Z 0 [Warning] Gtid table is not ready to be used. Table 'MysqL.gtid_executed' cannot be opened.
2019-11-03T09:47:19.646366Z 0 [Warning] CA certificate ca.pem is self signed.
2019-11-03T09:47:20.056792Z 1 [Note] A temporary password is generated for root@localhost: rY-6f??#!<zO

其中--basedir MysqL基础目录 --datadir MysqL数据存放目录,并创建了root用户的临时密码:rY-6f??#!<zO

(6)开启ssl连接:

[root@localhost MysqL]# bin/MysqL_ssl_rsa_setup
2019-11-03 23:09:55 [ERROR]  Failed to access directory pointed by --datadir. Please make sure that directory exists and is accessible by MysqL_ssl_rsa_setup. Supplied value : /usr/local/MysqL/data
[root@localhost MysqL]# bin/MysqL_ssl_rsa_setup --datadir=/app/data

命令后面不加参数报错,加了--datadir后不报错

(7)编辑配置文件,保存退出

[root@localhost MysqL]# vim /etc/my.cnf
[MysqLd]
# GENERAL
datadir=/app/data
socket=/app/data/MysqL.sock
user=MysqL
default-storage-engine=InnoDB

[MysqLd_safe]
log-error=/app/data/MysqL-error.log
pid-file=/app/data/MysqLd.pid

[client]
socket=/app/data/MysqL.sock

(8)启动MysqL

[root@localhost MysqL]# bin/MysqLd_safe --user=MysqL &

(9)配置环境变量:

[root@localhost ~]# vim /etc/profile
#添加下面一行
export PATH=$PATH:/usr/local/MysqL/bin
[root@localhost ~]# source /etc/profile

(10)设置开机启动:

[root@localhost MysqL]# cp support-files/MysqL.server /etc/init.d/MysqL.server
[root@localhost MysqL]# chkconfig --add MysqL.server

(11)测试登录成功:

[root@localhost ~]# MysqL -uroot -p
Enter password:
Welcome to the MysqL monitor. Commands end with ; or \g.
Your MysqL connection id is 2
Server version: 5.7.28

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.

MysqL>

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持编程之家。

相关文章

今天小编给大家分享一下excel图案样式如何设置的相关知识点,...
这篇文章主要讲解了“win10设置过的壁纸如何删除”,文中的讲...
这篇“Xmanager怎么显示远程linux程序的图像”文章的知识点大...
今天小编给大家分享一下xmanager怎么连接linux的相关知识点,...
这篇“如何重置Linux云服务器的远程密码”文章的知识点大部分...
本篇内容介绍了“Linux云服务器手动配置DNS的方法是什么”的...