# MariaDB post installation question



## fred974 (Nov 2, 2016)

Hi,

I just installed /databases/mariadb101 and I have set the /usr/local/etc/my.cnf as per my requirement.

When I started the service, I got the following error message:

```
2016-11-02 10:16:28 37028888832 [Warning] Failed to load slave replication state from table mysql.gtid_slave_pos: 1146: Table 'mysql.gtid_slave_pos' doesn't exist
2016-11-02 10:16:28 34422743040 [ERROR] Can't open and lock privilege tables: Table 'mysql.servers' doesn't exist
201
```
I have researched the message and this article sugest that I first need to run 
`mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql`

So my question is: On FreeBSD server, do I need to change the `--basedir=/usr` to a different path or just run the command as instructed above?

I have included my /usr/local/etc/my.cnf bellow for any further information

```
[client]

#password       = your_password
port            = 3306
socket          = /tmp/mysql.sock

[mysql]

# Prevent accidents
safe-updates

# CLIENT #
port                           = 3306
socket                         = /tmp/mysql.sock

[mysqld]

# GENERAL #
bind-address                   = 10.8.20.10
user                           = mysql
default-storage-engine         = InnoDB
socket                         = /tmp/mysql.sock
pid-file                       = /var/db/mysql/MariaDB.mydomain.uk.pid

# UNICODE encoding
character-set-server = utf8
collation-server = utf8_unicode_ci
skip-character-set-client-handshake

# MyISAM #
key-buffer-size                = 32M
myisam-recover                 = FORCE,BACKUP

# SAFETY #
max-allowed-packet             = 16M
max-connect-errors             = 1000000
skip-name-resolve
sql-mode                       = STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_AUTO_VALUE_ON_ZERO,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE,ONLY_FULL_GROUP_BY
sysdate-is-now                 = 1
innodb                         = FORCE

# DATA STORAGE #
datadir                        = /var/db/mysql/

# BINARY LOGGING #
log-bin                        = /var/db/mysql/mysql-bin
expire-logs-days               = 14
sync-binlog                    = 1

# CACHES AND LIMITS #
tmp-table-size                 = 32M
max-heap-table-size            = 32M
query-cache-type               = 0
query-cache-size               = 0
max-connections                = 500
thread-cache-size              = 50
open-files-limit               = 65535
table-definition-cache         = 4096
table-open-cache               = 4096

# INNODB #
innodb-flush-method            = O_DIRECT
innodb-log-files-in-group      = 2
innodb-log-file-size           = 128M
innodb-flush-log-at-trx-commit = 1
innodb-file-per-table          = 1
innodb-buffer-pool-size        = 2G

# LOGGING #
log-error                      = /var/db/mysql/mysql-error.log
log-queries-not-using-indexes  = 1
slow-query-log                 = 1
slow-query-log-file            = /var/db/mysql/mysql-slow.log
```

Thank you


----------



## fred974 (Nov 2, 2016)

I've look into it more and I came up with this 2 options:
`mysql_install_db --user=mysql --basedir=/var/db/mysql --datadir=/var/db/mysql`
or
`mysql_install_db --user=mysql --basedir=/var/db/mysql/mysql --datadir=/var/db/mysql`

Could someone please confirm which is the correct command?


----------



## SirDice (Nov 2, 2016)

The first one. The /var/db/mysql/mysql is the mysql database (where users are stored for example).


----------



## fred974 (Nov 3, 2016)

SirDice Thank you for your help.
I ran `mysql_install_db --user=mysql --basedir=/var/db/mysql --datadir=/var/db/mysql` and got the following error:

```
FATAL ERROR: Could not find my_print_defaults

The following directories were searched:

    /var/db/mysql/bin
    /var/db/mysql/extra

If you compiled from source, you need to either run 'make install' to
copy the software into the correct location ready for operation.
If you don't want to do a full install, you can use the --srcddir
option to only install the mysql database and privilege tables

If you are using a binary release, you must either be at the top
level of the extracted archive, or pass the --basedir option
pointing to that location.

The latest information about mysql_install_db is available at
https://mariadb.com/kb/en/installing-system-tables-mysql_install_db
```

I am trying to install mariadb101 inside sysutils/cbsd new jail.. 
Has anyone managed to do it? Is it supported?


----------



## fred974 (Nov 3, 2016)

Found solution here
`/usr/local/bin/mysql_install_db --basedir=/usr/local`


----------

