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
[root@localhost ~]# 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
完成!!成功登錄!
安裝基本就完成了,先補點水分。