准备环境:Centos6.5(6系列操作系统)

[root@localhost ~]# yum -y install gcc gcc-c++ ncurses-devel libxml2-devel zlib-devel pcre-devel

[root@localhost ~]# tar zxvf bison-2.5.tar.gz

[root@localhost ~]# cd bison-2.5

[root@localhost ~]# ./configure &&make &&make install

[root@localhost ~]# tar zxvf cmake-2.8.7.tar.gz

[root@localhost ~]# cd cmake-2.8.7

[root@localhost ~]# ./bootstrap &&gmake &&gmake install

[root@localhost ~]# tar zxvf mysql-5.5.22.tar.gz

[root@localhost ~]# cd mysql-5.5.22

[root@localhost ~]# useradd mysql

[root@localhost ~]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all -DSYSCONFDIR=/etc/ &&make &&make install

参数注释:安装目录、默认编码、校验字符集、安装所有扩展字符集、配置文件目录

[root@localhost ~]# chown -R :mysql /usr/local/mysql

[root@localhost ~]# cd /usr/local/mysql/support-files

[root@localhost ~]# cp my-medium.cnf /etc/my.cnf

[root@localhost ~]# cp mysql.server /etc/init.d/mysqld

[root@localhost ~]# cd ../scripts/


下面操作将进行mysql初始化,指定基础目录,存放数据目录,及运行用户

[root@localhost ~]# ./mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql 

[root@localhost ~]# /etc/init.d/mysqld start

[root@localhost ~]# echo "PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile

[root@localhost ~]# source /etc/profile

[root@localhost ~]# mysqladmin -u root password 'redhat'  设置mysql运行账户及密码,这个root可不是系统用户的root哦!

[root@localhost ~]# mysql -u root -p

Enter password: 


OK,安装完成