1.安裝依賴包及建立用戶
依賴包:yum install ncurses-devel libaio-devel -y
增長用戶組:groupadd mysql
增長用戶:useradd mysql -s /sbin/nologin -M -g mysql
2.解壓cmake壓縮包,並進入到文件夾
[root@db02 tools]# tar xvf cmake-2.8.8.tar.gz
[root@db02 cmake-2.8.8]# cd cmake-2.8.8/
[root@db02 cmake-2.8.8]# ./bootstrap
[root@db02 cmake-2.8.8]# make
[root@db02 cmake-2.8.8]# make install
3.解壓mysql壓縮包,並進入到文件夾
[root@db02 tools]# tar xf mysql-5.5.32.tar.gz
[root@db02 tools]# cd mysql-5.5.32/
4.解壓編譯MySQL
[root@db02 tools]# cd /tools/mysql-5.5.32
[root@db02 mysql-5.5.32]#
cmake . -DCMAKE_INSTALL_PREFIX=/application/mysql-5.5.32 \
-DMYSQL_DATADIR=/application/mysql-5.5.32/data \
-DMYSQL_UNIX_ADDR=/application/mysql-5.5.32/tmp/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DEXTRA_CHARSETS=gbk,gb2312,utf8,ascii \
-DENABLED_LOCAL_INFILE=ON \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \
-DWITHOUT_PARTITION_STORAGE_ENGINE=1 \
-DWITH_FAST_MUTEXES=1 \
-DWITH_ZLIB=bundled \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_READLINE=1 \
-DWITH_EMBEDDED_SERVER=1 \
-DWITH_DEBUG=0
[root@db02 mysql-5.5.32]# make && make install
[root@db02 mysql-5.5.32]# ln -s /application/mysql-5.5.32 /application/mysql
[root@db02 mysql-5.5.32]# cd /tools/mysql-5.5.32
[root@db02 mysql-5.5.32]# cp support-files/my-small.cnf /etc/my.cnf
[root@db02 mysql-5.5.32]# cp /application/mysql/support-files/mysql.server /etc/init.d/mysqld
[root@db02 mysql-5.5.32]# chown -R mysql.mysql /application/mysql
[root@db02 mysql-5.5.32]# chmod +X /etc/init.d/mysqld
5.加入環境變量
[root@db02 mysql-5.5.32]# export PATH="/application/mysql/bin:$PATH" >>/etc/profile
6.初始化mysql
[root@db02 mysql]# cd /application/mysql/scripts/
[root@db02 scripts]# ./mysql_install_db --basedir=/application/mysql/ --datadir=/application/mysql/data/ --user=mysql
[root@db02 scripts]# /etc/init.d/mysqld start
Starting MySQL... SUCCESS!
[root@db02 scripts]# /application/mysql/bin/mysql
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>