Reputation: 18469
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?
Upvotes: 5
Views: 486
Reputation: 1279
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
Upvotes: 3
Reputation: 825
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
Upvotes: 10