#!/bin/bash #(C)DatuX #update ld.so.conf paths if ! grep /usr/lib/mysql /etc/ld.so.conf; then echo /usr/lib/mysql >> /etc/ld.so.conf || exit 1 ldconfig fi svcstop /service/mysql || exit 1 #update config file mv /etc/my.cnf.new /etc/my.cnf #still uses old ib_logfile-size? if [ `stat -c %s /home/system/mysql5/ib_logfile0` -lt 60000000 ]; then mv /home/system/mysql5/ib_logfile0 /home/system/mysql5/ib_logfile0.old mv /home/system/mysql5/ib_logfile1 /home/system/mysql5/ib_logfile1.old fi #no mysql 5.x database yet? if [ ! -d /home/system/mysql5/mysql ]; then touch /etc/my.passwd #convert mysql4 database? #WARNING: you cant convert from 4.1 to 5.1 directly, you first need to upgrade from 4.1 to 5.0! if [ -d /home/system/mysql ]; then echo "* Converting mysql 4 database to 5.0:" svcstop /service/mysql || exit 1 #the database can be huge, so make sure nothing bad happens if cp gets aborted: rm -r /home/system/mysql5.tmp &>/dev/null cp -a /home/system/mysql /home/system/mysql5.tmp || exit 1 mv /home/system/mysql5.tmp /home/system/mysql5 || exit 1 #we need to run the database to update it svcstart /service/mysql || exit 1 mysql_upgrade --password=`cat /etc/my.passwd` || exit 1 #a restart is recommended after upgrading svcstop /service/mysql else #create new empty database svcstop /service/mysql || exit 1 mkdir -p /home/system/mysql5 || exit 1 chown mysql:mysql /home/system/mysql5 || exit 1 chmod 750 /home/system/mysql5 || exit 1 su mysql -c "mysql_install_db --force" || exit 1 fi #fix the root password and other stuff if neccesary on the new/converted database: syn3-mysqlfix || exit 1 #database exists, upgrade it: else echo "* Running mysql database upgrade:" #run a 'regular' upgrade on any existing database svcstart /service/mysql || exit 1 mysql_upgrade --password=`cat /etc/my.passwd` #a restart is recommended after upgrading svcstop /service/mysql fi svcreset /service/mysql || exit 1