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 startIf 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.
7 Responses
Manuel Guzman
September 28th, 2007 at 6:22 pm
1Thank you. It worked perfectly for my GoDaddy VPS as well.
Nick
March 23rd, 2008 at 8:52 am
2This works perfectly for Plesk 8.2 on Fedora Core 2 hosted by WebFusion.co.uk
Thanks!
Temi
April 10th, 2008 at 2:30 pm
3Would you by any chance know if this would work for downgrading from 5.0 to 4.1? I have a Plesk server that comes with MySQL 5.0 by default but my website requires 4.1.
Jeff
April 11th, 2008 at 3:41 pm
4Temi,
It should work downgrading as well. You’ll need to just find the old version that you want from their website. Otherwise you can follow the instructions in this post, and it should work.
Matt
April 11th, 2008 at 5:16 pm
5Thanks for the tutorial. Exactly what I needed and all is working great. I would only add that if you are going to be doing more database work from the command line you should put one more line in my.cnf:
[client]
socket=/var/lib/mysql/mysql.sock
Thanks!
Temi
April 13th, 2008 at 4:12 pm
6I followed these instructions in Plesk 8.3 trying to downgrade MySQL 5 to MySQL 4.
When I start the new service it starts but it breaks Plesk and I get this error:
Service is not available now, probably your Plesk is misconfigured.
Contact Your provider for details.
Internal Plesk error occurred: MySQL query failed: Table ‘./psa/misc’ was created with a different version of MySQL and cannot be read
What do I do now ?
Jeff
April 13th, 2008 at 6:41 pm
7Temi,
Make sure you backup your databases before trying any of this.
Basically you need to convert your MySQL5 db to a MySQL4 db. Heres the steps I recommend:
1. Reverse the process so you’re running MySQL 5.0 again.
2. cd into the /var/lib/mysql directory.
3. run the command - mysqldump -uadmin -p –compatible=mysql40 –all-databases –add-drop-database > /databases.sql
This will ask you for your Plesk admin password and then dump the contents of the databases in a format compatible with mysql4. Make sure you are root while doing all this, because it will save the databases.sql file in your root home directory.
4. Downgrade again to MySQL4.
5. cd /var/lib/mysql and then rm -rf *
BE CAREFUL. you only want to empty out the /var/lib/mysql directory.
6. Make sure your mysqld is running and then do this command - mysql < /databases.sql - then restart the mysqld again.
Hopefully this will get you running MySQL4 with your databases in the MySQL4 format.
RSS feed for comments on this post · TrackBack URI
Leave a reply
Categories
Archives
Other
About Me
My name is Jeff Baier and I'm a freelance computer consultant. Some of my jobs include web design, programming and timing track meets.
My Status
Random photos
View more photos >
Recent Posts
Recent Comments
Links
JeffBaier.com © 2007 All rights reserved.