2015年9月20日 星期日

Replace MySQL with MariaDB Installation

Replace MySQL with MariaDB Installation

簡述

Since MariaDB trends to be the open source drop-in replacement of MySQL, I'd like to try and write down how to drop-in replace MySQL with MariaDB in Ubuntu 14.04. The versions involved are mysql-server-5.5 and mariadb-server-5.5.

執行步驟


1. Backup all databases and configuration files:

$ sudo cp /etc/mysql /etc/mysql_mysql
$ mysqldump -uUserID -pPassword myDatabase > myDatabase.sql;

2. Stop services:

$ sudo service nginx stop
$ sudo service apache2 stop
$ sudo service mysql stop

3. Uninstall MySQL Packages:

$ sudo apt-get purge mysql-server mysql-client mysql-common
$ sudo apt-get autoremove
$ sudo apt-get autoclean
Some messages output: mysql-client not installed, so not removed; /etc/mysql not empty, so not removed, that's OK, don't care about it.
One thing should be cared about is php5-mysql and relative configurations also removed. We have to add them back after MariaDB installed.

4. Install MariaDB:

$ sudo apt-get install mariadb-server
An interface displayed several times during installation asking new MariaDB root user's password, just hit Enter to keep it unchanged. The installation process basically merges old MySQL database without change it.
New configuration files will write to /etc/mysql folder.

5. Stop MariaDB to do some configurations:

$ sudo service mysql stop
$ sudo vi /etc/my.cnf   

# -------------------------
# add following section to my.cnf
[mariadb]
aria_pagecache_buffer_size = 1M  # minimized mem. usage, default: 128M
character-set-server = utf8mb4   # full UTF-8 characters support
collation-server     = utf8mb4_unicode_ci    
# -------------------------

$ sudo service mysql restart
$ sudo service apache2 restart
$ sudo service nginx restart

6. Solving php5-mysql issue:

Try to connect to your WordPress sites, an error message will show up:
Your PHP installation appears to be missing the MySQL extension which is required by WordPress.
Just install it and restart Apache, your WordPress will back to alive!
$ sudo apt-get install php5-mysql
$ sudo service apache2 restart
Now I could have my WordPress run on LNAMP (Ubuntu, Nginx, Apache, MariaDB, PHP) VM web server! :D.

沒有留言:

張貼留言