4.5.1.2. mysql Commands
MySQL sends each SQL statement that you issue to the server to be executed. There is also a set of commands that mysql itself interprets. For a list of these commands, typehelp or \h at the mysql>
prompt: mysql> help
List of all MySQL commands:
Note that all text commands must be first on line and end with ';'
? (\?) Synonym for `help'.
clear (\c) Clear command.
connect (\r) Reconnect to the server. Optional arguments are db and host.
delimiter (\d) Set statement delimiter.
edit (\e) Edit command with $EDITOR.
ego (\G) Send command to mysql server, display result vertically.
exit (\q) Exit mysql. Same as quit.
go (\g) Send command to mysql server.
help (\h) Display this help.
nopager (\n) Disable pager, print to stdout.
notee (\t) Don't write into outfile.
pager (\P) Set PAGER [to_pager]. Print the query results via PAGER.
print (\p) Print current command.
prompt (\R) Change your mysql prompt.
quit (\q) Quit mysql.
rehash (\#) Rebuild completion hash.
source (\.) Execute an SQL script file. Takes a file name as an argument.
status (\s) Get status information from the server.
system (\!) Execute a system shell command.
tee (\T) Set outfile [to_outfile]. Append everything into given
outfile.
use (\u) Use another database. Takes database name as argument.
charset (\C) Switch to another charset. Might be needed for processing
binlog with multi-byte charsets.
warnings (\W) Show warnings after every statement.
nowarning (\w) Don't show warnings after every statement.
|
Option
|
Description
|
\c |
A
counter that increments for each statement you issue
|
\D |
The
full current date
|
\d |
The
default database
|
\h |
The
server host
|
\l |
The
current delimiter (new in 5.0.25)
|
\m |
Minutes
of the current time
|
\n |
A
newline character
|
\O |
The
current month in three-letter format (Jan, Feb, …)
|
\o |
The
current month in numeric format
|
\P |
am/pm
|
\p |
The
current TCP/IP port or socket file
|
\R |
The
current time, in 24-hour military time (0–23)
|
\r |
The
current time, standard 12-hour time (1–12)
|
\S |
Semicolon
|
\s |
Seconds
of the current time
|
\t |
A
tab character
|
\U |
Your full user_name@host_name account name |
\u |
Your
user name
|
\v |
The
server version
|
\w |
The
current day of the week in three-letter format (Mon, Tue, …)
|
\Y |
The
current year, four digits
|
\y |
The
current year, two digits
|
\_ |
A
space
|
\ |
A
space (a space follows the backslash)
|
\' |
Single
quote
|
\" |
Double
quote
|
\\ |
A
literal “
\” backslash character |
\x |
x, for any “x” not listed above |
·
Use an environment variable. You can set the
MYSQL_PS1 environment variable to a
prompt string. For example:
·
shell>
export
MYSQL_PS1="(\u@\h) [\d]> "
·
Use a command-line option. You can set the
--prompt option on the command line
to mysql.
For example:
·
shell>
mysql
--prompt="(\u@\h) [\d]> "·
(user@host) [database]>
·
Use an option file. You can set the
prompt option in the [mysql] group of any MySQL option file,
such as /etc/my.cnf or the .my.cnf file in your home directory. For
example:
·
[mysql]prompt=(\\u@\\h) [\\d]>\\_
In this example, note that the backslashes are
doubled. If you set the prompt using the
prompt
option in an option file, it is advisable to double the backslashes when using
the special prompt options. There is some overlap in the set of permissible
prompt options and the set of special escape sequences that are recognized in
option files. (The rules for escape sequences in option files are listed in Section 4.2.3.3, “Using Option
Files”.) The overlap may cause you problems if you use single backslashes.
For example, \s is
interpreted as a space rather than as the current seconds value. The following
example shows how to define a prompt within an option file to include the
current time in HH:MM:SS>
format:
[mysql]prompt="\\r:\\m:\\s> "
·
Set the prompt interactively. You can change your prompt
interactively by using the
prompt
(or \R) command. For
example:
·
mysql>
prompt (\u@\h)
[\d]>\_·
PROMPT set to '(\u@\h) [\d]>\_'·
(user@host) [database]>·
(user@host) [database]> prompt·
Returning to default PROMPT of mysql>·
mysql> 





0 comments:
Post a Comment