一、安裝cmake
# 安裝所需依賴包
yum -y install gcc libxml2-dev curl screen \
libpng12-dev autoconf libpcre3-dev make bzip2 \
libevent-dev patch libjpeg62-dev libcurl4-openssl-dev \
libfreetype6-dev g++ libtool libncurses5-dev psmisc lrzsz
# 下載文件
wget http://www.cmake.org/files/v2.8/cmake-2.8.5.tar.gz
www.2cto.com
# 編譯安裝
tar zxvf cmake-2.8.5.tar.gz
cd cmake-2.8.5
./boostarp
make
make install
cmake –version
二、 安裝配置mysql
# 下載源文件
wget http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.17.tar.gz/from/ftp://ftp.ntu.edu.tw/pub/MySQL/
# 或
wget ftp://ftp.ntu.edu.tw/pub/MySQL/Downloads/MySQL-5.5/mysql-5.5.17.tar.gz
# 創建用戶和組
groupadd mysql
useradd -g mysql -s /usr/sbin/nologin mysql
# 創建安裝目錄
mkdir /usr/local/ mysql
# 創建數據庫目錄
mkdir /usr/local/ mysql/data
www.2cto.com
# 解壓
tar -zxvf mysql-5.5.17.tar.gz
cd mysql-5.5.17
# 編譯及安裝mysql
# cmake編譯:
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_unicode_ci \
-DWITH_READLINE=1 \
-DWITH_SSL=system \
-DWITH_EMBEDDED_SERVER=1 \
-DENABLED_LOCAL_INFILE=1 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_DEBUG=0
www.2cto.com
# 安裝mysql
make && make install
# 復制配置文件
cp support-files/my-medium.cnf /etc/my.cnf
# 設置權限
chmod +x /usr/local/mysql
chown -R mysql.mysql /usr/local/mysql
chown -R mysql:mysql /usr/local/mysql/data
# 配置開機自啟動
cp support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
chkconfig –add mysqld
chkconfg mysqld on
www.2cto.com
# 修改my.cnf配置
vim /etc/my.cnf
# [mysqld] 添加:
datadir=/usr/local/mysql/data
default-storage-engine=MyISAM
# 以下可選:
log-error =/usr/local/mysql/data/error.log
pid-file = /usr/local/mysql/data/mysql.pid
user = mysql
tmpdir = /tmp
# 初始化數據庫
/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data &
# 啟動MySQL
/usr/local/mysql/bin/mysqld_safe –defaults-file=/etc/my.cnf &
或者:
/etc/init.d/mysql start (service mysql start)
www.2cto.com
# 測試MySQL是否啟動
# 1)查看是否有進程mysql
ps -ef | grep mysql
# 2)查看端口是否運行
netstat -tnl | grep 3306
# 3)讀取mysql版本信息
/usr/local/mysql/bin/mysqladmin version
# 至此,MySQL安裝完成