第一个历程:下载软件
wget https://downloads.mysql.com/archives/get/file/mysql-5.6.20.tar.gz
第二个历程:上传服务器并解压
tar xf mysql-5.6.20.tar.gz
第三个历程:下载依赖软件
yum install -y cmake gcc-c++ ncurses-devel perl-Dumper boot boot-doc boost-devel perl
第四个历程:创建目录
mkdir /usr/local/mysql
mkdir /data/mysql /var/run/mysqld /var/log/mysqld
第五个历程:创建用户并授权
useradd mysql
chown -R mysql.mysql /usr/local/mysql
第六个历程:编译mysql
cmake ./ -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=gbk,gb2312 -DENABLED_LOCAL_INFILE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1
make && make install
第七个历程:生成配置文件
cat > /etc/my.cnf <<EOF
[mysqld]
port=3306
datadir=/data/mysql
pid-file=/var/run/mysqld/mysql.pid
socket=/data/mysql/mysql.socket
log-error=/var/log/mysqld/mysql-err.log
user=mysql
[client]
port=3306
socket=/data/mysql/mysql.socket
EOF
第八个历程:授权
chown -R mysql.mysql /data/mysql /var/run/mysqld /var/log/mysqld /usr/local/mysql/
第九个历程:初始化数据
/usr/local/mysql/scripts/mysql_install_db --datadir=/data/mysql/ --user=mysql
第十个历程:启动数据库,登录数据库
/usr/local/mysql/bin/mysqld_safe --defaults-file=/usr/local/mysql/etc/my.cnf &
/usr/local/mysql/bin/mysql