Is it possible, in MySQL, to run a 'login profile' similar to the bash/ksh profile, when connecting with the mysql client? That is to say, something similar to mysql -e 'select * from a_table'
, but where mysql doesn't terminate after executing the statement?
1 Answer 1
The mysql client has the init-command
option, which does what you want, I think.
From the manual:
--init-command=str
SQL statement to execute after connecting to the server. If auto-reconnect is enabled, the statement is executed again after reconnection occurs.
-
It doesn't seem to do what I expect, certainly, if I try to start with a 'select something', tehre is no output.j4nd3r53n– j4nd3r53n2020年04月30日 13:58:13 +00:00Commented Apr 30, 2020 at 13:58
-
Then maybe this is your answer? serverfault.com/questions/436474/…tombom– tombom2020年04月30日 14:07:17 +00:00Commented Apr 30, 2020 at 14:07
-
no, I was hoping to display the output of a select, really. It isn't too important, just something that I thought might be useful.j4nd3r53n– j4nd3r53n2020年04月30日 14:11:55 +00:00Commented Apr 30, 2020 at 14:11
-
You can achieve that with cronfy's answer. I don't think there's another way (except adjusting the sources and recompiling).tombom– tombom2020年04月30日 14:13:51 +00:00Commented Apr 30, 2020 at 14:13