Last active
December 18, 2015 01:59
-
-
Save pacojp/5707825 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# # sample usage | |
# curl -o /tmp/install_mysql_server.sh https://gist.github.com/pacojp/5707825/raw | |
# nohup /bin/bash /tmp/install_mysql_server.sh > /tmp/install_mysql_server.sh.log && rm -f /tmp/install_mysql_server.sh & | |
# | |
# Make sure only root can run our script | |
if [ "$(id -u)" != "0" ]; then | |
echo "This script must be run as root" 1>&2 | |
exit 1 | |
fi | |
if [ -f "/etc/my.cnf" ]; | |
then | |
echo "my.cnf already exists" | |
exit 1 | |
else | |
# kari my.cnf | |
curl -o /etc/my.cnf https://gist.github.com/pacojp/5708158/raw | |
fi | |
INSTALLING_MYSQL_MAJOR_VERSION=5.5 | |
INSTALLING_MYSQL_VERSION=5.5.32-2.el6.x86_64 | |
cd /usr/local/src | |
ARRAY=(client server shared devel) | |
for (( i = 0; i < ${#ARRAY[*]}; i++ )) | |
{ | |
curl -L -o MySQL-${ARRAY[i]}-${INSTALLING_MYSQL_VERSION}.rpm \ | |
http://dev.mysql.com/get/Downloads/MySQL-${INSTALLING_MYSQL_MAJOR_VERSION}/MySQL-${ARRAY[i]}-${INSTALLING_MYSQL_VERSION}.rpm/from/http://cdn.mysql.com/ | |
rpm -hiv MySQL-${ARRAY[i]}-${INSTALLING_MYSQL_VERSION}.rpm | |
} | |
# for safety | |
chkconfig mysql off | |
/etc/init.d/mysql stop | |
rm -rf /var/lib/mysql/* | |
mkdir -p /mysql/innodb/ | |
mkdir -p /mysql/arclog/ | |
mkdir -p /mysql/backup/ | |
mkdir -p /mysql/data/ | |
chown -R mysql:root /mysql | |
mysql_install_db --user=mysql | |
echo "call '/etc/init.d/mysql start' for starting mysql server" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment