mysql
— The MySQL Command-Line Tool
277
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>
4.5.1.3.
mysql
Logging
On Unix, the
mysql
client logs statements executed interactively to a history file. By default, this file
is named
.mysql_history
in your home directory. To specify a different file, set the value of the
MYSQL_HISTFILE
environment variable.
How Logging Occurs
Statement logging occurs as follows:
• Statements are logged only when executed interactively. Statements are noninteractive, for example,
when read from a file or a pipe. It is also possible to suppress statement logging by using the
--
batch
[265]
or
--execute
[266]
option.
•
mysql
logs each nonempty statement line individually.
• If a statement spans multiple lines (not including the terminating delimiter),
mysql
concatenates the
lines to form the complete statement, maps newlines to spaces, and logs the result, plus a delimiter.
Consequently, an input statement that spans multiple lines can be logged twice. Consider this input:
mysql>
SELECT
->
'Today is'
->
,
->
CONCAT()
->
;
In this case,
mysql
logs the “SELECT”, “'Today is'”, “,”, “CONCAT()”, and “;” lines as it reads them.
It also logs the complete statement, after mapping
SELECT\n'Today is'\n,\nCURDATE()
to
SELECT 'Today is' , CURDATE()
, plus a delimiter. Thus, these lines appear in logged output:
SELECT
'Today is'
,
CURDATE()
;
SELECT 'Today is' , CURDATE();
Controlling the History File
The
.mysql_history
file should be protected with a restrictive access mode because sensitive
information might be written to it, such as the text of SQL statements that contain passwords. See
Section 6.1.2.1, “End-User Guidelines for Password Security”
.
If you do not want to maintain a history file, first remove
.mysql_history
if it exists. Then use either
of the following techniques to prevent it from being created again:
Summary of Contents for 5.0
Page 1: ...MySQL 5 0 Reference Manual ...
Page 18: ...xviii ...
Page 60: ...40 ...
Page 396: ...376 ...
Page 578: ...558 ...
Page 636: ...616 ...
Page 844: ...824 ...
Page 1234: ...1214 ...
Page 1427: ...MySQL Proxy Scripting 1407 ...
Page 1734: ...1714 ...
Page 1752: ...1732 ...
Page 1783: ...Configuring Connector ODBC 1763 ...
Page 1793: ...Connector ODBC Examples 1773 ...
Page 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Page 2850: ...2830 ...
Page 2854: ...2834 ...
Page 2928: ...2908 ...
Page 3000: ...2980 ...
Page 3122: ...3102 ...
Page 3126: ...3106 ...
Page 3174: ...3154 ...
Page 3232: ...3212 ...