# MariaDB still not reading my.cnf?



## MMacD (Feb 16, 2017)

Apologies if this isn't the right place for this. 

Am I doing something stupid, or not doing something I should be doing?  Because if not, MariaDB still isn't interpreting my.cnf, although it complains if it's not in /usr/local/etc/mysql.

The command:
`13:59:57 Thu, 16 Feb                                                                               
[server:root]~> /usr/local/libexec/mysqld --defaults-file="/usr/local/etc/my.cnf" -u root`

The contents of /usr/local/etc/mysql/my.cnf:

```
[mysqld]
aria_pagecache_buffer_size=2G
character_set_connection="latin1"
character_set_server="latin1"
character_set_database="latin1"
character_set_filesystem="latin1"
character_set_filesystem="latin1"
collation_client="latin1_general_ci"
collation_connection="latin1_general_ci"
collation_server="latin1_general_ci"
collation_database="latin1_general_ci"
datadir=/MC/tables
default_storage_engine=aria
innodb_file_per_table=1
log-error=/MC/logs/MariaDB_errors.log
loose_mutex_deadlock_detector
key_buffer_size=2G
```

But, from `mysqladmin variables`:

```
character_set_system            utf8
collation_connection              latin1_swedish_ci 
collation_database                 latin1_swedish_ci
collation_server                      latin1_swedish_ci 
datadir                                   /var/db/mysql/                                                          default_storage_engine          InnoDB
log_error
```


----------



## SirDice (Feb 16, 2017)

Start it properly, the rc(8) scripts take care of a lot of stuff and default settings. One of the things is running it on the mysql account, it should never be run as root.

Add to /etc/rc.conf:

```
mysql_dbdir="/MC/tables"
mysql_optfile="/usr/local/etc/my.cnf"
mysql_enable="YES"
```
Then `service mysql-server start`.


----------



## MMacD (Feb 16, 2017)

I'm having a problem making service work at present.  It's been working fine for years (I do have rc.conf set up properly), but just recently, after adding another 3-way zfs mirror to my server-of-all-work, an LSI 9211 card to manage the (now) two arrays, and moving the server hardware to a new enclosure, I haven't been able to get service to start mariadb.

As far as I know, I made no software changes at all.  But, ever since the move service says "starting mysql-server"  and then does nothing.  Nor does it put out any error messages.  Reinstalling the package didn't help.  I've been looking at the rc.d procedure file, but don't see anything obviously wrong (there appeared to be missing references, enough that I can't understand how it could ever have workd, but fixing them didn't change anything).

So I was horsing around with it by hand to see if I could see where the problem is.  I can point at the `datadir` successfully using a command-line switch, but it seems to me that even if I am running it as root, it should be interpreting my.cnf


----------



## OlivierW (Feb 17, 2017)

MMacD said:


> `13:59:57 Thu, 16 Feb
> [server:root]~> /usr/local/libexec/mysqld --defaults-file="/usr/local/etc/my.cnf" -u root`





MMacD said:


> /usr/local/etc/mysql/my.cnf




Where is your my.cnf file? Look at the two paths from your first post, one of them has a "/mysql" which isn't present in the other.
By default, MariaDB 10.1 will use /var/db/mysql/my.cnf. If you want to use another file, look at SirDice's post.


----------



## jalla (Feb 18, 2017)

OlivierW said:


> By default, MariaDB 10.1 will use /var/db/mysql/my.cnf.



Not correct AFAICT

```
gnome:~# mysqladmin --help
...
Default options are read from the following files in the given order:
/usr/local/etc/my.cnf /usr/local/etc/mysql/my.cnf ~/.my.cnf
...
```


----------



## OlivierW (Feb 19, 2017)

jalla, check: /usr/local/etc/rc.d/mysql-server:

```
# mysql_(instance_)?optfile (str): Server-specific option file.
#           Default to "${mysql_dbdir}/my.cnf".
```
and:

```
# mysql_(instance_)?dbdir (str):    Default to "/var/db/mysql"
#           Base database directory.
```


----------



## jalla (Feb 20, 2017)

OlivierW said:


> jalla, check: /usr/local/etc/rc.d/mysql-server:
> 
> ```
> # mysql_(instance_)?optfile (str): Server-specific option file.
> ...


Note that $optfile is passed to the startup command like this: `--defaults-[B]extra[/B]-file=${mysql_optfile}`

I believe this would be used in addition to (for instance) /usr/local/etc/mysql/my.cnf


----------

