MySQL源碼安裝的示例分析-創(chuàng)新互聯(lián)

這篇文章主要介紹MySQL源碼安裝的示例分析,文中介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們一定要看完!

成都創(chuàng)新互聯(lián)專注于紫云網(wǎng)站建設(shè)服務(wù)及定制,我們擁有豐富的企業(yè)做網(wǎng)站經(jīng)驗(yàn)。 熱誠為您提供紫云營銷型網(wǎng)站建設(shè),紫云網(wǎng)站制作、紫云網(wǎng)頁設(shè)計(jì)、紫云網(wǎng)站官網(wǎng)定制、成都小程序開發(fā)服務(wù),打造紫云網(wǎng)絡(luò)公司原創(chuàng)品牌,更為您提供紫云網(wǎng)站排名全網(wǎng)營銷落地服務(wù)。

操作系統(tǒng):CentOS 6.7
MySQL版本:5.6.30

·        1.前期準(zhǔn)備

·        2.系統(tǒng)配置

·        3.CMake編譯配置

·        4.make && make install

·        5.后期配置和測試

·        Reference

1.前期準(zhǔn)備

首先需要CMake,可以yum直接安裝:

yum install cmake

也可以官網(wǎng) https://cmake.org/ 下載源碼編譯。
我這里選擇了官網(wǎng)下載最新版本cmake-3.5.2.tar.gz。

# tar -zxvf cmake-3.5.2.tar.gz && cd cmake-3.5.2

# ./configure

部分輸出略。

-- Build files have been written to: /soft/cmake-3.5.2

---------------------------------------------

CMake has bootstrapped.  Now run gmake.

# gmake

# make install

2.系統(tǒng)配置

添加組和用戶:

groupadd mysql

useradd -g mysql mysql

vi /etc/security/limits.conf 文件末尾添加:

mysql   soft    nproc   2047

mysql   hard    nproc   16384

mysql   soft    nofile  1024

mysql   hard    nofile  65536

3.CMake編譯配置

解壓源碼包:

tar zxvf mysql-5.6.30.tar.gz && cd mysql-5.6.30

CMake編譯配置

cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \

-DDEFAULT_CHARSET=utf8 \

-DDEFAULT_COLLATION=utf8_general_ci \

-DENABLED_LOCAL_INFILE=ON \

-DWITH_INNOBASE_STORAGE_ENGINE=1 \

-DWITH_FEDERATED_STORAGE_ENGINE=1 \

-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \

-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \

-DWITH_PARTITION_STORAGE_ENGINE=1 \

-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \

-DCOMPILATION_COMMENT='JSS for mysqltest' \

-DWITH_READLINE=ON \

-DSYSCONFDIR=/data/mysqldata/3306 \

-DMYSQL_UNIX_ADDR=/data/mysqldata/3306/mysql.sock

遇到以下錯(cuò)誤,

-- Could NOT find Curses (missing:  CURSES_LIBRARY CURSES_INCLUDE_PATH)

CMake Error at cmake/readline.cmake:85 (MESSAGE):

  Curses library not found.  Please install appropriate package,

      remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is libncurses5-dev, on Redhat and derivates it is ncurses-devel.

Call Stack (most recent call first):

  cmake/readline.cmake:128 (FIND_CURSES)

  cmake/readline.cmake:202 (MYSQL_USE_BUNDLED_EDITLINE)

  CMakeLists.txt:421 (MYSQL_CHECK_EDITLINE)

-- Configuring incomplete, errors occurred!

See also "/soft/mysql-5.6.30/CMakeFiles/CMakeOutput.log".

See also "/soft/mysql-5.6.30/CMakeFiles/CMakeError.log".

[root@JY-DB mysql-5.6.30]#

yum安裝提示缺失的包:

yum install ncurses-devel

重新刪除配置文件:

rm -rf CMakeCache.txt

然后重新CMake工具編譯:

CMake Warning:

  Manually-specified variables were not used by the project:

    WITH_READLINE

-- Build files have been written to: /soft/mysql-5.6.30

[root@JY-DB mysql-5.6.30]#

4.make && make install

[root@JY-DB mysql-5.6.30]# make && make install

大量輸出略。

這個(gè)時(shí)間會(huì)比較長,也跟機(jī)器性能有關(guān)。

