CentOS7.4下MySQL5.7.28源码方式安装
发表于:2025-11-07 作者:千家信息网编辑
千家信息网最后更新 2025年11月07日,Linux系统版本:CentOS7.4MySQL版本:5.7.28在Linux平台有RPM包、二进制包、源码包3中安装方式,这一篇文章主要是以源码包为例来介绍如何在Linux平台下进行MySQL的安装
千家信息网最后更新 2025年11月07日CentOS7.4下MySQL5.7.28源码方式安装
Linux系统版本:CentOS7.4
MySQL版本:5.7.28
在Linux平台有RPM包、二进制包、源码包3中安装方式,这一篇文章主要是以源码包为例来介绍如何在Linux平台下进行MySQL的安装。
下载地址:https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-boost-5.7.28.tar.gz
国内镜像:http://mirrors.163.com/mysql/Downloads/MySQL-5.7/mysql-boost-5.7.28.tar.gz
具体安装步骤如下:
(1)首先卸载mariadb,不然后面会和安装mysql需要的库冲突:
[root@localhost ~]# rpm -qa | grep mariadbmariadb-libs-5.5.56-2.el7.x86_64[root@localhost ~]# rpm -e --nodeps mariadb-libs-5.5.56-2.el7.x86_64(2)创建mysql用户和用户组:
[root@localhost ~]# groupadd mysql[root@localhost ~]# useradd -r -g mysql -s /bin/false mysql(3)创建MySQL安装目录和data目录:
[root@localhost ~]# mkdir /opt/mysql[root@localhost ~]# mkdir -p /data/mysql[root@localhost ~]# chown mysql:mysql /opt/mysql[root@localhost ~]# chown mysql:mysql /data/mysql(4)安装相关依赖:
[root@localhost ~]#yum install -y cmake make gcc gcc-c++ ncurses-devel openssl-devel (4)编译安装:
[root@localhost ~]# tar -xvf mysql-boost-5.7.28.tar.gz[root@localhost mysql-5.7.28]# cmake \-DCMAKE_INSTALL_PREFIX=/opt/mysql \-DMYSQL_DATADIR=/data/mysql \-DMYSQL_USER=mysql \-DWITH_INNOBASE_STORAGE_ENGINE=1 \-DWITH_ARCHIVE_STORAGE_ENGINE=1 \-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \-DWITH_READLINE=1 -DDOWNLOAD_BOOST=1 \-DWITH_BOOST=/root/mysql-5.7.28/boost/boost_1_59_0/ \-DMYSQL_DATADIR=/data/mysql \-DWITH_SSL=system[root@localhost ~]#make && make install(5)初始化MySQL:
[root@localhost ~]# cd /opt/mysql/[root@localhost mysql]# ./bin/mysqld --initialize --user=mysql --basedir=/opt/mysql --datadir=/data/mysql2019-12-01T02:33:14.303069Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).2019-12-01T02:33:16.484507Z 0 [Warning] InnoDB: New log files created, LSN=457902019-12-01T02:33:16.735058Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.2019-12-01T02:33:16.816435Z 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: ee34514d-13e2-11ea-b534-000c29647ed4.2019-12-01T02:33:16.818202Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.2019-12-01T02:33:17.277339Z 0 [Warning] CA certificate ca.pem is self signed.2019-12-01T02:33:17.415078Z 1 [Note] A temporary password is generated for root@localhost: og5Q0qgu6;Ui生成临时密码为:og5Q0qgu6;Ui
(6)修改MySQL配置文件/etc/my.cnf,保存退出:
[root@localhost mysql]# vim /etc/my.cnf[mysqld]datadir=/data/mysqlsocket=/data/mysql/mysql.sockuser=mysqlport=3306default-storage-engine=InnoDB[mysqld_safe]log-error=/data/mysql/mysql-error.logpid-file=/data/mysql/mysqld.pid[client]socket=/data/mysql/mysql.sock(7)启动MySQL:
[root@localhost mysql]# bin/mysqld_safe --user=mysql &(8)配置环境变量:
[root@localhost ~]# vim /etc/profile#添加下面一行export PATH=/opt/mysql/bin:$PATH[root@localhost ~]# source /etc/profile(9)登录并修改MySQL管理员密码:
[root@localhost mysql]# mysql -uroot -pEnter password:Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 3Server version: 5.7.28Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> set password = PASSWORD('root123456');Query OK, 0 rows affected, 1 warning (0.00 sec)(10)配置原程登录:
mysql> grant all privileges on *.* to root@'%' identified by 'root123456';Query OK, 0 rows affected, 1 warning (0.00 sec)mysql> flush privileges;Query OK, 0 rows affected (0.00 sec)
配置
源码
密码
平台
版本
用户
目录
登录
方式
一行
二进制
变量
地址
文件
步骤
环境
用户组
管理员
篇文章
系统
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
莆田网络技术推广平台
网络安全培训基地二期
公开网络安全风险
东丽区信息网络技术质量保证
湖北应用软件开发服务费
至强服务器cpu
数据库中的数据表如何建立
数据库 行转列 列转行详解
华为pnf基础软件开发
itms服务器
河北云服务器云主机云空间
设备网络安全工程师
衡水营销软件开发公司电话
计算机网络安全测评师
网络安全作文电子版
抓鸡ftp服务器
数据库中插入表用的语句
算王无锁版连接不到服务器
数据库系统原理一课一文
win10磁贴数据库
沈阳尖峰软件开发骗局
java数据库高阶面试题
达芬奇无法安装数据库
各种软件开发模型的例子
网络技术管理员报名
mysql 上传数据库
数据库技术根本目标
前端软件开发哪家可靠
安全教育平台服务器卡
黑龙江破坏网络安全罪