1)创建用户

useradd -r -s /sbin/nologin mysql

mkdir /data/mysql -p

2)下载并解压安装

wget http://mysql.ntu.edu.tw/Downloads/MySQL-5.1/mysql-5.1.62.tar.gz

tar -zxvf mysql-5.1.62.tar.gz

cd mysql-5.1.62

./configure --prefix=/usr/local/mysql--datadir=/data/mysql --with-mysqld-user=mysql --enable-assembler--enable-thread-safe-client --with-big-tables --without-debug --with-pthread--with-extra-charsets=complex --with-readine --with-ssl --with-embedded-server--enable-local-infole --with-plugin=partition,innobase --with-plugin-PLUGIN--with-mysqld-ldflags=-all-static --with-client-ldfags=-all-static


3)安装前的准备

vim /etc/my.cnf

[mysqld]

datadir=/data/mysql

socket=/var/lib/mysql/mysql.sock

user=mysql

# Disabling symbolic-links is recommendedto prevent assorted security risks

symbolic-links=0


[mysqld_safe]

log-error=/var/log/mysqld.log

pid-file=/var/lib/mysql/mysqld.pid


chown -R mysql:mysql /usr/local/mysql

chown -R mysql:mysql /data/mysql

chown -R mysql:mysql /var/lib/mysql

cat /etc/profile.d/mysql.sh

export PATH=$PATH:/usr/local/mysql


source /etc/profile.d/mysql.sh

4)安装

/usr/local/mysql/bin/mysql_install_db--basedir=/usr/local/mysql --datadir=/data/mysql --user=mysql


cp /mysql-5.1.62/support-files/mysql.server/etc/init.d/mysqld

vim /etc/init.d/mysqld

basedir=/usr/local/mysql

datadir=/data/mysql


Chmod +x /etc/mysqld

5)启动

mysqladmin-u root –pmysql