This tutorial shows the step-by-step guide on upgrading and converting from MySQL version 5.1 firstly to MariaDB version 5.5, and then subsequently to MariaDB 10.0, in CentOS 6.6 system. The procedure should works on most Red Hat Enterprise Linux (RHEL), CentOS, Fedora, Scientific Linux and similar distributions version 5, 6 and 7.
Part 1 – Install and Upgrade MySQL 5.1 to MariaDB 5.5
- Make a backup of MySQL databases:
mysqldump --all-databases > /tmp/backup.sql
Backup the MySQL configuration file:
cp /etc/my.cnf /etc/my.cnf.bak
You may also want to backup the complete directory of databases, i.g. /var/lib/mysql. In this case, stop the MySQL daemon with service mysql stop then copy: cp -R /var/lib/mysql /tmp/mysql_lib_backup.
- Ensure that all software packages are up-to-date before upgrading:
yum update
- Visit MariaDB repository configuration generator to setup a MariaDB 5.5 repo by selecting your distro and release.
Create a file named MariaDB.repo (or any name you prefer) in /etc/yum.repos.d directory, and paste the custom MariaDB YUM repository entry for CentOS generated into it.
vi /etc/yum.repos.d/MariaDB.repo
For CentOS 6.6, the content of /etc/yum.repos.d/MariaDB.repo is:
# MariaDB 5.5 CentOS repository list - created 2015-01-01 22:33 UTC # http://mariadb.org/mariadb/repositories/ [mariadb] name = MariaDB baseurl = http://yum.mariadb.org/5.5/centos6-amd64 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1
- Clean the repository cache information:
yum clean all
- Stop the MySQL service if it's still running:
service mysqld stop
NoteDepending on your distro, the MySQL service name may be just “mysql” instead of “mysqld”. - Uninstall and remove MySQL 5.1:
yum remove mysql mysql-server
NoteYour system may have “mysql-libs” and “mysql-devel” packages installed. If they’re not been removed as part of dependencies, use yum remove mysql-libs mysql-devel to uninstall them too.Some errors that may be encountered if old version of MySQL still in existent include:
Transaction Check Error:
file /usr/share/mysql/english/errmsg.sys from install of MariaDB-server-10.0.9-1.el6.i686 conflicts with file from package mysql-libs-5.5.36-1.el6.remi.x86_64
TipSometimes yum will include a lot of still needed dependencies to be removed with MySQL. In this case, use the rpm -e –nodeps package_name to remove just the individual package without affecting any dependencies. For example, rpm -e –nodeps mysql. - Install MariaDB 5.5:
yum install mysql-server
- When installation is completed, start the MariaDB database service:
service mysql start
- Run the MariaDB upgrade script:
mysql_upgrade
NoteIf you encounter the following error, use mysql_upgrade -p then enter database root password.ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: NO)
- Verify that the MySQL is now MariaDB 5.5 by logging into the database system using command-line client:
mysql
The output should indicates MariaDB:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 12
Server version: 5.5.41-MariaDB MariaDB ServerCopyright (c) 2000, 2014, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>
If you want to use MariaDB 10, you can continue to Part 2 - Upgrade MySQL/MariaDB 5.5 to MariaDB 10.0.