首頁 > 資料庫 > mysql教程 > CentOS7怎麼編譯安裝MySQL 8.0

CentOS7怎麼編譯安裝MySQL 8.0

WBOY
發布: 2023-05-30 10:04:12
轉載
893 人瀏覽過

CentOS編譯安裝MySQL的教學網路上有很多,基本上是大同小異。但是安裝軟體有時就可能因為一個細節安裝而失敗。

CentOS7怎么编译安装MySQL 8.0

0.前期準備條件

•查看linux的版本

[root@mysql etc]# cat /etc/RedHat-releaseCentOS Linux release 7.3.1611 (Core)

•Could NOT find Curses

yum install ncurses-devel

•Bison executable not found in PATH

yum install bison
登入後複製

備註: 安裝過程中會缺少基礎包,本實例環境缺少上述套件,先事先安裝對應的套件

1.cmake的來源編譯安裝

[root@db software]# nohup tar zxvf cmake-3.11.1.tar.gz &[root@db software]# cd cmake-3.11.1[root@db cmake-3.11.1]# ./configure[root@localhost cmake-3.0.1]# gmake && make install
登入後複製

2.wolfssl套件的部署安裝[可選項]##

*. 从wolfssl.com网站下载wolfssl-3.13.0.zip压缩包
*. 解压至/data/software/mysql-8.0.11/extra/wolfssl-3.13.0目录中。
*. cd extra/wolfssl-3.13.0/IDE/MYSQL
*. 执行do.sh脚本
*. use -DWITH_SSL=wolfssl for CMake
登入後複製


3.openssl和openssl-devel[本實驗使用的是system ssl]

yum install –y openssl openssl-devel
登入後複製


4.mysql的編譯安裝

[root@mysql software]#tar zxvf mysql-8.0.11.tar.gz[root@mysql software]# cd mysql-8.0.11/[root@mysql software]# mkdir Zdebug[root@mysql software]# cd Zdebugcmake .. -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DENABLED_LOCAL_INFILE=ON \
-DWITH_INNODB_MEMCACHED=ON \
-DWITH_SSL=system \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \
-DCOMPILATION_COMMENT="zsd edition" \
-DDOWNLOAD_BOOST=1 \
-DWITH_BOOST=/tmp \
-DMYSQL_UNIX_ADDR=/data/mysqldata/3306/mysql.sock \
-DSYSCONFDIR=/data/mysqldata/3306 > /data/software/mysql-8.0.11/Zdebug/mysql_cmake80.log 2>&1
登入後複製

出現下列日誌:

............
-- Configuring done-- Generating done-- Build files have been written to: /data/software/mysql-8.0.11/Zdebug
............
登入後複製

說明編譯成功,其中-DWITH_SSL=system用的是linux作業系統的openssl,需要安裝openssl和openssl-devel包,才可以被編譯

#如果需要編譯安裝快速,可以運用多執行緒加快編譯安裝,指令如下:

make -j 12
make install
登入後複製

•MySQL 8.0的軟體目錄架構

[root@mysql Zdebug]# cd /usr/local/mysql/[root@mysql mysql]# ls -ltotal 612
drwxr-xr-x. 2 root root 4096 May 16 14:20 bin
drwxr-xr-x. 2 root root 55 May 16 14:20 docs
drwxr-xr-x. 3 root root 266 May 16 14:20 include
drwxr-xr-x. 4 root root 173 May 16 14:20 lib
-rw-r--r--. 1 root root 301518 Apr 8 14:44 LICENSE
-rw-r--r--. 1 root root 301518 Apr 8 14:44 LICENSE-test
drwxr-xr-x. 4 root root 30 May 16 14:20 man
drwxr-xr-x. 10 root root 4096 May 16 14:21 mysql-test
-rw-r--r--. 1 root root 687 Apr 8 14:44 README
-rw-r--r--. 1 root root 687 Apr 8 14:44 README-test
drwxr-xr-x. 28 root root 4096 May 16 14:21 share
drwxr-xr-x. 2 root root 90 May 16 14:21 support-files
登入後複製

5.建立mysql使用者&並修改相關檔案

[root@mysql mysql]# groupadd mysql[root@mysql mysql]# useradd -g mysql mysql
登入後複製

6.設定使用者作業系統資源的限制

[root@localhost cmake-3.0.1]# vi /etc/security/limits.confmysql soft nproc 65536
mysql hard nproc 65536
mysql soft nofile 65536
mysql hard nofile 65536
登入後複製

