Upgrade from MySQL to MariaDB on Centos 6

This afternoon I updated my Centos 6.3 VM and choose to drop the MySQL 5.1 and give the MariaDB fork a try. I’ve found several steps to do and some problems to take of – all of them described somewhere else. It may be useful for somebody doing the same upgrade to have my collection of tasks to do.

So this is the starting point:

  • Centos 6.3 (x66) running
  • mysql-server (5.1)
  • phpmysqladmin (2.11.11.3)
  • several applications which are using the MySQL server

and here it is how I did the upgrade:

1. Stop mysql: /etc/init.d/mysql stop
2. Backup mysql database: mv /var/lib/mysql /var/lib/mysql.bak
Alternatively you should do a backup of your databases with mysqldump.
3. Install the remi repo (if you are using a are different distro or arch): rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
You need to enable the repo manually.
4. Remove old phpmyadmin (which has no support for MariaDB): yum remove phpmyadmin
5. Install current phpmyadmin (with MariaDB support): yum install phpMyAdmin
6. Import PGP key for the mariadb repo: rpm --import https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
The id of the signing key is 0xcbcb082a1bb943db.
The short form of the id is 0x1BB943DB and the full key fingerprint is 1993 69E5 404B D5FC 7D2F E43B CBCB 082A 1BB9 43DB.
7. Create /etc/yum.repos.d/mariadb.repo with the help of the repository-generator at mariabb.org:
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/5.5/centos6-x86
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
enabled=1

More info
8. install compat library: yum --enablerepo=remi-test --disablerepo=remi install compat-mysql55
9. install MariaDB: yum install MariaDB-devel MariaDB-client MariaDB-server
if you are running into problems with these two steps because of dependencies or conflicts, you may need to erase the mysql-libs manually: rpm -e --nodeps mysql-libs
10. Restore mysql config in /etc/my.conf.d/server.conf from /etc/my.cnf.rpmsave; in my case I readded these values:
[mysqld]
log-error=/var/lib/mysql/mysqld.log
log_warnings = 2
max_allowed_packet = 32M
default-storage-engine=innodb

11. If you had already a database, restore it before starting the database:
mv /var/lib/mysql /var/lib/mysql.new
mv /var/lib/mysql.bak/ /var/lib/mysql

12. start the mysql server: /etc/init.d/mysql start
13. upgrade the mysql database: mysql_upgrade
If you starting with a new database, set the root password:
mysqladmin -u root password '<PASSWORD>'
mysqladmin -u root -h password '<PASSWORD>'

14. Login to mysql:
mysql

Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 60
Server version: 5.5.28a-MariaDB MariaDB Server

Copyright (c) 2000, 2012, Oracle, Monty Program Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
15. Show status:
<status
--------------
mysql Ver 15.1 Distrib 5.5.28a-MariaDB, for Linux (i686) using readline 5.1

Connection id: 59
Current database:
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server: MariaDB
Server version: 5.5.28a-MariaDB MariaDB Server
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: latin1
Db characterset: latin1
Client characterset: utf8
Conn. characterset: utf8
UNIX socket: /var/lib/mysql/mysql.sock
Uptime: 53 min 1 sec

Threads: 6 Questions: 2307 Slow queries: 0 Opens: 75 Flush tables: 1 Open tables: 50 Queries per second avg: 0.725
--------------

if you see a similar output your upgrade is complete.

Tagged : , , ,

Leave a Reply