0

I have a local Laravel instance that's set up and running on localhost. I want to connect from that instance to a remote MySQL DB to pull data out of the DB and migrate it to a new DB that's been created locally.

The problem though is that the remote DB is only accessible via one web server, and as such, I have to SSH tunnel through the web server to get to the DB.

I was able to successfully establish this sort of SSH tunnel connection to the remote MySQL DB via MySQL Workbench, but it required all sorts of SSH credentials for the web server in addition to an SSH key file.

Is it possible to set up this sort of thing in Laravel so that I can SSH tunnel from my local Laravel instance to the remote MySQL DB? Thank you.

HartleySan
  • 7,404
  • 14
  • 66
  • 119
  • Why don't you just create a database dump from the remote server and restore into the local mysql server instead of trying to actually connect remotely from your local instance. – Devon Bessemer Jan 23 '19 at 21:12
  • Possible duplicate of [Laravel MySql DB Connection with SSH](https://stackoverflow.com/questions/25495364/laravel-mysql-db-connection-with-ssh) – Raymond Nijland Jan 23 '19 at 21:42
  • Devon, yeah, I thought about creating a local copy of the remote DB, and that's certainly a possibility, but the ability to dynamically and automatically run a migration would be very beneficial. – HartleySan Jan 23 '19 at 21:46
  • Raymond, I saw that post before, but I couldn't understand what the accepted answer meant in the "Second, establish a tunnel:" part. Does that ssh command have to be put somewhere in the Laravel instance to connect to the remote DB? If I could understand that part then maybe that answer will answer my question as well. Thanks. – HartleySan Jan 23 '19 at 21:47

0 Answers0