cmake方式编译MySQL(cmake编写)

安装相关包

1.cmake软件

cd /home/shnne/tools/
tar xf cmake-2.8.8.tar.gz
cd cmake-2.8.8
./configure
gmake
gmake install
cd ../

2.依赖包

yum install ncurses-devel -y

 

3.开始安装mysql

创建用户和组

groupadd mysql

useradd mysql -s /sbin/nologin -M -g mysql


4.解压编译MySQL

tar zxf mysql-5.5.32.tar.gz

cd 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 \
-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 \
-DENABLE_DOWNLOADS=1  #5.6新增参数,下载Google Mock,编译5.6不添加可能编译不通过
(下面两个确定了字符集,可以再编译)
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \

make

make install

ln -s /application/mysql-5.5.32/ /application/mysql

如果上述操作未出现错误,则MySQL5.5.32软件cmake方式的安装就算成功了。

 

cd /home/shnne/tools/mysql-5.5.32/support-files/

cp my-small.cnf /etc/my.cnf

echo 'export PATH=/application/mysql/bin:$PATH' >>/etc/profile    #为什么把/application/mysql/bin放在前面,是因为防止yum安装的mysql的路径在前面,执行mysql的命令会先找yum安装下的mysql命令,而不执行编译安装的

tail -1 /etc/profile

source /etc/profile

echo $PATH

 

chown -R mysql.mysql /application/mysql/data/

chmod -R 1777 /tmp/

cd /application/mysql/scripts/

./mysql_install_db --basedir=/application/mysql/ --datadir=/application/mysql/data/ --user=mysql

 

cd /home/shnne/tools/mysql-5.5.32/support-files/

\cp mysql.server /etc/init.d/mysqld

chmod +x /etc/init.d/mysqld

/etc/init.d/mysqld start

netstat -lntup|grep mysql

 

echo '/etc/init.d/mysqld start ' >>/etc/rc.local

tail -1 /etc/rc.local


标签:

上一篇nginx与apache的相关插件安装(nginx和apache实际对比测试)
下一篇FTP通过shell脚本自动上传文件

相关文章