[HOWTO] Upgrade MariaDB v5 to v10 / Upgrade Mysql 5.5 to 5.6 / 5.7 on CentOS/RHEL 7 and Debian Systems
Posted: Sat Jan 14, 2017 1:40 am
Note that if you are running earlier version of MariaDB the recommended course of upgrading is by going through each version. For example MariaDB 5.1 -> 5.5 -> 10.1.
Step 1: Backup or Dump All MariaDB Databases
As always when performing an upgrade creating backup of your existing databases is important. You can either dump the databases with command such:
Or alternatively, you can stop the MariaDB service with:
Note: in some cases we prefer to stop MariaDB first.
And copy the databases directory in a separate folder like this:
In case of failure of the upgrade you can use one of the above copies to restore your databases.
Step 2: Add the MariaDB Repository
A good practice is to make sure your packages are up to date before making any changes to your repo files. You can do this with:
On RHEL/CentOS 7
if you have any old packages, wait for the installation to finish. Next, you will need to add the MariaDB 10.1 repo for CentOS/RHEL 7/ distributions. To do this, use your favorite text editor such as vim or nano and open the following file:
Add the following text in it:
Then save and exit the file (for vim :wq)
On Debian and Ubuntu
Run the following series of commands to add the MariaDB PPA on your system:
Important: Don’t forget to replace the ubuntu wily with your distribution name and release.
Step 3: Remove MariaDB 5
If you have taken backup of your databases as suggested in Step 1, you are now ready to proceed and remove the existing MariaDB installation.
To do this, simply run the following command:
Next, clean the repository cache:
Step 4: Installing MariaDB 10.1
Now it’s time to install the newer version of MariaDB, by using:
Once the installation is complete, you can start the MariaDB service with:
If you want MariaDB to automatically start after system boot, run:
Finally run the upgrade command to upgrade MariaDB with:
To verify that the upgrade was successful, run the following command:
MariaDB/MySQL upgrades are always tasks that should be performed with extra caution. I hope yours completed smoothly. If you encounter any issues, please do not hesitate to ask question.
Step 1: Backup or Dump All MariaDB Databases
As always when performing an upgrade creating backup of your existing databases is important. You can either dump the databases with command such:
Code: Select all
# mysqldump -u root -ppassword --all-databases > /tmp/all-database.sql
Code: Select all
# systemctl stop mysql
And copy the databases directory in a separate folder like this:
Code: Select all
# cp -a /var/lib/mysql/ /var/lib/mysql.bak
Step 2: Add the MariaDB Repository
A good practice is to make sure your packages are up to date before making any changes to your repo files. You can do this with:
Code: Select all
# yum update [On RHEL/CentOS 7]
# apt-get update [On Debian/Ubuntu]
if you have any old packages, wait for the installation to finish. Next, you will need to add the MariaDB 10.1 repo for CentOS/RHEL 7/ distributions. To do this, use your favorite text editor such as vim or nano and open the following file:
Code: Select all
# vim /etc/yum.repos.d/MariaDB10.repo
Code: Select all
# MariaDB 10.1 CentOS repository list - created 2016-01-18 09:58 UTC
# http://mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.1/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
On Debian and Ubuntu
Run the following series of commands to add the MariaDB PPA on your system:
Code: Select all
# apt-get install software-properties-common
# apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db
# add-apt-repository 'deb [arch=amd64,i386] http://kartolo.sby.datautama.net.id/mariadb/repo/10.1/[color=#FF0000]ubuntu wily[/color] main'
Step 3: Remove MariaDB 5
If you have taken backup of your databases as suggested in Step 1, you are now ready to proceed and remove the existing MariaDB installation.
To do this, simply run the following command:
Code: Select all
# yum remove mariadb-server mariadb mariadb-libs [On RHEL/CentOS 7]
# apt-get purge mariadb-server mariadb mariadb-libs [On Debian/Ubuntu]
Next, clean the repository cache:
Code: Select all
# yum clean all [On RHEL/CentOS 7]
# apt-get clean all [On Debian/Ubuntu]
Now it’s time to install the newer version of MariaDB, by using:
Code: Select all
# yum -y install MariaDB-server MariaDB-client [On RHEL/CentOS 7]
# apt-get install mariadb-server MariaDB-client [On Debian/Ubuntu]
Once the installation is complete, you can start the MariaDB service with:
Code: Select all
# systemctl start mariadb
Code: Select all
# systemctl enable mariadb
Code: Select all
# mysql_upgrade
To verify that the upgrade was successful, run the following command:
Code: Select all
# mysql -V
MariaDB/MySQL upgrades are always tasks that should be performed with extra caution. I hope yours completed smoothly. If you encounter any issues, please do not hesitate to ask question.