A program to list MySQL or MariaDB default option files

I’ve written an open-source Linux program, pgoptionfiles.c, that tells what a MySQL or MariaDB Connector C library will choose for default option files. In my last post I’d mentioned how choices can differ and can be hard to know. I said ptrace() was a possible help, and pgoptionfiles proves that ptrace() works.

First it forks so there are two processes, a tracee and a tracer. The tracee process calls dlopen() to load a Connector C library, then calls mysql_options(…MYSQL_READ_DEFAULT_GROUP…) to request reading of all default option files, then calls mysql_real_connect() with a fake target so that the connector will actually start. Meanwhile the tracer process is monitoring the tracee’s file-related calls such as access() or fopen() — and forcing them to return errors. At the end the tracer displays the connector version and the file names.

Here are some results:

/* Ubuntu 20 + , MariaDB connector */
(pgoptionfiles)(Connector C version 3.4.3)
/etc/my.cnf
/etc/mysql/my.cnf
/home/pgulutzan/.my.cnf

/* Fedora 42 + MySQL connector */
(pgoptionfiles)(Connector C version 8.0.42)
/etc/my.cnf
/etc/mysql/my.cnf
/home/pgulutzan/.my.cnf
/home/pgulutzan/.mylogin.cnf

/* Ubuntu 20 + MySQL connector */
(pgoptionfiles)(Connector C version 8.3.0)
/etc/my.cnf
/etc/mysql/my.cnf
/usr/local/mysql/etc/my.cnf
/home/pgulutzan/.my.cnf
/home/pgulutzan/.mylogin.cnf

For details — and some warnings about how it can fail — read the many comments in the source code. Clone it from https://github.com/pgulutzan/pgoptionfiles. To run it, you need gcc plus an acceptance of GPL.

, August 7, 2025. No Comments on A program to list MySQL or MariaDB default option files. Category: MySQL / MariaDB, Uncategorized.

About pgulutzan

Co-author of four computer books. Software Architect at MySQL/Sun/Oracle from 2003-2011, and at HP for a little while after that. Currently with Ocelot Computer Services Inc. in Edmonton Canada.

Leave a Reply

Your email address will not be published. Required fields are marked *