From fa347003219d94a00890c4c8eee612665fb8478b Mon Sep 17 00:00:00 2001 From: mueller-ma <22525368+mueller-ma@users.noreply.github.com> Date: Tue, 14 Jul 2026 10:26:46 +0200 Subject: [PATCH 1/3] mysql: find sockets on default mariadb installation on Debian The current auto-detect command doesn't work on a default MariaDB installation on Debian for two reasons: - The account is called mariadbd - No "socket" is in the CMD printed by ps As the default socket is `/run/mysqld/mysqld.sock`, use all sockets in `/run/mysqld` to support multi-instance setups. From new Debian installation: ``` root@ca9b0a452ef5:/# grep socket -Ri /etc/mysql/ /etc/mysql/my.cnf:# Port or socket location where to connect /etc/mysql/my.cnf:socket = /run/mysqld/mysqld.sock /etc/mysql/my.cnf.fallback:# Remember to edit /etc/mysql/debian.cnf when changing the socket location. /etc/mysql/debian.cnf:# anyway thanks to unix socket authentication and hence /etc/mysql/mariadb.cnf:# Port or socket location where to connect /etc/mysql/mariadb.cnf:socket = /run/mysqld/mysqld.sock ``` --- agents/plugins/mk_mysql | 3 +++ 1 file changed, 3 insertions(+) diff --git a/agents/plugins/mk_mysql b/agents/plugins/mk_mysql index 2b1325dd5cb..cde33f7e263 100755 --- a/agents/plugins/mk_mysql +++ b/agents/plugins/mk_mysql @@ -78,6 +78,9 @@ alias_string=$(grep -F -h alias "$MK_CONFDIR"/mysql{.local,}.cfg | sed -ne 's/.* if [ -z "$mysql_socket_string" ]; then mysql_socket_string=$(ps -fww -C mysqld | grep "socket" | sed -ne 's/.*socket=\([^ ]*\).*/\1/p') fi +if [ -z "$mysql_socket_string" ]; then + mysql_socket_string=$(find /run/mysqld -type s) +fi if [ -z "$mysql_socket_string" ]; then do_query "" "" else From da582506b64e2af2c0e34ce5217f1d73a3b4259f Mon Sep 17 00:00:00 2001 From: mueller-ma <22525368+mueller-ma@users.noreply.github.com> Date: Fri, 25 Sep 2026 13:33:28 +0200 Subject: [PATCH 2/3] Keep 'mysql' when only one instance is running --- agents/plugins/mk_mysql | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/agents/plugins/mk_mysql b/agents/plugins/mk_mysql index cde33f7e263..157ee32bb04 100755 --- a/agents/plugins/mk_mysql +++ b/agents/plugins/mk_mysql @@ -79,10 +79,14 @@ if [ -z "$mysql_socket_string" ]; then mysql_socket_string=$(ps -fww -C mysqld | grep "socket" | sed -ne 's/.*socket=\([^ ]*\).*/\1/p') fi if [ -z "$mysql_socket_string" ]; then - mysql_socket_string=$(find /run/mysqld -type s) + mysql_socket_string=$(find /run/mysqld -type s 2>/dev/null) + mysql_socket_count=$(grep -c . <<<"$mysql_socket_string") fi if [ -z "$mysql_socket_string" ]; then do_query "" "" +elif [ "$mysql_socket_count" = 1 ]; then + # keep the default instance name "mysql" for a single auto-detected socket + do_query "$mysql_socket_string" "" else IFS=" " mapfile -t mysql_sockets <<<"$mysql_socket_string" IFS="," read -r -a aliases <<<"$alias_string" From 26dd942a95a60dff78a57fb49e0b3bb41722f03b Mon Sep 17 00:00:00 2001 From: mueller-ma <22525368+mueller-ma@users.noreply.github.com> Date: Mon, 28 Sep 2026 11:26:27 +0200 Subject: [PATCH 3/3] Ignore x protocol socket --- agents/plugins/mk_mysql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/agents/plugins/mk_mysql b/agents/plugins/mk_mysql index 157ee32bb04..33f4c903627 100755 --- a/agents/plugins/mk_mysql +++ b/agents/plugins/mk_mysql @@ -79,7 +79,7 @@ if [ -z "$mysql_socket_string" ]; then mysql_socket_string=$(ps -fww -C mysqld | grep "socket" | sed -ne 's/.*socket=\([^ ]*\).*/\1/p') fi if [ -z "$mysql_socket_string" ]; then - mysql_socket_string=$(find /run/mysqld -type s 2>/dev/null) + mysql_socket_string=$(find /run/mysqld -type s ! -name 'mysqlx*' 2>/dev/null) mysql_socket_count=$(grep -c . <<<"$mysql_socket_string") fi if [ -z "$mysql_socket_string" ]; then