vi editor and mysql
Hi there,
I am trying to use vi or even emacs from within mysql and neither one seems to work. I even checked my.cnf but did not see anything that could help me set up any editor. I know that by default mysql uses vi. My problem is that I would like to edit sql scripts inside mysql. As it is right now, I have to open another xterm and invoke emacs or vi to edit the scripts. I can execute them from mysql (source filename.sql). has anyone seen this problem? It is kicking my rear end hard. I'm using mysql version 4.1.1-alpha. Thaks in advance for any feedback. |
Quote:
|
I assume you're talking about the MySQL monitor you get by logging into a DB with the mysql command? This program doesn't use either vi or emacs. It uses the GNU readline command line editing library. The default keybindings are emacs-like, and configured in ~/.inputrc.
There are all sorts of other interfaces you can use. For example, if you want to connect to MySQL inside Emacs, use "M-x sql-mysql", which opens a comint buffer with the monitor. |
keefaz: I noticed the default editor after I attempted
to open an sql script from inside mysql: I saw the typical ~ in a vertical line from top to bottom. ==== solnul: no luck on your suggestion from inside mysql. Maybe there is something else going on here that I need to sort out. I managed to set the editor to emacs via my .bash_profile. However, I cannot get to the scripts I want. I know I am getting closer to resolving this puzzle. By the way, I do not have a file named .inputrc. Thanx for the feedback anyway :D |
I was curious and just do :
Code:
$ mysql -u admin -p |
Ok, I found the answer to my previous question: according to the book
'Beginning Databases with MySQL" by Neil Mathews and Richard Stones, chapter 5, page, 121, the default editor for MySQL is vi. However, the choice of an editor can be altered by passing it as an option when connecting to MySQL.. I'll try that next. |
Quote:
Code:
> nopager |
I think what you are after is to execute a shell command from within the mysql client.
Do that like this Code:
\! command Code:
\! vi slack.sql Code:
\. slack.sql I just noticed this is a very old thread that someone woke up - hope the answer is useful to someone! :) [/EDIT] |
The post was useful to me, Astrogeek! I usually have an extra screen window open just to run the occasional Bash command, you just saved me the trouble!
I once has someone reply to a four-year-old thread of mine with a useful answer that was able to help me, and other people will google the threads (I found this thread through google) so helpful answers to old questions are still relevant. |
All times are GMT -5. The time now is 12:50 PM. |