LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 05-02-2010, 02:07 PM   #1
vikas027
Senior Member
 
Registered: May 2007
Location: Sydney
Distribution: RHEL, CentOS, Ubuntu, Debian, OS X
Posts: 1,305

Rep: Reputation: 107Reputation: 107
Question Enable Reverse Search of MySQL History


Hi,

I am sorry to post here, if in case this is not the right forum.

I am new to MySQL.

I just installed MYSQL 5.0.90 from http://www.sfr-fresh.com/unix/misc/mysql-5.0.90.tar.gz/
on my RHEL 5.0 machine.

I have seen "Reverse Searching of MySQL History" , but however I am unable to do so in my MYSQL 5.0.90.

Can someone help me out please ?
 
Old 05-18-2010, 06:53 PM   #2
vikas027
Senior Member
 
Registered: May 2007
Location: Sydney
Distribution: RHEL, CentOS, Ubuntu, Debian, OS X
Posts: 1,305

Original Poster
Rep: Reputation: 107Reputation: 107
Any ideas gurus ?
 
Old 05-18-2010, 07:21 PM   #3
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
I believe that the mysql client uses the same readline function as the bash shell, but uses a .myql_history file instead of .bash_history. It is the client rather than the server that would be the reason for your lack of command history.

First question is do you use the bash shell. Does CTRL_R in the console work?

Are you using the --quick or --batch options? If you do, mysql doesn't use the ~/.mysql_history file.

Run `echo MYSQL_HISTORY'. Does it equal /dev/null?
Run `ls -l ~/.mysql_history'. Is it linked to /dev/null?
 
Old 05-21-2010, 12:59 PM   #4
vikas027
Senior Member
 
Registered: May 2007
Location: Sydney
Distribution: RHEL, CentOS, Ubuntu, Debian, OS X
Posts: 1,305

Original Poster
Rep: Reputation: 107Reputation: 107
Quote:
Originally Posted by jschiwal View Post
First question is do you use the bash shell. Does CTRL_R in the console work?
Yes, CTRL+R is working perfectly with bash shell.



Quote:
Originally Posted by jschiwal View Post
Are you using the --quick or --batch options? If you do, mysql doesn't use the ~/.mysql_history file.
How can I check this ?
By the way, I have installed mysql using these options.
Code:
./configure \
--prefix=/usr/local/mysql \
--localstatedir=/usr/local/mysql/data \
--disable-maintainer-mode \
--with-mysqld-user=mysql \
--with-unix-socket-path=/tmp/mysql.sock \
--without-comment \
--without-debug \
--without-bench
Quote:
Originally Posted by jschiwal View Post
Run `echo MYSQL_HISTORY'. Does it equal /dev/null?
Code:
[root@server ~]# echo $MYSQL_HISTORY

[root@server ~]#



Quote:
Originally Posted by jschiwal View Post
Run `ls -l ~/.mysql_history'. Is it linked to /dev/null?
No
Code:
[root@server ~]# ls -l ~/.mysql_history
-rw------- 1 root root 23958 May  6 03:36 /root/.mysql_history
 
Old 05-26-2010, 02:32 AM   #5
vikas027
Senior Member
 
Registered: May 2007
Location: Sydney
Distribution: RHEL, CentOS, Ubuntu, Debian, OS X
Posts: 1,305

Original Poster
Rep: Reputation: 107Reputation: 107
Dear jschiwal,

Any idea.
 
Old 06-16-2010, 02:06 AM   #6
vikas027
Senior Member
 
Registered: May 2007
Location: Sydney
Distribution: RHEL, CentOS, Ubuntu, Debian, OS X
Posts: 1,305

Original Poster
Rep: Reputation: 107Reputation: 107
Any update Gurus/Jschiwal ?
 
Old 06-16-2010, 02:21 AM   #7
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297
Hello Vikas,

Is there content in your .mysql_history file? Check using
Code:
cat /root/.mysql_history
If there is content then you can reverse search when in your MySQL console by pressing CTRL R as indicated by jschiwal.

You should see something like this:
Code:
(reverse-i-search)`':
at which point you can start by typing the first letters of the command you're looking for.

Normally if mysql_history is enabled you can browse through the commands already executed with the arrow up and down keys also, just like in bash.

Kind regards,

Eric
 
Old 07-06-2010, 01:39 PM   #8
vikas027
Senior Member
 
Registered: May 2007
Location: Sydney
Distribution: RHEL, CentOS, Ubuntu, Debian, OS X
Posts: 1,305

Original Poster
Rep: Reputation: 107Reputation: 107
Unhappy

Quote:
Originally Posted by EricTRA View Post
Hello Vikas,

Is there content in your .mysql_history file? Check using
Code:
cat /root/.mysql_history
If there is content then you can reverse search when in your MySQL console by pressing CTRL R as indicated by jschiwal.

Hi Eric,

Sorry for long delay.
Yes, there is content in /root/.mysql_history.
Code:
[root@server ~]# ls -l /root/.mysql_history 
-rw------- 1 root root 335 Jul  6 23:57 /root/.mysql_history
[root@server ~]# tail -5 /root/.mysql_history
show\040tables;
show\040tables;
\134q
\134q
\134q
Quote:
Originally Posted by EricTRA View Post
Normally if mysql_history is enabled you can browse through the commands already executed with the arrow up and down keys also, just like in bash.
Yes, I can use up-down arrow keys, but not the Ctrl+R feature.

I have tested the same on many machines, it is NOT working in any machine. May be I have missed out something at compiling OR in config file.
 
  


Reply



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
how to search command history beginning with what you type xiawinter Linux - Desktop 9 10-05-2010 03:58 AM
ESC+/ to search command history in tcsh wycolorado Linux - Newbie 1 06-30-2006 04:20 AM
ESC+/ to search command history in tcsh wycolorado Linux - General 0 06-28-2006 06:43 PM
Search Box History List akosombo Fedora 0 05-06-2005 07:36 PM
enable reverse dns on RH9 client marcbachman Linux - Wireless Networking 1 03-15-2004 10:47 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 12:31 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration