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?
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?
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
init_connect
is not executed for root
. This is a strong reason for having separate user(s) for application code. –
Gustation 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
© 2022 - 2024 — McMap. All rights reserved.
shell
andlinux
tagged here. There is nosession
with mysql like PHP. It has connections. You can mimic some behavior or availability of info. But this question is all over the place. Rein it in bro. Enable someone to help you here by clearly defining what you want, not 5 word blurbs. Otherwise people read the vaguaries and gladly move on to other questions that are viable. – Euterpe