驗證limit是否生效

[root@mysql ~]# su - mysql[mysql@mysql ~]$ ulimit -a
登入後複製

日誌如下:

open files (-n) 65536
max user processes (-u) 65536
............
登入後複製

7.建立MySQL數據目錄及賦予對應權限

#cd /data/#mkdir -p /data/mysqldata/{3306/{data,tmp,binlog,innodb_ts,innodb_log},backup,scripts}#chown -R mysql:mysql mysqldata#su - mysql
登入後複製

8.設定my.cnf檔

$vi /data/mysqldata/3306/my.cnf

[client]
port = 3306
socket = /data/mysqldata/3306/mysql.sock# The MySQL server[mysqld]
port = 3306
user = mysql
socket = /data/mysqldata/3306/mysql.sock
pid-file = /data/mysqldata/3306/mysql.pid
basedir = /usr/local/mysql
datadir = /data/mysqldata/3306/data
tmpdir = /data/mysqldata/3306/tmp
open_files_limit = 60000
explicit_defaults_for_timestamp
server-id = 1203306
lower_case_table_names = 1
character-set-server = utf8
federated#sql_mode=STRICT_TRANS_TABLESmax_connections = 1000
max_connect_errors = 100000
interactive_timeout = 86400
wait_timeout = 86400
sync_binlog=0
back_log=100
default-storage-engine = InnoDB
log_slave_updates = 1#*********** Logs related settings ***********log-bin = /data/mysqldata/3306/binlog/mysql-bin
binlog_format= mixed
binlog_cache_size=32m
max_binlog_cache_size=64m
max_binlog_size=512m
long_query_time = 1
log_output = FILElog-error = /data/mysqldata/3306/mysql-error.log
slow_query_log = 1
slow_query_log_file = /data/mysqldata/3306/slow_statement.log#log_queries_not_using_indexesgeneral_log = 0
general_log_file = /data/mysqldata/3306/general_statement.log#expire-logs-days = 14binlog_expire_logs_seconds = 1728000
relay-log = /data/mysqldata/3306/binlog/relay-bin
relay-log-index = /data/mysqldata/3306/binlog/relay-bin.index#****** MySQL Replication New Feature*********master-info-repository=TABLE
relay-log-info-repository=TABLE
relay-log-recovery#*********** INNODB Specific options ***********innodb_buffer_pool_size = 2048M
transaction-isolation=REPEATABLE-READ
innodb_buffer_pool_instances = 8
innodb_file_per_table = 1
innodb_data_home_dir = /data/mysqldata/3306/innodb_ts
innodb_data_file_path = ibdata1:2048M:autoextend
innodb_thread_concurrency = 8
innodb_log_buffer_size = 16M
innodb_log_file_size = 128M
innodb_log_files_in_group = 3
innodb_log_group_home_dir = /data/mysqldata/3306/innodb_log
innodb_flush_log_at_trx_commit = 2
innodb_max_dirty_pages_pct = 70
innodb_flush_method=O_DIRECT
[mysql]
no-auto-rehash
default-character-set=gbk
prompt = (\u@\h) [\d]>\_
登入後複製

9.初始化MySQL資料庫

$/usr/local/mysql/bin/mysqld --defaults-file=/data/mysqldata/3306/my.cnf --initialize --user=mysql
登入後複製

10.啟動mysql服務

$/usr/local/mysql/bin/mysqld_safe --defaults-file=/data/mysqldata/3306/my.cnf --user=mysql &
登入後複製

11.登陸資料庫

備註:密碼來自error log日誌,明細如下:

2018-05-16T07:17:57.335486Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: jlocal/mysql/bin/mysql -uroot -p'j
登入後複製

12.資料庫一些基本權限配置

修改root帳號密碼:

ALTER USER 'root'@'localhost' IDENTIFIED WITH sha256_password BY 'zsd@7101' PASSWORD EXPIRE INTERVAL 360 DAY;
登入後複製

查看目前的使用者帳號

(root@localhost) [(none)]> select user,host from mysql.user;
+------------------+-----------+
| user | host |
+------------------+-----------+
| mysql.infoschema | localhost |
| mysql.session | localhost |
| mysql.sys | localhost |
| root | localhost |
+------------------+-----------+
登入後複製
#

以上是CentOS7怎麼編譯安裝MySQL 8.0的詳細內容。更多資訊請關注PHP中文網其他相關文章!

相關標籤:
來源:yisu.com
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板