I'm running macOS Mojave, just installed MySQL using the official installer. I can start/stop the server without problem from the Preference pane. But from the command line I always get Permission denied trouble:
$ mysql.server start
Starting MySQL
./usr/local/mysql/bin/mysqld_safe: line 144: /usr/local/mysql/data/mysqld.local.err: Permission denied
/usr/local/mysql/bin/mysqld_safe: line 144: /usr/local/mysql/data/mysqld.local.err: Permission denied
/usr/local/mysql/bin/mysqld_safe: line 199: /usr/local/mysql/data/mysqld.local.err: Permission denied
/usr/local/mysql/bin/mysqld_safe: line 144: /usr/local/mysql/data/mysqld.local.err: Permission denied
ERROR! The server quit without updating PID file (/usr/local/mysql/data/mysqld.local.pid).
I also tried with the mysqld
and mysqld_safe
commands with the same results.
The owner of the data directory is the _mysql user:
$ ls -l mysql/
drwxr-x--- 42 _mysql _mysql 1344 Nov 5 21:14 data
I would do su _mysql 'mysql.server start'
for example, but I don't know the password of _mysql
if it has any, I think it's not a login account.
So how can I start the server from the command line?
Update
As the official MySQL documentation explains here, to run the server as normal user you have to own the data directory recursively works:
$ chown bob -R /usr/local/mysql/data
I can start/stop the server from the command line, using any of the commands above, and connect to the server as well.
Problem is, now it doesn't work the Preference pane! Now the question is: Is there any way of getting back the Pref pane working? Most importantly, why did that happen?