Cannot connect to remote MySQL database

Bug Summary

I’m trying to connect to a remote MySQL database from my WordPress plugin. My code works on any other WordPress installation, but not with Local on Windows 10.

Steps to reproduce

Here is the minimal code to demonstrate this issue. You just need to change the arguments.

<?php $mysqli = mysqli_init(); if ( $mysqli ) { if ( ! $mysqli->real_connect( '1.2.3.4', 'username', 'password', 'database' ) ) { echo 'Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error(); } else { echo 'Connected...' . $mysqli->host_info . "\n"; } } ?>

Environment Info

Local on Windows 10, using Apache, PHP, a remote MySQL database. Same issue with Nginx. Using Local version 6.5.2.

  • What Operating System are you using?
  • What versions of site software (Nginx, Apache, PHP, MySQL) is used?
  • What version of Local is installed?

Supporting info

Please provide your Local Log. See this Community Forum post for instructions on how to do so:

Include any screenshots or video recordings of the issue to help others reproduce.

Sorry, there are no log entries related to this issue. The connection just dies.

Following. Really curious to see what answers @austinwendt or others might come up with. I’m having a similar issue, except mine is MySQL won’t launch in the site shell at all. I’m not sure what you are using, but mine is set up to use GitBash on Windows 11. Typing mysql -u root -p doesn’t do anything except carriage return and show a blinking cursor.

If need be, I’ll create my own issue. But, it looks like this might be related. Could it be as simple as a recent LocalWP update broke something and needs brought to their attention so the awesome devs can get it fixed?

P.S: I only posted this comment because the note at the bottom indicates the post is still open and will close in a month:

Hey @CodeSlayer2010!

So was this something that was working prior to the update? Or this was your first time attempting it?

Could you share a Local Log with us?

Yes, I think mysql worked prior to the update. This screenshot is static you can’t see the “blinking”, but there it is – just a cursor. It never does anything else. I’ve waited 5 minutes one time to see if it was just slow - nope. It just doesn’t do anything.

Also, not sure if it helps, but while most WP-CLI commands work fine, NONE of the wp db commands work. When I type wp db tables, for instance, I always get “Error establishing a database connection”. Not sure if the db issue and the mysql issue could have the same root cause?

My local WP sites all work, so I’d say the database itself appears to be working.

Logs zip is attached.


local-logs.zip (467.3 KB)

Any ideas @Nick-B ?

Hey @CodeSlayer2010! Sorry I was reviewing this with the team but we weren’t able to pinpoint anything yet. Have you tried downgrading yet to see if functionality returns?

This topic was automatically closed after 730 days. New replies are no longer allowed.