Last modified: [last-modified]
I’m running CentOS 6.3 64-bit and have been for a little while. I decided I wanted to swap out MySQL 5.1.x with MiriaDB 5.3.x.
Why? Because I can. Plus I’ve read a bit and it sounds like MiriaDB is better optimized than MySQL. Also Oracle is evil.
These instructions are based off my history file. I didn’t think to write this down as I did it. That means there may be a mistake in the following process but with some Googling you should be able to fix any problems you come across.
One thing to know before proceeding If you’re using PHP 5.3.3 that comes with CentOS 6 you will get a header miss-match error when PHP uses the ‘php-mysql’ package to access MySQL. I believe you can safely ignore this. I did for a few hours and nothing seemed broken. I’ll include steps on fixing this problem in another post as it requires completely replacing PHP in CentOS with PHP from another repository. If you’ve compiled your own PHP then you’ll just want to re-compile it with the MySQL Native Driver (mysqlnd).
- Stop your webserver and any other applications that may be trying to access your MySQL Database
- Take a full backup of your MySQL database just in case
12345mysqldump --add-drop-database --add-drop-table --allow-keywords --all-databases --complete-insert --quick --user=root --password=<ROOT PASSWORD> > fullDataset.sqlservice stop mysqldcp -Ra <Path to MySQL DB> <Path to MySQL DB>.bak
- Next find out what MySQL RPMs you have installed and remove them. This will automatically create a backup of your existing ‘/etc/my.cnf’ file.
12345678910rpm -qa |grep mysql# --- Command output start ---mysql-5.1.67-1.el6_3.x86_64mysql-server-5.1.67-1.el6_3.x86_64mysql-devel-5.1.67-1.el6_3.x86_64mysql-libs-5.1.67-1.el6_3.x86_64# --- Command output end ---rpm -e --nodeps mysql-5.1.67-1.el6_3.x86_64 mysql-server-5.1.67-1.el6_3.x86_64 mysql-devel-5.1.67-1.el6_3.x86_64 mysql-libs-5.1.67-1.el6_3.x86_64
- Alright now you’ve got no MySQL on your system. Lets drop MiriaDB in.
1234567891011vim /etc/yum.repos.d/MariaDB.repo#--- Add the content below to the file ---[mariadb]name = MariaDBbaseurl = http://yum.mariadb.org/5.3/centos5-amd64gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDBgpgcheck=1#--- Save and close the file ---yum install MariaDB-client.x86_64 MariaDB-devel.x86_64 MariaDB-server.x86_64 MariaDB-shared.x86_64
- You should now have MariaDB 5.3.x installed. Next we want to put the old configuration file back.
1cp /etc/my.cnf.rpmsave /etc/my.cnf
- Fire up MiriaDB, verify the version and upgrade the databases
12345678910/etc/init.d/mysql startmysql --version# --- Command output start ---mysql Ver 15.1 Distrib 5.3.10-MariaDB, for unknown-linux-gnu (x86_64) using readline 5.1# --- Command output end ---# Upgrade the databasemysql_upgrade -u root -p
- Configure MiriaDB to start on boot
12chkconfig --add mysqlchkconfig --levels 35 mysql on
That’s it! You should now be running the latest stable version of MariaDB 5.3.x which you will be able to keep up to date with the ‘yum’ command.