Register

Reply

Forum Administrator

Lyle@Spry's Avatar

Join Date: May 2005
Posts: 455
Quote  
11-29-2005, 01:24 PM
Default HOWTO Upgrade Plesk's MySQL

  • 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 czf /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
__________________
Lyle
Spry Support Member

Last edited by Lyle@Spry; 12-28-2005 at 01:12 PM.
Reply With Quote
Lyle@Spry is offline
Junior Member

Join Date: Feb 2006
Posts: 4
Quote  
02-17-2006, 05:46 PM
Default Restoring databases

Do I need to restore the databases anyhow?

What binary do I need for the version of Linux supplied by Spry?

What about this post from SWSoft? http://faq.sw-soft.com/article_23_741_en.html

Any help is greatly appreciated. I want to make sure I have no down time.
Reply With Quote
tobowers is offline
StephenAtSpry
Guest

Posts: n/a
Quote  
02-17-2006, 10:43 PM
Default

Linux (x86) binaries will work for any distribution of linux you chose from Spry. If you have a distro that supports RPM well you can use the RPM release that most closely matches your distro.

The link from SWSoft is a necessary step if you're upgrading past 4.0.

Feel free to use our support system at https://www.spry.com/support/myaccount/login.php if you have any specific questions about your VPS and don't want to give out details in the forum.
Reply With Quote
Junior Member

Join Date: Feb 2006
Posts: 4
Quote  
02-22-2006, 02:10 PM
Default As long as it helps

As long as it's going to help others... I don't mind posting some specifics:

Here's what I have:
psa v7.5.4_build75051014.16 os_RedHat 9
OS Linux 2.4.20-021stab028.17.777-enterprise

How can I tell if I can support RPM? That would be "yum" ? Which mine does NOT support. Can I install that without breaking plesk?

The only RPM distributions I see at: http://dev.mysql.com/downloads/mysql/4.1.html

Are for Enterprise 3

What would you recommend for my system?

Also - I notice you say to backup the databases. Do I need to restore them into the new MySQL 4?

What if it doesn't work? Can I roll back?

Thanks for any and all help. I'm a little bit of a newbie at server administration.

Last edited by tobowers; 02-22-2006 at 02:12 PM.
Reply With Quote
tobowers is offline
StephenAtSpry
Guest

Posts: n/a
Quote  
02-22-2006, 10:49 PM
Default

The generic linux x86 RPMs work with RH9. The way to tell if you support RPM is to ask yourself 'Do I Run Linux?'. RPM (Redhat Package Manager) runs on almost every GNU/Linux distro currently in production (yes, even slackware).

The reason I say to backup your databases is specifically so you can roll back. If you don't backup your DBs, once you upgrade, the DBs are converted to a new format incompatable with older versions.
Reply With Quote
Junior Member

Join Date: Mar 2006
Posts: 5
Quote  
04-25-2006, 10:38 AM
Default Having trouble with this

I'm trying to go from MySQL 4 to 5 and I'm having trouble getting things working with Lyle's instructions above. I downloaded the mysql-standard-5.0.20a-linux-i686-glibc23 tarball, unpacked it, and added a link. But then the trouble began:

First of all,
Code:
# service mysqld stop
didn't work for my. I got "unrecognized service". I looked at the process list and saw a bunch of different mysqld processes, all started by mysqld_safe. On a whim I tried
Code:
#service mysql stop
(without the d) and that worked.

Now I find that I have no mysqld file in /etc/init.d. This directory just contains a bunch of executables (including mysql) which does me no good. Where do I go to change which version of mysql gets used on startup.

Next up I'm worrying about having to remember to use /usr/local/mysql/bin/mysql instead of just mysql (which lives in /usr/bin). Isn't there some way around this?

Thanks,

Songdog
Reply With Quote
Songdog is offline
Junior Member

Join Date: Mar 2006
Posts: 5
Quote  
04-25-2006, 11:50 AM
Default

Whoops! You folks are on Plesk and I'm on CPanel. My mistake!
Reply With Quote
Songdog is offline
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT -8. The time now is 04:07 AM. Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 VBulletin Skin by ForumMonkeys.