Last active
August 29, 2015 14:01
-
-
Save 1-1/1d473e85a85b386b7fba to your computer and use it in GitHub Desktop.
Installing MySQL 5.6 in Centos 5 and Centos 6
This file contains 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
#!/usr/bin/env bash | |
MYSQL_RPM_DIR="$HOME/mysql-5_6" | |
mkdir -p "$MYSQL_RPM_DIR" | |
cd "$MYSQL_RPM_DIR" | |
release=$(cat /etc/redhat-release | awk '{print $3}' | cut -d. -f1) | |
if [ "$release" == "6" ]; then | |
printf "Proceeding with Centos 6+ mysql installation.\nRemoving old mysql mysql-client\n" | |
yum -y remove mysql-libs #This removes cronie | |
printf "Completed Removing old mysql mysql-client\n" | |
printf "Downloading mysql rpm from repos\n" | |
wget "http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm/from/http://repo.mysql.com/" -O "mysql-community-release-el6-5.noarch.rpm" | |
printf "Completed Downloading mysql rpm from repos\n" | |
printf "Installing mysql with yum\n" | |
yum -y localinstall mysql-community-release-el6-5.noarch.rpm | |
yum -y install mysql-community-server | |
printf "Completed Installing mysql with yum\n" | |
#Restore cronie boy | |
yum -y install cronie postfix | |
elif [ "$release" == "5" ]; then | |
printf "Proceeding with Centos 5+ mysql installation.\nRemoving old mysql mysql-client\n" | |
yum -y remove mysql mysql-client | |
printf "Completed Removing old mysql mysql-client\n" | |
printf "Downloading rpm from repos\n" | |
wget 'http://dev.mysql.com/get/mysql-community-release-el5-5.noarch.rpm' | |
printf "Completed Downloading rpm from repos\n" | |
printf "Installing mysql rpm\n" | |
rpm -Uvh mysql-community-release-el5-5.noarch.rpm | |
printf "Completed Installing mysql rpm\n" | |
#Check whether mysql successfully installed | |
#yum repolist enabled | grep "mysql.*-community.*" | |
printf "Starting installation of mysql-server\n" | |
yum -y install mysql-server | |
printf "Completed installation of mysql-server\n" | |
else | |
printf "Cannot install mysql. Exiting" | |
exit 1 | |
fi | |
printf "Done.\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment