MariaDB is a famous MySQL community fork that gained lots of popularity after Oracle acquisition of the MySQL project. On December 24th 2015 the latest stable version has been released which is MariaDB 10.1.10.
What’s new
Few new features have been added in this version and you can see them below:
- Galera, a multi-master cluster solution is now standard part of MariaDB.
- Added two new information schema tables added for better examining wsrep information. The tables in question are WSREP_MEMBERSHIP and WSREP_STATUS.
- Page compression for InnoDB and XtraDB. Page compression is similar to InnoDB COMPRESSED storage format.
- Page compression for FusionIO.
- Few optimization tweaks included are:
- Don’t create .frm files for temporary tables
- Use the MAX_STATEMENT_TIME to abort long running queries automatically
- malloc() function is used less and simple queries are executed faster
- Webscale patches
- Plugins update
- Security fixes (Many vulnerabilities have been addressed).
In this tutorial we are going to show you how to upgrade MariaDB 5.5 to MariaDB 10.1 latest stable version. You will need to have root access to the machine, where you will be performing the upgrade.
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:
# mysqldump -u root -ppassword --all-databases > /tmp/all-database.sql
Or alternatively, you can stop the MariaDB service with:
# systemctl stop mysql
And copy the databases directory in a separate folder like this:
# cp -a /var/lib/mysql/ /var/lib/mysql.bak
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:
# yum update [On RHEL/CentOS 7] # apt-get update [On Debian/Ubuntu]
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:
# vim /etc/yum.repos.d/MariaDB10.repo
Add the following text in it:
# 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
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:
# 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/ubuntu wily main'
Important: Don’t forget to replace the ubuntu wily with your distribution name and release.
Step 3: Remove MariaDB 5.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:
# 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:
# yum clean all [On RHEL/CentOS 7] # apt-get clean all [On Debian/Ubuntu]
Step 4: Installing MariaDB 10.1
Now it’s time to install the newer version of MariaDB, by using:
# 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:
# systemctl start mariadb
If you want MariaDB to automatically start after system boot, run:
# systemctl enable mariadb
Finally run the upgrade command to upgrade MariaDB with:
# mysql_upgrade
To verify that the upgrade was successful, run the following command:
# mysql -V
Congratulations, your upgrade has been completed!
Conclusion
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 post a comment.
Hi,
After adding the Repo
nano /etc/yum.repos.d/MariaDB10.repo
I just did and upgrade.
yum -y upgrade maria*
I didn’t uninstall the previous installation and in 2 mins it was Up and running with new MariaDB 10
Thanks,
Regarding the dependencies, removing via rpm command without blowing up dependencies:
Then yum install the packages. MariaDB-Shared replaces mariadb-libs which is what postfix, etc needs.
You will then find the packages are satisfied:
and you will see the MariaDB-Shared is a accepted provider.
Thanks everyone for your tips and advice. I was able to recovered my previously existing databases by adding the datadir parameter to the my.cnf file. I then restarted the database and all was good. Interestingly enough I later had to remove this references from the my.cnf because of startup errors but the database does not lose its relationships with the databases. This I can not explain.
Upgraded MariaDB5.5 to 10.0 following these steps including removal of MariaDB. I then used yum to install mariadb10.0. This went without error. I then started the MariaDB service and it showed the correct version.
However, the previously existing database was not found. How do I re-attach the old database to the new database engine so I can run the upgrade procedure against it? The old data files are still available.
@Kirt,
You can import your database and run mysql_upgrade command to upgrade the database structures with new engine..
Did you notice that this article removes postfix, which has a dependency on mariadb-libs? You don’t address reinstalling postfix at all.
Hi,
Removing the dependencies broke a lot of things for me. So I’ve done this, which seems to work:
# just remove mariadb-server, removing other packages breaks lots of things
yum remove mariadb-server
# update other maria packages
yum update -y
# install mariadb-server v 10.1
yum install mariadb-server
# start and enable mariadb
systemctl start mariadb
systemctl enable mariadb
# upgrade DBs
mysql_upgrade -uroot -ppassword
@David,
Thanks for the tip, hope it will help other fellow readers..
How do I put back whatever I had backed up
@Mojo,
Follow this article, on how to backup or restore MySQL databases..
https://www.tecmint.com/mysql-backup-and-restore-commands-for-database-administration/
after i upgrade mysql my sentora panel stop working.
sudo /usr/bin/php -q /etc/sentora/panel/bin/daemon.php
PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/lib64/php/modules/suhosin.so’ – /usr/lib64/php/modules/suhosin.so: undefined symbol: php_register_info_logo in Unknown on line 0
PHP Fatal error: Undefined class constant ‘MYSQL_ATTR_INIT_COMMAND’ in /etc/sentora/panel/inc/dbc.inc.php on line 28
Can you help me to fix plz.
i just solve:
1. yum install php-pdo php-mysqli –skip-broken
2. service httpd restart