码迷,mamicode.com
首页 > 数据库 > 详细

mysql的编译安装脚本

时间:2019-10-28 00:51:53      阅读:131      评论:0      收藏:0      [点我收藏+]

标签:rop   编译安装   gen   basedir   print   source   http   share   enabled   

#!/usr/bin/env bash
#mysql 编译安装 by blackmed
byhe(){

rpm -qa | grep mariadb
if [ $? -eq 0 ];then
    rpm -e --nodeps >/dev/null
fi
rm -rf /etc/my* >/dev/null
rm -rf /var/lib/mysql >/dev/null
userdel -r mysql >/dev/null

rpm -qa | grep cmake
if [ $? -ne 0 ];then 
yum -y install cmake ncurses ncurses-devel openssl-devel bison gcc gcc-c++ make >/dev/null
echo "========================================"
echo "The success of the prophase environment."
echo "========================================"
fi

useradd -r mysql -M -s /sbin/nologin

mkdir /mysql
wget  -O /mysql/mysql-5.7.20.tar.gz https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.20.tar.gz   >/dev/null
tar xvf /mysql/mysql-5.7.20.tar.gz -C /mysql/
cd /mysql/mysql-5.7.20

cmake .  
-DDOWNLOAD_BOOST=1 
-DWITH_BOOST=boost_1_59_0/ 
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql 
-DSYSCONFDIR=/etc 
-DMYSQL_DATADIR=/usr/local/mysql/data 
-DINSTALL_MANDIR=/usr/share/man 
-DMYSQL_TCP_PORT=3306 
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock 
-DDEFAULT_CHARSET=utf8 -DEXTRA_CHARSETS=all 
-DDEFAULT_COLLATION=utf8_general_ci 
-DWITH_READLINE=1 -DWITH_SSL=system 
-DWITH_EMBEDDED_SERVER=1 
-DENABLED_LOCAL_INFILE=1 
-DWITH_INNOBASE_STORAGE_ENGINE=1

    make && make install
    echo "==========================="
    echo "mysql install successfully"
    echo "==========================="

chown -R mysql.mysql /usr/local/mysql/
local_mysql=/usr/local/mysql/bin
${local_mysql}/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data 
mima=`${local_mysql}/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data | awk ‘/localhost\:/{print $NF}‘ `
touch /etc/my.cnf
echo "[mysqld]" >> /etc/my.cnf
echo "basedir=/usr/local/mysql" >> /etc/my.cnf
echo "datadir=/usr/local/mysql/data" >> /etc/my.cnf

sed -i ‘/PATH=/cPATH=$PATH:$HOME/bin:/usr/local/mysql/bin‘ ~/.bash_profile

source ~/.bash_profile

mysqld_safe --user=mysql &  
mysqladmin -u root -p${mima} password 1
echo "==============================================="
echo "Initialization completion can be used normally."
echo "==============================================="
}

byhe

mysql的编译安装脚本

标签:rop   编译安装   gen   basedir   print   source   http   share   enabled   

原文地址:https://blog.51cto.com/14535577/2445833

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!