Upgrading from MySQL to MariaDB on Ubuntu Server 16.04LTS

Let’s see which version of MySQL is installed

root@mysql-bak:~# dpkg -l | grep mysql
ii  mysql-client-5.7                 5.7.22-0ubuntu0.16.04.1  
ii  mysql-client-core-5.7            5.7.22-0ubuntu0.16.04.1  
ii  mysql-common                     5.7.22-0ubuntu0.16.04.1
ii  mysql-server                     5.7.22-0ubuntu0.16.04.1 
ii  mysql-server-5.7                 5.7.22-0ubuntu0.16.04.1  
ii  mysql-server-core-5.7            5.7.22-0ubuntu0.16.04.1

Rumour says that MariaDB is a “drop-in” replacement for MySQL. Let’s try install MariaDB as is.

reimport them hereroot@mysql-bak:~# apt-get install mariadb-server
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following package was automatically installed and is no longer required:
  libevent-core-2.0-5
Use 'apt autoremove' to remove it.
The following additional packages will be installed:
  libdbd-mysql-perl libdbi-perl libmysqlclient20 libterm-readkey-perl mariadb-client-10.0 mariadb-client-core-10.0 mariadb-common mariadb-server-10.0 mariadb-server-core-10.0
Suggested packages:
  libclone-perl libmldbm-perl libnet-daemon-perl libsql-statement-reimport them hereperl mailx mariadb-test tinyca
The following packages will be REMOVED:
  mysql-client-5.7 mysql-client-core-5.7 mysql-server mysql-server-5.7 mysql-server-core-5.7
The following NEW packages will be installed:
  libdbd-mysql-perl libdbi-perl libmysqlclient20 libterm-readkey-perl mariadb-client-10.0 mariadb-client-core-10.0 mariadb-common mariadb-server mariadb-server-10.0 mariadb-server-core-10.0
0 upgraded, 10 newly installed, 5 to remove and 0 not upgraded.
Need to get 16.3 MB of archives.
After this operation, 15.2 MB disk space will be freed.
Do you want to continue? [Y/n]

And we press Y!

The old data directory will be saved at new location. │ │ A file named /var/lib/mysql/debian-*.flag exists on this system. The number indicated │ │ Therefore the previous data directory will be renamed to /var/lib/mysql-* and a new d │ │ Please manually export/import your data (e.g. with mysqldump) if needed.

And all your data is not accessible.

You’ll need to have MariaDB 10.1 or higher which can import MySQL data.

sudo apt-get install software-properties-common
sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
sudo add-apt-repository 'deb [arch=amd64,i386,ppc64el] http://mariadb.mirrors.ovh.net/MariaDB/repo/10.2/ubuntu xenial main'
sudo apt update
sudo apt install mariadb-server

You database should now be MariaDB 😉

Leave a Reply

Your email address will not be published. Required fields are marked *