Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't Restart MySQL After Editing my.cnf on Mac OS X 10.8.3

I am trying to enable logging on MySQL on my Mac, OS X version 10.8.3.

Everywhere I searched, I get the same answer, i.e. to add the following to my.cnf:

[mysqld]
general_log=1
log=/var/log/mysql-query.log

and then restart mysql.

Permissions on the log file are correct and owner is _mysql like all other MySQL files.

However, doesn't matter how much I try, once my.cnf has been modified, MySQL won't restart. It would only shutdown and that's it. Via command line or via Preferences Pane, it won't start again.

I tried enabling log vie Workbench too, but as soon as log=... entry goes into my.cnf, MySQL refuses to start. I have to manually delete this entry to start MySQL.

Can anybody please guiding me on how to enable logging for MySQL on OS X 10.8.3?

like image 693
zeeshan Avatar asked Jun 14 '13 10:06

zeeshan


2 Answers

Ok, finally wasting more than a day, what worked for me is this:

general-log
general_log_file = /var/log/mysql-query.log

For almost 10 years, in all the Linux systems I have ever used and installed, which must be at least 100 if not more, it has always been a simple entry like log=< path to log file > under [mysqld] section. Apparently it was the same on Macs too what I read from various blogs etc, however on this particular setup which I am doing, this is the first time that I am setting it up like above.

So my current working /etc/my.cnf file is as follows:

[client]
socket=/var/mysql/mysql.sock

[mysqld]
socket=/var/mysql/mysql.sock
general-log
general_log_file = /var/log/mysqld.log

I had to do:

touch /etc/my.cnf
chown _mysql /etc/my.cnf 

to create one.

Also I had to do:

touch /var/log.mysqld.log
chown _mysql /var/log/mysqld.log

followed by restarting mysql via Workbench. Also tried restart via command line as follows:

/usr/local/mysql/bin/mysqladmin -uroot -p shutdown
sudo /usr/local/mysql/bin/mysqld_safe &

Main thing is, finally it is working and I can move ahead with my day.

like image 51
zeeshan Avatar answered Sep 23 '22 13:09

zeeshan


I'm running MySQL Workbench 5.2.47 on Mac Mountain Lion. The above steps (create a /etc/my.cnf, create a dummy log file for mysql to populate, etc) could all be accomplished in MySQL Workbench.

1) Go to Server Admin -> Options File(Configuration). 2) Set your options, including location of 'general-log' under the 'Logging' tab. Click 'Apply'.
3) Startup / Shutdown -> Stop Server 4) Startup / Shutdown -> Start Server Logging should now be turned on for all your statements.

like image 35
snowbound Avatar answered Sep 24 '22 13:09

snowbound