# ezjail, MySQL and strange problem



## kel (Nov 25, 2015)

I am totally stumped here. I've spent several days trying to fix a strange problem. I have two nearly identical servers, one is working just fine and the other is not. Each one is as follows:

FreeBSD 10.2 host
jail1: webjail 10.0.0.1 with apache24
jail2: dbjail 10.0.0.2 with mysql56-server
Both jails created using ezjail

The problem is only with MySQL and its socket, on both systems I can get mysql56-server installed and running into the dbjail but on one system it will not create its /tmp/mysql.sock. I have searched for days on how to fix this problem. On the problem host I've destroyed the jail, created a new dbjail, and the problem persists. I've even tried archiving the working dbjail from one host and restoring it on the problem host, but still have the problem where /tmp/mysql.sock won't get created so I can't connect to the database. I've tried other similar packages including mysql55-server and MariaDB 10 and 5.5 with the same issues.

I'm able to install MySQL on the problem host without issue. But I can't get it running in the jail on that host. On another host I have no problems running MySQL in the jail.

Here is an example of what I'm doing that works fine on one host but not on the other:


```
root@europa:~#ezjail-admin create dbjail 10.0.0.2
root@europa:~#cp /etc/resolv.conf /usr/jails/dbjail/etc
root@europa:~#ezjail-admin start dbjail
Starting jails: dbjail.
/etc/rc.d/jail: WARNING: Per-jail configuration via jail_* variables  is obsolete.  Please consider to migrate to /etc/jail.conf.
root@europa:~#jexec dbjail /bin/csh
root@dbjail:/ # pkg install mysql56-server
root@dbjail:/ # echo 'mysql_enable="YES"' >> /etc/rc.conf
root@dbjail:/ # /usr/local/etc/rc.d/mysql-server start
```

At this point the prompt never returns. It seems like MySQL never finishes its startup routine. From another console I can see that MySQL is running but there is no PID file or /tmp/mysql.sock either:


```
root@dbjail:~ # ps auxww|grep mysql
root  15713  0.0  0.5  17084  2400  0  I+J   2:59PM 0:00.01 /bin/sh /usr/local/etc/rc.d/mysql-server start
root  15718  0.0  1.5  39348  7668  0  I+J   2:59PM 0:00.07 /usr/local/bin/perl /usr/local/bin/mysql_install_db --basedir=/usr/local --defaults-extra-file=/var/db/mysql/my.cnf --datadir=/var/db/mysql --force
root  15720  0.0  7.5 204464 37380  0  I+J   2:59PM 0:00.06 /usr/local/libexec/mysqld --defaults-extra-file=/var/db/mysql/my.cnf --bootstrap --basedir=/usr/local --datadir=/var/db/mysql --log-warnings=0 --loose-skip-ndbcluster --max_allowed_packet=8M --default-storage-engine=MyISAM --net_buffer_length=16K

root@dbjail:~ # ls -l /tmp
total 16
drwxrwxrwt  2 root  wheel  512 Nov 25 14:56 .ICE-unix
drwxrwxrwt  2 root  wheel  512 Nov 25 14:56 .X11-unix
drwxrwxrwt  2 root  wheel  512 Nov 25 14:56 .XIM-unix
drwxrwxrwt  2 root  wheel  512 Nov 25 14:56 .font-unix

root@dbjail:/var/db/mysql # ls -al /var/db/mysql
total 16
drwxr-xr-x   4 mysql  mysql  512 Nov 25 14:59 .
drwxr-xr-x  11 root   wheel  512 Nov 25 14:58 ..
drwx------   2 root   mysql  512 Nov 25 14:59 mysql
drwx------   2 root   mysql  512 Nov 25 14:59 test
```

It looks like MySQL never finishes its startup routine. There are no errors in the logs. Since I've done this exact same set of steps on another host without issue there must be something different with this host. I have the same issue when installing MySQL into another jail (webjail) on the same hosts. So I investigate the host, check /etc/rc.conf and /etc/sysctl.conf and see no difference. I've also double-checked the /usr/local/etc/ezjail.conf config and both are identical. I'm stumped as to what is wrong with the problem host.

I had the bright idea of archiving a working dbjail from another host where MySQL is running fine, then restoring it on this host. I did that and the jail starts up fine and MySQL is indeed running but there's still no /tmp/mysql.sock. If I enter the jail I'm also unable to kill the mysqld processes which is strange. The kill command runs and does not generate an error but the process never gets killed. Why does this jail work on one host but not another? They are both running FreeBSD 10.2.

I'm at the point of thinking about reinstalling the host from scratch. However I have about 10G of data on this system that I don't want to have to backup & restore, so I'd really like to just find the source of the problem & fix it. Any ideas?


----------



## SirDice (Nov 26, 2015)

I've had issues starting MySQL for the first time too when I used a modified my.cnf. Did you create or copied my.cnf? Try starting MySQL without it. Make sure /var/db/mysql/ is empty so it'll run the initialization. If that fails, clean up before trying again.


----------

