Sudo apt-get install cmake                       ;( Cmake 编译的必要工具) 
sudo apt-get install libncurses5-dev             ;(需要安装  不然Cmake会报错) 
sudo apt-get install bison                       ;(make会出警告) 
sudo apt-get install chkconfig                   ;(开机启动  )  
sudo apt-get install build-essential (安装gcc-c++组件)
groupadd mysql                            


useradd -g mysql -s /sbin/nologin mysql        



tar zxvf mysql-5.5.21.tar.gz                    

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql  -DMYSQL_DATADIR=/usr/local/mysql/data   -DSYSCONFDIR=/etc -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock -DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DMYSQL_USER=mysql

make
make install

cp  /usr/src/mysql-5.5.21/support-files/mysql.server  /etc/init.d/mysqld                     

vim mysqld  

basedir=/usr/local/mysql 
datadir=/usr/local/mysql/data 


mv mysqld /etc/init.d/mysqld

chmod 755 /etc/init.d/mysql

cd /usr/local/mysql/support-files 
cp my-medium.cnf /etc/my.cnf


vim /etc/my.cnf

[mysqld]

character_set_server=utf8 
log-error=/usr/local/mysql/data/error.log



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

chown
–R mysql /usr/local/mysql/

echo "/usr/local/mysql/lib/mysql" >> /etc/ld.so.conf

/etc/init.d/mysqld start 

/usr/local/mysql/bin/mysqladmin
–u root password $mysqlpass

FLUSH PRIVILEGES;