MacPort MySQL “Can’t find file: ‘./mysql/host.frm’” Error

I recently set up a new Mac OS X Snow Leopard laptop for software development purposes. After going through my usual MacPorts installation and installed MySQL using the following steps

  1. sudo install mysql5-server
  2. sudo cp /opt/local/var/macports/software/mysql5/5.1.44_0/opt/local/share/mysql5/mysql/my-medium.cnf /opt/local/etc/mysql5/my.cnf
  3. sudo -u mysql mysql_install_db5
  4. sudo launchctl load -w /Library/LaunchDaemons/org.macports.mysql5.plist

A few days past, and one day I notice that launchctl was loading the script, but `nmap localhost` did not show the the process listening on port 3306 as expected. I looked at the log file:

sudo tail -f /opt/local/var/db/mysql5/preston.local.err

..and noticed it was terminating with the following errors:

100331 12:05:30 [ERROR] /opt/local/libexec/mysqld: Can’t find file: ‘./mysql/host.frm’ (errno: 13)
100331 12:05:30 [ERROR] Fatal error: Can’t open and lock privilege tables: Can’t find file: ‘./mysql/host.frm’ (errno: 13)

100331 12:05:30 [ERROR] /opt/local/libexec/mysqld: Can’t find file: ‘./mysql/host.frm’ (errno: 13)100331 12:05:30 [ERROR] Fatal error: Can’t open and lock privilege tables: Can’t find file: ‘./mysql/host.frm’ (errno: 13)

After a considerable amount of grief I evertually discovered that the contents of /opt/local/var/db/mysql5/ need to be owned by the appropriate mysql user (in my case “_mysql”), but some files were being owned by the “root” user. After correcting all file ownership and restarting the service…

  1. sudo chown -R _mysql /opt/local/var/db/mysql5/
  2. sudo launchctl unload -w /Library/LaunchDaemons/org.macports.mysql5.plist
  3. sudo launchctl load -w /Library/LaunchDaemons/org.macports.mysql5.plist

Everything now seems to work fine again. Hope this helps!

Comments

9 responses to “MacPort MySQL “Can’t find file: ‘./mysql/host.frm’” Error”

  1. David Liontooth Avatar
    David Liontooth

    Thanks! I ran into the same problem and appreciate the solution.

    Cheers,
    Dave

  2. mitjak Avatar

    Much appreciated. That worked like a charm after getting the same error message.

  3. Brian Wisti Avatar

    I was wrestling with the same issue and Google led me here. Thanks for doing the hard work and sharing the fruits of your labor!

  4. admin Avatar
    admin

    You’re very welcome!

  5. John Avatar

    Setting up mysql using macports and then this?!! Thanks for the quick fix!

  6. admin Avatar
    admin

    It was originally set up using MacPorts, yes.

  7. Matt Avatar

    Brand new install of Snow Leopard, then XCode, then MacPorts. Same exact issue. Thank you!

  8. David Avatar
    David

    This was a big help, thank you.

  9. Malcolm Avatar
    Malcolm

    Thanks for your help. Been trying to solve this problem for awhile now.

Leave a Reply

Your email address will not be published. Required fields are marked *