Terry.Li-彬

虚其心,可解天下之问;专其心,可治天下之学;静其心,可悟天下之理;恒其心,可成天下之业。

  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  143 随笔 :: 344 文章 :: 130 评论 :: 0 Trackbacks
https://github.com/fly2wind/TSShellScript

#!/bin/sh
########################################################################################
#
# Install MySQL Script
#
# Shawn Ma
# 2013-01-06
#
########################################################################################
# Define
TARGET=mysql-5.5.29.tar.gz
SOURCE=http://cdn.mysql.com/Downloads/MySQL-5.5/$TARGET

# Create a build directory
mkdir -p /opt/install/mysql && cd /opt/install/mysql

# Prepare for compilation source
curl -o $TARGET $SOURCE
mkdir -p tmp && tar -zxvf $TARGET -C tmp

# Install build dependencies
yum install -y gcc gcc-c++ make cmake autoconf automake
yum install -y bison ncurses-devel

# Create a User Group
groupadd mysql
useradd -r -g mysql mysql

# Compile and deploy
mv tmp/* source && cd source
cmake \
-DCMAKE_INSTALL_PREFIX=/opt/server/database/mysql \
-DSYSCONFDIR=/opt/server/database/mysql \
-DMYSQL_UNIX_ADDR=/opt/server/database/mysql/tmp/mysql.sock \
-DMYSQL_TCP_PORT=3306 \
-DMYSQL_DATADIR=/opt/server/database/mysql/data \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS:STRING=all \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_DEBUG=OFF \
-DMYSQL_USER=mysql
make
make install

cd /opt/server/database/mysql
curl -o my.cnf https://raw.github.com/fly2wind/TSShellScript/master/mysql/conf/my.cnf


# Postinstallation setup
cd /opt/server/database/mysql
chown -R mysql .
chgrp -R mysql .
scripts/mysql_install_db --user=mysql
chown -R root .
chown -R mysql data

# Configuration
curl -o /etc/init.d/mysql https://raw.github.com/fly2wind/TSShellScript/master/mysql/init/mysql
chmod a+x /etc/init.d/mysql

/etc/init.d/mysql start
bin/mysqladmin -u root password "TV.xian"
bin/mysql -u root -pTV.xian -e "GRANT ALL ON *.* TO 'root'@'%' IDENTIFIED BY 'TV.xian' WITH GRANT OPTION; FLUSH PRIVILEGES;"
bin/mysql -u root -pTV.xian -e "GRANT REPLICATION SLAVE ON *.* TO 'backup'@'%' IDENTIFIED BY 'backup'; FLUSH PRIVILEGES;";
/etc/init.d/mysql stop

# Additional
chkconfig --add mysql
chkconfig mysql on

posted on 2013-01-09 14:59 礼物 阅读(822) 评论(0)  编辑  收藏 所属分类: Linux