If you in a mysql command shell, you can use \e to launch whatever is
is defined in your $EDITOR (vim, i hope) and edit command - these are
then submitted as if type on the command line - sometimes it seems to
need an extra ; after you ZZ or :wq out of vim,
Alternatively (what I do) is run: mysql mydatabsae < mycommand.sql
from a command promp in another window -
i.e. if I had just saved an SQL file 'update.sql' and wanted to run it
against database 'davep'
my command would be 'mysql davep < update.sql' (take the quotes off ... )
on a mac, option n rotates beween terminal sessions very nicely - I do
the same thing in kde konsole with shift - arrow.
you could do a control-Z in vim to suspend oyu vim session, then fg to
bring vim back to the foreground ... but I find multiple console
sessions to be quicker ...
also ... if your workstation in secure, you can store your user id and
password in ~/.my.cnf - so you do not need the -p ...
davep@htpc:~/audio]$ cat ~/.my.cnf
#comments are #'s
#this is my password
# grant insert,select on cdr.* to 'r0ckyCDr'@'%' identified by
regardless of password ... you can use the same command environment
against a mysql database on a remote server by including a -h switch
mysql -h davesdb.kinaole.org davep < update.sql ... would run my
local sql file against database davep on my remote mysql server ...
and display outuput on my
Hope this helps.