1

I created an SSH port tunnel:

ssh -f -N -L 3306:localhost:3306 myuser@thedomain.com

On that same machine where I created the port tunnel, I can connect to mysql by doing:

mysql -h 127.0.0.1 -u user -p

On that same machine, if I try to make Wordpress connect to MySQL, none of the following work:

/** MySQL hostname - NONE of these work */
define('DB_HOST', 'localhost');
//define('DB_HOST', 'localhost:3306');
//define('DB_HOST', '127.0.0.1');
//define('DB_HOST', '127.0.0.1:3306');

Why can't WordPress connect?

I tried restarting httpd but that didn't fix the issue.

Don Rhummy
  • 24,730
  • 42
  • 175
  • 330
  • because mysql specialcases `localhost` and turns it into a local unix-domain socket connection. That means it won't be a TCP connection at all, and comlpetely invisible to your port forwarding. – Marc B Sep 19 '16 at 21:09
  • @MarcB Other people have successfully set up WordPress with SSH tunneling for the DB, so i know it's possible. Can you tell me what I could do to make it visible as normal? – Don Rhummy Sep 19 '16 at 21:10
  • 2
    your 127.0.0.1 SHOULD have worked. http://stackoverflow.com/questions/11743654/force-wordpress-to-connect-to-database-over-tcp – Marc B Sep 19 '16 at 21:12
  • 1
    When you say it doesn't work, what specifically happens? Do you get any error messages? Timeouts? – Kenster Sep 19 '16 at 22:14
  • If this is for establishing a secure connection, then it might be worth checking MySQL's docs about establishing secure connections. If it isn't, ignore this comment and I'll remove it later. – N.B. Sep 19 '16 at 22:41
  • @Kenster All I see is WordPress says it cannot conect to that database and that it might mean it's down. – Don Rhummy Sep 19 '16 at 23:06

0 Answers0