Warning the user/local/mysql/data directory is not owned by the mysql user

42,146

Solution 1

If you can't start mysql service in snow leopard, and in the panel prefs appears 'warning the user/local/mysql/data directory is not owned by the mysql user', you have to:

  • sudo chown -RL root:mysql /usr/local/mysql
  • sudo chown -RL mysql:mysql /usr/local/mysql/data
  • sudo /usr/local/mysql/support-files/mysql.server start

Solution 2

This work for me in El Capitan & Sierra

sudo chown -R _mysql:wheel /usr/local/mysql/data

That's it.


Update: to fix auto start

I found it more useful if you fix Auto Starting too:

sudo nano /Library/LaunchDaemons/com.mysql.mysql.plist

And paste in:

<!--?xml version="1.0" encoding="UTF-8"?-->
<plist version="1.0">
  <dict>
    <key>KeepAlive</key>
    <true />
    <key>Label</key>
    <string>com.mysql.mysqld</string>
    <key>ProgramArguments</key>
    <array>
      <string>/usr/local/mysql/bin/mysqld_safe</string>
      <string>--user=mysql</string>
    </array>        
  </dict>
</plist>

Save it and then:

sudo chown root:wheel /Library/LaunchDaemons/com.mysql.mysql.plist
sudo chmod 644 /Library/LaunchDaemons/com.mysql.mysql.plist
sudo launchctl load -w /Library/LaunchDaemons/com.mysql.mysql.plist

Then it will load on a restart.

Reference: https://coolestguidesontheplanet.com/get-apache-mysql-php-phpmyadmin-working-osx-10-10-yosemite/

Share:
42,146

Related videos on Youtube

Kronos
Author by

Kronos

Updated on November 08, 2020

Comments

  • Kronos
    Kronos over 3 years

    I can't start the mysql service in Snow Leopard, and in the panel prefs appears the message,

    warning the user/local/mysql/data directory is not owned by the mysql user

    How can I fix this?

    • Scott
      Scott over 11 years
      Thank you. Whether it's a question or not, it solved the issue for me.
    • joemar.ct
      joemar.ct over 11 years
      I had the same problem in Mountain Lion, this worked for me.
    • Henley
      Henley over 11 years
      Who cares if it's not a question. It worked. +10000000 points.
    • callum
      callum over 11 years
      This solved my problem, but I think it's a disgrace that @Kronos tried to use SO to be helpful in the wrong format. An absolute disgrace. This blatant disregard for the Q&A format could permanently destabilise this community. To the administrators who closed this thread: keep fighting the good fight. I believe in you.
    • Chris Craft
      Chris Craft almost 11 years
      Well Jeff Atwood the creator of the site says "It’s OK to Ask and Answer Your Own Questions", blog.stackoverflow.com/2011/07/… and searches on Google are pretty much coming here for the answer as well.
    • Josh
      Josh over 10 years
      +1 as it worked for me. I do agree with both Chris and callum at the same time. As the article that Chris pointed out, it IS okay to answer your own QUESTION. The point is here there is no question to answer, just the answer. It would've been better if he would've asked the question, then answered it.
    • Julia Zhao
      Julia Zhao almost 10 years
      I had the same problem in Mavericks. The suggested commands worked for me. Thanks!
    • monal86
      monal86 almost 10 years
      Thanks so much! I was struggling to fix my issue and this was a life saver!!
    • Nirmal Ram
      Nirmal Ram over 9 years
      Thanks, You saved my day.
  • Shog9
    Shog9 over 9 years
    Apparently this is still biting people - so I've moved your answer into an... Answer. Hope you don't mind...
  • John Ruddell
    John Ruddell over 8 years
    for others coming to this now.. this works in El Capitan as well
  • zeros-and-ones
    zeros-and-ones over 8 years
    Why hasn't this been checked as the correct answer?
  • albertski
    albertski over 8 years
    I couldn't get mysql to start after upgrading to El Capitan. This worked for me.
  • Joshua Pinter
    Joshua Pinter about 8 years
    @zeros-ones Because the OP originally answered it in the question itself and an admin (@Shog9) moved it to an answer. The OP needs to mark it as the correct answer now.
  • craigmiller160
    craigmiller160 about 8 years
    is wheel your own user name, or something special? If that could be clarified that would be great
  • Ihab Shoully
    Ihab Shoully about 8 years
    Wheel is (Unix term) refers to a user account with a wheel bit.
  • saq7
    saq7 over 7 years
    This fixed it in Sierra, as well.
  • lewis
    lewis over 7 years
    This randomly started happening to me on Sierra (weeks after updating). Fix still works
  • Dave Nottage
    Dave Nottage almost 7 years
    Seriously.. does this happen after every macOS update??
  • Feras
    Feras about 6 years
    it's working, You save my time on macOS Hight Sierra, Yes @DaveNottage this happened after Sierra update
  • Joshua Pinter
    Joshua Pinter over 5 years
    Tried this on macOS Mojave and no joy. I get ERROR! The server quit without updating PID file when trying mysql.server start
  • Nick Lee
    Nick Lee about 5 years
    What is a 'wheel bit' ?
  • Ihab Shoully
    Ihab Shoully about 5 years
    'Wheel bit' is a system setting that provides additional special system privileges that empower a user to execute restricted commands that ordinary user accounts cannot access.
  • Ben
    Ben over 4 years
    Tried this on MacOS Catalina - I got an error message on the last command (sorry, I didn't save the message) but the server seems to be up and running for me.