当前位置:网站首页>数据库系统原理与应用教程(006)—— 编译安装 MySQL5.7(Linux 环境)
数据库系统原理与应用教程(006)—— 编译安装 MySQL5.7(Linux 环境)
2022-07-01 16:14:00 【睿思达DBA_WGX】
数据库系统原理与应用教程(006)—— 编译安装 MySQL5.7(Linux 环境)
目录
一、下载 MySQL 安装包
1、进入 MySQL官网(网址:https://www.mysql.com/),单击 DOWNLOADS,如下图所示。

2、在页面的下方【DOWNLOADS】区域中选择【MySQL Community Server】,如下图所示。

3、在弹出的页面中单击【Archives】,如下图所示。

4、在弹出的页面中选择 MySQL 的版本号(5.7.25)、操作系统的类型(Source Code)以及操作系统的版本(All Operating System(Generic)(Architecture Independent))。MySQL5.7 编译安装需要 boost 库,选择包含 boost 的源码包,如下图所示。

二、安装所需的依赖包
1、下载所需的依赖包
[[email protected] pack]# yum install -y make cmake gcc gcc-c++ bison bison-devel ncurses ncurses-devel autoconf automake --downloadonly --downloaddir=/soft/pack
[[email protected] pack]# pwd
/soft/pack
[[email protected] pack]# ll
总用量 82764
-rw-r--r--. 1 root root 717912 7月 4 2014 autoconf-2.69-11.el7.noarch.rpm
-rw-r--r--. 1 root root 695620 7月 4 2014 automake-1.13.4-3.el7.noarch.rpm
-rw-r--r--. 1 root root 690564 11月 12 2018 bison-3.0.4-2.el7.x86_64.rpm
-rw-r--r--. 1 root root 24144 11月 12 2018 bison-devel-3.0.4-2.el7.x86_64.rpm
-rw-r--r--. 1 root root 7392732 11月 21 2016 cmake-2.8.12.2-2.el7.x86_64.rpm
-rw-r--r--. 1 root root 6230552 10月 15 2020 cpp-4.8.5-44.el7.x86_64.rpm
-rw-r--r--. 1 root root 16963328 10月 15 2020 gcc-4.8.5-44.el7.x86_64.rpm
-rw-r--r--. 1 root root 7531804 10月 15 2020 gcc-c++-4.8.5-44.el7.x86_64.rpm
-rw-r--r--. 1 root root 3817244 5月 19 20:50 glibc-2.17-326.el7_9.x86_64.rpm
-rw-r--r--. 1 root root 12059896 5月 19 20:50 glibc-common-2.17-326.el7_9.x86_64.rpm
-rw-r--r--. 1 root root 1128524 5月 19 20:50 glibc-devel-2.17-326.el7_9.x86_64.rpm
-rw-r--r--. 1 root root 707512 5月 19 20:50 glibc-headers-2.17-326.el7_9.x86_64.rpm
-rw-r--r--. 1 root root 9496636 5月 19 20:50 kernel-headers-3.10.0-1160.66.1.el7.x86_64.rpm
-rw-r--r--. 1 root root 326848 1月 29 2020 libarchive-3.1.2-14.el7_7.x86_64.rpm
-rw-r--r--. 1 root root 105308 10月 15 2020 libgcc-4.8.5-44.el7.x86_64.rpm
-rw-r--r--. 1 root root 162384 10月 15 2020 libgomp-4.8.5-44.el7.x86_64.rpm
-rw-r--r--. 1 root root 51732 7月 4 2014 libmpc-1.0.1-3.el7.x86_64.rpm
-rw-r--r--. 1 root root 313196 10月 15 2020 libstdc++-4.8.5-44.el7.x86_64.rpm
-rw-r--r--. 1 root root 1581424 10月 15 2020 libstdc++-devel-4.8.5-44.el7.x86_64.rpm
-rw-r--r--. 1 root root 262480 11月 25 2015 m4-1.4.16-10.el7.x86_64.rpm
-rw-r--r--. 1 root root 430712 8月 23 2019 make-3.82-24.el7.x86_64.rpm
-rw-r--r--. 1 root root 208316 7月 4 2014 mpfr-3.1.1-4.el7.x86_64.rpm
-rw-r--r--. 1 root root 310928 9月 7 2017 ncurses-5.9-14.20130511.el7_4.x86_64.rpm
-rw-r--r--. 1 root root 69900 9月 7 2017 ncurses-base-5.9-14.20130511.el7_4.noarch.rpm
-rw-r--r--. 1 root root 729508 9月 7 2017 ncurses-devel-5.9-14.20130511.el7_4.x86_64.rpm
-rw-r--r--. 1 root root 323192 9月 7 2017 ncurses-libs-5.9-14.20130511.el7_4.x86_64.rpm
-rw-r--r--. 1 root root 8360316 2月 4 2021 perl-5.16.3-299.el7_9.x86_64.rpm
-rw-r--r--. 1 root root 19672 7月 4 2014 perl-Carp-1.26-244.el7.noarch.rpm
-rw-r--r--. 1 root root 19244 7月 4 2014 perl-constant-1.27-2.el7.noarch.rpm
-rw-r--r--. 1 root root 48296 7月 4 2014 perl-Data-Dumper-2.145-3.el7.x86_64.rpm
-rw-r--r--. 1 root root 1545440 7月 4 2014 perl-Encode-2.51-7.el7.x86_64.rpm
-rw-r--r--. 1 root root 29092 7月 4 2014 perl-Exporter-5.68-3.el7.noarch.rpm
-rw-r--r--. 1 root root 27088 7月 4 2014 perl-File-Path-2.09-2.el7.noarch.rpm
-rw-r--r--. 1 root root 57680 7月 4 2014 perl-File-Temp-0.23.01-3.el7.noarch.rpm
-rw-r--r--. 1 root root 78236 7月 4 2014 perl-Filter-1.49-3.el7.x86_64.rpm
-rw-r--r--. 1 root root 57176 4月 25 2018 perl-Getopt-Long-2.40-3.el7.noarch.rpm
-rw-r--r--. 1 root root 39292 7月 4 2014 perl-HTTP-Tiny-0.033-3.el7.noarch.rpm
-rw-r--r--. 1 root root 706128 2月 4 2021 perl-libs-5.16.3-299.el7_9.x86_64.rpm
-rw-r--r--. 1 root root 45324 2月 4 2021 perl-macros-5.16.3-299.el7_9.x86_64.rpm
-rw-r--r--. 1 root root 12592 7月 4 2014 perl-parent-0.225-244.el7.noarch.rpm
-rw-r--r--. 1 root root 84468 7月 4 2014 perl-PathTools-3.40-5.el7.x86_64.rpm
-rw-r--r--. 1 root root 53064 2月 4 2021 perl-Pod-Escapes-1.04-299.el7_9.noarch.rpm
-rw-r--r--. 1 root root 114320 7月 4 2014 perl-podlators-2.5.1-3.el7.noarch.rpm
-rw-r--r--. 1 root root 88756 7月 4 2014 perl-Pod-Perldoc-3.20-4.el7.noarch.rpm
-rw-r--r--. 1 root root 221216 7月 4 2014 perl-Pod-Simple-3.28-4.el7.noarch.rpm
-rw-r--r--. 1 root root 27436 7月 4 2014 perl-Pod-Usage-1.63-3.el7.noarch.rpm
-rw-r--r--. 1 root root 36808 7月 4 2014 perl-Scalar-List-Utils-1.27-248.el7.x86_64.rpm
-rw-r--r--. 1 root root 49868 4月 4 2020 perl-Socket-2.010-5.el7.x86_64.rpm
-rw-r--r--. 1 root root 78888 7月 4 2014 perl-Storable-2.45-3.el7.x86_64.rpm
-rw-r--r--. 1 root root 309212 8月 12 2015 perl-Test-Harness-3.28-3.el7.noarch.rpm
-rw-r--r--. 1 root root 14056 7月 4 2014 perl-Text-ParseWords-3.29-4.el7.noarch.rpm
-rw-r--r--. 1 root root 17448 7月 4 2014 perl-Thread-Queue-3.02-2.el7.noarch.rpm
-rw-r--r--. 1 root root 50392 7月 4 2014 perl-threads-1.87-4.el7.x86_64.rpm
-rw-r--r--. 1 root root 39868 7月 4 2014 perl-threads-shared-1.43-6.el7.x86_64.rpm
-rw-r--r--. 1 root root 46304 7月 4 2014 perl-Time-HiRes-1.9725-3.el7.x86_64.rpm
-rw-r--r--. 1 root root 24792 7月 4 2014 perl-Time-Local-1.2300-2.el7.noarch.rpm
2、安装依赖包
[[email protected] pack]# rpm -ivh --nodeps --force *.rpm
警告:autoconf-2.69-11.el7.noarch.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
准备中... ################################# [100%]
正在升级/安装...
1:libgcc-4.8.5-44.el7 ################################# [ 2%]
2:glibc-common-2.17-326.el7_9 ################################# [ 4%]
3:glibc-2.17-326.el7_9 警告:/etc/nsswitch.conf 已建立为 /etc/nsswitch.conf.rpmnew
################################# [ 5%]
4:perl-parent-1:0.225-244.el7 ################################# [ 7%]
5:perl-HTTP-Tiny-0.033-3.el7 ################################# [ 9%]
6:perl-podlators-2.5.1-3.el7 ################################# [ 11%]
7:perl-Pod-Perldoc-3.20-4.el7 ################################# [ 13%]
8:perl-Pod-Escapes-1:1.04-299.el7_9################################# [ 14%]
9:perl-Text-ParseWords-3.29-4.el7 ################################# [ 16%]
10:perl-Encode-2.51-7.el7 ################################# [ 18%]
11:perl-Pod-Usage-1.63-3.el7 ################################# [ 20%]
12:perl-constant-1.27-2.el7 ################################# [ 21%]
13:perl-Carp-1.26-244.el7 ################################# [ 23%]
14:perl-Exporter-5.68-3.el7 ################################# [ 25%]
15:perl-Filter-1.49-3.el7 ################################# [ 27%]
16:perl-libs-4:5.16.3-299.el7_9 ################################# [ 29%]
17:perl-macros-4:5.16.3-299.el7_9 ################################# [ 30%]
18:perl-File-Path-2.09-2.el7 ################################# [ 32%]
19:perl-File-Temp-0.23.01-3.el7 ################################# [ 34%]
20:perl-PathTools-3.40-5.el7 ################################# [ 36%]
21:perl-Scalar-List-Utils-1.27-248.e################################# [ 38%]
22:perl-Socket-2.010-5.el7 ################################# [ 39%]
23:perl-Storable-2.45-3.el7 ################################# [ 41%]
24:perl-threads-1.87-4.el7 ################################# [ 43%]
25:perl-threads-shared-1.43-6.el7 ################################# [ 45%]
26:perl-Pod-Simple-1:3.28-4.el7 ################################# [ 46%]
27:perl-Getopt-Long-2.40-3.el7 ################################# [ 48%]
28:perl-Time-Local-1.2300-2.el7 ################################# [ 50%]
29:perl-Time-HiRes-4:1.9725-3.el7 ################################# [ 52%]
30:perl-4:5.16.3-299.el7_9 ################################# [ 54%]
31:libstdc++-4.8.5-44.el7 ################################# [ 55%]
32:mpfr-3.1.1-4.el7 ################################# [ 57%]
33:libmpc-1.0.1-3.el7 ################################# [ 59%]
34:m4-1.4.16-10.el7 ################################# [ 61%]
35:cpp-4.8.5-44.el7 ################################# [ 63%]
36:libstdc++-devel-4.8.5-44.el7 ################################# [ 64%]
37:perl-Data-Dumper-2.145-3.el7 ################################# [ 66%]
38:autoconf-2.69-11.el7 ################################# [ 68%]
39:perl-Test-Harness-3.28-3.el7 ################################# [ 70%]
40:perl-Thread-Queue-3.02-2.el7 ################################# [ 71%]
41:libarchive-3.1.2-14.el7_7 ################################# [ 73%]
42:libgomp-4.8.5-44.el7 ################################# [ 75%]
43:ncurses-base-5.9-14.20130511.el7_################################# [ 77%]
44:ncurses-libs-5.9-14.20130511.el7_################################# [ 79%]
45:kernel-headers-3.10.0-1160.66.1.e################################# [ 80%]
46:glibc-headers-2.17-326.el7_9 ################################# [ 82%]
47:glibc-devel-2.17-326.el7_9 ################################# [ 84%]
48:gcc-4.8.5-44.el7 ################################# [ 86%]
49:gcc-c++-4.8.5-44.el7 ################################# [ 88%]
50:cmake-2.8.12.2-2.el7 ################################# [ 89%]
51:ncurses-5.9-14.20130511.el7_4 ################################# [ 91%]
52:ncurses-devel-5.9-14.20130511.el7################################# [ 93%]
53:automake-1.13.4-3.el7 ################################# [ 95%]
54:bison-3.0.4-2.el7 ################################# [ 96%]
55:make-1:3.82-24.el7 ################################# [ 98%]
56:bison-devel-3.0.4-2.el7 ################################# [100%]
三、配置安装环境
1、修改 /etc/hosts 文件内容如下
[[email protected] pack]# vi /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
10.1.1.7 mysql
2、永久关闭 selinux
[[email protected] pack]# vi /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled # 把 SELINUX 选项的值修改为 disabled
# SELINUXTYPE= can take one of three two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
[[email protected] pack]# setenforce 0
3、永久关闭防火墙
[[email protected] pack]# systemctl stop firewalld
[[email protected] pack]# systemctl disable firewalld
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.
四、创建所需的目录,添加用户和组并配置环境变量
1、创建用户和组
groupadd mysql
useradd mysql -s /sbin/nologin -M -g mysql
#====================================================================
[[email protected] pack]# groupadd mysql
[[email protected] pack]# useradd mysql -s /sbin/nologin -M -g mysql
[[email protected] pack]# id mysql
uid=1000(mysql) gid=1000(mysql) 组=1000(mysql)
2、创建所需的目录并修改权限
# 1、MySQL 执行文件目录:把编译好的 mysql 程序安装到这个目录
mkdir -p /usr/local/mysql/
chown mysql:mysql /usr/local/mysql/
#====================================================================
[[email protected] pack]# mkdir -p /usr/local/mysql/
[[email protected] pack]# chown mysql:mysql /usr/local/mysql/
[[email protected] pack]# ll /usr/local/
总用量 0
drwxr-xr-x. 2 root root 6 11月 5 2016 bin
drwxr-xr-x. 2 root root 6 11月 5 2016 etc
drwxr-xr-x. 2 root root 6 11月 5 2016 games
drwxr-xr-x. 2 root root 6 11月 5 2016 include
drwxr-xr-x. 2 root root 6 11月 5 2016 lib
drwxr-xr-x. 2 root root 6 11月 5 2016 lib64
drwxr-xr-x. 2 root root 6 11月 5 2016 libexec
drwxr-xr-x. 2 mysql mysql 6 7月 1 06:23 mysql
drwxr-xr-x. 2 root root 6 11月 5 2016 sbin
drwxr-xr-x. 5 root root 49 6月 23 18:14 share
drwxr-xr-x. 2 root root 6 11月 5 2016 src
mkdir -p /home/mysql/data
mkdir -p /home/mysql/logs
mkdir -p /home/mysql/temp
chown mysql:mysql /home/mysql/*
#============================================================
# 2、MySQL 数据文件目录
[[email protected] pack]# mkdir -p /home/mysql/data
# 3、MySQL 日志目录
[[email protected] pack]# mkdir -p /home/mysql/logs
[[email protected] pack]# mkdir -p /home/mysql/temp
# 4、修改目录的所有者
[[email protected] pack]# chown mysql:mysql /home/mysql/*
[[email protected] pack]# ll /home/mysql
总用量 0
drwxr-xr-x. 2 mysql mysql 6 7月 1 06:24 data
drwxr-xr-x. 2 mysql mysql 6 7月 1 06:24 logs
drwxr-xr-x. 2 mysql mysql 6 7月 1 06:24 temp
3、配置环境变量
在 /etc/profile 文件的结尾添加如下内容:
[[email protected] pack]# vi /etc/profile
unset -f pathmunge
..........
export PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH
[[email protected] pack]# source /etc/profile
五、编译安装 MySQL 5.7
1、上传安装文件
[[email protected] soft]# pwd
/soft
[[email protected] soft]# ll
总用量 47966
drwxr-xr-x. 8 root root 2048 12月 5 2016 cdrom
-rw-r--r--. 1 root root 49107578 6月 30 14:41 mysql-boost-5.7.25.tar.gz
drwxr-xr-x. 2 root root 4096 7月 1 06:18 pack
2、解压缩安装文件
[[email protected] soft]# tar -zxvf mysql-boost-5.7.25.tar.gz
[[email protected] soft]# ll
总用量 47970
drwxr-xr-x. 8 root root 2048 12月 5 2016 cdrom
drwxr-xr-x. 36 7161 31415 4096 12月 21 2018 mysql-5.7.25
-rw-r--r--. 1 root root 49107578 6月 30 14:41 mysql-boost-5.7.25.tar.gz
drwxr-xr-x. 2 root root 4096 7月 1 06:18 pack
[[email protected] soft]# cd mysql-5.7.25/
[[email protected] mysql-5.7.25]# ll
总用量 280
drwxr-xr-x. 3 7161 31415 26 12月 21 2018 boost
drwxr-xr-x. 2 7161 31415 4096 12月 21 2018 BUILD
drwxr-xr-x. 6 7161 31415 4096 12月 21 2018 client
drwxr-xr-x. 4 7161 31415 4096 12月 21 2018 cmake
-rw-r--r--. 1 7161 31415 27753 12月 21 2018 CMakeLists.txt
drwxr-xr-x. 3 7161 31415 21 12月 21 2018 cmd-line-utils
-rw-r--r--. 1 7161 31415 13900 12月 21 2018 config.h.cmake
-rw-r--r--. 1 7161 31415 25850 12月 21 2018 configure.cmake
-rw-r--r--. 1 7161 31415 17987 12月 21 2018 COPYING
drwxr-xr-x. 2 7161 31415 4096 12月 21 2018 dbug
drwxr-xr-x. 2 7161 31415 80 12月 21 2018 Docs
-rw-r--r--. 1 7161 31415 66241 12月 21 2018 Doxyfile-perfschema
drwxr-xr-x. 6 7161 31415 4096 12月 21 2018 extra
drwxr-xr-x. 5 7161 31415 4096 12月 21 2018 include
-rw-r--r--. 1 7161 31415 333 12月 21 2018 INSTALL
drwxr-xr-x. 5 7161 31415 135 12月 21 2018 libbinlogevents
drwxr-xr-x. 3 7161 31415 39 12月 21 2018 libbinlogstandalone
drwxr-xr-x. 7 7161 31415 4096 12月 21 2018 libevent
drwxr-xr-x. 4 7161 31415 275 12月 21 2018 libmysql
drwxr-xr-x. 3 7161 31415 204 12月 21 2018 libmysqld
drwxr-xr-x. 2 7161 31415 4096 12月 21 2018 libservices
drwxr-xr-x. 2 7161 31415 4096 12月 21 2018 man
drwxr-xr-x. 10 7161 31415 4096 12月 21 2018 mysql-test
drwxr-xr-x. 2 7161 31415 4096 12月 21 2018 mysys
drwxr-xr-x. 2 7161 31415 4096 12月 21 2018 mysys_ssl
drwxr-xr-x. 10 7161 31415 131 12月 21 2018 packaging
drwxr-xr-x. 18 7161 31415 4096 12月 21 2018 plugin
drwxr-xr-x. 4 7161 31415 36 12月 21 2018 rapid
-rw-r--r--. 1 7161 31415 2478 12月 21 2018 README
drwxr-xr-x. 2 7161 31415 4096 12月 21 2018 regex
drwxr-xr-x. 3 7161 31415 4096 12月 21 2018 scripts
drwxr-xr-x. 7 7161 31415 20480 12月 21 2018 sql
drwxr-xr-x. 2 7161 31415 198 12月 21 2018 sql-common
drwxr-xr-x. 13 7161 31415 175 12月 21 2018 storage
drwxr-xr-x. 2 7161 31415 4096 12月 21 2018 strings
drwxr-xr-x. 4 7161 31415 241 12月 21 2018 support-files
drwxr-xr-x. 2 7161 31415 98 12月 21 2018 testclients
drwxr-xr-x. 5 7161 31415 70 12月 21 2018 unittest
-rw-r--r--. 1 7161 31415 88 12月 21 2018 VERSION
drwxr-xr-x. 3 7161 31415 4096 12月 21 2018 vio
drwxr-xr-x. 2 7161 31415 32 12月 21 2018 win
drwxr-xr-x. 11 7161 31415 4096 12月 21 2018 zlib
3、编译安装 MySQL
(1)执行 cmake 命令
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_DATADIR=/home/mysql/data \
-DMYSQL_USER=mysql \
-DMYSQL_TCP_PORT=3306 \
-DSYSCONFDIR=/etc \
-DWITH_BOOST=./boost
# 参数说明:
# (1)DCMAKE_INSTALL_PREFIX:指定MySQL安装路径;
# (2)DMYSQL_DATADIR:指定MySQL数据库存放目录;
# (3)DMYSQL_UNIX_ADDR:指定sock文件的路径;
# (4)DSYSCONFDIR:指定配置文件路径;
# (5)DWITH_MYISAM_STORAGE_ENGINE=1:安装 myisam 存储引擎;
# (6)DWITH_INNOBASE_STORAGE_ENGINE=1:安装 innodb 存储引擎;
# (7)DDEFAULT_CHARSET:设置默认字符集;
# (8)DDEFAULT_COLLATION:设置默认校对集;
# (9)DMYSQL_TCP_PORT:设置服务器监听端口,默认 3306。
# =========================================================================================
[[email protected] mysql-5.7.25]# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
> -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \
> -DDEFAULT_CHARSET=utf8 \
> -DDEFAULT_COLLATION=utf8_general_ci \
> -DWITH_MYISAM_STORAGE_ENGINE=1 \
> -DWITH_INNOBASE_STORAGE_ENGINE=1 \
> -DWITH_ARCHIVE_STORAGE_ENGINE=1 \
> -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
> -DWITH_MEMORY_STORAGE_ENGINE=1 \
> -DWITH_READLINE=1 \
> -DENABLED_LOCAL_INFILE=1 \
> -DMYSQL_DATADIR=/home/mysql/data \
> -DMYSQL_USER=mysql \
> -DMYSQL_TCP_PORT=3306 \
> -DSYSCONFDIR=/etc \
> -DWITH_BOOST=./boost
-- Running cmake version 2.8.12.2
-- Could NOT find Git (missing: GIT_EXECUTABLE)
-- Configuring with MAX_INDEXES = 64U
-- The C compiler identification is GNU 4.8.5
-- The CXX compiler identification is GNU 4.8.5
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
..............
(2)执行 make & make install 命令
[[email protected] mysql-5.7.25]# make & make install
...............
[[email protected] mysql-5.7.25]# make clean
六、配置 MySQL
1、初始化数据文件
[[email protected] bin]# ./mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
2022-06-30T23:19:31.968785Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation f
or more details).2022-06-30T23:19:33.302137Z 0 [Warning] InnoDB: New log files created, LSN=45790
2022-06-30T23:19:33.478698Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2022-06-30T23:19:33.541446Z 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:
19bb8d85-f8cb-11ec-bdeb-000c2913d893.2022-06-30T23:19:33.544704Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2022-06-30T23:19:33.546445Z 1 [Warning] [email protected] is created with an empty password ! Please consider switching off the --initialize-insecure option.
2、创建配置文件
[[email protected] bin]# vi /etc/my.cnf
[client]
#password = your_password
port = 3306
socket = /usr/local/mysql/tmp/mysql.sock
# Here follows entries for some specific programs
# The MySQL server
[mysqld]
port = 3306
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
pid-file = /usr/local/mysql/mysql.pid
log_error = /usr/local/mysql/mysql-error.log
socket = /usr/local/mysql/tmp/mysql.sock
3、修改相关目录的所有者与权限
# 目录:/tmp
[[email protected] mysql]# chmod -R 1777 /tmp
[[email protected] mysql]# /usr/local/mysql/tmp/
# 创建错误日志文件
[[email protected] mysql]# touch /usr/local/mysql/mysql-error.log
# 修改目录 /usr/local/mysql 的所有者为 mysql:mysql
[[email protected] mysql]# chown -R mysql:mysql /usr/local/mysql
[[email protected] mysql]# ll /usr/local/mysql
总用量 64
drwxr-xr-x. 2 mysql mysql 4096 7月 1 07:10 bin
-rw-r--r--. 1 mysql mysql 17987 12月 21 2018 COPYING
-rw-r--r--. 1 mysql mysql 17987 12月 21 2018 COPYING-test
drwxr-x---. 5 mysql mysql 147 7月 1 07:47 data
drwxr-xr-x. 2 mysql mysql 55 7月 1 07:10 docs
drwxr-xr-x. 3 mysql mysql 4096 7月 1 07:10 include
drwxr-xr-x. 4 mysql mysql 192 7月 1 07:10 lib
drwxr-xr-x. 4 mysql mysql 30 7月 1 07:10 man
-rw-r--r--. 1 mysql mysql 0 7月 1 07:38 mysql-error.log
drwxr-xr-x. 10 mysql mysql 4096 7月 1 07:11 mysql-test
-rw-r--r--. 1 mysql mysql 2478 12月 21 2018 README
-rw-r--r--. 1 mysql mysql 2478 12月 21 2018 README-test
drwxr-xr-x. 28 mysql mysql 4096 7月 1 07:11 share
drwxr-xr-x. 2 mysql mysql 90 7月 1 07:11 support-files
drwxr-xr-x. 2 mysql mysql 6 7月 1 07:35 tmp
4、配置MySQL启动脚本
[[email protected] support-files]# pwd
/usr/local/mysql/support-files
[[email protected] support-files]# cp ./mysql.server /etc/init.d/mysqld
[[email protected] mysql]# chmod 700 /etc/init.d/mysqld
# 启动 mysql 服务
[[email protected] mysql]# /etc/init.d/mysqld start
Starting MySQL. SUCCESS!
# 设置 Mysql 开机自启动
[[email protected] mysql]# chkconfig mysqld on
[[email protected] mysql]# chkconfig --list mysqld
注意:该输出结果只显示 SysV 服务,并不包含原生 systemd 服务。SysV 配置数据可能被原生 systemd 配置覆盖。
如果您想列出 systemd 服务,请执行 'systemctl list-unit-files'。
欲查看对特定 target 启用的服务请执行
'systemctl list-dependencies [target]'。
mysqld 0:关 1:关 2:开 3:开 4:开 5:开 6:关
5、设置登录账号和密码
(1)编译安装完成后默认不需要密码即可以登录
[[email protected] mysql]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.25 Source distribution
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.
(2)为 root 账户设置登录密码
mysql> alter user root@localhost identified by '123456';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
(3)重新登录 MySQL
[[email protected] mysql]# mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
[[email protected] mysql]# mysql -uroot -p123456
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.25 Source distribution
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>
边栏推荐
- Thinkphp内核工单系统源码商业开源版 多用户+多客服+短信+邮件通知
- [open source data] open source data set for cross modal (MRI, Meg, eye movement) human spatial memory research based on virtual reality scenes
- Im instant messaging develops a message delivery scheme for 10000 people
- 圈铁发音,动感与无噪强强出彩,魔浪HIFIair蓝牙耳机测评
- 制造业数字化转型究竟是什么
- Origin2018安装与使用(整理中)
- ADS算力芯片的多模型架构研究
- 芯片供应转向过剩,中国芯片日产增加至10亿,国外芯片将更难受
- 苹果自研基带芯片再次失败,说明了华为海思的技术领先性
- 虚拟串口模拟器和串口调试助手使用教程「建议收藏」
猜你喜欢

【开源数据】基于虚拟现实场景的跨模态(磁共振、脑磁图、眼动)人类空间记忆研究开源数据集

AVL balanced binary search tree

Crypto Daily: Sun Yuchen proposed to solve global problems with digital technology on MC12

Sweden announced its decision to exclude Huawei 5g equipment, but Huawei has successfully found a new way out

ThinkPHP kernel work order system source code commercial open source version multi user + multi customer service + SMS + email notification

Pico, do you want to save or bring consumer VR?

StoneDB 为国产数据库添砖加瓦,基于 MySQL 的一体化实时 HTAP 数据库正式开源!

基于PHP的轻量企业销售管理系统

There will be a gap bug when the search box and button are zoomed
![[SQL statement] Why do you select two Shanghai and query different counts here? I want it to become a Shanghai, and count only displays a sum](/img/a4/58b942d1389834069e9a6ec9f8ee0a.png)
[SQL statement] Why do you select two Shanghai and query different counts here? I want it to become a Shanghai, and count only displays a sum
随机推荐
Malaysia's Star: Sun Yuchen is still adhering to the dream of digital economy in WTO MC12
2022-07-01日报:谷歌新研究:Minerva,用语言模型解决定量推理问题
ABAP call restful API
Embedded development: five revision control best practices
process.env.NODE_ENV
怎麼用MySQL語言進行行列裝置?
普通二本,去过阿里外包,到现在年薪40W+的高级测试工程师,我的两年转行心酸经历...
电脑屏幕变色了怎么调回来,电脑屏幕颜色怎么改
Microservice tracking SQL (support Gorm query tracking under isto control)
表格存储中tablestore 目前支持mysql哪些函数呢?
Action after deleting laravel's model
开机时小键盘灯不亮的解决方案
Telecommuting experience? Let's introduce ourselves ~ | community essay solicitation
部门来了个拿25k出来的00后测试卷王,老油条表示真干不过,已被...
SQLServer查询: a.id与b.id相同时,a.id对应的a.p在b.id对应的b.p里找不到的话,就显示出这个a.id和a.p
There is a difference between u-standard contract and currency standard contract. Will u-standard contract explode
2023 spring recruitment Internship - personal interview process and face-to-face experience sharing
全面看待企业数字化转型的价值
Huawei issued hcsp-solution-5g security talent certification to help build 5g security talent ecosystem
In the era of super video, what kind of technology will become the base?