5.后期配置和測試

5.1 打包MySQL二進(jìn)制版本:

[root@JY-DB data]# tar zcvf mysql-5.6.30.tar.gz /usr/local/mysql/

5.2 修改MySQL軟件所在目錄擁有者:

chown -R mysql.mysql /usr/local/mysql

5.3 修改mysql用戶環(huán)境變量:

vi ~/.bash_profile

export LANG=zh_CN.GB18030

export PATH=/usr/local/mysql/bin:$PATH

5.4 創(chuàng)建數(shù)據(jù)庫服務(wù):

# mkdir -p /data/mysqldata/{3306/{data,tmp,binlog},backup,scripts}

# chown -R mysql.mysql /data/mysqldata

# su - mysql

$ more /usr/local/mysql/support-files/my-default.cnf

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

my.cnf配置文件內(nèi)容如下:

[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 = 10240

explicit_defaults_for_timestamp

sql_mode = NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

#Buffer

max_allowed_packet = 256M

max_heap_table_size = 256M

net_buffer_length = 8k

sort_buffer_size = 2M

join_buffer_size = 4M

read_buffer_size = 2M

read_rnd_buffer_size = 16M

#Log

log-bin = /data/mysqldata/3306/binlog/mysql-bin

binlog_cache_size = 32M

max_binlog_cache_size = 512M

max_binlog_size = 512M

binlog_format = mixed

log_output = FILE

log-error = ../mysql-error.log

slow_query_log = 1

slow_query_log_file = ../slow_query.log

general_log = 0

general_log_file = ../general_query.log

expire-logs-days = 14

#InnoDB

innodb_data_file_path = ibdata1:2048M:autoextend

innodb_log_file_size = 256M

innodb_log_files_in_group = 3

innodb_buffer_pool_size = 1024M

[mysql]

no-auto-rehash

prompt = (\u@\h)[\d]>\_

default-character-set = gbk

初始化MySQL數(shù)據(jù)庫:

$ /usr/local/mysql/scripts/mysql_install_db --datadir=/data/mysqldata/3306/data --basedir=/usr/local/mysql

5.5 啟動(dòng)數(shù)據(jù)庫服務(wù):

mysqld_safe --defaults-file=/data/mysqldata/3306/my.cnf &

測試連接并查看MySQL進(jìn)程和端口監(jiān)聽狀態(tài):

netstat -lnt | grep 3306

ps -ef | grep bin/mysql | grep -v grep

實(shí)際操作過程如下:

[root@JY-DB ~]# su - mysql

[mysql@JY-DB ~]$ mysql

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 1

Server version: 5.6.30-log JSS for mysqltest

Copyright (c) 2000, 2016, 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.

(root@localhost)[(none)]> exit

Bye

[mysql@JY-DB ~]$ netstat -lnt |grep 3306

tcp        0      0 :::3306                     :::*                        LISTEN     

[mysql@JY-DB ~]$ 

[mysql@JY-DB ~]$ ps -ef | grep bin/mysql | grep -v grep

mysql     6736  1753  0 11:24 pts/0    00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --defaults-file=/data/mysqldata/3306/my.cnf

mysql     7202  6736  0 11:24 pts/0    00:00:00 /usr/local/mysql/bin/mysqld --defaults-file=/data/mysqldata/3306/my.cnf --basedir=/usr/local/mysql --datadir=/data/mysqldata/3306/data --plugin-dir=/usr/local/mysql/lib/plugin --log-error=/data/mysqldata/3306/data/../mysql-error.log --open-files-limit=10240 --pid-file=/data/mysqldata/3306/mysql.pid --socket=/data/mysqldata/3306/mysql.sock --port=3306

以上是“MySQL源碼安裝的示例分析”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對(duì)大家有幫助,更多相關(guān)知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)-成都網(wǎng)站建設(shè)公司行業(yè)資訊頻道!

本文名稱:MySQL源碼安裝的示例分析-創(chuàng)新互聯(lián)
當(dāng)前地址:http://muchs.cn/article38/dchjpp.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供小程序開發(fā)關(guān)鍵詞優(yōu)化、全網(wǎng)營銷推廣、虛擬主機(jī)、營銷型網(wǎng)站建設(shè)、網(wǎng)站制作

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

小程序開發(fā)