Q:

How to automatically call a query for every new connection in MySQL?

Is it possible to set or initialize a query in MySQL for every new connection ?
Whenever a connection is created, it will call a procedure or a select query automatically ?
Any script or config option for this?

A:

You may want to check init_connect variable: 

A string to be executed by the server for each client that connects.
  The string consists of one or more SQL statements, separated by
  semicolon characters. For example, each client session begins by
  default with autocommit mode enabled.

http://dev.mysql.com/doc/refman/5.5/en/server-system-variables.html#sysvar_init_connect

A:

If you have not only mysql-client tool, but additional any application layer, there is more jedi-style :) You can create simple decorator for your connector's class that will execute some queries when instance created (in constructor)/connect method invoked.
Hope it helps

