MySQL Upgrade – How to Upgrade from MySQL 5.1.37 to 5.1.73

MySQLmysql-5.1

We have a fairly advanced website that runs on a cloud system. We have one master DB server and 2 Slave DBs that read from the Master.

We're currently using 5.1.37 (I know…its old and from 2009), and we're getting some common slave/replication errors.

I've done my research and MYSQL have fixed the errors I'm getting in later releases. So I need to upgrade.

My concern is losing any configuration I have already set within the server. If I upgrade to 5.1.73 will I lose my current setup of everything? Master users/Slaves/data etc.?

Also, what would be the ssh command to perform this upgrade?

Thanks in advance for your help!

Best Answer

I upgraded an old server from 5.1.34sp1 to 5.1.67 some time back... that was about the same amount of "jump" in minor versions as you are contemplating. In this case, the system worked without incident.

Within the same major release of MySQL (e.g. 5.1.x to 5.1.y), assuming the versions involved are after the GA milestone, upgrading should be relatively straightforward.

For upgrades between versions of a MySQL release series that has reached General Availability status, you can move the MySQL format files and data files between different versions on systems with the same architecture.

http://dev.mysql.com/doc/refman/5.1/en/upgrading.html

Nevertheless, a complete backup is essential.

Importantly, if you haven't tried restoring your backup on a different server, then for all practical purposes, you don't actually have a backup.

Giving you the "ssh commands" (actually, shell commands) to do the upgrade isn't possible, since there are variations in installation that make it impossible to provide a list of "type these things and it will work" commands. Assuming your current installation is using an Oracle tarball binary distribution, you'll need to download and extract the binaries into a new directory, stop the server, move or relink the data files where the new copy of MySQL can see them, and rename a couple of directories or change a couple of symlinks. There's not really a concept of "uninstalling" the old version, since the old version can live harmlessly on your server in a different directory. You just move it out of the way, and if the upgraded version doesn't start up properly, will often still be able to start the old version back up, if needed. Eventually, you can remove the old directory, with caution, to avoid removing the wrong things.

You'll need to read the documentation.

http://dev.mysql.com/doc/refman/5.1/en/upgrading.html

http://dev.mysql.com/doc/refman/5.1/en/upgrading-from-previous-series.html

After you do the upgrade, don't forget to run the mysql_upgrade utility. This utility does not upgrade the version of your server; instead, it upgrades your data files to be fully compatible with the new version you've just installed. You run this after you do the upgrade, and after you restart the MySQL server daemon.

http://dev.mysql.com/doc/refman/5.1/en/mysql-upgrade.html

Depending on how well the server was maintained in the past, if it was upgraded in the past, then it's possible that this was not done when it was upgraded previously. If so, it would actually be a good idea to run it before doing the upgrade, so that all of your structures are all consistent. Two important points, here: The version of the mysql_upgrade utility that you run needs to be the version bundled with the currently running version of the server, and you need to make your backup before you run this. If you have some serious latent structural corruption that can't be automatically fixed, this can be theoretically be uncovered by mysql_upgrade and the server may shut down to prevent the detected corruption from causing even more serious problems. This is because mysql_upgrade uses CHECK TABLE as part of its work, and:

If CHECK TABLE finds a problem for an InnoDB table, the server may shut down to prevent error propagation. Details of the error will be written to the error log.

http://dev.mysql.com/doc/refman/5.1/en/check-table.html

This is not a likely scenario, but it's a documented possibility of which you need to be aware.

As a general rule, the slave server should be upgraded before the master, not after. This is somewhat less critical when remaining within 5.1 (if you were upgrading to 5.5, you absolutely need to upgrade the slaves first) but upgrading the master last is most definitely the most correct approach.

Upgrading the slave first will also give you a better idea of what to expect, and if the slave's data is consistent with the master, you can always promote it to master if your upgrade of the actual master fails.