使用脚本一键安装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(免安装版)的更多相关文章

  1. MySQL安装 MySQL5.7.10免安装版配置,mysql5.7.10免安装版

    MySQL5.7.10免安装版配置,mysql5.7.10免安装版  最新版的 Mysql 不提供图形界面的安装了, 下载下来是一个压缩包的形式, 那么我们如何来使用它呢, 让它为我们工作呢? 环境: ...

  2. 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 ...

  3. Shell脚本一键部署——源码编译安装MySQL及自动补全工具

    Shell脚本一键部署--源码编译安装MySQL及自动补全工具 编译安装MySQL 1.软件包 Mysql安装包 将安装包拖至/opt目录下,编辑一个脚本文件,将以下内容复制进去,然后source或者 ...

  4. Centos 6.4上面用Shell脚本一键安装vsftpd

    Centos 6.4上面用Shell脚本一键安装vsftpd install.sh #!/bin/bash if [ `uname -m` == "x86_64" ];then m ...

  5. 安装完Ubuntu后通过shell脚本一键安装软件

    安装完Ubuntu后通过shell脚本一键安装软件 以下代码中#是单行注释 :<<! ! 是多行注释. 运行的时候需要把多行注释去掉. 比如把以下代码保存为install.sh, 那么在终 ...

  6. MySQL-5.6.13免安装版配置方法

    MySQL-5.6.13免安装版配置方法   1. 下载MySQL Community Server 5.6.13 2. 解压MySQL压缩包    将以下载的MySQL压缩包解压到自定义目录下,我的 ...

  7. mysql5.7版本免安装配置教程

    自己花了两天时间才搞清楚,希望对新手有一定帮助,有问题可以联系哦! mysql分为安装版本msi,免安装要压缩版本ZIP,下载网址:http://dev.mysql.com/downloads 免安装 ...

  8. shell脚本一键同步集群时间

    shell脚本一键同步集群时间 弋嘤捕大 椿澄辄 ψ壤 茇徜燕 ㄢ交涔沔 阚龇棚绍 テ趼蜱棣 灵打了个寒颤也没有去甩脱愣是拖着 喇吉辔 秋北酏崖 琮淄脸酷 茇呶剑 莲夤罱 陕遇骸淫  ...

  9. MySQL5.7.19 免安装配置 + Navicat for MySQL安装和破解(附全部资源)

    近段时间因为工作原因安装了好多次本地MySQL,安装过程也是时有曲折,索性记录一下. 环境: Win10 家庭版 MySQL5.7.19   (链接:https://pan.baidu.com/s/1 ...

随机推荐

  1. Project Euler 516 5-smooth totients (数论)

    题目链接: https://projecteuler.net/problem=516 题目: \(5\)-smooth numbers are numbers whose largest prime ...

  2. Javascript和jquery事件--事件监听器

    之前看完了js和jq的冒泡捕获和事件对象event,这里看看同时使用js和jq后我最容易混淆的监听器的绑定. (1) js的监听器绑定解绑 绑定监听器有两种方式: a.on-事件type,比如oncl ...

  3. IDEACould not autowire. No beans of 'xxxMapper' type found.

    作为一名刚开始使用idea的新手,最近在使用maven+springMVC框架时遇到了这样一个问题:Could not autowire. No beans of 'xxxMapper' type f ...

  4. 损失函数 - Andrew Ng机器学习公开课笔记1.2

    线性回归中提到最小二乘损失函数及其相关知识.对于这一部分知识不清楚的同学能够參考上一篇文章<线性回归.梯度下降>. 本篇文章主要解说使用最小二乘法法构建损失函数和最小化损失函数的方法. 最 ...

  5. mysql :Native table 'performance_schema'.'cond_instances' has the wrong structure

    err: 150418 13:25:06 [ERROR] Native table 'performance_schema'.'cond_instances' has the wrong struct ...

  6. [Nuxt] Build a Vue.js Form then use Vuex Actions to Post to an API in Nuxt

    The default behavior of submitting an HTML form is to reload the page. You can use the Vue.js @submi ...

  7. Android之RecyclerView简单使用(三)

    使用过ListView滴小伙伴都知道.ListView有这样一个属性android:divider,用来设置每一个item之间切割线滴属性.问题来了,那么RecyclerView这个控件有没有这个属性 ...

  8. 结合Wireshark捕获分组深入理解TCP/IP协议之以太网帧

    摘要:     本文摘抄并整理了以太网相关理论知识,包括CSMA/CD协议机制及工作.LAN互连,详细分析了Ethernet II帧格式,最后给出Ethernet II帧实例. 一.以太网[1] 1. ...

  9. MongoDB集群安装与配置2.4.3版本

    mongoDB安装http://www.mongodb.org/downloads拷文件到# cp mongodb-linux-i686-2.4.1.tgz /usr/local/进入目录:# cd ...

  10. Mybatis全面详解——下(学习总结)

    原文地址:https://blog.csdn.net/ititii/article/details/79999481 一.Mybatis关联查询映射 这里采用一个案例来进行分析:(下面的案例都是采用M ...