OS X: MySQL not dealing properly with data directory via soft link
- by GJ
I am trying to get a macports-installed MySQL to use a data directory stored inside my FileVault-protected home dir.
I used sudo cp -a /opt/local/var/db/mysql5 ~/db/ (the -a to ensure file permissions remain intact) and then replaced the original mysql5 directory with a soft link: sudo ln -s ~/db/mysql5 /opt/local/var/db/mysql5
However, when I now try to start MySQL it fails. It follows the soft link at least to the extent that it modifies some files in the ~/db/mysql5 dir, notably the error log which gets appended to it this:
110108 15:33:08 mysqld_safe Starting mysqld daemon with databases from /opt/local/var/db/mysql5
110108 15:33:08 [Warning] '--skip-locking' is deprecated and will be removed in a future release. Please use '--skip-external-locking' instead.
110108 15:33:08 [Warning] '--log_slow_queries' is deprecated and will be removed in a future release. Please use ''--slow_query_log'/'--slow_query_log_file'' instead.
110108 15:33:08 [Warning] '--default-character-set' is deprecated and will be removed in a future release. Please use '--character-set-server' instead.
110108 15:33:08 [Warning] Setting lower_case_table_names=2 because file system for /opt/local/var/db/mysql5/ is case insensitive
110108 15:33:08 [Note] Plugin 'FEDERATED' is disabled.
110108 15:33:08 [Note] Plugin 'ndbcluster' is disabled.
/opt/local/libexec/mysqld: Table 'mysql.plugin' doesn't exist
110108 15:33:08 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
110108 15:33:09 InnoDB: Started; log sequence number 4 1596664332
110108 15:33:09 [ERROR] /opt/local/libexec/mysqld: Can't create/write to file '/opt/local/var/db/mysql5/mac.local.pid' (Errcode: 13)
110108 15:33:09 [ERROR] Can't start server: can't create PID file: Permission denied
110108 15:33:09 mysqld_safe mysqld from pid file /opt/local/var/db/mysql5/gPod.local.pid ended
I can't see why MySQL can't create the pid file, since manually creating it using the _mysql user succeeds (sudo -u _mysql touch mac.local.pid from inside ~/db/mysql5)
Any ideas how to resolve this?