0

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

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.

4
  • It doesn't seem to do what I expect, certainly, if I try to start with a 'select something', tehre is no output. – j4nd3r53n Apr 30 '20 at 13:58
  • Then maybe this is your answer? serverfault.com/questions/436474/… – tombom Apr 30 '20 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 Apr 30 '20 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 Apr 30 '20 at 14:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.