Wednesday, 16 November 2016

restart MySQL Server on MacOSX after Sierra Upgrade

After each upgrade of MacOS X, MySQL won't restart, as the upgrade process delete the logging directory of MySQL :


If you try to run mysqld_safe manually, you'll get cristal clear error :

[10:45] tmanson@busyboxy:/usr/local/mysql/bin$ ./mysqld_safe
./mysqld_safe: line 544: /usr/local/mysql/data/mysqld_safe.pid: Permission denied
awk: i/o error occurred while closing /dev/stdout
 input record number 3, file
 source line number 1
161116 10:46:07 mysqld_safe Logging to '/var/log/mysql/error.log'.
touch: /var/log/mysql/error.log: No such file or directory
chmod: /var/log/mysql/error.log: No such file or directory
161116 10:46:07 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
./mysqld_safe: line 129: /var/log/mysql/error.log: No such file or directory
./mysqld_safe: line 166: /var/log/mysql/error.log: No such file or directory
touch: /var/log/mysql/error.log: No such file or directory
chown: /var/log/mysql/error.log: No such file or directory
chmod: /var/log/mysql/error.log: No such file or directory
161116 10:46:07 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
./mysqld_safe: line 129: /var/log/mysql/error.log: No such file or directory


(note: the error about mysql_safe.pid is just here because I've launch mysqld_safe as my regular user instead of root, but the path exists and the mysql tool that starts mysql is starting it as root)

To solve this :

sudo mkdir /var/log/mysql/
sudo chown _mysql:admin /var/log/mysql/

normally, MySQL is tried to start periodically, so you actually don't need to startit manually!
so you should just check, in the system preference/mysql :