Although MariaDB is compatible with versions of Ghost 4.x, it has stopped being compatible in the latest updates. Especially with version Ghost 5.x. If you plan to upgrade Ghost 4.x to Ghost 5.x you should keep in mind that if you use our image, you will need to replace MariaDB 10.x with MySQL 8.x.
In this tutorial, we explain how to make this change. Keep in mind that the Ghost image is based on Ubuntu 20.04, so MySQL 8.x is not available in the repositories.
Back up the data
The first step is to create a snapshot to have a copy of the server before making the change. Then we will need to create a database backup to import it back into MySQL 8.x.
To back up the database:
# mysqldump -u ghost ghost -p > ghost.sqlRemove MariaDB
The next step is to remove MariaDB from our server. To do this, run the following command:
# apt remove --purge mariadb-client-10.4 mariadb-client-core-10.4 mariadb-common mariadb-server mariadb-server-10.4 mariadb-server-core-10.4During the process, you will be asked whether you want to delete the databases. Since a backup of the database for Ghost has already been created, answer yes.
Install MySQL
The first step is to add the repository. Download the following package:
# wget https://dev.mysql.com/get/mysql-apt-config_0.8.22-1_all.debInstall it:
# dpkg -i mysql-apt-config_0.8.22-1_all.debSelect the first option and click Ok.
Select mysql-8.0. and click Ok. On the next screen, select Ok again.
After installing the package, update the repositories:
# apt updateThen install the necessary packages:
# apt install mysql-client mysql-community-server mysql-serverDuring the installation process, you will be asked to set a strong password.
Secure MySQL
Once installed, we recommend running the following command to secure the service:
# mysql_secure_installationImport the database
Now import the database that we exported earlier. To do this, we need to access MySQL, create the database, and grant the necessary permissions:
# mysql -u root -pThen run:
CREATE DATABASE ghost;
CREATE USER ghost@localhost IDENTIFIED BY '[CONTRASEÑA]';
GRANT ALL PRIVILEGES ON ghost.* TO ghost@localhost;
FLUSH PRIVILEGES;For the user's password, use the same one found in the file /var/www/ghost/config.production.json.
Now import it:
# mysql -u ghost -p ghost < ghost.sqlOnce the database has been imported, we recommend restarting the Ghost instance so that it reloads the configuration.
# su - ghostinst
# cd /var/www/ghost
# ghost restart