Now let’s continue with updating MySQL.
Since you have decided to update it, I’ll strongly suggest going directly to MariaDB. Luckily, the process is indeed easy enough. Let’s start
Backup
The first and most important step is to backup your databases. You can do so by using the following command
mysqldump --all-databases --user=root --password --master-data > backupdb.sql
This will dump your database in a file called backupdb.sql in the directory you currently are.
Optionally you can create a backup of my.cnf file somewhere in your system as well
cp /etc/mysql/my.cnf /opt/my.cnf.bak
Remove MySQL
Like PHP, MySQL needs to be reinstalled to have a higher version.
service mysql stop
Now we can uninstall the MySql server, associated utilities amd MySql user.
apt-get remove mysql-server mysql-client mysql-common
deluser mysql
rm -rf /var/lib/mysql
MySQL has been removed from your droplet
Installation
Now, going to the fun part, adding the updated software, in this case MariaDB 10.3.
First you need to add MariaDB repository on your system in order to Install MariaDB.
apt-get install software-properties-common
apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
add-apt-repository 'deb [arch=amd64] http://mirror.zol.co.zw/mariadb/repo/10.3/ubuntu bionic main'
Once this has been covered, just in case run an update on your droplet and then continue with the installation
apt update
apt -y install mariadb-server mariadb-client
cp /opt/my.cnf /etc/mysql/
Once this has been completed, just start your MariaDB service like so
service mysqld start
If this doesn’t work, try with
service mariadb start
Ready for work
Finally, we have to import the previously exported databases back to MariaDB server as follows.
mysql -u root -p < backupdb.sql
You are ready to go!
Regards,
KDSys