时间:2021-07-01 10:21:17 帮助过:2人阅读
#!/bin/bash
#Date:2017-04-21
#Author:Allen_Jol
#mysql-5.6.17_v2.0
#卸载自带的mysql-libs
rpm -e --nodeps mysql-libs
#安装所需软件依赖
yum -y install make gcc gcc-c++ ncurses ncurses-devel pcre pcre-devel zlib zlib-devel openssl openssl-devel
MDIR=/usr/local/src
cd $MDIR
ls *.tar.gz | xargs -n1 tar zxvf
#Mysql install
echo "============Mysql-5.6.17 install==========="
sleep 2
groupadd mysql
useradd -s /sbin/nologin -g mysql -M mysql
mkdir -p /usr/local/mysql/data
#编译camke mysql5.5以后都用cmake代替原来的./configure
cd $MDIR/cmake-2.8.12.2
./configure
make && make install
sleep 2
#正式开始编译安装mysql
cd $MDIR/mysql-5.6.17/
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DSYSCONFDIR=/etc -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock -DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/usr/local/src/boost_1_59_0
sleep 3
make && make install
sleep 2
#更改权限
chmod +w /usr/local/mysql
chown -R mysql:mysql /usr/local/mysql
#初始化数据库
/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
#拷贝脚本文件
\cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
#给脚本文件赋予权限
chmod +x /etc/init.d/mysqld
#拷贝/my.cnf文件
\cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf
#启动mysql或者用/etc/init.d/mysqld start
service mysqld start
#开机自启
chkconfig mysqld on
#更改mysql密码
/usr/local/mysql/bin/mysqladmin -uroot password ‘123456‘
#配置环境变量
echo ‘export PATH=$PATH:/usr/local/mysql/bin‘>> /etc/profile
. /etc/profile
#如果不能直接登录mysql 手动source /etc/profile一下即可
本文出自 “12252646” 博客,请务必保留此出处http://12262646.blog.51cto.com/12252646/1947183
mysql-5.6.17编译安装脚本
标签:mysql