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.

4
  • 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. Commented Jan 23, 2019 at 21:12
  • Possible duplicate of Laravel MySql DB Connection with SSH Commented Jan 23, 2019 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. Commented Jan 23, 2019 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. Commented Jan 23, 2019 at 21:47

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.