Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am on a mac os 10 and I want to connect a local copy of a drupal site to a remote mysql data. I can access the server using ssh as root, the database is setup and running, how can I connect to the database on the remote server using a ssh tunnel or similar? I don't want to have a local copy of the database running for development.

share|improve this question
add comment

1 Answer

ssh using this command

ssh remotehost -L3306:localhost:3306

and leave that open. You should then be able to connect to the remote mysql server as if it were running on the local machine. The -L parameter on ssh listens on that port on the local machine and forwards all traffic to it across the ssh connction to the host and port specified at the other end.

share|improve this answer
    
something is still wrong. I entered ssh root@[remote ip] -L 3306:localhost:3306 and was prompted for a password, I entered the password and gained access to my server as expected. But when I reload the drupal site it still says: "Failed to connect to your MySQL database server. MySQL reports the following message: No such file or directory." This is what the drupal connection string looks like mysql://dbuser:dbpass@localhost/database_name –  kristian nissen Feb 15 '11 at 12:35
    
did you get a port in use error or do you have mysql on the local machine? you may have to specify a different port to listen on and connect to. –  Andee Feb 15 '11 at 21:44
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.