The blog of freelance Designer & Developer, David Rice.
Okay, so say we have a database on our production/qa server that we want to test a coding change against.
What i’d usually do would be to:
svn commit
rake deploy
That’s not really good practice for working in a team, as we don’t want to check in cruft that someone might pick up…. or kill the production server!
Alternatives
- Mirroring data from our remote database to our local copy
- Connect directly to the remote database
Obviously i’m focusing on the second one for now, but i might take a look into the other at some point…. :)
Because of our secure setup, we can’t just connect directly to the database from outside. So….
Enter the tunnel
What we want to do is create a tunnel from our development machine to the remote database. Fire open the command line. I’m assuming you’re using mysql, and it’s on port 3306… just choose a random ephemeral port for the local port.
ssh dave@server.domain.com -L 10293:127.0.0.1:3306
What we’re doing is routing traffic via ssh, through port 10293 on our local machine to mysql on our remote server. If you were successful, a new shell should open to the remote server.
What’s the connection
We can connect to the database by any means we want now, I like to use cocoamysql for browsing, the following snippet from datebase.yml should help configure things,
production:
adapter: mysql
database: database_name
username: dave
password: xxxxxxx
host: server.domain.com
port: 10293
- email me@davidjrice.co.uk
- phone me on +44 7590 538 303
If you need help with the Design, Build, Management, Hosting or Support of your project do get in touch, I'd love to hear from you!
Recently
- 22 Apr » HTML5 Validator.nu ruby gem
- 28 Sep » ActiveMerchant Support for Realex
- 09 Sep » Getting Real with Realex
- 04 Sep » Back in Black
- 25 Nov » Rails Session Storage Cookie Vs Active Record
- 06 Jun » Get Exceptional
- 21 Apr » git and github ftw
- 19 Apr » Co-Working Belfast, Put Your Money Where Your Mouth Is
- 28 Mar » Co-working Belfast Plan
- 26 Feb » Do Not Buy an Apple AirPort Extreme Base Station, They Crash and Burn
- 13 Feb » Ssh, Presentation in Progress