LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

Reply
 
Search this Thread
Old 06-05-2004, 08:29 PM   #1
slackerboy
Member
 
Registered: Jul 2002
Location: USA
Distribution: Slackware, Red Hat, Ubuntu
Posts: 58

Rep: Reputation: 15
Angry 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.
 
Old 06-06-2004, 12:08 PM   #2
keefaz
Senior Member
 
Registered: Mar 2004
Distribution: Slackware
Posts: 4,290

Rep: Reputation: 69
Quote:
I know that by default mysql uses vi.
Where did you learn that ?
 
Old 06-07-2004, 01:33 AM   #3
solnul
Member
 
Registered: Jan 2003
Distribution: Slackware
Posts: 82

Rep: Reputation: 15
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.
 
Old 06-09-2004, 07:07 PM   #4
slackerboy
Member
 
Registered: Jul 2002
Location: USA
Distribution: Slackware, Red Hat, Ubuntu
Posts: 58

Original Poster
Rep: Reputation: 15
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
 
Old 06-10-2004, 03:53 PM   #5
keefaz
Senior Member
 
Registered: Mar 2004
Distribution: Slackware
Posts: 4,290

Rep: Reputation: 69
I was curious and just do :
Code:
$ mysql -u admin -p
mysql> help
...
pager   (\P)    Set PAGER [to_pager]. Print the query results via PAGER.
...
mysql> pager vi
mysql>
...and all result of query return in a sort of vi editor, but I didn't find a good way to exit this mode after
 
Old 07-12-2004, 09:01 PM   #6
slackerboy
Member
 
Registered: Jul 2002
Location: USA
Distribution: Slackware, Red Hat, Ubuntu
Posts: 58

Original Poster
Rep: Reputation: 15
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.
 
Old 12-18-2012, 10:18 AM   #7
dotancohen
Member
 
Registered: Dec 2004
Location: Haifa
Distribution: Fedora Core 4, Kubuntu
Posts: 235

Rep: Reputation: 32
Quote:
Originally Posted by keefaz View Post
I was curious and just do :
Code:
$ mysql -u admin -p
mysql> help
...
pager   (\P)    Set PAGER [to_pager]. Print the query results via PAGER.
...
mysql> pager vi
mysql>
...and all result of query return in a sort of vi editor, but I didn't find a good way to exit this mode after
Use the 'nopager' command:
Code:
> nopager
The pager is meant to filter the output from mysqld, not mean to edit the input. To edit the input, use the '\e' command. It leaves a lot to be desired, though, as you can only edit the previous command, and the command is not shown in the CLI afterward.
 
Old 12-18-2012, 02:48 PM   #8
astrogeek
Senior Member
 
Registered: Oct 2008
Distribution: Slackware: 12.1, 13.1, 14.1, 64-14.1, -current, FreeBSD-10
Posts: 1,637

Rep: Reputation: 567Reputation: 567Reputation: 567Reputation: 567Reputation: 567Reputation: 567
I think what you are after is to execute a shell command from within the mysql client.

Do that like this

Code:
\! command
So to edit the file slack.sql you would do this:

Code:
\! vi slack.sql
Then, of course, to execute the file:

Code:
\. slack.sql
[EDIT]
I just noticed this is a very old thread that someone woke up - hope the answer is useful to someone!
[/EDIT]

Last edited by astrogeek; 12-18-2012 at 05:08 PM.
 
Old 12-19-2012, 05:34 AM   #9
dotancohen
Member
 
Registered: Dec 2004
Location: Haifa
Distribution: Fedora Core 4, Kubuntu
Posts: 235

Rep: Reputation: 32
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock welery Linux - Software 19 03-06-2014 07:19 AM
ERROR 2002: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql. NoviceW Linux - Networking 16 12-10-2012 02:34 AM
ERROR 2002: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql. suziecorbett Linux - Software 8 10-09-2008 01:52 AM
mysql error Can't connect to local MySQL server through socket '/var/lib/mysql/mysql. Dannux Linux - Software 3 03-24-2006 08:44 AM
MySQL editor Siebe Linux - Software 8 01-14-2004 12:18 PM


All times are GMT -5. The time now is 08:41 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration