Tuesday, April 28, 2015

CentOS - How to Upgrade MySQL 5.1 to 5.6

OS version: CentOS release 6.6 (Final)

Download the proper MySQL yum repo (http://dev.mysql.com/downloads/repo/), I use (mysql-community-release-el6-5.noarch.rpm).

Install the rpm:
# cd /root/mysql-upgrade
# yum local install mysql-community-release-el6-5.noarch.rpm

Backup the current databases:
# mysqldump -u root -p --all-databases > all_databases.sql
or you can backup each database individually:
# mysqldump -u root -p DB_NAME > DB_NAME.sql

Stop current running mysql:
# service mysqld stop

Fire up "yum shell":
# yum shell
> update mysql-server
> transaction list
> transaction solve
# If you don't see any error or dependencies
> run

Start the new mysql process:
# service mysqld start
# mysql -u root -p
mysql> select version();
+-----------+
| version() |
+-----------+
| 5.6.24    |
+-----------+

1 row in set (0.00 sec)

You are all set. If all goes well, you don't need to resotre from MySQL backup.

2 comments:

Peter Marcoen said...

Good guide. The only problem I had is that afterwards mysqld would not start.
In the log file (/var/log/mysqld.log) I found the following error:

[ERROR] Fatal error: mysql.user table is damaged. Please run mysql_upgrade.

Since the server couldn't start mysql_upgrade also couldn't run.
I found this to be the solution: http://stackoverflow.com/questions/36156475/mysqld-doesnt-start-after-brew-upgrade-from-5-6-to-5-7

First, start your mysql without reading the user table: mysqld --skip-grant-tables

Then run mysql_upgrade which should now run smoothly.

Next stop mysqld: killall mysqld.

Now you should be able to start up your mysql service normally again.

Peter Marcoen said...

Good guide. The only problem I had is that afterwards mysqld would not start.
In the log file (/var/log/mysqld.log) I found the following error:

[ERROR] Fatal error: mysql.user table is damaged. Please run mysql_upgrade.

Since the server couldn't start mysql_upgrade also couldn't run.
I found this to be the solution: http://stackoverflow.com/questions/36156475/mysqld-doesnt-start-after-brew-upgrade-from-5-6-to-5-7

First, start your mysql without reading the user table: mysqld --skip-grant-tables

Then run mysql_upgrade which should now run smoothly.

Next stop mysqld: killall mysqld.

Now you should be able to start up your mysql service normally again.