#安装支持库
yum install -y bison gcc gcc-c++ autoconf automake zlib* libxml* ncurses-devel libtool-ltdl-devel*
yum groupinstall "Development Tools"
yum install -y kernels*
yum install readline-devel -y
yum install gperf -y
yum install libaio-devel -y
#下载安装cmake
wget http://www.cmake.org/files/v2.8/cmake-2.8.6.tar.gz
tar zxvf cmake-2.8.6.tar.gz
cd cmake-2.8.6/
./configure
gmake
gmake install

#下载MYSQL
wget http://dev.mysql.com/get/Downloads/MySQL-5.5/MySQL-5.5.24-1.linux2.6.src.rpm/from/http://mysql.cs.pu.edu.tw/
#解压包
rpm -ivh MySQL-5.5.24-1.linux2.6.src.rpm
#其实,上边这边,把编译完成的mysql安装包放在了/root/rpmbuild/SOURCES/,当然,这个目录可能会变化,如果找不到,可用命令:find / -name mysql-5.5.24
cp /root/rpmbuild/SOURCES/* ~/
tar xvf mysql-5.5.24.tar.gz
cd mysql-5.5.24
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/home/data/mysql -DSYSCONFDIR=/etc/ -DEXTRA_CHARSETS=all -DENABLED_LOCAL_INFILE=1 -DWITH_READLINE=1 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EMBEDDED_SERVER=1

#cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DEXTRA_CHARSETS=all -DENABLED_LOCAL_INFILE=1 -DWITH_READLINE=1 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EMBEDDED_SERVER=1 -DWITH_SSL=system
/*
-- MySQL 5.5.24
-- Packaging as: mysql-5.5.24-Linux-x86_64
-- Configuring done
-- Generating done
-- Build files have been written to: /root/mysql-5.5.24
*/
cd /root/mysql-5.5.24
make
make install

chmod 711 scripts/mysql_install_db
groupadd mysql
useradd mysql -g mysql

./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql/
cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld
chmod 755 /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
chkconfig --level 3 mysqld on

vim /etc/rc.d/init.d/mysqld
/*
把basedir=编辑成basedir=/usr/local/mysql
把datadir=编辑成datadir=/data/mysql/
*/

cd /usr/local/mysql/
cp bin/mysqladmin /bin
cp bin/mysql /bin

#好吧,下边启动mysqld服务
service mysqld start 
/*
如果报错,请查看my.cnf下的日志记录
如果报:Can't open and lock privilege tables: Table 'mysql.host' doesn't exist 这个错,
就重新运行./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/home/data/mysql/
*/

posted on 2012-05-31 17:30  davyfamer  阅读(664)  评论(0编辑  收藏  举报