MySQL 安裝(源碼安裝模式)

來源:互聯網
上載者:User

標籤:

MySQL 安裝(RPM安裝模式)及目錄結構

MySQL 安裝(二進位安裝模式)

MySQL 安裝(源碼安裝模式)



本篇使用mysql源碼來安裝,稍微比較麻煩。

 CentOS release 5.11+ mysql-5.6.22


使用源碼編譯,需要下載一款工具cmake:

What’s Cmake?官方說明如下:

CMake is a family of tools designed tobuild, test and package software. CMake is used to control the software compilationprocess using simple platform and compiler independent configuration files.CMake generates native makefiles and workspaces that can be used in thecompiler environment of your choice.

Cmake官方:http://www.cmake.org/download/


本次測試安裝的cmake版本:

Release Candidate(3.2.0-rc2)—Source distributions—Unix/Linux Source (has \n line feeds)—cmake-3.2.0-rc2.tar.gz


Cmake解壓:

ll /usr/local/src/cmake-3.2.0-rc2.tar.gz

tar zxvfcmake-3.2.0-rc2.tar.gz

mv/usr/local/src/cmake-3.2.0-rc2 /usr/local/cmake


編譯安裝:

cd /usr/local/cmake/

./configure


#configure完成後提示:now run gmake,接下來再執行gmake

gmake

make

make install


安裝mysql,官方參考:Installing MySQL Using a Standard Source Distribution


先建立mysql使用者及組:

groupadd mysql

useradd -r -g mysql mysql


mysql當前執行個體:(size 30M)

http://ftp.iij.ad.jp/pub/db/mysql/Downloads/MySQL-5.6/MySQL-5.6.22-1.linux_glibc2.5.src.rpm


解壓rpm包:

mv MySQL-5.6.22-1.linux_glibc2.5.src.rpm /usr/local/src

rpm2cpioMySQL-5.6.22-1.linux_glibc2.5.src.rpm | cpio -div


tar zxvf mysql-5.6.22.tar.gz

mv/usr/local/src/mysql-5.6.22 /usr/local/mysql


編譯mysql:(5.5版本(含)以上使用cmake,5.1使用./configure

cd /usr/local/mysql

 

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

-DMYSQL_DATADIR=/usr/local/mysql/data\

-DMYSQL_TCP_PORT=3306 \

-DSYSCONFDIR=/etc \

-DEXTRA_CHARSETS=all \

-DDEFAULT_CHARSET=utf8 \

-DDEFAULT_COLLATION=utf8_general_ci\

-DENABLED_LOCAL_INFILE=1 \

-DWITH_INNOBASE_STORAGE_ENGINE=1\

-DWITH_ARCHIVE_STORAGE_ENGINE=1\

-DWITH_BLACKHOLE_STORAGE_ENGINE=1\

-DWITH_PERFSCHEMA_STORAGE_ENGINE=1

 

#以上配置參數更多參考:MySQL Source-Configuration Options

make

make install


設定根目錄所有者:

chown -R mysql:mysql/usr/local/mysql


複製服務和設定檔到系統設定檔中:

cp /usr/local/mysql/support-files/mysql.server/etc/init.d/mysqld

cp/usr/local/mysql/support-files/my-default.cnf /etc/my.cnf


編輯mysql設定檔添加以下參數:vi /etc/my.cnf

[mysqld]

basedir =/usr/local/mysql

datadir=/usr/local/mysql/data

port = 3306

server_id = 1


初始化資料庫:

chmod 755/usr/local/mysql/scripts/mysql_install_db

/usr/local/mysql/scripts/mysql_install_db--user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data


設定開機啟動mysqld服務:

chkconfig mysqld on


設定環境變數:vi/root/.bash_profile

#PATH=$PATH:$HOME/bin

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


[[email protected] ~]# source/root/.bash_profile


啟動mysqld服務:

chmod 755 /etc/init.d/mysqld

/etc/init.d/mysqld start

service mysqld restart



設定mysql密碼及相關設定:

/usr/local/mysql/bin/mysql_secure_installation

 

完成!!成功登入!




安裝基本就完成了,先補點水分。


MySQL 安裝(源碼安裝模式)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.