пятница, 21 августа 2015 г.

Solaris - Install Mysql Server


Download package with mysql package for specific server type from packages repository like ftp.ussg.iu.edu/solaris/freeware/sparc/5.10, for instance:
ftp.ussg.iu.edu/solaris/freeware/sparc/5.10/mysql-5.0.67-sol10-sparc-local.gz


Unpack gz archive by executing following command:
# gzip -d mysql-5.0.67-sol10-sparc-local.gz

Then execute following command:
# pkgadd -d mysql-5.0.67-sol10-sparc-local

Configure MySQL:
# groupadd mysql
# useradd -g mysql mysql
# cd /usr/local
# chown -R mysql:mysql mysql
# chmod -R 770 /var/mysql

Then initialize MySQL database:
# cd /usr/local/mysql/bin
# ./mysql_install_db --user=mysql

Now you can start MySQL Server:
# /usr/local/mysql/share/mysql/mysql.server start
Create startup/shutdown script:
# vi /etc/init.d/mysql.rc

And fill it in with the following simple code:
#!/sbin/sh
# script starts or stops all hardcoded mysql servers
# depending on passed parameter
# Parameters:
#       $1 - start/stop

ulimit -c 0

# Shutdown if instance of a specified tomcat server version
# running
# Parameters:
#       $1 - apache tomcat version
ShutdownIfRunning()
{
        count=`ps -ef | grep -i mysql | egrep -v grep | wc -l`
        if [ $count -gt 0 ]
        then
           /usr/local/mysql/share/mysql/mysql.server stop
        fi
}

case "$1" in
start )
        /usr/local/mysql/share/mysql/mysql.server start
        ;;
stop )
        ShutdownIfRunning
        ;;
* )
        echo "Usage: $0 (start | stop)"
        exit 1
esac

Do not forget to make it executable:
chmod +x /etc/init.d/mysql.rc

Now create a symlink to this script in appropriate runcom directory:
# ln -s /etc/init.d/mysql.rc /etc/rc3.d/S100mysql.rc
# ln -s /etc/init.d/mysql.rc /etc/rc3.d/K100mysql.rc