1. 创建用户
# groupadd mysql
# useradd -g mysql mysql -s /sbin/nologin
2. 安装所需软件
# yum install -y gcc.x86_64 gcc-c++.x86_64 ncurses-devel.x86_64 make bison.x86_64 bison-devel.x86_64
# tar xvf cmake-2.8.12.2.tar.gz #安装高版本的cmake是为安装ndbcluster做准备
# ./bootstrap; make; make install #cmake 的安装命令
3. 解压安装
# tar xvf mysql-5.5.30.tar.gz
# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/data/dbdata \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DMYSQL_UNIX_ADDR=/usr/local/mysql/tmp/mysql.sock \
-DMYSQL_TCP_PORT=3306 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_EXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_SSL=yes
# make && make install
4. 创建目录
# mkdir -p /data/dbdata
# chown mysql.mysql /usr/local/mysql -R
# chown mysql.mysql /data/dbdata -R
5. 复制配置文件
# cp /soft/mysql-5.5.30/support-files/my-large.cnf /etc/my.cnf
6. 复制启动脚本
# cp /soft/mysql-5.5.30/support-files/mysql.server /etc/init.d/mysqld
# chmod +x /etc/init.d/mysqld
7. 初始化数据库文件
# /usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/data/dbdata/
8. 启动MySQL,并登录
# /etc/init.d/mysqld start
# /usr/local/mysql/bin/mysql -uroot
9. 修改用户登录密码
# /usr/local/mysql/bin/mysqladmin -u root password "mysql"
# /usr/local/mysql/bin/mysql -uroot -pmysql
###修改环境变量
# vim ~/.bash_profile
PATH=$PATH:$HOME/bin:/usr/local/mysql/bin export PATH
# source ~/.bash_profile #使修改后的文件立即生效
# mysql -uroot -pmysql