diff --git a/auxdir/x_ac_databases.m4 b/auxdir/x_ac_databases.m4
index a0ede7ece32f4a0ec59e2229e59f5d1490bf1fe2..6f78741a0ecbf02bb85adc51b38618c848f4f20f 100644
--- a/auxdir/x_ac_databases.m4
+++ b/auxdir/x_ac_databases.m4
@@ -22,9 +22,9 @@ AC_DEFUN([X_AC_DATABASES],
 		[_x_ac_mysql_bin="$withval"])
 
 	if test x$_x_ac_mysql_bin = xno; then
-    		AC_PATH_PROG(HAVEMYSQLCONFIG, mysql_config, no)
+		AC_PATH_PROGS(HAVEMYSQLCONFIG, [mysql_config mariadb_config], no)
 	else
-   		AC_PATH_PROG(HAVEMYSQLCONFIG, mysql_config, no, $_x_ac_mysql_bin)
+		AC_PATH_PROGS(HAVEMYSQLCONFIG, [mysql_config mariadb_config], no, $_x_ac_mysql_bin)
 	fi
 
 	if test x$HAVEMYSQLCONFIG = xno; then
diff --git a/configure b/configure
index 5474f8c79a3351733a63b605f46a119f9d7a7424..0b635a8a95a0ce5792522d19e472418e1deef792 100755
--- a/configure
+++ b/configure
@@ -21788,8 +21788,10 @@ fi
 
 
 	if test x$_x_ac_mysql_bin = xno; then
-    		# Extract the first word of "mysql_config", so it can be a program name with args.
-set dummy mysql_config; ac_word=$2
+		for ac_prog in mysql_config mariadb_config
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
 if ${ac_cv_path_HAVEMYSQLCONFIG+:} false; then :
@@ -21815,7 +21817,6 @@ done
   done
 IFS=$as_save_IFS
 
-  test -z "$ac_cv_path_HAVEMYSQLCONFIG" && ac_cv_path_HAVEMYSQLCONFIG="no"
   ;;
 esac
 fi
@@ -21829,9 +21830,15 @@ $as_echo "no" >&6; }
 fi
 
 
+  test -n "$HAVEMYSQLCONFIG" && break
+done
+test -n "$HAVEMYSQLCONFIG" || HAVEMYSQLCONFIG="no"
+
 	else
-   		# Extract the first word of "mysql_config", so it can be a program name with args.
-set dummy mysql_config; ac_word=$2
+		for ac_prog in mysql_config mariadb_config
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
 if ${ac_cv_path_HAVEMYSQLCONFIG+:} false; then :
@@ -21857,7 +21864,6 @@ done
   done
 IFS=$as_save_IFS
 
-  test -z "$ac_cv_path_HAVEMYSQLCONFIG" && ac_cv_path_HAVEMYSQLCONFIG="no"
   ;;
 esac
 fi
@@ -21871,6 +21877,10 @@ $as_echo "no" >&6; }
 fi
 
 
+  test -n "$HAVEMYSQLCONFIG" && break
+done
+test -n "$HAVEMYSQLCONFIG" || HAVEMYSQLCONFIG="no"
+
 	fi
 
 	if test x$HAVEMYSQLCONFIG = xno; then