##安装mysql需要的依赖包
yum install ncurses-devel libaio-devel -y
##安装编译MySQL需要的软件
由于MySQL5.5及以上的系列产品要采用特殊的编译方式安装,因此,需要先安装常用的编译MySQL的工具cmake软件包,命令为:
yum install cmake -y
##上传软件到/home/oldboy/tools
解压 tar xf
##编译
cmake \
-DCMAKE_INSTALL_PREFIX=/application/mysql-5.6.34 \
-DMYSQL_DATADIR=/application/mysql-5.6.34/data \
-DMYSQL_UNIX_ADDR=/application/mysql-5.6.34/tmp/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DEXTRA_CHARSETS=gbk,gb2312,utf8,ascii \
-DENABLED_LOCAL_INFILE=ON \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \
-DWITH_FAST_MUTEXES=1 \
-DWITH_ZLIB=bundled \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_READLINE=1 \
-DWTIH_EMBEDDED_SERVER=1 \
-DWITH_DEBUG=0
##创建软连接
ln -s /application/mysql-5.6.34/ /application/mysql
useradd -s /sbin/nologin -M mysql
chown -R mysql.mysql /application/mysql/
# 复制配置文件
\cp /application/mysql/support-files/my-default.cnf /etc/my.cnf
# 初始化
/application/mysql/scripts/mysql_install_db --basedir=/application/mysql --datadir=/application/mysql/data/ --user=mysql
# 授权用户
chown -R mysql. /application/mysql*
# 复制启动文件
\cp /application/mysql/support-files/mysql.server /etc/init.d/mysqld
# 降权,降权限
chmod 700 /etc/init.d/mysqld
# 开机自启动
chkconfig mysqld on
chkconfig --list mysqld
/etc/init.d/mysqld start
# cp /application/mysql/bin/mysql /usr/local/sbin/
# 命令的配置文件。
echo "PATH=/application/mysql/bin/:$PATH" >> /etc/profile
tail -1 /etc/profile
. /etc/profile
echo $PATH