title: Trouble running mysql on OSX 10.6 development machine: "ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)"
body: <p>I've installed MySQL on my personal/development machine using the .dmg package, according to the instructions here: <a href="http://dev.mysql.com/doc/refman/5.5/en/macosx-installation-pkg.html" rel="nofollow">http://dev.mysql.com/doc/refman/5.5/en/macosx-installation-pkg.html</a> including installing the startup item and the preferences pane.  And yet, I can't seem to use MySQL at all.</p>
  
  <p>running:</p>
  
  <pre><code>/Library/StartupItems/MySQLCOM/MySQLCOM start
  </code></pre>
  
  <p>or</p>
  
  <pre><code>/Library/StartupItems/MySQLCOM/MySQLCOM restart
  </code></pre>
  
  <p>"appears" to work -- in that, it gives me a message like "Starting MySQL database server" -- but afterward, I still can't go into mysql at the command-line, or connect to it in a Rails 2.3.8 application running in script/server.  I get the error denoted in the question title.</p>
  
  <p>Also, the MySQL preferences pane doesn't seem to work either.  If I click the "Start MySQL Server" button, I'm asked for my password, but then nothing happens -- the pane continues to say that the server is stopped.</p>
  
  <p>(I believe I had a MacPorts version of MySQL installed previously, and it's also possible that there was one built from source at some time in the past -- but I'm reasonably sure I've uninstalled these and deleted all the files having to do with it that I could find.)</p>
  
  <p>I'm also trying <code>mysqld start</code> in terminal.  here's the output:</p>
  
  <pre><code>110127 15:40:28 [Warning] Can't create test file /usr/local/mysql-5.5.8-osx10.6-x86_64/data/Lucky-Charm.lower-test
  110127 15:40:28 [Warning] Can't create test file /usr/local/mysql-5.5.8-osx10.6-x86_64/data/Lucky-Charm.lower-test
  110127 15:40:28 [Note] Plugin 'FEDERATED' is disabled.
  mysqld: Can't find file: './mysql/plugin.frm' (errno: 13)
  110127 15:40:28 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
  InnoDB: The InnoDB memory heap is disabled
  InnoDB: Mutexes and rw_locks use GCC atomic builtins
  InnoDB: Compressed tables use zlib 1.2.3
  110127 15:40:28  InnoDB: Initializing buffer pool, size = 128.0M
  110127 15:40:28  InnoDB: Completed initialization of buffer pool
  110127 15:40:28  InnoDB: Operating system error number 13 in a file operation.
  InnoDB: The error means mysqld does not have the access rights to
  InnoDB: the directory.
  InnoDB: File name ./ibdata1
  InnoDB: File operation call: 'open'.
  InnoDB: Cannot continue operation.
  </code></pre>
  
  <p>Tried following the message about running mysql_upgrade but that just gives me my original error again.</p>
  
  <hr>
  
  <p>UPDATE:</p>
  
  <p>OK I've been pursuing the theory that it's a permissions problem.  Seeing that the datadir was owned by root, I chown -R it to _mysql.  In response to Mike, here's where that now stands:</p>
  
  <pre><code>$ ls -al /usr/local/mysql-5.5.8-osx10.6-x86_64
  total 296
  drwxr-xr-x  16 root    wheel     544 Dec  3 12:53 .
  drwxrwxr-x  12 root    staff     408 Jan 27 14:38 ..
  -rw-r--r--   1 root    wheel   17987 Dec  3 11:58 COPYING
  -rw-r--r--   1 root    wheel   12388 Dec  3 11:58 INSTALL-BINARY
  -rw-r--r--   1 root    wheel  113534 Dec  3 11:58 README
  drwxr-xr-x  44 root    wheel    1496 Dec  3 12:53 bin
  drwxr-xr-x   9 _mysql  wheel     306 Jan 27 16:46 data
  drwxr-xr-x   4 root    wheel     136 Dec  3 12:53 docs
  drwxr-xr-x  47 root    wheel    1598 Dec  3 12:53 include
  drwxr-xr-x  12 root    wheel     408 Jan 27 14:38 lib
  drwxr-xr-x   4 root    wheel     136 Dec  3 12:53 man
  drwxr-xr-x  19 root    wheel     646 Jan 27 14:38 mysql-test
  drwxr-xr-x   3 root    wheel     102 Dec  3 12:53 scripts
  drwxr-xr-x  32 root    wheel    1088 Dec  3 12:53 share
  drwxr-xr-x  28 root    wheel     952 Dec  3 12:53 sql-bench
  drwxr-xr-x  16 root    wheel     544 Dec  3 12:53 support-files
  </code></pre>
  
  <p>I was trying to do <code>mysqld start</code> in the Terminal because it was the only thing giving me anything that seemed like meaningful error message output (see <a href="https://gist.github.com/799436" rel="nofollow">https://gist.github.com/799436</a>) but I'm told by folks in #mysql that that's not intended to be run directly (and if I try <code>sudo mysqld start</code> i get a message bitching me out for trying to run mysql as root).</p>
  
  <p>I seem to have <em>something</em> working now: <code>mysqld_safe &amp;</code> successfully gets a MySQL server running.  What still <em>doesn't</em> work is the "normal" method of starting up the server (the Startup Item or Preferences Pane)</p>
  
  <p>... leading someone in #mysql to tell me that apparently MySQL is fine, it's the startup item that's borked.</p>