Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you set a default pager for the MySQL client?

Tags:

I know you can set a pager in mysql (the client program) using e.g. \P less. But how would one configure mysql so that your pager of choice is activated whenever you start using the client?

like image 826
dan Avatar asked Apr 10 '11 13:04

dan


People also ask

How to set pager in MySQL?

Use the \pager | \P command MySQL Shell command to set the value of shell . options["pager"] option. If called with no arguments, restores the initial value of shell. options["pager"] option (the one MySQL Shell had at startup.

How do I get to the MySQL prompt?

Enter mysql.exe -uroot -p , and MySQL will launch using the root user. MySQL will prompt you for your password. Enter the password from the user account you specified with the –u tag, and you'll connect to the MySQL server.

What is MySQL prompt?

mysql is a simple SQL shell with input line editing capabilities. It supports interactive and noninteractive use. When used interactively, query results are presented in an ASCII-table format. When used noninteractively (for example, as a filter), the result is presented in tab-separated format.

Which option selects the current MySQL version?

SELECT VERSION Statement It's possible to obtain the version from within the MYSQL client by typing the SELECT VERSION() statement: SELECT VERSION(); This command derives the data from the version variable disregarding other variables.


1 Answers

To force this without having to pass parameters, you can put it in your my.cnf option file, under a [client] section (note that this is on the machine you're connecting from not to).

Something like this:

[client] user = my_usual_user host = my_usual_host pager = less 

If you want it to apply only to the actual mysql command, and no other applications that MySQL considers to be a 'client' (utilities like mysqldump read the [client] section too), then use [mysql] instead.

like image 129
Simon Avatar answered Sep 18 '22 12:09

Simon