Cloud, DevOps, MySQL

Connecting to MySQL running inside Vagrant

Vagrant is pretty neat! It helps dev-teams or even stand-alone developers to easily setup their machines by making their development environments “configurable, reproducible and portable“. All the details about your dev setup is specified in a file called Vagrantfile.

This is really handy if you use a Windows/Mac machine for your IDE but want to have a Linux based “runtime-box” consistent with your Cloud/VPS environment to deploy and test your app.

But this post is not about how to setup and use Vagrant itself, the Vagrant docs does a superb job to help you get started. This post is rather about a simple method that you can use to connect to a MySQL server running inside your Vagrant box.

Let’s say you are running a MySQL server on the Guest (e.g. Ubuntu) inside your Vagrant box, how do you connect to it from your Host (e.g. Windows)?

The first thing that came to my mind is the port forwarding functionality provided by Vagrant it self, where you can perhaps say 3366 (Win/Host) -> 3306 (Ubuntu/guest)

But there is a much easier way to do this since Vagrant by default allows the host to connect to the guest through SSH you can use MySQL workbench installed on your host (Windows/Mac machine) to connect to MySQL running inside you Vagrant/Ubuntu box as shown below.


Note: The connection only uses the default SSH port forwarding (2222 -> 22) and MySQL port remains the same.

Databases, NoSQL

Introduction to NoSQL by Martin Fowler

Martin Fowler has this great ability of explaining potentially complicated stuff in an easy to understand manner. Moreover he is the ultimate pragmatist. He provides real life examples that helps explain the concepts he talks about and does not get emotionally attached to any technology 🙂

This is an excellent talk Introducing the emergence of NoSQL and the rationale behind the use of products such as MongoDB, Cassandra and Neo4J. One of the key points mentioned is, although NoSQL databases will play a major role as a persistence technology it will most likely be used in combination with traditional Relational databases in many (enterprise?) scenarios. This is known as Polyglot Persistence.

Watch this brilliant talk to get a better understanding of the basic concepts behind NoSQL DBs, the rationale for using them in software development and the trade-offs of using them compared to RDBMSs.