This blog is one of about 10 websites I run on a dedicated server hosted in GoDaddy’s datacenter. I use Plesk Reloaded 7.5.4 as my control panel. It’s simple to use and has worked reliably for me. Compared to cPanel, it doesn’t have as much advanced control or features, but I also payed a lot less. I really just use it for configuring DNS, hosting, and email for the different domains of my websites. Most advanced work I do on the command line through SSH.

Plesk 7.5.4 installs and uses MySQL 3.23.58 and PHP 4.3.11 and up until now this has not been a problem. However, yesterday I went to install Wordpress 2.1.2 (the latest version as of this writing) and I discovered that Wordpress now requires MySQL 4. This didn’t upset me that much, because I’ve upgraded MySQL before on some of my other Linux systems and I like to see applications taking advantage of features and performance of new versions of PHP and MySQL. The catch was this system is running Plesk and Fedora Core 2. I had never tried updating my Plesk installation, since its mostly production websites which i prefer not to disturb.

After spending a few hours researching how to upgrade MySQL in a Plesk server environment, I realized there’s not much material available on the subject. Basically I had two options: go through SWsoft and download a new update for Plesk or upgrade only the components I needed. Upgrading all of Plesk requires getting a new key, and going through a hastle I didnt’ want to deal with.

So I opted to just upgrade MySQL on my own. After some trial and error, I found out the process is fairly straightforward and simple. Below I’ll detail a few instructions and tips I discovered while upgrading my server. Hopefully this information can be helpful to someone in a similar situation.

Step 1

Download the latest version of the MySQL binaries. Here is where I encountered the first problem. Plesk 7.5.4 doesn’t support anything higher than MySQL 4.1, but I didn’t realize this until after I had already installed MySQL 5. This page contains links to older versions of MySQL -In my case I went with mysql-standard-4.1.21-pc-linux-gnu-i686-glibc23.tar.gz. From here on out, you’ll probably want to be root. Note that in the below ’su’ command I put a dash on the end. This logs you in as root and also puts you into the /root directory. It also changes your $PATH variable so you can execute files in the /usr/sbin folder. This becomes important later when we use the ’service’ command.

# su -
# wget http://downloads.mysql.com/mysql-standard-4.1.21-pc-linux-gnu-i686-glibc23.tar.gz

Step 2

Make sure there is a mysql user and group in /etc/passwd and /etc/group.

# grep mysql /etc/group /etc/passwd

That should return should return something simliar to the following. If it doesn’t use useradd and groupadd to add them.

/etc/group:mysql:x:27:
/etc/passwd:mysql:x:27:27:MySQL Server:/var/lib/mysql:/bin/bash

Step 3

Unpack the archive you downloaded from the MySQL website, and then create a symbolic link to the folder. In my example I downloaded the archive into my home folder. Substitute the folder name and archive name if applicable.

# cd /usr/local # tar xzvf ~/mysql-standard-4.1.21-pc-linux-gnu-i686-glibc23.tar.gz
# ln -s mysql-standard-4.1.21-pc-linux-gnu-i686-glibc23.tar.gz mysql

Step 4

Stop the currently running MySQL server and also back up the databases incase we need to roll back. If you get the error ’service: command not found’, then you didn’t listen to me in Step 1. You need to become super user by using ’su -’. This changes your $PATH so that you can execute ’service’.

# service mysqld stop
# tar czf /var/lib/mysql.tgz /var/lib/mysql

Step 5

Now we need to modify the mysqld startup script to use our new version of mysql that we put in /usr/local/mysql. Backup your existing /etc/init.d/mysqld and then either create a new mysqld script and paste the following into it, or just edit the existing one and change each instance of /usr/bin/ to /usr/local/mysql/bin/

# cp /etc/init.d/mysqld /etc/init.d/mysqld_3.23
# nano /etc/init.d/mysqld

Step 6

Start your newly upgraded mysql and see if it works.

# service mysqld start

If you see a [FAILED] message, but the ‘ps’ command still shows a mysqld process running, then you need to edit /etc/my.cnf and put this at the bottom (update socket line to match the path thats specified in the [mysqld] section at the top.

[mysqladmin]
socket=/var/lib/mysql/mysql.sock

Next verify you can connect to the database server and enter the Plesk admin password when prompted. Then we need to run a script to update the mysql database corresponding to the new tables format. This is only necessary if updating to 4.1.x or higher (which we are).

# /usr/local/mysql/bin/mysql -uadmin -p
# /usr/local/mysql/bin/mysql_fix_privilege_tables --user=admin --password=`cat /etc/psa/.psa.shadow`

If you get an error about not being able to connect via socket on either one of those commands, then you need to add the following sections to the bottom of /etc/my.cnf

# nano /etc/my.cnf
[mysql]
socket=/var/lib/mysql/mysql.sock [mysql_fix_privilege_tables]
socket=/var/lib/mysql/mysql.sock

Closing Comments

Your server should now be running an upgraded version of MySQL. If there were any problems, or its still not working, you should be able to revert back to your old version simply by renaming your /etc/init.d/mysqld_backup file. If the database was corrupted you can restore the original from the archive we made in /var/lib.