Enable remote access to PostgreSQL database server

Often it’s good to access databases directly from desktop. Or maybe you want your database server to be different from your application server. Whatever your reason is, the requirement is enabling remote access to your PostgreSQL database server.

It’s very simple procedure. First locate your DB configuration files. Commonly they lives under /etc/postgresql/9.3/main/ directory. Be sure to replace ‘9.3’ with your own database version.

Now open up the file pg_hba.conf with your favorite text editor and paste the bellow code at the end of the file:

host all all md5

Okay, Attention first: this will open up your server to the whole world. You can alter the above code to meet your specific need. Like replace the first ‘all’ with your single database name or replace second ‘all’ with your database user name. Also you can limit the network at the 4th column. Just tweak it as you need. It’ll be more secure.

Next open up postgresql.conf and change the value of listen_addresses = ‘localhost’ to something like this:

listen_addresses = '*'

Now PostgreSQL will listen to the whole network.

Simply restart your server:

sudo service postgresql restart

You should be good to go by now!

Test your setup:

psql -h server.ip -U postgres

Basic Database Design tips for Relational Database

Database is one of the biggest bottleneck of a Web App performance now a days.

A poorly designed database can make your life hell as a dev while optimizing an app.

On the other hand, A good design can speedup your development process along with the performance of the app.

I’m also learning the basics of database design, in that process here listing some basic tips.

  • Actually draw the design on a big paper.
  • List down all columns you may need.
  • If you have confusion about a column (you may need or not), list it down.
  • Now break those into multiple tables.
  • Don’t keep any irrelevant data on a table, better use additional table.
  • As it’s a relational database design, check your relations properly.
  • For MySQL advanced engines like InnoDB supports relations inside database end, use them, This way you’ll have to write less code and less query.
  • Now run your design through Normalization Form (NF) rules.

As I always say, Database design is almost 30% of whole development process for me. With a solid design I can write code very confidently.
So think before the design, don’t be upset later.

If you have any other point, please let me know via comment. I’m eagerly waiting to learn something new.

Goodbye, welcome

Yesterday got a brand new called
I was searching for a own name domain from a long back. Specially after getting my MacMini. People started irritating me as i derived from iOS of ibabar. :P
Unfortunately for Babar The Elephant, it was very hard to get domains for me!

Day before yesterday, even thought of the domain name and posted it on facebook!

Someone suggested me, liked it.
Whoished from terminal, it said it’s free yet!

Went to NameCheap, they says it’s not free! Damn.

Later yesterday morning, went to, and they said it’s free! Only then I noticed NameCheap actually doesn’t sell .im domain, they showed me result for!

And yeah, I bought it from and it’s live now.

So, site is from now on

Farewell, thanks for your service mate. :)

And warm welcome to

Determine MySQL Database Size

Simple tips.
Sometimes we want a summery of size consumed by our databases in MySQL engine.
Here is a simple SQL snippet for that.
This will list all databases that current MySQL user can access and list their size in megabyte.

Tested it on MySQL, on other databases, may also work.
Hope it helps you.

Why my WP_AJAX returning Zero (0) with my response?

Wrote a start up post on WP_Ajax last time.

Some of you may still surprise, why the callback function for WP_Ajax returning an additional 0 or something else which is very unwanted at the end of your own response.

It’s annoying and at first you may get caught confused.

Actually the thing happened for a little different nature of WP_Ajax.

We usually use a return to end a function, but for callback function of WP_Ajax you are doing this wrong.
You’ll have to use die() or exit at the end of your code instead of return for a clean output.

Only this way you can have a clean output without any 0 or something else.