Upgrading MySQL on CentOS 6

I’ve been migrating a web site from a community web server to a dedicated 30:30 server running CentOS, Apache, MySQL and PHP. The issue is that CentOS stopped updating MySQL at version 5.1 in the CentOS 6 track and the ‘source’ database is version 5.5. After the first MySQLdump would not import into the 5.1 version I decided to update the 30:30 server to a more modern version of MySQL – 5.7!

Firstly, backup the databases using mysqldump.

Stop the server.

# service mysqld stop

Remove the old software.

# yum remove mysql mysql-server

At this point I found it was a good idea to completely remove the mysql directory.

# cd /etc/lib/
# rm -f mysql/

Fetch the new software.

# wget http://dev.mysql.com/get/mysql57-community-release-el6-7.noarch.rpm

Install the code.

# yum localinstall mysql57-community-release-el6-7.noarch.rpm

Install the new software.

yum install mysql mysql-server

Start the service.

# service mysqld start

Now here’s the next snag – normally I’d run the secure install programme, which I did, but I could not get in with the usual blank password, which I thought was odd! Also the old root password failed the password strength requirement MySQL had assigned itself! I wanted to maintain the old password for the time being so that issue needed resolving.

First things first, MySQL 5.7 assigns itself a temporary root password which is logs in the MySQL log file. You will need to find this.

# grep "temporary password" /var/log/mysqld.log

Now you can run:

# mysql_secure_installation

Lastly, if you want to remove the password enforcement policy then add this to your .cnf file

validate-password=0

So that’s it for this task, now I can get on with the site migration.

This entry was posted in CentOS, MySQL. Bookmark the permalink.

Leave a Reply