shell脚本一键安装mysql5.7.x(免安装版)
使用脚本一键安装mysql5.7.x,初始化数据库,启动数据库----
mysql版本:源码mysql5.7.10
linux版本:centos6.5 x86_64
#!/bin/bash
GROUP_NAME=mysql
USER_NAME=mysql
MYSQLDB_HOME=/home/mysql/mysql
MYSQLDB_DATA_HOME=/home/mysql/mysql/data
ERROR_EXIT=65
MYSQL_VERSION="mysql-5.7.10"
CMAKE_VERSION="cmake-3.4.3"
BOOST_VERSION="boost_1_59_0"
CPU_NUMBERS=$(cat /proc/cpuinfo |grep "processor"|wc -l)
MYSQL_ID=`ifconfig eth0 | grep "inet addr" | awk -F. '{print $4}' | awk '{print $1}'`
COMPUTER_MEM=`free -m |grep "Mem"|awk '{print $2}'`
MYSQL_MEM=`expr $COMPUTER_MEM - $COMPUTER_MEM / 4`
echo "$MYSQL_MEM"
echo "====================================================="
echo "setup MySQL 5.7.10 on centos6.5_64bit "
echo "your computer is $CPU_NUMBERS processes ,mysql Memory is $MYSQL_MEM M"
echo "you will input mysql's root password and mysql's memory"
echo "====================================================="
sleep 1
read -n1 -p "are you sure setup[y/n]?" answer
case $answer in
Y | y)
echo
echo "start setup....";;
N | n)
echo
echo "Cancel setup...."
exit 10 ;;
*)
echo
echo "error input parameter....."
exit 11 ;;
esac
#check if user is root
if [ $(id -u) != "0" ];then
echo "Error: You must be root to run this script!"
exit 1
fi
#addGroup
if [ -z $(cat /etc/group|awk -F: '{print $1}'| grep -w "$GROUP_NAME") ]
then
groupadd $GROUP_NAME
if(( $? == 0 ))
then
echo "group $GROUP_NAME add sucessfully!"
fi
else
echo "$GROUP_NAME is exsits"
fi
#addUser
if [ -z $(cat /etc/passwd|awk -F: '{print $1}'| grep -w "$USE_NAME") ]
then
adduser -g $GROUP_NAME $USER_NAME
if (( $? == 0 ))
then
echo "user $USER_NAME add sucessfully!"
fi
else
echo "$USER_NAME is exsits"
fi
for i in make gcc-c++ bison-devel ncurses-devel perl perl-devel wget
do
yum -y install $i
done
####down lib:System Requirements,CMAKE>=2.8,BOOST>=1.59.0
rm -rf /tmp/cmake-3.4*
wget https://cmake.org/files/v3.4/${CMAKE_VERSION}.tar.gz -P /tmp
if(( $? == 0 ))
then
echo "cmake DownLoad sucessfully!"
else
echo "cmake DownLoad failed!"
exit $ERROR_EXIT
fi
cd /tmp
tar xzvf ${CMAKE_VERSION}.tar.gz
cd ${CMAKE_VERSION}
./bootstrap
make && make install
yum install gcc gcc-c++ bzip2 bzip2-devel bzip2-libs python-devel -y
rm -rf /tmp/boost_1_59*
wget http://downloads.sourceforge.net/project/boost/boost/1.59.0/${BOOST_VERSION}.tar.gz -P /tmp
if(( $? == 0 ))
then
echo "boost DownLoad sucessfully!"
else
echo "boost DownLoad failed!"
exit $ERROR_EXIT
fi
cd /tmp
tar xzvf ${BOOST_VERSION}.tar.gz
cd ${BOOST_VERSION}
./bootstrap.sh
./b2 install
#downMySQL
rm -rf /tmp/mysql-5.7.*
wget http://downloads.mysql.com/archives/get/file/${MYSQL_VERSION}.tar.gz -P /tmp
if(( $? == 0 ))
then
echo "MySQL DownLoad sucessfully!"
else
echo "MySQL DownLoad failed!"
exit $ERROR_EXIT
fi
cd /tmp
tar xzvf ${MYSQL_VERSION}.tar.gz
cd ${MYSQL_VERSION}
if [ -s /etc/my.cnf ]; then
mv /etc/my.cnf /etc/my.cnf.`date +%Y%m%d%H%M%S`.bak
fi
cmake \
-DCMAKE_INSTALL_PREFIX=/home/mysql/mysql \
-DMYSQL_DATADIR=/home/mysql/mysql/data \
-DWITH_BOOST=/usr/local/include/boost \
-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
make -j$CPU_NUMBERS && make install
if [ -s /etc/my.cnf ]; then
mv /etc/my.cnf /etc/my.cnf.`date +%Y%m%d%H%M%S`.bak
fi
#custom set mysql mem
#MYSQL_MEM="800M"
#echo -e "please input Mysql Memory ,like 1G ,1M !"
#read -p "(Default Memory is: 800M):" MYSQL_MEM
#if [ "$MYSQL_MEM" = "" ];then
# MYSQL_MEM="800M"
#fi
#set mysql root password
echo "==========================="
mysqlrootpwd="root"
echo -e "Please input the root password of mysql:"
read -p "(Default password: root):" mysqlrootpwd
if [ $mysqlrootpwd = "" ]
then
mysqlrootpwd="root"
fi
echo "MySQL root's password is $mysqlrootpwd"
echo "================================="
mkdir -p $MYSQLDB_HOME/log
touch $MYSQLDB_HOME/log/mysql-error.log
touch $MYSQLDB_HOME/log/mysql-slow.log
chown -R mysql:mysql $MYSQLDB_HOME
echo "[mysql]
default-character-set=UTF8
[client]
#default-character-set=UTF8
[mysqld]
#datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
port = 3306
basedir = $MYSQLDB_HOME
datadir = $MYSQLDB_DATA_HOME
pid-file = $MYSQLDB_HOME/mysql.pid
user = mysql
server-id = $MYSQL_ID
#rpl_semi_sync_master_enabled=1
#rpl_semi_sync_master_timeout=1000
#rpl_semi_sync_slave_enabled=1
relay_log_purge=0
read_only=0
slave-skip-errors=1396
lower_case_table_names = 1
character-set-server=utf8
skip-name-resolve
skip-external-locking
back_log = 500
max_connections = 500
max_connect_errors = 2000
open_files_limit = 65535
table_open_cache = 128
max_allowed_packet = 64M
##thread_concurrency = `expr $CPU_NUMBERS + $CPU_NUMBERS`
key_buffer_size = 64M
read_buffer_size = 64M
read_rnd_buffer_size = 16M
sort_buffer_size = 16M
join_buffer_size = 16M
tmp_table_size = 96M
max_heap_table_size = 96M
query_cache_size = 8M
query_cache_limit = 8M
thread_cache_size = 64
log_bin = mysql-bin
binlog_format = mixed
binlog_cache_size = 8M
sync_binlog = 1
max_binlog_cache_size = 8M
max_binlog_size = 500M
expire_logs_days = 10
log_error = $MYSQLDB_HOME/log/mysql-error.log
slow_query_log = 1
long_query_time = 1
slow_query_log_file = $MYSQLDB_HOME/log/mysql-slow.log
default_storage_engine = InnoDB
innodb_buffer_pool_size = $MYSQL_MEM
innodb_file_per_table = 1
innodb_data_home_dir = $MYSQLDB_DATA_HOME
innodb_data_file_path = ibdata1:500M;ibdata2:1G:autoextend
innodb_log_group_home_dir = $MYSQLDB_HOME
innodb_log_file_size = 500M
innodb_log_buffer_size = 20M
innodb_flush_log_at_trx_commit = 1
innodb_print_all_deadlocks = 1
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid" >/etc/my.cnf
##$MYSQLDB_HOME/scripts/mysql_install_db --defaults-file=/etc/my.cnf --basedir=$MYSQLDB_HOME --datadir=$MYSQLDB_DATA_HOME --user=$USER_NAME
####Before MySQL 5.7.6使用mysql_install_db,MySQL 5.7.6 and up使用mysqld
${MYSQLDB_HOME}/bin/mysqld --initialize-insecure --basedir=$MYSQLDB_HOME --datadir=$MYSQLDB_DATA_HOME --user=$USER_NAME
cp $MYSQLDB_HOME/support-files/mysql.server /etc/init.d/mysql
chmod 755 /etc/init.d/mysql
chkconfig --add mysql
chkconfig mysql on
/etc/init.d/mysql start
cat >> /etc/profile <<EOF
PATH=$MYSQLDB_HOME/bin:\$PATH
export PATH
EOF
source /etc/profile
mysqladmin -u root password $mysqlrootpwd
echo "set up successfully!enjoy it...."
exit 0
shell脚本一键安装mysql5.7.x(免安装版)的更多相关文章
- MySQL安装 MySQL5.7.10免安装版配置,mysql5.7.10免安装版
MySQL5.7.10免安装版配置,mysql5.7.10免安装版 最新版的 Mysql 不提供图形界面的安装了, 下载下来是一个压缩包的形式, 那么我们如何来使用它呢, 让它为我们工作呢? 环境: ...
- Centos 6.4上面用Shell脚本一键安装mysql 5.6.15
Centos 6.4上面用Shell脚本一键安装mysql 5.6.15 #!/bin/bash if [ `uname -m` == "x86_64" ];then machi ...
- Shell脚本一键部署——源码编译安装MySQL及自动补全工具
Shell脚本一键部署--源码编译安装MySQL及自动补全工具 编译安装MySQL 1.软件包 Mysql安装包 将安装包拖至/opt目录下,编辑一个脚本文件,将以下内容复制进去,然后source或者 ...
- Centos 6.4上面用Shell脚本一键安装vsftpd
Centos 6.4上面用Shell脚本一键安装vsftpd install.sh #!/bin/bash if [ `uname -m` == "x86_64" ];then m ...
- 安装完Ubuntu后通过shell脚本一键安装软件
安装完Ubuntu后通过shell脚本一键安装软件 以下代码中#是单行注释 :<<! ! 是多行注释. 运行的时候需要把多行注释去掉. 比如把以下代码保存为install.sh, 那么在终 ...
- MySQL-5.6.13免安装版配置方法
MySQL-5.6.13免安装版配置方法 1. 下载MySQL Community Server 5.6.13 2. 解压MySQL压缩包 将以下载的MySQL压缩包解压到自定义目录下,我的 ...
- mysql5.7版本免安装配置教程
自己花了两天时间才搞清楚,希望对新手有一定帮助,有问题可以联系哦! mysql分为安装版本msi,免安装要压缩版本ZIP,下载网址:http://dev.mysql.com/downloads 免安装 ...
- shell脚本一键同步集群时间
shell脚本一键同步集群时间 弋嘤捕大 椿澄辄 ψ壤 茇徜燕 ㄢ交涔沔 阚龇棚绍 テ趼蜱棣 灵打了个寒颤也没有去甩脱愣是拖着 喇吉辔 秋北酏崖 琮淄脸酷 茇呶剑 莲夤罱 陕遇骸淫 ...
- MySQL5.7.19 免安装配置 + Navicat for MySQL安装和破解(附全部资源)
近段时间因为工作原因安装了好多次本地MySQL,安装过程也是时有曲折,索性记录一下. 环境: Win10 家庭版 MySQL5.7.19 (链接:https://pan.baidu.com/s/1 ...
随机推荐
- Python中的文本(一)
本文主要记录和总结本人在阅读<Python标准库>一书,文本这一章节的学习和理解. 事实上在Python中,使用文本这种一些方法是特别经常使用的一件事.在一般的情况下,都会使用String ...
- 展示C代码覆盖率的gcovr工具简单介绍及相关命令使用演示样例
(本人正在參加2015博客之星评选,诚邀你来投票,谢谢:username=zhouzxi">http://vote.blog.csdn.net/blogstar2015/candida ...
- 并发,one
引言 最近工作当中写了一个有关并发的程序,引起了LZ对并发的强烈兴趣.这一下一发不可收拾,LZ用了一个多星期,看完了这本共280+页的并发编程书.之所以能看这么快,其实这主要归功于,自己之前对并发就有 ...
- 芯片SA58672(功放芯片)
1::下面的中文图可能不准: 针对上面的图,数据手册中有一些参数的推导: 这个式子是电压增益的 这个式子是关于截止频率的 典型原理图: 需要电源去耦,能够提高效率. PVDD引脚处的电 ...
- Day2:字典
一.定义 字典是一种“key-value”成对出现的数据类型,中间用冒号把key与value隔,不同的数据用逗号隔开,全部数据用大括号括起来 info = { 'stu1101': "Ten ...
- 【Codeforces Round #301 (Div. 2) C】 Ice Cave
[链接] 我是链接,点我呀:) [题意] 给你一个n*m的地图. 每个地图为0的时候可以安全走过,且走过后变成1. (一定要离开之后才会变成1) 而为1的则走过之后会掉入下一层. 你一开始在初始位置( ...
- 10.14 android输入系统_多点触摸驱动测试及Reader线程、InputStage分析
21. 多点触摸_电容屏驱动程序_实践_tiny4412 tiny4412触摸屏: 分辨率为800 x 480http://wiki.friendlyarm.com/wiki/index.php/LC ...
- NIO 入门(转)
NIO 入门 Greg Travis2003 年 11 月 17 日发布 分享此页面 WeiboGoogle+用电子邮件发送本页面 20 在开始之前 关于本教程 新的输入/输出 (NIO) 库是在 J ...
- radare, the reverse engineering framework
History The radare project [http://radare.org/] started in February of 2006 aiming to provide a free ...
- 3D 应用程序性能
原文:3D 应用程序性能 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/m0_37591671/article/details/74595999 3 ...