How to upgrade mySQL on CentOS

By default CentOS 6.5 would be installed with MySQL 5.1 (it puzzles my as 5.1 is archaic, but well…). I was interested in updating my MySQL engine to 5.5 and just happen that when it become a necessity. So after browsing various sites, forums and trying different repos, everything boiled down to the following steps…

DISCLAIMER: These particular steps were tested when upgrading default MySQL 5.1 part of CentOS 6.5 with Plesk 12.

Assumptions:

  • you are familiar with SSH
  • and have SSH root access
  • Webtastic repo is used
  • Prior MySQL installation exists (check $ rpm -q mysql mysql-server)

Core update

  • Enable repo – Webtatic EL6 for CentOS/RHEL 6.x
    $ rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm
  • Install 5.5 side-by-side, replace engine and resolve dependencies
    $ yum install mysql.`uname -i` yum-plugin-replace
    $ yum replace mysql --replace-with mysql55w
  • And the last step system DB structure need to be updated
    This is very important especially if your Plesk backup start failing with the error

    Not all the data was backed up into XXXXXX successfully.
    mysqldump: Couldn't execute 'SHOW FUNCTION STATUS WHERE Db = 'XXXXX'':
    Cannot load from mysql.proc. The table is probably corrupted (1548)
    
    $ service mysqld start
    $ mysql_upgrade -u root -p

    If for any reason this fails with error

    Looking for 'mysql' as: mysql
    Looking for 'mysqlcheck' as: mysqlcheck
    FATAL ERROR: Upgrade failed

    try the “backdoor”

    $ mysql_upgrade -uadmin -p`< /etc/psa/.psa.shadow `

    If after that error still present itself try to force upgrade by running the same command with extra key

    $ mysql_upgrade -uadmin -p`< /etc/psa/.psa.shadow ` -f

At that point you all set but it is recommended that MySQL service is restarted

$ sudo service mysqld stop
$ sudo service mysqld start
$ sudo service mysqld status
mysqld (pid NNNN) is running...

Enjoy

This entry was posted in CentOS Maintenance, Scratch Pad. Bookmark the permalink.

5 thoughts on “How to upgrade mySQL on CentOS”

  1. Matt says:

    mysql_upgrade -uadmin -p`< /etc/psa/.psa.shadow ` <— the solution! I was leading towards that command actually myself just verified using your site that it would be appropriate. Thanks for the instructions.

  2. Dennis says:

    Thanks for the backdoor, this did the trick.

  3. Dean Turner says:

    Thank you very much back door option did the trick for me.

  4. Alex says:

    I tried this solution but i kept getting a list of huge dependencies. It started working after i installed the Atomic repo and then just did yum upgrade mysql. I made a quick how to guide on my blog if anyone has the same issues, here: https://fabriceleven.com/dev/how-to-upgrade-mysql-on-centos/

  5. Jella says:

    Thanks, It worked fine with “mysql_upgrade -u root -p” .

Leave a Reply