Install MariaDB Package in HestiaCP

Hello, i forgot install mariadb in my server, i don’t know how can i add this package without reinstall all system.

Hi @francis99,

What’s your OS version and architecture?

Also, RAM in your server.

I have debian12, my ram 4gb

I’ll assume you are using amd64 architecture.

I just created a script to install it using Hestia way.

Disclaimer: It should work but I didn’t test it so use it at your own risk.

curl -fsSL https://7j.gg/insmardeb | sudo bash --

Above command will execute this script as root:

#!/usr/bin/env bash
set -euo pipefail
mariadb_v="10.11"
ARCH="amd64"
VERSION="debian"
codename="bookworm"
apt="/etc/apt/sources.list.d"
HESTIA_BIN="/usr/local/hestia/bin"
HESTIA_INSTALL_DIR="/usr/local/hestia/install/deb"
mycnf="my-large.cnf"

if [[ $EUID -ne 0 ]]; then
    echo "Error: you must be root to execute this script" >&2
    exit 1
fi

gen_pass() {
    matrix=$1
    length=$2
    if [ -z "$matrix" ]; then
        matrix="A-Za-z0-9"
    fi
    if [ -z "$length" ]; then
        length=16
    fi
    head /dev/urandom | tr -dc $matrix | head -c$length
}

echo "deb [arch=$ARCH signed-by=/usr/share/keyrings/mariadb-keyring.gpg] https://dlm.mariadb.com/repo/mariadb-server/$mariadb_v/repo/$VERSION $codename main" >$apt/mariadb.list
curl -s https://mariadb.org/mariadb_release_signing_key.asc | gpg --dearmor | tee /usr/share/keyrings/mariadb-keyring.gpg >/dev/null 2>&1

apt update
apt install mariadb-client mariadb-client-compat mariadb-server mariadb-server-compat mariadb-common -y
cp -f "$HESTIA_INSTALL_DIR/mysql/$mycnf" /etc/mysql/my.cnf
mariadb-install-db
update-rc.d mariadb defaults
systemctl -q enable mariadb
systemctl start mariadb

mpass=$(gen_pass)
echo -e "[client]\npassword='$mpass'\n" >/root/.my.cnf
chmod 600 /root/.my.cnf

mysql_server="mariadb"
$mysql_server -e "ALTER USER 'root'@'localhost' IDENTIFIED BY '$mpass'; FLUSH PRIVILEGES;"
$mysql_server -e "UPDATE mysql.global_priv SET priv=json_set(priv, '$.password_last_changed', UNIX_TIMESTAMP(), '$.plugin', 'mysql_native_password', '$.authentication_string', 'invalid', '$.auth_or', json_array(json_object(), json_object('plugin', 'unix_socket'))) WHERE User='root';"
$mysql_server -e "DELETE FROM mysql.global_priv WHERE User='';"
$mysql_server -e "DROP DATABASE IF EXISTS test"
$mysql_server -e "DELETE FROM mysql.db WHERE Db='test' OR Db='test\\_%'"
$mysql_server -e "FLUSH PRIVILEGES;"

"$HESTIA_BIN"/v-change-sys-config-value DB_SYSTEM "mysql"
systemctl restart mariadb

Thanks bro, i’ll try today :slight_smile:

1 Like

Unable to locate package mariadb-client-compat

Unable to locate package mariadb-server-compat

Unfortunately, this is the current error.

I’ve changed the script so it installs by default version 11.8, try again.

Thanks, seems now it shows: ERROR: Mysql not available. Installation aborted

I am trying to install roundcube, which I missed during my initial installation.

But did you add MariaDB to Hestia install?

You can run the script in debug mode:

curl -fsSL https://7j.gg/insmardeb | sudo bash -s -x --

ahh. I just checked. I had marked mysql as no in error. :frowning:

Stupid me.

Any way to get this fixed?

Here:

https://pb.flossboxin.org.in/?60b9be2ec68801cd#121TgC5psrLn1VgAHhi7aGXuMm3LMcs9fACg2gBh2hh5

Sincerely, right now I don’t know whether you have installed MySQL, MariaDB, neither of them, or what the current status of the installation is. Also, the link doesn’t work (it times out).

I feel embarrassed about this now. It was my mistake, no db was installed. About the link, probably your IP was blocked in a list of bots getting blocked. If you can ping me you IP, I will unblock it.

Hi, nice to see you. Is your script able to update mariadb in Hestia from 11.4 to 11.8? If so, could you post it here again and I’ll try it? Thanks.

Hi,

You don’t need any script to upgrade MariaDB from 11.4 to 11.8. Just edit the mariadb apt sources list and replace 11.4 with 11.8. After that, apt update and apt full-upgrade

2 Likes