Score:0

Finding history of commands in mysql of ubuntu

us flag

When i press up arrow key on keyboard after logging in mysql by root, i can see what all commands i ran. I want to get the commands which i ran long time ago. So how can i show that all commands in a single file.

Muhammed Sinan C K avatar
us flag
I want to do this because i lost my queries files for lab assignment. Pls help
Score:2
fr flag

By default, the MySQL history file is $HOME/.mysql_history.

You should be able to print it's contents using:

cat $HOME/.mysql_history

If you've run mysql using sudo, then it shall be:

sudo -i bash -c "cat \$HOME/.mysql_history"

or simply (assuming default $HOME):

sudo cat /root/.mysql_history
Muhammed Sinan C K avatar
us flag
thanks for the solution
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.