JavaScript Editor Js editor     Website development 

Main Page

Previous Page
Next Page

Upgrading MySQL

Eventually you might have the need to upgrade your MySQL installation. When doing so, it's important to consider what type of upgrade you'll be making. If you are staying within the same release series, going from, say, 4.1.12 to 4.1.17 or from 5.0.3 to 5.0.4, that's a relatively safe upgrade. If you are changing the release series, 4.0.9 to 4.1.12 or 4.1.17 to 5.0.18, there's a bit more to it.

The first type of upgrade is best if you want the latest, most stable and secure version, without any hassle. The second type of upgrade is normally for the benefit of adding features but has a higher potential for problems. MySQL recommends jumping only a single release at a time (3.23 to 4.0, 4.0 to 4.1, 4.1 to 5.0, and so on).

The MySQL manual covers the specifics of upgrading from one version of MySQL to another in great detail so that you can be best prepared as to what you might encounter. The directions I give next are more generalized recommendations.

To upgrade MySQL:

Back up your existing MySQL data.

See Chapter 13, "MySQL Administration," for information about how to do this.

Stop the currently running MySQL server daemon.

Technically, this isn't required, especially when upgrading within the same release series (e.g., from 5.0.15 to 5.0.18), but I do think it is a good idea. I will discuss stopping the MySQL application more specifically in Chapter 2

Install the new version of MySQL.

Follow the directions in this chapter, installing MySQL as you otherwise would. Some steps you can omit here, such as creating a new user and running the mysql_install_db script (part of the Linux instructions).

Restart MySQL.

Update the grant tables, if necessary.

Sometimes new versions of MySQL will require changes to the mysql database. A script called mysql_fix_privilege_tables will be installed for this purpose (check your scripts directory).

As a rule of thumb, if upgrading from one major version to another (like from 4.1 to 5.0), you'll have to update the grant tables.

On Unix and Mac OS X, you can run this script from within the MySQL directory, using this command:

./scripts/mysql_fix_privilege_tables --password=rootUserPassword

On Windows, you'll want to run the mysql_fix_privilege_tables.sql file in the mysql client (which will be discussed in the next chapter). The command would be something like:

SOURCE C:/Program Files/MySQL/MySQL Server 5.0/scripts/mysql_fix_privilege_tables.sql

On any platform, if you see error warnings about duplicate column names, you can safely ignore those.

After updating the grant tables, you'll need to stop and restart MySQL one more time.

Test, test, test!

Don't just assume everything went smoothly. Run some queries and check the results to be certain!


  • The Mac MySQL installer does not replace the old version of MySQL. Instead it installs MySQL in a new directory and then changes the symbolic link to point there.

  • Advanced Unix users may also appreciate the benefits of installing MySQL into a version-specific directory, and then updating the symbolic links to make the association to the new installation. This way you'll have the old installation to fall back on, just in case.

Previous Page
Next Page

JavaScript Editor Js editor     Website development