Skip to content

Instantly share code, notes, and snippets.

@1-1
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 1-1/1d473e85a85b386b7fba to your computer and use it in GitHub Desktop.
Save 1-1/1d473e85a85b386b7fba to your computer and use it in GitHub Desktop.
Installing MySQL 5.6 in Centos 5 and Centos 6
#!/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