Reputation: 333
I'm trying to configure a MySQL server on a virtual machine using Alpine.
I installed the packages mysql
and mysql-client
.
I know that to install them properly, one has to either set things up via command line or edit the configs.
I also know that MariaDB is a forked version of MySQL. I know that MySQL's option file is called my.cnf
and Maria's is mariadb-server.cnf
.
The question is: which one I have to configure, and why in one of the implementation I'm looking at, both files are configured? I'm having some difficulties with understanding how MySQL and MariaDB are connected and why I have to edit both configs. my.cnf
happens to contain only
[mysqld]
port=3306
datadir=/var/lib/mysql
bind-address=0.0.0.0
while mariadb-server.cnf
has only
[galera]
bind-address=0.0.0.0
I do understand what the fields mean, but I'd like to understand how the two configs are read together, in which precedence and so on.
There's even more confusion after all these "configuring MariaDB server with a my.cnf file" pages on web. So only the my.cnf
file should suffice? It seems like I even fail to find any mention of the mariadb-server.cnf
file. It might be useful that this config is located at /etc/my.cnf.d/mariadb-server.cnf
.
Upvotes: 2
Views: 4842
Reputation: 562310
By default, mysqld will read an option file in a few default locations (e.g. /etc/my.cnf). These are documented: https://mariadb.com/kb/en/configuring-mariadb-with-option-files/#default-option-file-locations
In addition, the my.cnf file may contain a directive to load others:
!includedir /etc/my.cnf.d/
This means to load all the files under /etc/my.cnf.d. The filenames don't matter. You could name a file /etc/my.cnf.d/postgresql.cnf, or anything else, and mysqld would still load it happily.
Why would you put some directives into separate files instead of just keeping them all in /etc/my.cnf? For modularity.
If you want to deploy some sets of config directives in a modular way, using a directory of individual files is a little easier than editing a single file. You might make a mistake in editing, and accidentally change a different line than you intended.
Also removing some set of configuration options is easy if they are organized into individual files. Just delete one of the files under /etc/my.cnf.d, and restart mysqld, and then it's done.
Many other services on Linux follow this pattern of using a directory of config files. Try this sometime, and you'll likely see a lot of them:
ls -d /etc/*.d
Upvotes: 2