Here is the shell script that will install mysql version 5.5 on a new instance.
sh -xv /root/clean_install.sh
The mysql data directory (/data/mysql/jun19) should be changed in 2 places.
#!/bin/sh
## disable selinux
/usr/sbin/setenforce 0
## shut-down mysql if already running
mysqladmin shutdown
# remove old data directory
rm -rf /var/lib/mysql/
rm -rf /root/download
## create required directories
# datadir
mkdir -p /data/mysql/jun19
# pid directory
mkdir -p /var/run/mysql
# default socket directory
mkdir -p /var/lib/mysql
# download directory
mkdir /root/download
cd /root/download
wget http://files.directadmin.com/services/all/mysql/64-bit/5.5.20/MySQL-client-5.5.20-1.linux2.6.x86_64.rpm
wget http://files.directadmin.com/services/all/mysql/64-bit/5.5.20/MySQL-devel-5.5.20-1.linux2.6.x86_64.rpm
wget http://files.directadmin.com/services/all/mysql/64-bit/5.5.20/MySQL-server-5.5.20-1.linux2.6.x86_64.rpm
wget http://files.directadmin.com/services/all/mysql/64-bit/5.5.20/MySQL-shared-5.5.20-1.linux2.6.x86_64.rpm
# create my.cnf file
cat > /etc/my.cnf << "heredoc"
[mysqld]
datadir=/data/mysql/jun19
socket=/var/lib/mysql/mysql.sock
user=root
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysql/mysqld.pid
heredoc
# reset data-directory
mydir=`grep ^datadir /etc/my.cnf | awk -F'=' '{print $2}'`
rm -rf $mydir/*
# remove mysql
for package in `rpm -qa | grep -i mysql`
do
rpm -e $package
done
# install mysql
rpm -iUh /root/download/*
# install mysql system files
mysql_install_db --datadir=$mydir
# restart mysql
/etc/init.d/mysql restart
Comments
Post a Comment