2

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 127.0.0.1.
  • 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.

UPDATE 10-Apr

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.

UPDATE 11-Apr

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 = 127.0.0.1 from my.cnf (and the various other solutions) based on this question.
It's WPTom
  • 29
  • 4

2 Answers2

0

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
0

Have you tried running mysql.server start?

I was having the same issue, and after three days of debugging, came across this post. They recommended running mysql.server start, and I don't know why, but since then, mariadb has been starting up with brew services as expected after rebooting.

Krislunde
  • 11
  • 2