Nethserver-rh-mariadb102 or greater

NethServer Version: your_version
Module: your_module

I am trying to get a virtual website installed and functioning on my NS box (a Joomla 4.0 one specifically), but I need a couple things. I need at least mariadb 10, which I see is available (based on my topic), and I need db access for a user with full permissions to be able to create the website’s db and populate it when constructing the website. Is mariadb 10.2 the latest version in Stephen’s repo? I’ve already changed permissions on the virtual webroot to allow the install, but I need a newer version of mariadb and db access. Is there a default root password for all the databases? I wouldn’t mind using PHPmyAdmin rather than command line, but I can work with command line if necessary. Having root access would allow me to create a db user with permissions.

Will a newer db mess with my NS installation? I have Nextcloud functioning just fine and I’d hate to break it. Thanks for any insight you can offer.

No, it’s 10.3, see mariadb103 [NethServer Wiki]
Management via phpmyadmin is supported.

Yes, the one in /root/.my.cnf

You can run more database engines next to each other without issues.

1 Like

Nextcloud is using mariadb 10.5 (nethserver-rh-mariadb105) from nethserver repos but do not remember if phpmyadmin is supported.

Thanks! So I installed 10.3. Now how do I get my NS system to use it rather than the default 5.5.68? Why doesn’t NS just use the latest version?

mysql -V returns Distrib 5.5.68-MariaDB

Mariadb 10.3 is available at 127.0.0.1:3313, just enter it like that in the Joomla config, see mariadb103 [NethServer Wiki]

On command line you can use mysql103 -V, see mariadb103 [NethServer Wiki]

NS 7 is based on CentOS 7 that provides newer versions via SCL. So the apps that needed a newer DB engine were migrated, the rest stayed with mariadb 5.

2 Likes

I know I’m getting closer. At this point, I can’t access the database during my Joomla install or using phpMyAdmin, even tho I’ve configured a user with a password and granted the user all privileges using mysql103 from the command line. I can login to mysql103 with the new user from the command line. I can also login to mysql103 as root, which is how I created the new user and granted privileges. I even created the database I need for the Joomla install, using mysql103 from the command line. I also changed the phpMyAdmin configuration to use

$i++;
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['port'] = '3313';
$cfg['Servers'][$i]['socket'] = '/var/lib/rh-mariadb103/mysql.sock';
$cfg['Servers'][$i]['connect_type'] = 'socket';
$cfg['Servers'][$i]['compress'] = false;

In my browser, phpMyAdmin shows the server choice as localhost:3313, but trying to use root or the new user’s credentials still tells that I can’t login to the mysql database. The Joomla install (thru my browser) tells me “Check your database credentials, database type, database name or hostname.” I’m using localhost:3313 as my hostname in the Joomla install. Any ideas?

You need to use 127.0.0.1 instead of localhost.

From mariadb103 [NethServer Wiki] :

127.0.0.1:3313
YourIP:3313

You cannot use localhost:3313, this direct to the mysql socket and you will use the default mysql version.

This isn’t necessary. It should work out of the box. Maybe it helps to reapply the configuration or you need to revert your changes.

signal-event nethserver-phpmyadmin-update

2 Likes

Thank you so much for your help, Markus. Using 127.0.0.1:3313 did the trick, for both the Joomla install hostname and the phpMyAdmin config file.

1 Like

I think I have a related issue here. After installing rh-mariadb103 and using 127.0.0.1:3313 for my Joomla server and phpMyAdmin to gain access to mariadb103, I am getting a pre-backup failed to a USB drive (/dev/sdb, which worked prior to installing mariadb103). The logs show the following:

Backup log:

Backup: nethserver
Backup started at 2023-06-15 08:38:53
Event pre-backup-data: FAIL
Backup status: FAIL

Messages log:

Jun 14 01:05:12 portal esmith::event[31252]: Time elapsed: 0 hours, 0 minutes, 10 seconds
Jun 14 01:05:12 portal esmith::event[31252]: Action: /etc/e-smith/events/pre-backup-data/S20nethserver-backup-config-predatabackup SUCCESS [9.852512]
Jun 14 01:05:12 portal esmith::event[31252]: Action: /etc/e-smith/events/pre-backup-data/S50mysql-dump-tables SUCCESS [0.329196]
**Jun 14 01:05:12 portal esmith::event[31252]: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)**
**Jun 14 01:05:12 portal esmith::event[31252]: Action: /etc/e-smith/events/pre-backup-data/S50rh-mariadb103-dump-tables FAILED: 1 [0.094858]**
Jun 14 01:05:13 portal esmith::event[31252]: Action: /etc/e-smith/events/pre-backup-data/S60nethserver-nextcloud-rh-mariadb105-dump-database SUCCESS [0.496473]
Jun 14 01:05:13 portal esmith::event[31252]: Event: pre-backup-data FAILED

Contents of /etc/e-smith/events/pre-backup-data/S50rh-mariadb103-dump-tables are:

#!/bin/sh

backup_dir=/var/lib/nethserver/backup/rh-mariadb103/
if [ ! -d $backup_dir ]; then
    mkdir -p $backup_dir
fi

status=$(/sbin/e-smith/config getprop rh-mariadb103-mariadb status)
if [ "$status" = "disabled" ]
then
    echo "rh-mariadb103-mariadb is disabled - no tables dumped" >&2
    exit 0
fi
dbs=`mysql103 -BNre "show databases"` || exit 1
for db in $(echo $dbs)
do
    if [[ ("$db" != "information_schema") && ("$db" != "performance_schema") ]]; then
        mysqldump103 --skip-dump-date --ignore-table=mysql.event --single-transaction --quick --add-drop-table -QB "$db" -r $backup_dir/"$db".dump || exit 1
    fi
done

The two lines that stand out are "access denied for user ‘root’@‘localhost’ " and the “S50rh-mariadb103-dump-tables FAILED”. I’m thinking the pre-backup is failing because the backup app can’t gain access to the db. I wouldn’t know where to change the hostname to 127.0.0.1:3313. Any ideas? Thanks.

Can you still login to mariadb 10.3 without password?

mysql103

If you changed the mariadb root password, please change it back to the original password that is stored in /var/lib/nethserver/secrets/mysql

1 Like

After installing rh-nethserver-mariadb103, I used the mysql103 command to create a root password from within MariaDB103 (or so I thought?). I initially entered mysql103 -u root -p and then ENTER. mysql103 is a legit command. I used the command below afterwards. The password in root/my.cnf wouldn’t work for accessing the 103 db . It only works for the default MariaDB 5.5.68 from what I can tell. I don’t think there was one for 103 db initially, until I created one.

Created password this way:

MariaDB [(none)]> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('mypassword');

I can use the password in root.my.cnf to get into mysql -u root -p, just not mysql103.

NethServer intends to make the installation simple so a secure maria db root password is automatically created and stored in /var/lib/nethserver/secrets/mysql. This password is used for root of mariadb 5 and 10.1-10.3. So the mariadb root user has a password after installation.
In Nethserver the user root is allowed to login as mariadb root user without password, for example the backup uses this method.

For reverting to the old password just login to mysql103 using the new password and set the password to the original one.
If you want to keep the new password then just edit /var/lib/nethserver/secrets/mysql to your new password and execute the following:

expand-template /root/my.cnf

Now it should be possible to login as root without password again like:

[root@testserver ~]# mysql103
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 17
Server version: 10.3.35-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>
1 Like

Bless you Markus. You really know your stuff. That worked and the backup was able to complete without failing. Thank you!

1 Like