Showing posts with label MySQL. Show all posts
Showing posts with label MySQL. Show all posts

Wednesday, March 2, 2011

Connect to MySQL via SSH Tunnel

I have set up a MySQL server and want to connect to it from different machines.  However, I do not want to open it up to the public.  To secure my connection, I will not allow external connections to the MySQL server.  I will simply set up a SSH tunnel and connect to it that way.  My local MySQL commands are forwarded to the remote host.

Assumptions:

  1. You can SSH into the remote host.
  2. If you are like me, you are not running a MySQL on your local host.

Setting up the SSH tunnel:
  1. ssh -f -L 3306:localhost:3306 user@host -N
  2. Enter password:
Connect to MySQL
  1. mysql -h 127.0.0.1 -u user -p
  2. Enter password:
You should be see the MySQL prompt.
mysql>

Friday, August 20, 2010

Installing the MySQL RubyGem on Ubuntu

I have successfully installed the MySQL driver for Ruby on Windows and Mac OS X but I had not installed it on Ubuntu until today.

I am assuming that you have already installed the MySQL server.  I am using MySQL 5.1.
$ sudo apt-get install mysql-server

Install the MySQL database client library.  I am not certain of this but I believe that the number '15' in 'libmysqlclient15-dev' indicates the version.  This is apparently the most current one and the default version on Ubuntu 10.4 as of today.
$ sudo apt-get install libmysqlclient15-dev

Install RubyGems if you have not done so already.  I am using Ruby 1.9.1.
 $ sudo apt-get install rubygems1.9

If everything was successfuly, then you should be able to use the mysql RubyGem in  your Ruby scripts.