当前位置:网站首页>數據庫系統原理與應用教程(006)—— 編譯安裝 MySQL5.7(Linux 環境)
數據庫系統原理與應用教程(006)—— 編譯安裝 MySQL5.7(Linux 環境)
2022-07-01 16:19: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>
边栏推荐
- Microservice tracking SQL (support Gorm query tracking under isto control)
- 苹果自研基带芯片再次失败,说明了华为海思的技术领先性
- 【观察】数字化时代的咨询往何处走?软通咨询的思与行
- [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
- China's intelligent transportation construction from the perspective of "one hour life circle" in Dawan District
- 怎麼用MySQL語言進行行列裝置?
- Zabbix2.2监控之系统及应用日志监控报警
- [open source data] open source data set for cross modal (MRI, Meg, eye movement) human spatial memory research based on virtual reality scenes
- Idea start command line is too long problem handling
- 电脑屏幕变色了怎么调回来,电脑屏幕颜色怎么改
猜你喜欢

Overview | slam of laser and vision fusion

Automatic, intelligent and visual! Deeply convinced of the eight designs behind sslo scheme

Talking from mlperf: how to lead the next wave of AI accelerator

电脑屏幕变色了怎么调回来,电脑屏幕颜色怎么改

Zhou Shaojian, rare

广东用电量大跌,说明高新技术产业替代高能耗产业已取得初步成果

Thinkphp内核工单系统源码商业开源版 多用户+多客服+短信+邮件通知

【IDM】IDM下载器安装

学会了selenium 模拟鼠标操作,你就可以偷懒点点点了

Pico,是要拯救还是带偏消费级VR?
随机推荐
开机时小键盘灯不亮的解决方案
用手机在同花顺上开户靠谱吗?这样有没有什么安全隐患
The latest NLP game practice summary!
Motion capture system for apple picking robot
Pico,是要拯救还是带偏消费级VR?
Sales management system of lightweight enterprises based on PHP
Submission lottery - light application server essay solicitation activity (may) award announcement
Sqlserver query: when a.id is the same as b.id, and the A.P corresponding to a.id cannot be found in the B.P corresponding to b.id, the a.id and A.P will be displayed
普通二本,去过阿里外包,到现在年薪40W+的高级测试工程师,我的两年转行心酸经历...
德国iF多项大奖加冕,这副耳机有多强?音珀GTW 270 Hybrid深度评测
Nuxt.js数据预取
Does 1.5.1 in Seata support mysql8?
动作捕捉系统用于苹果采摘机器人
【开源数据】基于虚拟现实场景的跨模态(磁共振、脑磁图、眼动)人类空间记忆研究开源数据集
Seata中1.5.1 是否支持mysql8?
STM32F1与STM32CubeIDE编程实例-PWM驱动蜂鸣器生产旋律
idea启动Command line is too long问题处理
Origin2018安装与使用(整理中)
Learn selenium to simulate mouse operation, and you can be lazy a little bit
Problems encountered in IM instant messaging development to maintain heartbeat