Mysql脚本备忘

#
# Installation script
#
# Prepare for compilation environment
yum install -y groupinstall "Development Tools"

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

# Prepare for compilation source
cd /opt/install/mysql
curl -o mysql-5.5.24.tar.gz http://ftp.iij.ad.jp/pub/db/mysql/Downloads/MySQL-5.5/mysql-5.5.24.tar.gz
tar -zxvf mysql-5.5.24.tar.gz

# Install build dependencies
yum install -y cmake ncurses-devel

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

# Compile and deploy
cd mysql-5.5.24
cmake \
-DCMAKE_INSTALL_PREFIX=/opt/server/database/mysql \
-DSYSCONFDIR=/opt/server/database/mysql/conf \
-DMYSQL_UNIX_ADDR=/opt/server/database/mysql/tmp/mysql.sock \
-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

# 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
mkdir -p conf
cp support-files/my-medium.cnf conf/my.cnf
cp support-files/mysql.server /etc/init.d/mysql
chmod a+x /etc/init.d/mysql
##chkconfig --add mysql
##chkconfig --level 345 mysql on

# Additional
/etc/init.d/mysql start
bin/mysqladmin -u root password "****"
/etc/init.d/mysql stop

猜你喜欢

转载自fly2wind.iteye.com/blog/1545087