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>