MariaDB Database set key_buffer_size to 20% of available RAM, MariaDB no longer runs

SYSTEM INFORMATION
OS type and version AlmaLinux 9.5
Webmin version 2.202

Webmin → Servers → MariaDB Database server
and set key_buffer_size to 20% of available RAM (recommended at MariaDB website for MyISAM)

Now it errors:
“Error! MariaDB is not running on your system - database list could not be retrieved.”
MariaDB error message
The full MariaDB error message was : DBI connect failed : Can’t connect to local server through socket ‘/var/lib/mysql/mysql.sock’ (2) ?

Attempt to start MariaDB: Job for mariadb.service failed because the control process exited with error code.
See “systemctl status mariadb.service” and “journalctl -xeu mariadb.service” for details.

systemctl status mariadb.service:

× mariadb.service - MariaDB 10.5 database server
     Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; preset: disabled)
     Active: failed (Result: exit-code) since Sat 2024-12-28 09:08:41 AEDT; 1min 5s ago
       Docs: man:mariadbd(8)
             https://mariadb.com/kb/en/library/systemd/
    Process: 4953 ExecStartPre=/usr/libexec/mariadb-check-socket (code=exited, status=0/SUCCESS)
    Process: 4975 ExecStartPre=/usr/libexec/mariadb-prepare-db-dir mariadb.service (code=exited, status=0/SUCCESS)
    Process: 5010 ExecStart=/usr/libexec/mariadbd --basedir=/usr $MYSQLD_OPTS $_WSREP_NEW_CLUSTER (code=exited, status=7)
   Main PID: 5010 (code=exited, status=7)
     Status: "MariaDB server is down"
        CPU: 185ms

Dec 28 09:08:41 hostname.example.com.au systemd[1]: Starting MariaDB 10.5 database server...
Dec 28 09:08:41 hostname.example.com.au mariadb-prepare-db-dir[4975]: Database MariaDB is probably initialized in /var/lib/mysql already, nothing is done.
Dec 28 09:08:41 hostname.example.com.au mariadb-prepare-db-dir[4975]: If this is not the case, make sure the /var/lib/mysql is empty before running mariadb-prepare-db-dir.
Dec 28 09:08:41 hostname.example.com.au systemd[1]: mariadb.service: Main process exited, code=exited, status=7/NOTRUNNING
Dec 28 09:08:41 hostname.example.com.au systemd[1]: mariadb.service: Failed with result 'exit-code'.
Dec 28 09:08:41 hostname.example.com.au systemd[1]: Failed to start MariaDB 10.5 database server.

journalctl -xeu mariadb.service:

A start job for unit mariadb.service has begun execution.
 The job identifier is 1019.
Dec 28 09:08:41 hostname.example.com.au mariadb-prepare-db-dir[4975]: Database MariaDB is probably initialized in /var/lib/mysql already, nothing is done.
Dec 28 09:08:41 hostname.example.com.au mariadb-prepare-db-dir[4975]: If this is not the case, make sure the /var/lib/mysql is empty before running mariadb-prepare-db-dir.
Dec 28 09:08:41 hostname.example.com.au systemd[1]: mariadb.service: Main process exited, code=exited, status=7/NOTRUNNING
 Subject: Unit process exited
Defined-By: systemd
Support: https://wiki.almalinux.org/Help-and-Support

An ExecStart= process belonging to unit mariadb.service has exited.

The process' exit code is 'exited' and its exit status is 7.
Dec 28 09:08:41 hostname.example.com.au systemd[1]: mariadb.service: Failed with result 'exit-code'.
Subject: Unit failed
Defined-By: systemd
Support: https://wiki.almalinux.org/Help-and-Support

The unit mariadb.service has entered the 'failed' state with result 'exit-code'.
Dec 28 09:08:41 hostname.example.com.au systemd[1]: Failed to start MariaDB 10.5 database server.
Subject: A start job for unit mariadb.service has failed
Defined-By: systemd 
Support: https://wiki.almalinux.org/Help-and-Support
 A start job for unit mariadb.service has finished with a failure.
 
 The job identifier is 1019 and the job result is failed.

Contents of /var/lib/MySQL:
aria_log.00000001 aria_log_control databasename ib_buffer_pool ib_logfile0 ibdata1 multi-master.info mysql mysql_upgrade_info performance_schema

The error message
“Dec 28 09:08:41 hostname.example.com.au mariadb-prepare-db-dir[4975]: Database MariaDB is probably initialized in /var/lib/mysql already, nothing is done.
Dec 28 09:08:41 hostname.example.com.au mariadb-prepare-db-dir[4975]: If this is not the case, make sure the /var/lib/mysql is empty before running mariadb-prepare-db-dir.”
appears to imply the /var/lib/MySQL directory should be empty?

No!

It is implying there’s already data there. If you have already databases, you should want it to find data there. It would be a catastrophic loss if it were empty and your only remedy would be restoring from backup.

Thanks, that’s what I thought.

At a loss why a simple config change would cause the server to stop.

For me incorrect syntax can break stuff, and it won’t stop the server, it will stop it from restarting as the config file is only read when starting.

Well, I would start by undoing that change. Maybe you made a typo and it wasn’t a valid configuration directive?

Unfortunately can’t do it via Webmin (unlikely an error in entering a one digit number in the key_buffer_size) :

Then do it via SSH.

It is bug-like, though, that we need a running Mariadb server to manage the configuration file. @Jamie can you make the Webmin Mariadb/MySQL module allow editing config files even when the server isn’t running and won’t start?

1 Like

Thank you.

Commented out the line in /etc/my.cnf.d/mariadb-server.cnf

ie (set via Webmin interface):

set-variable = key_buffer_size=2G

by editing config file manually to

# set-variable = key_buffer_size=2G

and entered

key_buffer_size=2G

Server is back.

Note: the key_buffer_size in the Webmin MariaDB Server Configuration interface still shows radio button for default, not the 2G (bug or accessing incorrect config file?) as

MySQL CLI shows:
SHOW GLOBAL VARIABLES LIKE “key_buffer_size”;
±----------------±-----------+
| Variable_name | Value |
±----------------±-----------+
| key_buffer_size | 2147483648 |
±----------------±-----------+