How can I migrate from MariaDB to MYSQL8

How can I migrate from MariaDB to MYSQL8? I need to use ghost cms bu it does not support it. I could not use docker images and they are not up to date. I would like to pas to MYSQL8. is it possible reinstall hestiacp or broke anything?

The Ghost forums suggest that MariaDB should work. Have you tested this in a vm guest to see if MySQL really is required?

1 Like

GhostCMS works fine with MariaDB. MySQL 8 is not needed

2 Likes

I could not run. Also anymore mariadb is not supported by Ghost CMS as officially.

yes really required I cant some features because of MariaDB I get 400 error while I am shown post statistics or some pages.

@gOOvER

Make a clean install or remove and install Mysql 8 manually

1 Like

HestiaCP does not officially support MySQL, so you can’t really use HestiaCP to run MySQL for you.

Good news is, you can run a MySQL server via the ssh terminal! Note however that you’ll have no automatic security updates for this MySQL server (a problem that can be largely mitigated by using unix sockets instead of tcp ports). Nevertheless:

in ssh run

mkdir mysql;
cd mysql;
mkdir datadir;
wget ‘https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.32-linux-glibc2.12-x86_64.tar.xz’;
tar xfv ‘mysql-8.0.32-linux-glibc2.12-x86_64.tar.xz’;
rm -v ‘mysql-8.0.32-linux-glibc2.12-x86_64.tar.xz’;
nano my.cnf

add to my.cnf:

[mysqld]
socket = /home/username/mysql/mysqld.sock
datadir = /home/username/mysql/datadir
skip_networking = 1
max_connections = 20
disable-log-bin = 1
skip-name-resolve = 1
performance-schema = 0
mysqlx = 0
max_allowed_packet = 50M
innodb_buffer_pool_size = 8M
innodb_buffer_pool_instances = 1

then run:

'/home/username/mysql/mysql-8.0.32-linux-glibc2.12-x86_64/bin/mysqld' \
--defaults-file='/home/username/mysql/my.cnf' \
--initialize-insecure

then make a /home/username/mysql/mysql_restarter.php with

<?php
declare(strict_types=1);
$mysqld_path = __DIR__ . "/mysql-8.0.32-linux-glibc2.12-x86_64/bin/mysqld";
$my_cnf_path = __DIR__ . "/my.cnf";
$restart_log = __DIR__ . "/restart.log";
$max_restarts = 100;
$timezone = "Europe/Oslo";
$format = DateTime::RFC3339;
$singleInstanceLock = fopen(__FILE__, 'rb');
if (!flock($singleInstanceLock, LOCK_EX | LOCK_NB)) {
    die("Another instance is already running.\n");
}
for ($i = 0; $i < $max_restarts; ++$i) {
    $date = (new DateTime('now', timezone_open($timezone)))->format($format);
    $msg = "{$date}: Restarting mysqld. Attempt $i of $max_restarts\n";
    file_put_contents($restart_log, $msg, FILE_APPEND | LOCK_EX);
    echo $msg;
    $cmd = implode(" ", array(
        escapeshellarg($mysqld_path),
        "--defaults-file=" . escapeshellarg($my_cnf_path),
    ));
    echo "cmd:\n$cmd\n";
    // passthru() is easier but lose shell size information, proc_open doesn't.
    $empty1 = array();
    $empty2 = array();
    $proc = proc_open($cmd, $empty1, $empty2);
    $ret = proc_close($proc);
    $date = (new DateTime('now', timezone_open($timezone)))->format($format);
    $msg = "{$date}: mysqld exited with code $ret\n";
    echo $msg;
    file_put_contents($restart_log, $msg, FILE_APPEND | LOCK_EX);
}
$date = (new DateTime('now', timezone_open($timezone)))->format($format);
$msg = "{$date}: mysqld crashed too many times, exiting.. crash count: $i\n";
file_put_contents($restart_log, $msg, FILE_APPEND | LOCK_EX);
echo $msg;
flock($singleInstanceLock, LOCK_UN);
fclose($singleInstanceLock);
exit(1);

then make a /home/username/mysql/mysql_cronjob_starter.sh with

#!/bin/bash

if [[  $(screen -ls | grep mysqld_screen_session) ]]
        then
                echo "mysqld_screen_session already running!"
                /bin/true
        else
                echo "starting mysqld_screen_session"
                screen -S mysqld_screen_session -dm
                # workaround for https://savannah.gnu.org/bugs/index.php?54164
                sleep 1
                screen -S mysqld_screen_session -X stuff "php /home/username/mysql/mysql_restarter.php^M"
fi

next up, we need to add the mysql_cronjob_starter.sh to the crontab, so run crontab -e (and if it ask what editor to use, nano is a good choice.) add the line

@reboot /bin/bash /home/username/mysql/mysql_cronjob_starter.sh

now your mysql server will automatically start whenever the host server is restarted :slight_smile:
to start the server manually, the very first time, run

bash /home/username/mysql/mysql_cronjob_starter.sh

now you can inspect the mysql server (stdout/stderr console messages) with screenie
and your mysql server is listening on the unix socket /home/username/mysql/mysqld.sock with the username root and no password. (hence the mysqld --initialize-insecure )

Hestia supports mysql since 1.7 How ever you need to reinstall the OS :slight_smile:

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.