This is a small tip to find mysql commands history without login into mysql server.When we login into MySQL server,generally we uses up and down arrow key to find the history of MySQL commands.
Actually the MySQL commands history are saved in file called .mysql_history located in user’s home directory by which he/she logged into Linux System.

For eg. I login into MySQL server after using my system username called linuxworld and after this I log into mysql server,the MySQL history file will be saved in user’s home directory that is linuxworld home directory.
If you log into system with any particular user and then login into mysql server ,only mysql history will be saved in .mysql_history located in this particular user’s home directory.

linux@tuxworld:~$ ls -l .mysql_history 
-rw------- 1 linux linux 2448 Nov 15 20:57 .mysql_history
linux@tuxworld:~$ ls -l ~/.mysql_history 
-rw------- 1 linux linux 2448 Nov 15 20:57 /home/linux/.mysql_history
linux@tuxworld:~$ 
linux@tuxworld:~$ tail ~/.mysql_history 
select time();
select date();
SELECT CURDATE();
SELECT CURTIME();
use owncloud
show databases;
create database owncloud;
use owncloud
show tables;
select * from oc_queuedtasks;
linux@tuxworld:~$ 

Read Some More Articles

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.