4.15 MySQL Upgrade (Linux)

Upgrading and existing MySQL on a Retain server.

  1. Stop Tomcat on the Retain server.

  2. Perform a dump of the database.

  3. Download MySQL onto the server on which you wish to install MySQL and un-tar it. Retain only needs the client and the server RPM's, but it is simpler to download one bundle file then two separate files.

  4. Stop MySQL: rcmysql stop

  5. Uninstall MySQL if upgrading to the same server; otherwise, skip to step #8.

    1. Check YaST | Software Management first for MySQL. Uninstall it from there if applicable.

      If it has a "lock" icon, it cannot be uninstalled from Software Management. Proceed to step "b".

    2. Check for any other MySQL RPMs.

      rpm -qa | grep -i mysql

      Sample screen output:

    3. Uninstall all instances of MySQL found in step b (if any) - but only the entries beginning with "MySQL..."

      rpm -e [current mysql rpm]

      Based on the screenshot shown above in in sub-step "b", I would type:

      rpm -e MySQL-server-community-5.1.72-1.sles11

      This has to be done for each RPM discovered.

  6. Delete or rename the entire "datadir" directory.

    This is the mysql directory containing the ibdata1 database and the "retain" subdirectory. It is no longer needed since you have already dumped the database. All of the files and subdirectories will be re-created without any loss of data as long as you have a good/current dump.

    The "datdir" directory is specified in the /etc/my.cnf. Look for the "[mysqld]" section. The first line reads, "datdir=[path]"

    If not specified in the my.cnf, the datadir could be at /var/lib/mysql. This is the default datadir directory if MySQL is installed manually without using the Retain installation's "mysqlsetup.sh".

  7. Rename /etc/my.cnf to my.cnf.old.

  8. Install MySQL and configure the retain database.

    NOTE:The following steps utilize the MySQL setup script in the Retain installation directory. This script greatly simplifies the MySQL setup and configuration, including creating the "retain" database. Some customers do not like the fact that the script creates a datadir called "mysql-retain". In those cases, you can manually install and configure MySQL. See the appendix of the Linux Install Guide for instructions; then, come back and perform step #6 in this article.

    1. Change to the main Retain installation directory (assuming it has been unzipped).

    2. Give the *.sh files the "execute" attribute: chmod +x *.sh

    3. Execute the Retain MySQL setup script: ./mysqlsetup.sh.

      This will install the new version and set up the Retain database. It will ask for the location of the MySQL RPM files you downloaded in step #3.

      It will also create a new datadir for you called "mysql-archive" off the directory path you give it and it will create the my.cnf with a path to the datadir specified.

  9. Import the dump into the new retain database.

    mysql -u root -p retain < /[path to dump file]/[dump filename]

    To watch the progress of the import, use this command: watch "mysqladmin -u root -p[mysql root user pw] processlist"

  10. Reboot the server to clear the memory; otherwise, start up Tomcat and you are done.