yum install gcc
yum install gcc-c++
groupadd mysql
useradd --shell /sbin/nologin -g mysql mysql
tar zxvf mysql-5.1.51.tar.gz
cd mysql-5.1.51
./configure --prefix=/usr/local/mysql \
--localstatedir=/usr/local/mysql/data \
--with-charset=utf8 \
--with-collation=utf8_general_ci \
--with-extra-charsets=gb2312,gbk \
--with-plugins=max-no-ndb \
--with-unix-socket-path=/tmp/mysql.sock \
--enable-local-infile \
--enable-assembler \
--with-client-ldflags=-all-static \
--with-mysqld-ldflags=-all-static \
--enable-thread-safe-client
make
make install
cp support-files/my-medium.cnf /etc/my.cnf
cp support-files/mysql.server /etc/init.d/mysql
chmod u+x /etc/init.d/mysql
cd /usr/local/mysql
bin/mysql_install_db --user=mysql
chown -R root .
chown -R mysql data
chgrp -R mysql .
chkconfig --add mysql
chkconfig --level 345 mysql on
bin/mysqld_safe --user=mysql &
service mysql restart
ln -s /usr/local/mysql/bin/mysql /sbin/mysql
ln -s /usr/local/mysql/bin/mysqladmin /sbin/mysqladmin
mysqladmin -uroot password "yourpassword"
reference:
http://www.sqlstudy.com/article/mysql-compile-install-under-linux-centos-5.html