1

With my current setup, it's going to be very hard, if not impossible, to get my terminal window to scroll up and down. That means I can only see 25 rows of text at once. If I have to display something longer, I use |more to be able to scroll through it, like this:

ifconfig | more

But what can I do when a MySQL statement returns more than 25 lines?

describe mysql.user;

I can't just add "| more" in MySQL, and "limit 5" would be invalid syntax here. How can I view the rows a few at a time?

2
  • 3
    You are confusing commands in the command line with mysql queries/commands run from inside MySQL. You can execute queries from the command line with -e and then feed them to more or less or whatever else (save them to a file, etc.) : mysql -u qaz -p -e 'describe mysql.user;' | more – ypercubeᵀᴹ Jul 14 '14 at 16:41
  • 1
    I think you can also use the pager inside MySQL, with for example: pager less and then your output will "page" nicely. – ypercubeᵀᴹ Jul 14 '14 at 16:42
1

In the MySQL shell, enter

pager less

Then enter your query. Use Enter to scroll down and 'q' to stop browsing the results.

My system doesn't have less, so I used more instead:

pager more

More can scroll down and quit like less, but it can't scroll up.

0

The "less command is far more flexible - check it out - forward and back an arbitrary number of lines - sophisticated searches - it's great. Otherwise, use the tee command to output what you need to a file.

[EDIT] I forgot to specify (thanks @ypercube) that you have to set your pager to less mysql> pager less; To install it, use sudo apt-get install less (or whatever the syntax is for your distro).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.