I'm using brew install mysql/brew install mariadb, and cannot find a way around the following error:

ERROR 2002 (HY000): Can't connect to local server through socket '/tmp/mysql.sock' (2)

Here are the key takeaways:

  • I have nothing running on ports 80, 8080, 3306, etc.
  • brew services list shows mysql/mariadb as stopped, regardless of how I start it up.
  • I've looked at permission settings using sudo chown -R mysql:mysql /opt/homebrew/var/mysql and sudo chown -R mysql:mysql /opt/homebrew/var/mysql.
  • There are no set flags when running ls -lO /opt/homebrew/var/mysql or ls -l0 /opt/homebrew/bin/mariadb
  • My default my.cnf file (as per Homebrew's installation) is tiny. It only contains a bind-address and a mysqlx-bind-address – both
  • I cannot find a /tmp/mysql.sock file anywhere, and know it's not enough to simply create one.
  • Installing MySQL through the DMG actually works, although I need to use MariaDB primarily and that is only available through brew.

I've looked at other questions here to try and find an answer. I've gone through solutions relating to macOS root passwords, access denied issues with brew installs, tried the solutions in an answer on ServerFault, and many of the other top answers on this issue over at ServerFault.

What else could I look into to fix this? Could there be a more complex permissions issue, and if so, how do I go about diagnosing it? I'll of course add further details here if requested, so please let me know what you'd want to see.


After looking at my .err logs, it appears as though I have some data corruption in the ibdata1 table:

2024-04-10T22:19:41.436840Z 1 [ERROR] [MY-012224] [InnoDB] Tablespace flags are invalid in datafile: ./ibdata1, Space ID:0, Flags: 21. Please refer to http://dev.mysql.com/doc/refman/8.3/en/innodb-troubleshooting-datadict.html for how to resolve the issue.
2024-04-10T22:19:41.436882Z 1 [ERROR] [MY-012237] [InnoDB] Corrupted page [page id: space=0, page number=0] of datafile './ibdata1' could not be found in the doublewrite buffer.
2024-04-10T22:19:41.436891Z 1 [ERROR] [MY-012930] [InnoDB] Plugin initialization aborted with error Data structure corruption.
2024-04-10T22:19:41.438452Z 1 [ERROR] [MY-011013] [Server] Failed to initialize DD Storage Engine.
2024-04-10T22:19:41.438575Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
2024-04-10T22:19:41.438583Z 0 [ERROR] [MY-010119] [Server] Aborting

To try and get round this, I've looked to use innodb_force_recovery = 1 in my.cnf, and went up to 6. mariadb-safe --skip-grant-tables hasn't fixed anything either.

Running brew services start -v mariadb gives me the following:

/bin/launchctl enable gui/501/homebrew.mxcl.mariadb
/bin/launchctl bootstrap gui/501 /Users/<user>/Library/LaunchAgents/homebrew.mxcl.mariadb.plist
Bootstrap failed: 5: Input/output error
Try re-running the command as root for richer errors.
Error: Failure while executing; `/bin/launchctl bootstrap gui/501 /Users/<user>/Library/LaunchAgents/homebrew.mxcl.mariadb.plist` exited with 5.

However, I don't have a storage issue, nor does my hard drive seem to have any issues.


I had already checked this, but wanted to recheck permissions and for flags on /opt/homebrew/var/mysql and /opt/homebrew/bin/mariadb as detailed in the takeaways list. Here's what I've done:

  • Ran dscl . -list /Groups and confirmed there is the _mysql group.
  • Ran id mysql and confirmed it's a member of the _mysql group (uid=74(_mysql) gid=74(_mysql))
  • Ran ls -lO /opt/homebrew/bin/mariadb to check the permissions for mysql:mysql and username:admin (755 lrwxr-xr-x)
  • Ran ls -lO /opt/homebrew/var/mysql to check the permissions for mysql:mysql and username:admin (700 drwx------)

I've also reconfirmed solutions I'd already come across and discarded:

  • Removing mysqlx-bind-address = from my.cnf (and the various other solutions) based on this question.
  • What actually happens or gets logged to the respective log files when you try to start your MySQL or MariaDB services? Can you share the relevant outputs from said logs?
    – esqew
    Commented Apr 10 at 22:22
  • @esqew There are no MySQL log files in /opt/homebrew/var/log, only those related to PHP.
    – It's WPTom
    Commented Apr 10 at 22:25
  • Not sure why you think they'd only be in /opt/homebrew/var/log when they could be in a few different places (per this Server Fault thread). For instance, a fresh Homebrew-based install of mysql on my own Mac just now created logfiles in the directory /opt/homebrew/var/mysql. In my case there was a file in that directory titled with the hostname of my machine followed by .err, containing logs for the MySQL service I started just beforehand. I would assume there's something similar on your side.
    – esqew
    Commented Apr 10 at 22:32
  • The lock file is probably installed somewhere else. Would recommend just connecting to instead of localhost to ensure you're going over the TCP stack instead of the unix socket.
    – Evert
    Commented Apr 10 at 22:35
  • @esqew I actually ran find / -name mysql.log and came up with nothing, although I will do some further digging to look for .err files.
    – It's WPTom
    Commented Apr 10 at 22:37

1 Answer 1


Drop everything. start using docker.

Its isolated, as fast as local-native.

docker link :

//mysql installation cmds. ( for v8)
$ docker pull mysql 
$ docker run --name mysql8-docker-local -e MYSQL_ROOT_PASSWORD=your_password123 -p 3306:3306 -d mysql
  • 2
    This doesn't really answer, it just move the problem somewhere to make it different to manage
    – Elikill58
    Commented Apr 12 at 6:05
  • 1
    I appreciate the input, although I use Laravel Valet so need this locally. Docker is something I use though, and I don't have a DB problem with it.
    – It's WPTom
    Commented Apr 12 at 10:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.