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?

asked Apr 30, 2020 at 10:35

1 Answer 1

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.

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

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.