Solved MySQL Server 5.7.12 crappy PKG on FreeBSD 10.3


I've just tried to install MySQL 5.7 via package (mysql57-server-5.7.12) on a brand new FreeBSD 10.3-REL (last ones at the time of writing this), and **** happens: mysql will not start as is.

In fact the package seems to not fully install what it should.

Here is what I've done to make it work:

Starting as usual:

$ pkg install mysql57-server
All seems ok...

Add this, of course, to /etc/rc.conf:

$ service mysql-server start
/usr/local/etc/rc.d/mysql-server: WARNING: failed precmd routine for mysql
What? It used to work in the past months...

Looking at: /var/db/mysql/, ..owned by mysql and totally empty.

Looking at: /usr/local/etc/mysql/my.cnf
Owned by root and unreadable by mysql...
# ll -a /usr/local/etc/mysql/my.cnf
total 20
drwxr-xr-x  3 root  wheel  512 Jun 16 15:50 ./
drwxr-xr-x  11 root  wheel  512 Jun 16 15:50 ../
drwxr-x---  2 mysql  mysql  512 Jun 14 04:01 keyring/
-rw-r-----  1 root  wheel  2319 Jun 14 04:01 my.cnf
-rw-r-----  1 root  wheel  2319 Jun 14 04:01 my.cnf.sample
So changing owner:
$ chown mysql:mysql /usr/local/etc/mysql/my.cnf

Looking at: /root/.mysql_secret, exists and contains a password.

So... doing the "data-directory-initialization":
( )
$ /usr/local/libexec/mysqld --initialize --user=mysql

At the end it writes:
[Note] A temporary password is generated for root@localhost: xxxxx

Copying the new password into  : /root/.mysql_secret
(for below "mysql_secure_installation" call)

$ service mysql-server start
$ service mysql-server status

Great, it works ;-)

And so on:
$ /usr/local/bin/mysql_secure_installation
change root password etc...
and every finetuning you want.