This article will show how to upgrade the MariaDB database version from an old one to a new one. The old version available for an example in this context is the MariaDB database 5.5.65. On the other hand, the new version in this context is the MariaDB database 10.1.20. The following are the steps in order to upgrade the database :
1. First of all, use the mysql_upgrade tool which is available in MariaDB database tools from the old version of 5.5.65. The following is the execution process of the ‘mysql_upgrade’ tool :
[root@hostname ~]# mysql_upgrade -uroot -p Enter password: Phase 1/4: Fixing views Phase 2/4: Fixing table and database names Phase 3/4: Checking and upgrading tables Processing databases information_schema db_app db_app.table OK db_app.table2 OK mysql mysql.columns_priv OK mysql.db OK mysql.event OK mysql.func OK mysql.help_category OK mysql.help_keyword OK mysql.help_relation OK mysql.help_topic OK mysql.host OK mysql.ndb_binlog_index OK mysql.plugin OK mysql.proc OK mysql.procs_priv OK mysql.proxies_priv OK mysql.servers OK mysql.tables_priv OK mysql.time_zone OK mysql.time_zone_leap_second OK mysql.time_zone_name OK mysql.time_zone_transition OK mysql.time_zone_transition_type OK mysql.user OK performance_schema Phase 4/4: Running 'mysql_fix_privilege_tables' OK [root@hostname ~]#
[root@hostname ~]# mysql --version mysql Ver 15.1 Distrib 5.5.65-MariaDB, for Linux (x86_64) using readline 5.1 [root@hostname ~]#
2. According to the output above, although the command execution above for upgrading the version using the tool or the utility available from MariaDB database version of 5.5.65 is done, apparently it doesn’t update the version. So, another solution to reach for is to continue on updating the MariaDB database totally to a higher version which is the MariaDB version of 10. In order to do that, first of all remove or uninstall the MariaDB database version of 5.5.65 :
[root@hostname ~]# yum remove mariadb mariadb-server Loaded plugins: fastestmirror Resolving Dependencies --> Running transaction check ---> Package mariadb.x86_64 1:5.5.65-1.el7 will be erased ---> Package mariadb-server.x86_64 1:5.5.65-1.el7 will be erased --> Finished Dependency Resolution Dependencies Resolved ======================================================================================================================== Package Arch Version Repository Size ======================================================================================================================== Removing: mariadb x86_64 1:5.5.65-1.el7 @base 49 M mariadb-server x86_64 1:5.5.65-1.el7 @base 58 M Transaction Summary ======================================================================================================================== Remove 2 Packages Installed size: 107 M Is this ok [y/N]: y Downloading packages: Running transaction check Running transaction test Transaction test succeeded Running transaction Erasing : 1:mariadb-server-5.5.65-1.el7.x86_64 1/2 warning: /var/log/mariadb/mariadb.log saved as /var/log/mariadb/mariadb.log.rpmsave Erasing : 1:mariadb-5.5.65-1.el7.x86_64 2/2 Verifying : 1:mariadb-server-5.5.65-1.el7.x86_64 1/2 Verifying : 1:mariadb-5.5.65-1.el7.x86_64 2/2 Removed: mariadb.x86_64 1:5.5.65-1.el7 mariadb-server.x86_64 1:5.5.65-1.el7 Complete! [root@hostname ~]#
3. After that, install MariaDB database 10 using yum installer. Prior to that, it need a MariaDB database 10 repository file definition. Just define the repository file that can show or point out to yum package installer where to get the installer source of the MariaDB database 10. Just create a new file with the name of MariaDB.repo in the folder of /etc/yum.repos.d. Write the following content in the file :
# MariaDB 10.1 RedHat repository list - created 2016-02-06 03:30 UTC # http://mariadb.org/mariadb/repositories/ [mariadb] name = MariaDB baseurl = http://yum.mariadb.org/10.1/rhel7-amd64 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1
4. Next one, in order to make sure that the MariaDB database 10 is available for further use, just execute the following command first :
[root@hostname yum.repos.d]# yum repolist Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirror.*********** * extras: mirror.*********** * updates: mirror.*********** repo id repo name status base/7/x86_64 CentOS-7 - Base 10,070 extras/7/x86_64 CentOS-7 - Extras 413 mariadb MariaDB 86 updates/7/x86_64 CentOS-7 - Updates 1,134 repolist: 11,703 [root@hostname yum.repos.d]#
5. After reassuring that the MariaDB database repository is available for access and the MariaDB database 10 exist in the repository list, one thing that must be done next is to search the MariaDB database 10 installer package by running the following command :
[root@hostname ~]# yum search MariaDB Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirror.*********** * extras: mirror.*********** * updates: mirror.*********** ================================================= N/S matched: MariaDB =================================================MariaDB-backup.x86_64 : MariaDB: a very fast and robust SQL database server MariaDB-backup-debuginfo.x86_64 : Debug information for package MariaDB-backup MariaDB-cassandra-engine.x86_64 : MariaDB: a very fast and robust SQL database server MariaDB-cassandra-engine-debuginfo.x86_64 : Debug information for package MariaDB-cassandra-engine MariaDB-client.x86_64 : MariaDB: a very fast and robust SQL database server MariaDB-client-debuginfo.x86_64 : Debug information for package MariaDB-client MariaDB-common.x86_64 : MariaDB: a very fast and robust SQL database server MariaDB-common-debuginfo.x86_64 : Debug information for package MariaDB-common MariaDB-compat.x86_64 : MariaDB: a very fast and robust SQL database server MariaDB-connect-engine.x86_64 : MariaDB: a very fast and robust SQL database server MariaDB-connect-engine-debuginfo.x86_64 : Debug information for package MariaDB-connect-engine MariaDB-cracklib-password-check.x86_64 : MariaDB: a very fast and robust SQL database server MariaDB-cracklib-password-check-debuginfo.x86_64 : Debug information for package MariaDB-cracklib-password-check MariaDB-devel.x86_64 : MariaDB: a very fast and robust SQL database server MariaDB-gssapi-client.x86_64 : MariaDB: a very fast and robust SQL database server MariaDB-gssapi-client-debuginfo.x86_64 : Debug information for package MariaDB-gssapi-client MariaDB-gssapi-server.x86_64 : MariaDB: a very fast and robust SQL database server MariaDB-gssapi-server-debuginfo.x86_64 : Debug information for package MariaDB-gssapi-server MariaDB-oqgraph-engine.x86_64 : MariaDB: a very fast and robust SQL database server MariaDB-oqgraph-engine-debuginfo.x86_64 : Debug information for package MariaDB-oqgraph-engine MariaDB-server.x86_64 : MariaDB: a very fast and robust SQL database server MariaDB-server-debuginfo.x86_64 : Debug information for package MariaDB-server MariaDB-shared.x86_64 : MariaDB: a very fast and robust SQL database server MariaDB-shared-debuginfo.x86_64 : Debug information for package MariaDB-shared MariaDB-test.x86_64 : MariaDB: a very fast and robust SQL database server MariaDB-test-debuginfo.x86_64 : Debug information for package MariaDB-test mariadb-bench.x86_64 : MariaDB benchmark scripts and data mariadb-devel.i686 : Files for development of MariaDB/MySQL applications mariadb-devel.x86_64 : Files for development of MariaDB/MySQL applications mariadb-embedded.i686 : MariaDB as an embeddable library mariadb-embedded.x86_64 : MariaDB as an embeddable library mariadb-embedded-devel.i686 : Development files for MariaDB as an embeddable library mariadb-embedded-devel.x86_64 : Development files for MariaDB as an embeddable library mariadb-libs.i686 : The shared libraries required for MariaDB/MySQL clients mariadb-libs.x86_64 : The shared libraries required for MariaDB/MySQL clients mariadb-server.x86_64 : The MariaDB server and related files mariadb.x86_64 : A community developed branch of MySQL mariadb-test.x86_64 : The test suite distributed with MariaD Name and summary matches only, use "search all" for everything. [root@hostname ~]#
6. From the search result above, there is a MariaDB database package installer. But before installing that package installer, confirm that the installation package of MariaDB database is the version 10. In order to confirm it, just execute the following command :
[root@hostname ~]# yum info mariadb-server Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirror.*********** * extras: mirror.*********** * updates: mirror.*********** Available Packages Name : MariaDB-server Arch : x86_64 Version : 10.1.20 Release : 1.el7.centos Size : 24 M Repo : mariadb Summary : MariaDB: a very fast and robust SQL database server URL : http://mariadb.org License : GPLv2 Description : : : It is GPL v2 licensed, which means you can use the it free of charge under the : conditions of the GNU General Public License Version 2 (http://www.gnu.org/licenses/). : : MariaDB documentation can be found at https://mariadb.com/kb : MariaDB bug reports should be submitted through https://jira.mariadb.org Name : mariadb-server Arch : x86_64 Epoch : 1 Version : 5.5.65 Release : 1.el7 Size : 11 M Repo : base/7/x86_64 Summary : The MariaDB server and related files URL : http://mariadb.org License : GPLv2 with exceptions and LGPLv2 and BSD Description : MariaDB is a multi-user, multi-threaded SQL database server. It is a : client/server implementation consisting of a server daemon (mysqld) : and many different client programs and libraries. This package contains : the MariaDB server and some accompanying files and directories. : MariaDB is a community developed branch of MySQL. [root@hostname ~]#
7. The above output command execution ‘yum info’ above display that there are two versions of MariaDB database. It is the new version of 10.1.20 and the old version of 5.5.65. The only one needed is the 10.1.20 version which is the new one. Actually, the installation process which is done with a standard command will choose and prioritize the newest version as the following command :
[root@hostname ~]# yum -y install mariadb mariadb-server Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirror.*********** * extras: mirror.*********** * updates: mirror.*********** Package mariadb is obsoleted by MariaDB-client, trying to install MariaDB-client-10.1.20-1.el7.centos.x86_64 instead Package mariadb-server is obsoleted by MariaDB-server, trying to install MariaDB-server-10.1.20-1.el7.centos.x86_64 instead Resolving Dependencies --> Running transaction check ---> Package MariaDB-client.x86_64 0:10.1.20-1.el7.centos will be installed --> Processing Dependency: MariaDB-common for package: MariaDB-client-10.1.20-1.el7.centos.x86_64 ---> Package MariaDB-server.x86_64 0:10.1.20-1.el7.centos will be installed --> Processing Dependency: lsof for package: MariaDB-server-10.1.46-1.el7.centos.x86_64 --> Processing Dependency: galera for package: MariaDB-server-10.1.46-1.el7.centos.x86_64 --> Processing Dependency: libjemalloc.so.1()(64bit) for package: MariaDB-server-10.1.46-1.el7.centos.x86_64 --> Running transaction check ---> Package MariaDB-common.x86_64 0:10.1.20-1.el7.centos will be installed ---> Package galera.x86_64 0:25.3.29-1.rhel7.el7.centos will be installed --> Processing Dependency: libboost_program_options.so.1.53.0()(64bit) for package: galera-25.3.29-1.rhel7.el7.centos.x86_64 ---> Package jemalloc.x86_64 0:3.6.0-1.el7 will be installed ---> Package lsof.x86_64 0:4.87-6.el7 will be installed --> Running transaction check ---> Package boost-program-options.x86_64 0:1.53.0-28.el7 will be installed --> Processing Conflict: MariaDB-common-10.1.20-1.el7.centos.x86_64 conflicts mariadb-libs < 1:10.1.46-1.el7.centos --> Restarting Dependency Resolution with new changes. --> Running transaction check ---> Package MariaDB-shared.x86_64 0:10.1.20-1.el7.centos will be obsoleting ---> Package mariadb-libs.x86_64 1:5.5.65-1.el7 will be obsoleted --> Finished Dependency Resolution Dependencies Resolved ============================================================================================================================================================================ Package Arch Version Repository Size ============================================================================================================================================================================ Installing: MariaDB-client x86_64 10.1.20-1.el7.centos mariadb 10 M MariaDB-server x86_64 10.1.20-1.el7.centos mariadb 24 M MariaDB-shared x86_64 10.1.20-1.el7.centos mariadb 622 k replacing mariadb-libs.x86_64 1:5.5.65-1.el7 Installing for dependencies: MariaDB-common x86_64 10.1.20-1.el7.centos mariadb 68 k boost-program-options x86_64 1.53.0-28.el7 base 156 k galera x86_64 25.3.29-1.rhel7.el7.centos mariadb 8.2 M jemalloc x86_64 3.6.0-1.el7 mariadb 104 k lsof x86_64 4.87-6.el7 base 331 k Transaction Summary ============================================================================================================================================================================ Install 3 Packages (+5 Dependent packages) Total download size: 44 M Downloading packages: warning: /var/cache/yum/x86_64/7/mariadb/packages/MariaDB-common-10.1.20-1.el7.centos.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 1bb943db: NOKEY 69 kB 00:18:27 ETA Public key for MariaDB-common-10.1.20-1.el7.centos.x86_64.rpm is not installed (1/8): MariaDB-common-10.1.20-1.el7.centos.x86_64.rpm | 68 kB 00:00:01 (2/8): MariaDB-client-10.1.20-1.el7.centos.x86_64.rpm | 10 MB 00:00:10 (3/8): boost-program-options-1.53.0-28.el7.x86_64.rpm | 156 kB 00:00:00 (4/8): MariaDB-shared-10.1.20-1.el7.centos.x86_64.rpm | 622 kB 00:00:01 (5/8): galera-25.3.29-1.rhel7.el7.centos.x86_64.rpm | 8.2 MB 00:00:09 (6/8): lsof-4.87-6.el7.x86_64.rpm | 331 kB 00:00:00 (7/8): jemalloc-3.6.0-1.el7.x86_64.rpm | 104 kB 00:00:01 (8/8): MariaDB-server-10.1.20-1.el7.centos.x86_64.rpm | 24 MB 00:00:35 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Total 1.2 MB/s | 44 MB 00:00:37 Retrieving key from https://yum.mariadb.org/RPM-GPG-KEY-MariaDB Importing GPG key 0x1BB943DB: Userid : "MariaDB Package Signing Key <[email protected]>" Fingerprint: 1993 69e5 404b d5fc 7d2f e43b cbcb 082a 1bb9 43db From : https://yum.mariadb.org/RPM-GPG-KEY-MariaDB Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : MariaDB-common-10.1.20-1.el7.centos.x86_64 1/9 Installing : MariaDB-client-10.1.20-1.el7.centos.x86_64 2/9 Installing : boost-program-options-1.53.0-28.el7.x86_64 3/9 Installing : galera-25.3.29-1.rhel7.el7.centos.x86_64 4/9 Installing : lsof-4.87-6.el7.x86_64 5/9 Installing : jemalloc-3.6.0-1.el7.x86_64 6/9 Installing : MariaDB-server-10.1.20-1.el7.centos.x86_64 7/9 Installing : MariaDB-shared-10.1.20-1.el7.centos.x86_64 8/9 Erasing : 1:mariadb-libs-5.5.65-1.el7.x86_64 9/9 Verifying : MariaDB-client-10.1.20-1.el7.centos.x86_64 1/9 Verifying : MariaDB-common-10.1.20-1.el7.centos.x86_64 2/9 Verifying : jemalloc-3.6.0-1.el7.x86_64 3/9 Verifying : lsof-4.87-6.el7.x86_64 4/9 Verifying : galera-25.3.29-1.rhel7.el7.centos.x86_64 5/9 Verifying : MariaDB-server-10.1.20-1.el7.centos.x86_64 6/9 Verifying : MariaDB-shared-10.1.20-1.el7.centos.x86_64 7/9 Verifying : boost-program-options-1.53.0-28.el7.x86_64 8/9 Verifying : 1:mariadb-libs-5.5.65-1.el7.x86_64 9/9 Installed: MariaDB-client.x86_64 0:10.1.20-1.el7.centos MariaDB-server.x86_64 0:10.1.20-1.el7.centos MariaDB-shared.x86_64 0:10.1.20-1.el7.centos Dependency Installed: MariaDB-common.x86_64 0:10.1.20-1.el7.centos boost-program-options.x86_64 0:1.53.0-28.el7 galera.x86_64 0:25.3.29-1.rhel7.el7.centos jemalloc.x86_64 0:3.6.0-1.el7 lsof.x86_64 0:4.87-6.el7 Replaced: mariadb-libs.x86_64 1:5.5.65-1.el7 Complete! [root@hostname ~]#
8. After the installation process is finished, the next step is to activate the service and to automate the service for starting every time when server boots or starts. Soon after that, try to execute another upgrade script further by executing the following command :
[root@hostname ~]# systemctl start mysql [root@hostname ~]# systemctl enable mysql mysql.service is not a native service, redirecting to /sbin/chkconfig. Executing /sbin/chkconfig mysql on [root@hostname ~]# mysql_upgrade -uroot -p Enter password: Phase 1/7: Checking and upgrading mysql database Processing databases mysql mysql.columns_priv OK mysql.db OK mysql.event OK mysql.func OK mysql.help_category OK mysql.help_keyword OK mysql.help_relation OK mysql.help_topic OK mysql.host OK mysql.ndb_binlog_index OK mysql.plugin OK mysql.proc OK mysql.procs_priv OK mysql.proxies_priv OK mysql.servers OK mysql.tables_priv OK mysql.time_zone OK mysql.time_zone_leap_second OK mysql.time_zone_name OK mysql.time_zone_transition OK mysql.time_zone_transition_type OK mysql.user OK Phase 2/7: Installing used storage engines Checking for tables with unknown storage engine Phase 3/7: Fixing views Phase 4/7: Running 'mysql_fix_privilege_tables' Phase 5/7: Fixing table and database names Phase 6/7: Checking and upgrading tables Processing databases db_app db_app.table OK db_app.table2 OK information_schema performance_schema Phase 7/7: Running 'FLUSH PRIVILEGES' OK [root@hostname ~]#
By looking the above output, the upgrade process is actually finished. It upgrade from the MariaDB database version of 5.5 into MariaDB database version of 10.1.20.