"service mysql-server start" returns: "WARNING: failed precmd routine for mysql"

molofishy

Member

Reaction score: 4
Messages: 54

I installed mysql-server in a jail (running FreeBSD 11.0-RELEASE) with:
pkg install mysql80-server-8.0.2_1

When I try to start it:
service mysql-server start
The following is returned:
WARNING: failed precmd routine for mysql


A google search tells me others have experienced this issue (https://forums.freebsd.org/threads/no-database-will-run-on-my-10-2.56564/; https://serverfault.com/questions/7...server-5-7-12-fails-to-start-on-freebsd-10-3; https://stackoverflow.com/questions/37103450/freebsd-mysql-error-after-installation). I've tried some suggestions with no luck.

Most suggest suggest something like:
rm -rf /var/db/mysql/*
then:
/usr/local/libexec/mysqld --initialize --user=mysql
then:
service mysql-server start
Which gives me the same initial error:
WARNING: failed precmd routine for mysql
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 10,665
Messages: 36,409

(running FreeBSD 11.0-RELEASE
FreeBSD 11.0 is End-of-life and not supported any more. Please upgrade to 11.2.

Code:
rm -rf /var/db/mysql/*
service mysql-server start
There is no need to initialize the database by hand, the startup scripts already take care of this.
 

ShelLuser

Son of Beastie

Reaction score: 2,023
Messages: 3,732

After you started it (tried to) check /var/db/mysql again, it probably has an *.err file in there which most likely shows the reason why the service couldn't start. This file is usually named after the host.
 
OP
M

molofishy

Member

Reaction score: 4
Messages: 54

Making sure FreeBSD 11.1 was used in the jail solved this. Version 11.2 is not out yet.
 

n9010

Member

Reaction score: 1
Messages: 23

Hi
I'am having the same issue, MYSQL installed inside a Jail. Cannot find any log stating what is wrong.

Code:
root@mysql:/usr/local # service mysql-server start
/usr/local/etc/rc.d/mysql-server: WARNING: failed precmd routine for mysql
Messages:
Code:
Jun 29 14:56:13 mysql pkg-static: cyrus-sasl-2.1.26_13 installed
Jun 29 14:56:45 mysql pkg-static: openldap-sasl-client-2.4.46 installed
Jun 29 14:57:34 mysql pkg-static: mysql57-client-5.7.22_1 installed
Jun 29 15:02:56 mysql pkg-static: mysql57-server-5.7.22 installed
Jun 29 15:16:58 mysql root: /usr/local/etc/rc.d/mysql-server: WARNING: failed precmd routine for mysql

Code:
root@mysql:/usr/local # ll mysql/data/
total 1
-rw-r-----  1 mysql  mysql  0 Jun 29 15:22 mysql-bin.index
This file is empty

Code:
root@mysql:/usr/local # uname -a
FreeBSD HOSTNAME 11.2-RELEASE FreeBSD 11.2-RELEASE #0 r335510: Fri Jun 22 04:32:14 UTC 2018     root@releng2.nyi.freebsd.org:/usr/obj/usr/src/sys/GENERIC  amd64

Any idea?

Thanks
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 10,665
Messages: 36,409

When you first start MySQL make sure /var/db/mysql is completely empty!
 

jiro

New Member


Messages: 2

I have same issue in jail.
jail # service mysql-server start
/usr/local/etc/rc.d/mysql-server: WARNING: failed precmd routine for mysql


It makes zero-size file at mysql_dbdir.
jail # ls -alg
total 8
drwxr-xr-x 2 mysql mysql 512 Oct 17 09:44 .
drwxr-xr-x 5 root wheel 512 Jun 8 17:07 ..
-rw-r----- 1 mysql mysql 0 Oct 17 09:44 mysql-bin.index


jail # uname -a
FreeBSD * 11.2-RELEASE-p4 FreeBSD 11.2-RELEASE-p4 #0: Thu Sep 27 08:16:24 UTC 2018 root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC amd64


But it success without jail.
# service mysql-server start
Starting mysql.
 

jiro

New Member


Messages: 2

Solved?

jail # cd /var/db
jail # mkdir mysql mysql_secure mysql_tmpdir
jail # chown mysql mysql mysql_secure mysql_tmpdir
jail # /usr/local/libexec/mysqld --user=mysql --initialize
2018-10-17T04:04:57.119817Z 0 [Warning] [MY-011068] [Server] The syntax 'expire-logs-days' is deprecated and will be removed in a future release. Please use binlog_expire_logs_seconds instead.
2018-10-17T04:04:57.119945Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.
2018-10-17T04:04:57.119998Z 0 [System] [MY-013169] [Server] /usr/local/libexec/mysqld (mysqld 8.0.12) initializing of server in progress as process 44359
100
100 200
100 200
100
mysqld: Error on delete of './auto.cnf' (OS errno 2 - No such file or directory)
2018-10-17T04:05:10.187583Z 0 [Warning] [MY-010107] [Server] World-writable config file './auto.cnf' has been removed.
2018-10-17T04:05:10.697067Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: *********
2018-10-17T04:05:12.916495Z 0 [System] [MY-013170] [Server] /usr/local/libexec/mysqld (mysqld 8.0.12) initializing of server has completed
jail # service mysql-server start
Starting mysql.
 

Brian546

Member

Reaction score: 1
Messages: 24

I don't know if anyone is still receiving the "failed precmd routine for mysql" error message when trying to start the MySQL server, but I ran into this a few days ago after building the port for mariadb105-server in a jail. I tried nearly every suggestion I could find here and on the web. Directory permissions such as /usr/local/etc/mysql and /var/db/mysql were correct, /etc/passwd was definitely synced with master.passwd. Then I rebuilt it in the same jail. Same error message. Set up a completely different jail and built it, this time the mysql server started with no issues. What was the difference? The original jail I used was one of those fancy base jails with the read only directories nullfs mounted ro (while directories like /var, /tmp, /usr/home, /etc are mounted rw). The other jail I made was a full jail. This tells me the mysql-server daemon is trying to write to somewhere it absolutely should not be writing to.
 

Brian546

Member

Reaction score: 1
Messages: 24

I was able to figure out my problem starting mariadb in my original jail. I didn't have permissions on /tmp set to 1777. Works great now.
 
Top