1.安装cmake
上传tar包
rz cmake-2.8.8.tar.gz
解压tar包,并进入解压后的文件夹
tar xf cmake-2.8.8.tar.gz
cd cmake-2.8.8
编译和安装
./configure
gmake && gmake install
2.安装mysql
上传mysql-5.5.32.tar.gz
rz mysql-5.5.32.tar.gz
解压mysql-5.5.32.tar.gz
tar xf mysql-5.5.32.tar.gz
进入到mysql-5.5.32
cd mysql-5.5.32
创建mysql用户
useradd mysql -s /sbin/nologin -M
yum 安装依赖库
yum install ncurses-devel -y
指定cmake编译参数
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
编译和安装
make && make install
添加环境变量到profile
echo 'export PATH=/application/mysql/bin:$PATH' >>/etc/profile source /etc/profile echo $PATH
创建软连接,链接mysql-5.5.32 到mysql
ln -s /application/mysql-5.5.32 /application/mysql
复制my-small.cnf配置文件到/etc/下并改名为my.cnf
cp /tools/mysql-5.5.32/support-files/my-small.cnf /etc/my.cnf
授权data tmp目录的属组和用户
chown -R mysql.mysql /application/mysql/data/
chmod -R 1777 /tmp/
3.初始化数据库
cd /application/mysql/scripts/
./mysql_install_db --basedir=/application/mysql/ --datadir=/application/mysql/data/ --user=mysql
复制启动脚本到/etc/init.d/下并改名为mysqld
cp /application/mysql/support-files/mysql.server /etc/init.d/mysqld
给mysqld赋予可执行权限
chmod +x /etc/init.d/mysqld
启动mysqld
/etc/init.d/mysqld start
检查mysqld是否启动起来
netstat -luptn |grep mysqld
给mysqld设置开机启动
chkconfig mysqld on
chkconfig --list |grep mysqld
给数据库添加密码
/application/mysql/bin/mysqladmin -u root password 'admin'