OS X Articles

May 22, 2007 – 11:20am How to set up an SSH tunnel to a remote MySQL server

If you have SSH access to your hosting account and want to use a GUI to view your MySQL databases on that remote server, you can set up an SSH tunnel and use a program like CocoaMySQL to manage your remote database. When it works, it can be really userful and is a nice break from a web-based solution like phpMyAdmin.

First, make sure you can login to your host through SSH. After you are certain it works, you can open up a tunnel like this:

ssh -L 3307:[ip address of host]:3306 [username]@[ip address of host] [-p ssh portnumber]

This opens up a tunnel from your local port 3307 to port 3306 on the remote host. Here is the example again with dummy data, using a non-standard ssh port 8022:

ssh -L 3307:192.168.2.1:3306 user@192.168.2.1 -p8022

Once that connection is set up, fire up your MySQL GUI and connect to your local IP address (127.0.0.1) and specify the new port you set up in your tunnel (3307). Here is how it looks in CocoaMySQL.

CocoaMySQL Connection

Posted in  OS X Web Development   |     |  No Comments »   |  delicious  Digg

May 15, 2007 – 3:17pm OS X Shortcuts, Terminal, Emacs

There are a lot of key commands that exist in OS X that are based on the standard Emacs keys (which admittedly I know nothing about). In bash, tcsh, and other unix environments you will find a lot of these work, and sometimes they will even work in Cocoa text editing tools as well.

These are supported by Mail, TextEdit, and other a lot of other Cocoa apps:

  • ctrl-a Move to the beginning of the line
  • ctrl-e Move to the end of the line
  • ctrl-f Move forward one character
  • ctrl-b Move back one character
  • ctrl-n Move to next line
  • ctrl-p Move to previous line
  • ctrl-d Delete character to right of cursor
  • ctrl-h Delete character to left of cursor
  • ctrl-k Kill from cursor to end of line (kill remembers what was deleted)
  • ctrl-y Yank back what was killed, at the cursor
  • (these two use their own clipboard, not the cmd-x/c/v one)
  • ctrl-o Insert line after cursor
  • ctrl-t Transpose characters on either side of cursor
  • ctrl-l Center the display on cursor
  • ctrl-v Scroll the display one screen forward

Here’s a pretty complete list of existing Mac key bindings for editing:

<http://www.hcs.harvard.edu/~jrus/Site/system-bindings.html>

Here’s how to add even more bindings to Cocoa (by adding them to

~/Library/KeyBindings/DefaultKeyBinding.dict):

<http://www.hcs.harvard.edu/~jrus/Site/Cocoa%20Text%20System.html>

And more on Emacs productivity and the Mac:

<http://bc.tech.coop/blog/060620.html>

Posted in  OS X   |  No Comments »   |  delicious  Digg