TablePlus / DBngin

DB Engine
https://dbngin.com
1.04k stars 19 forks source link

Super strange Wordpress / Laravel Bug #127

Closed flatcapco closed 9 months ago

flatcapco commented 9 months ago

1, latest mysql image (ARM)

2, ver 6.9

  1. macOS 14.1.2

This is super weird, hopefully I can explain it clearly enough.

I mainly work with Laravel locally using DBEngin, Herd and TablePlus. It's always worked fine and been a total dream. Occassionally I work with WP with no issues - today I went to setup a local WP site.. made the table in mysql via TablePlus and went to wp-config to setup... real basic stuff.. table_name, localhost, root (user) no password.

However it says it cannot connect to the database.

I've confirmed tableplus has access to the table and I can read and write from it. All my other laravel projects also work. I'm perplexed! I've tried the simple stuff (restarting, clearing ports etc) but no joy.

The details are 100% correct.

I see this error with wp_debug turned on:

Warning: mysqli_real_connect(): (HY000/2002): No such file or directory in /wp-includes/class-wpdb.php on line 1987
No such file or directory

I'm not sure how to debug this further - however running "mysql" in the terminal doesn't say its running - is that normal? I'm sure it is because its certainly running!

Thank you

huyphams commented 9 months ago

Hi @flatcapco, I think you should use 127.0.0.1 instead of localhost. MySQL treats them differently.

huyphams commented 9 months ago

Warning: mysqli_real_connect(): (HY000/2002): No such file or directory in /wp-includes/class-wpdb.php on line 1987 No such file or directory

I'm not using PHP or Wordpress for a long time so I'm not sure but it seems like a Wordpress issue.

however running "mysql" in the terminal doesn't say its running

By default mysql command will look for socket connection not host, port I think.

flatcapco commented 9 months ago

Hi @flatcapco, I think you should use 127.0.0.1 instead of localhost. MySQL treats them differently.

Jeeeeez it literally was just that! I had been using valet and homebrew for mysql on my other laptop for years so I hadn't even clocked that. but it makes sense!

Thank you!!!