Plesk - MySQL Update From 3.x To MySQL 4.1.x

  • Download the requested version from http://dev.mysql.com/downloads/ (Easiest option and the one described here is the tar file binary distribution)
  • Ensure there is a mysql user and group in /etc/passwd and /etc/group. Use useradd and groupadd to add them if not already present.
    Code:
    # grep mysql /etc/group /etc/passwd
    /etc/group:mysql:x:27:
    /etc/passwd:mysql:x:27:27:MySQL Server:/var/lib/mysql:/bin/bash
  • Unpack the tarball in /usr/local
    Code:
    # cd /usr/local && tar xzvf /path/to/mysql-VERSION-OS.tar.gz
  • Create a link to avoid RSI
    Code:
    # ln -s mysql-VERSION-OS mysql
  • Stop the currently running MySQLd and back up the databases. (You could also do a full dump while it's running, but this is the safest.)
    Code:
    # service mysqld stop && tar cpzf /var/lib/mysql.tgz /var/lib/mysql
  • Modify the startup script in /etc/init.d/mysqld to use the newly installed mysql in /usr/local/mysql/bin vs. the original /usr/bin/mysql
    Code:
    #!/bin/bash
    #
    # mysqld This shell script takes care of starting and stopping
    # the MySQL subsystem (mysqld).
    #
    # chkconfig: - 78 12
    # description: MySQL database server.
    # processname: mysqld
    # config: /etc/my.cnf
    # pidfile: /var/run/mysqld/mysqld.pid

    # Source function library.
    . /etc/rc.d/init.d/functions

    # Source networking configuration.
    . /etc/sysconfig/network


    prog="MySQL"

    datadir="/var/lib/mysql"

    start(){
    touch /var/log/mysqld.log
    chown mysql.mysql /var/log/mysqld.log
    chmod 0640 /var/log/mysqld.log
    if [ ! -d $datadir/mysql ] ; then
    action $"Initializing MySQL database: " /usr/local/mysql/bin/mysql_install_db
    ret=$?
    chown -R mysql.mysql $datadir
    if [ $ret -ne 0 ] ; then
    return $ret
    fi
    fi
    chown -R mysql.mysql $datadir
    chmod 0755 $datadir
    /usr/local/mysql/bin/safe_mysqld --defaults-file=/etc/my.cnf --pid-file=/var/run/mysqld/mysqld.pid >/dev/null 2>&1 &
    ret=$?
    # Spin for a maximum of N seconds waiting for the server to come up.
    # Rather than assuming we know a valid username, accept an "access
    # denied" response as meaning the server is functioning.
    if [ $ret -eq 0 ]; then
    STARTTIMEOUT=10
    while [ $STARTTIMEOUT -gt 0 ]; do
    RESPONSE=`/usr/local/mysql/bin/mysqladmin -uUNKNOWN_MYSQL_USER ping 2>&1` && break
    echo "$RESPONSE" | grep -q "Access denied for user" && break
    sleep 1
    let STARTTIMEOUT=${STARTTIMEOUT}-1
    done
    if [ $STARTTIMEOUT -eq 0 ]; then
    echo "Timeout error occurred trying to start MySQL Daemon."
    action $"Starting $prog: " /bin/false
    else
    action $"Starting $prog: " /bin/true
    fi
    else
    action $"Starting $prog: " /bin/false
    fi
    [ $ret -eq 0 ] && touch /var/lock/subsys/mysqld
    return $ret
    }

    stop(){
    /bin/kill `cat /var/run/mysqld/mysqld.pid 2> /dev/null ` > /dev/null 2>&1
    ret=$?
    if [ $ret -eq 0 ]; then
    action $"Stopping $prog: " /bin/true
    else
    action $"Stopping $prog: " /bin/false
    fi
    [ $ret -eq 0 ] && rm -f /var/lock/subsys/mysqld
    [ $ret -eq 0 ] && rm -f $datadir/mysql.sock
    return $ret
    }

    restart(){
    stop
    sleep 2
    start
    }

    condrestart(){
    [ -e /var/lock/subsys/mysqld ] && restart || :
    }

    # See how we were called.
    case "$1" in
    start)
    start
    ;;
    stop)
    stop
    ;;
    status)
    status mysqld
    ;;
    restart)
    restart
    ;;
    condrestart)
    condrestart
    ;;
    *)
    echo $"Usage: $0 {start|stop|status|condrestart|restart}"
    exit 1
    esac

    exit $?
  • Start the newly installed mysql with 'service mysqld start'
    If you see a [FAILED] message, but ps still shows a mysqld process running, modify /etc/my.cnf to include the following (update socket line to match the path specified in the [mysqld] section):
    Code:
    [mysqladmin]
    socket=/var/lib/mysql/mysql.sock
  • Verify you can connect to the database server with: (Use the Plesk admin password when prompted.)

    Code:
    # /usr/local/mysql/bin/mysql -uadmin -p

    If you get an error about not being able to connect via socket:

    Quote:
    ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

    Add this section to /etc/my.cnf like above:

    Code:
    [mysql]
    socket=/var/lib/mysql/mysql.sock
To finish MySQL server update from 3.23.58 to 4.1.x version you have to install Mysql 4.1.x RPMs first and then perform the following command to update mysql database corresponding to the new tables format.

/usr/bin/mysql_fix_privilege_tables --user=admin --password=`cat /etc/psa/.psa.shadow`

Also you might have seen the following failed dependencies message during mysql server installation:
error: Failed dependencies:
libmysqlclient.so.10 is needed by (installed) php-mysql
In this case PHP itself needs to be recompiled as well.
Recompile and install PHP:
# wget ftp://ftp.pbone.net/mirror/ftp.redhat.com/pub/redhat/linux/updates/enter...
# rpmbuild --rebuild php-4.3.2-39.ent.src.rpm

# rpm -Uvh --force /usr/src/redhat/RPMS/i386/php-*