You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2837 lines
56 KiB

  1. '\" t
  2. .\" Title: \fBmysql\fR
  3. .\" Author: [FIXME: author] [see http://docbook.sf.net/el/author]
  4. .\" Generator: DocBook XSL Stylesheets v1.75.2 <http://docbook.sf.net/>
  5. .\" Date: 04/06/2010
  6. .\" Manual: MySQL Database System
  7. .\" Source: MySQL 5.1
  8. .\" Language: English
  9. .\"
  10. .TH "\FBMYSQL\FR" "1" "04/06/2010" "MySQL 5\&.1" "MySQL Database System"
  11. .\" -----------------------------------------------------------------
  12. .\" * set default formatting
  13. .\" -----------------------------------------------------------------
  14. .\" disable hyphenation
  15. .nh
  16. .\" disable justification (adjust text to left margin only)
  17. .ad l
  18. .\" -----------------------------------------------------------------
  19. .\" * MAIN CONTENT STARTS HERE *
  20. .\" -----------------------------------------------------------------
  21. .\" mysql
  22. .\" command-line tool
  23. .\" tools: command-line
  24. .\" scripts: SQL
  25. .\" SQL scripts
  26. .\" batch SQL files
  27. .SH "NAME"
  28. mysql \- the MySQL command\-line tool
  29. .SH "SYNOPSIS"
  30. .HP \w'\fBmysql\ [\fR\fB\fIoptions\fR\fR\fB]\ \fR\fB\fIdb_name\fR\fR\ 'u
  31. \fBmysql [\fR\fB\fIoptions\fR\fR\fB] \fR\fB\fIdb_name\fR\fR
  32. .SH "DESCRIPTION"
  33. .PP
  34. \fBmysql\fR
  35. is a simple SQL shell (with GNU
  36. readline
  37. 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\&. The output format can be changed using command options\&.
  38. .PP
  39. If you have problems due to insufficient memory for large result sets, use the
  40. \fB\-\-quick\fR
  41. option\&. This forces
  42. \fBmysql\fR
  43. to retrieve results from the server a row at a time rather than retrieving the entire result set and buffering it in memory before displaying it\&. This is done by returning the result set using the
  44. mysql_use_result()
  45. C API function in the client/server library rather than
  46. mysql_store_result()\&.
  47. .PP
  48. Using
  49. \fBmysql\fR
  50. is very easy\&. Invoke it from the prompt of your command interpreter as follows:
  51. .sp
  52. .if n \{\
  53. .RS 4
  54. .\}
  55. .nf
  56. shell> \fBmysql \fR\fB\fIdb_name\fR\fR
  57. .fi
  58. .if n \{\
  59. .RE
  60. .\}
  61. .PP
  62. Or:
  63. .sp
  64. .if n \{\
  65. .RS 4
  66. .\}
  67. .nf
  68. shell> \fBmysql \-\-user=\fR\fB\fIuser_name\fR\fR\fB \-\-password=\fR\fB\fIyour_password\fR\fR\fB \fR\fB\fIdb_name\fR\fR
  69. .fi
  70. .if n \{\
  71. .RE
  72. .\}
  73. .PP
  74. Then type an SQL statement, end it with
  75. \(lq;\(rq,
  76. \eg, or
  77. \eG
  78. and press Enter\&.
  79. .PP
  80. As of MySQL 5\&.1\&.10, typing Control\-C causes
  81. \fBmysql\fR
  82. to attempt to kill the current statement\&. If this cannot be done, or Control\-C is typed again before the statement is killed,
  83. \fBmysql\fR
  84. exits\&. Previously, Control\-C caused
  85. \fBmysql\fR
  86. to exit in all cases\&.
  87. .PP
  88. You can execute SQL statements in a script file (batch file) like this:
  89. .sp
  90. .if n \{\
  91. .RS 4
  92. .\}
  93. .nf
  94. shell> \fBmysql \fR\fB\fIdb_name\fR\fR\fB < \fR\fB\fIscript\&.sql\fR\fR\fB > \fR\fB\fIoutput\&.tab\fR\fR
  95. .fi
  96. .if n \{\
  97. .RE
  98. .\}
  99. .SH "MYSQL OPTIONS"
  100. .\" mysql command options
  101. .\" command options: mysql
  102. .\" options: command-line: mysql
  103. .\" startup parameters: mysql
  104. .PP
  105. \fBmysql\fR
  106. supports the following options, which can be specified on the command line or in the
  107. [mysql]
  108. and
  109. [client]
  110. option file groups\&.
  111. \fBmysql\fR
  112. also supports the options for processing option files described at
  113. Section\ \&4.2.3.3.1, \(lqCommand-Line Options that Affect Option-File Handling\(rq\&.
  114. .sp
  115. .RS 4
  116. .ie n \{\
  117. \h'-04'\(bu\h'+03'\c
  118. .\}
  119. .el \{\
  120. .sp -1
  121. .IP \(bu 2.3
  122. .\}
  123. .\" mysql: help option
  124. .\" help option: mysql
  125. \fB\-\-help\fR,
  126. \fB\-?\fR
  127. .sp
  128. Display a help message and exit\&.
  129. .RE
  130. .sp
  131. .RS 4
  132. .ie n \{\
  133. \h'-04'\(bu\h'+03'\c
  134. .\}
  135. .el \{\
  136. .sp -1
  137. .IP \(bu 2.3
  138. .\}
  139. .\" mysql: auto-rehash option
  140. .\" auto-rehash option: mysql
  141. \fB\-\-auto\-rehash\fR
  142. .sp
  143. Enable automatic rehashing\&. This option is on by default, which enables database, table, and column name completion\&. Use
  144. \fB\-\-disable\-auto\-rehash\fR
  145. to disable rehashing\&. That causes
  146. \fBmysql\fR
  147. to start faster, but you must issue the
  148. rehash
  149. command if you want to use name completion\&.
  150. .sp
  151. To complete a name, enter the first part and press Tab\&. If the name is unambiguous,
  152. \fBmysql\fR
  153. completes it\&. Otherwise, you can press Tab again to see the possible names that begin with what you have typed so far\&. Completion does not occur if there is no default database\&.
  154. .RE
  155. .sp
  156. .RS 4
  157. .ie n \{\
  158. \h'-04'\(bu\h'+03'\c
  159. .\}
  160. .el \{\
  161. .sp -1
  162. .IP \(bu 2.3
  163. .\}
  164. .\" mysql: batch option
  165. .\" batch option: mysql
  166. \fB\-\-batch\fR,
  167. \fB\-B\fR
  168. .sp
  169. Print results using tab as the column separator, with each row on a new line\&. With this option,
  170. \fBmysql\fR
  171. does not use the history file\&.
  172. .sp
  173. Batch mode results in nontabular output format and escaping of special characters\&. Escaping may be disabled by using raw mode; see the description for the
  174. \fB\-\-raw\fR
  175. option\&.
  176. .RE
  177. .sp
  178. .RS 4
  179. .ie n \{\
  180. \h'-04'\(bu\h'+03'\c
  181. .\}
  182. .el \{\
  183. .sp -1
  184. .IP \(bu 2.3
  185. .\}
  186. .\" mysql: character-sets-dir option
  187. .\" character-sets-dir option: mysql
  188. \fB\-\-character\-sets\-dir=\fR\fB\fIpath\fR\fR
  189. .sp
  190. The directory where character sets are installed\&. See
  191. Section\ \&9.5, \(lqCharacter Set Configuration\(rq\&.
  192. .RE
  193. .sp
  194. .RS 4
  195. .ie n \{\
  196. \h'-04'\(bu\h'+03'\c
  197. .\}
  198. .el \{\
  199. .sp -1
  200. .IP \(bu 2.3
  201. .\}
  202. .\" mysql: column-names option
  203. .\" column-names option: mysql
  204. \fB\-\-column\-names\fR
  205. .sp
  206. Write column names in results\&.
  207. .RE
  208. .sp
  209. .RS 4
  210. .ie n \{\
  211. \h'-04'\(bu\h'+03'\c
  212. .\}
  213. .el \{\
  214. .sp -1
  215. .IP \(bu 2.3
  216. .\}
  217. .\" mysql: column-type-info option
  218. .\" column-type-info option: mysql
  219. \fB\-\-column\-type\-info\fR,
  220. \fB\-m\fR
  221. .sp
  222. Display result set metadata\&. This option was added in MySQL 5\&.1\&.14\&. (Before that, use
  223. \fB\-\-debug\-info\fR\&.) The
  224. \fB\-m\fR
  225. short option was added in MySQL 5\&.1\&.21\&.
  226. .RE
  227. .sp
  228. .RS 4
  229. .ie n \{\
  230. \h'-04'\(bu\h'+03'\c
  231. .\}
  232. .el \{\
  233. .sp -1
  234. .IP \(bu 2.3
  235. .\}
  236. .\" mysql: comments option
  237. .\" comments option: mysql
  238. \fB\-\-comments\fR,
  239. \fB\-c\fR
  240. .sp
  241. Whether to preserve comments in statements sent to the server\&. The default is \-\-skip\-comments (discard comments), enable with \-\-comments (preserve comments)\&. This option was added in MySQL 5\&.1\&.23\&.
  242. .RE
  243. .sp
  244. .RS 4
  245. .ie n \{\
  246. \h'-04'\(bu\h'+03'\c
  247. .\}
  248. .el \{\
  249. .sp -1
  250. .IP \(bu 2.3
  251. .\}
  252. .\" mysql: compress option
  253. .\" compress option: mysql
  254. \fB\-\-compress\fR,
  255. \fB\-C\fR
  256. .sp
  257. Compress all information sent between the client and the server if both support compression\&.
  258. .RE
  259. .sp
  260. .RS 4
  261. .ie n \{\
  262. \h'-04'\(bu\h'+03'\c
  263. .\}
  264. .el \{\
  265. .sp -1
  266. .IP \(bu 2.3
  267. .\}
  268. .\" mysql: database option
  269. .\" database option: mysql
  270. \fB\-\-database=\fR\fB\fIdb_name\fR\fR,
  271. \fB\-D \fR\fB\fIdb_name\fR\fR
  272. .sp
  273. The database to use\&. This is useful primarily in an option file\&.
  274. .RE
  275. .sp
  276. .RS 4
  277. .ie n \{\
  278. \h'-04'\(bu\h'+03'\c
  279. .\}
  280. .el \{\
  281. .sp -1
  282. .IP \(bu 2.3
  283. .\}
  284. .\" mysql: debug option
  285. .\" debug option: mysql
  286. \fB\-\-debug[=\fR\fB\fIdebug_options\fR\fR\fB]\fR,
  287. \fB\-# [\fR\fB\fIdebug_options\fR\fR\fB]\fR
  288. .sp
  289. Write a debugging log\&. A typical
  290. \fIdebug_options\fR
  291. string is
  292. \'d:t:o,\fIfile_name\fR\'\&. The default is
  293. \'d:t:o,/tmp/mysql\&.trace\'\&.
  294. .RE
  295. .sp
  296. .RS 4
  297. .ie n \{\
  298. \h'-04'\(bu\h'+03'\c
  299. .\}
  300. .el \{\
  301. .sp -1
  302. .IP \(bu 2.3
  303. .\}
  304. .\" mysql: debug-check option
  305. .\" debug-check option: mysql
  306. \fB\-\-debug\-check\fR
  307. .sp
  308. Print some debugging information when the program exits\&. This option was added in MySQL 5\&.1\&.21\&.
  309. .RE
  310. .sp
  311. .RS 4
  312. .ie n \{\
  313. \h'-04'\(bu\h'+03'\c
  314. .\}
  315. .el \{\
  316. .sp -1
  317. .IP \(bu 2.3
  318. .\}
  319. .\" mysql: debug-info option
  320. .\" debug-info option: mysql
  321. \fB\-\-debug\-info\fR,
  322. \fB\-T\fR
  323. .sp
  324. Before MySQL 5\&.1\&.14, this option prints debugging information and memory and CPU usage statistics when the program exits, and also causes display of result set metadata during execution\&. As of MySQL 5\&.1\&.14, use
  325. \fB\-\-column\-type\-info\fR
  326. to display result set metadata\&.
  327. .RE
  328. .sp
  329. .RS 4
  330. .ie n \{\
  331. \h'-04'\(bu\h'+03'\c
  332. .\}
  333. .el \{\
  334. .sp -1
  335. .IP \(bu 2.3
  336. .\}
  337. .\" mysql: default-character-set option
  338. .\" default-character-set option: mysql
  339. \fB\-\-default\-character\-set=\fR\fB\fIcharset_name\fR\fR
  340. .sp
  341. Use
  342. \fIcharset_name\fR
  343. as the default character set for the client and connection\&.
  344. .sp
  345. A common issue that can occur when the operating system uses
  346. utf8
  347. or another multi\-byte character set is that output from the
  348. \fBmysql\fR
  349. client is formatted incorrectly, due to the fact that the MySQL client uses the
  350. latin1
  351. character set by default\&. You can usually fix such issues by using this option to force the client to use the system character set instead\&.
  352. .sp
  353. See
  354. Section\ \&9.5, \(lqCharacter Set Configuration\(rq, for more information\&.
  355. .RE
  356. .sp
  357. .RS 4
  358. .ie n \{\
  359. \h'-04'\(bu\h'+03'\c
  360. .\}
  361. .el \{\
  362. .sp -1
  363. .IP \(bu 2.3
  364. .\}
  365. .\" mysql: delimiter option
  366. .\" delimiter option: mysql
  367. \fB\-\-delimiter=\fR\fB\fIstr\fR\fR
  368. .sp
  369. Set the statement delimiter\&. The default is the semicolon character (\(lq;\(rq)\&.
  370. .RE
  371. .sp
  372. .RS 4
  373. .ie n \{\
  374. \h'-04'\(bu\h'+03'\c
  375. .\}
  376. .el \{\
  377. .sp -1
  378. .IP \(bu 2.3
  379. .\}
  380. .\" mysql: disable named commands
  381. .\" disable named command: mysql
  382. \fB\-\-disable\-named\-commands\fR
  383. .sp
  384. Disable named commands\&. Use the
  385. \e*
  386. form only, or use named commands only at the beginning of a line ending with a semicolon (\(lq;\(rq)\&.
  387. \fBmysql\fR
  388. starts with this option
  389. \fIenabled\fR
  390. by default\&. However, even with this option, long\-format commands still work from the first line\&. See
  391. the section called \(lqMYSQL COMMANDS\(rq\&.
  392. .RE
  393. .sp
  394. .RS 4
  395. .ie n \{\
  396. \h'-04'\(bu\h'+03'\c
  397. .\}
  398. .el \{\
  399. .sp -1
  400. .IP \(bu 2.3
  401. .\}
  402. .\" mysql: execute option
  403. .\" execute option: mysql
  404. \fB\-\-execute=\fR\fB\fIstatement\fR\fR,
  405. \fB\-e \fR\fB\fIstatement\fR\fR
  406. .sp
  407. Execute the statement and quit\&. The default output format is like that produced with
  408. \fB\-\-batch\fR\&. See
  409. Section\ \&4.2.3.1, \(lqUsing Options on the Command Line\(rq, for some examples\&.
  410. .RE
  411. .sp
  412. .RS 4
  413. .ie n \{\
  414. \h'-04'\(bu\h'+03'\c
  415. .\}
  416. .el \{\
  417. .sp -1
  418. .IP \(bu 2.3
  419. .\}
  420. .\" mysql: force option
  421. .\" force option: mysql
  422. \fB\-\-force\fR,
  423. \fB\-f\fR
  424. .sp
  425. Continue even if an SQL error occurs\&.
  426. .RE
  427. .sp
  428. .RS 4
  429. .ie n \{\
  430. \h'-04'\(bu\h'+03'\c
  431. .\}
  432. .el \{\
  433. .sp -1
  434. .IP \(bu 2.3
  435. .\}
  436. .\" mysql: host option
  437. .\" host option: mysql
  438. \fB\-\-host=\fR\fB\fIhost_name\fR\fR,
  439. \fB\-h \fR\fB\fIhost_name\fR\fR
  440. .sp
  441. Connect to the MySQL server on the given host\&.
  442. .RE
  443. .sp
  444. .RS 4
  445. .ie n \{\
  446. \h'-04'\(bu\h'+03'\c
  447. .\}
  448. .el \{\
  449. .sp -1
  450. .IP \(bu 2.3
  451. .\}
  452. .\" mysql: html option
  453. .\" html option: mysql
  454. \fB\-\-html\fR,
  455. \fB\-H\fR
  456. .sp
  457. Produce HTML output\&.
  458. .RE
  459. .sp
  460. .RS 4
  461. .ie n \{\
  462. \h'-04'\(bu\h'+03'\c
  463. .\}
  464. .el \{\
  465. .sp -1
  466. .IP \(bu 2.3
  467. .\}
  468. .\" mysql: ignore-spaces option
  469. .\" ignore-spaces option: mysql
  470. \fB\-\-ignore\-spaces\fR,
  471. \fB\-i\fR
  472. .sp
  473. Ignore spaces after function names\&. The effect of this is described in the discussion for the
  474. IGNORE_SPACE
  475. SQL mode (see
  476. Section\ \&5.1.8, \(lqServer SQL Modes\(rq)\&.
  477. .RE
  478. .sp
  479. .RS 4
  480. .ie n \{\
  481. \h'-04'\(bu\h'+03'\c
  482. .\}
  483. .el \{\
  484. .sp -1
  485. .IP \(bu 2.3
  486. .\}
  487. .\" mysql: line-numbers option
  488. .\" line-numbers option: mysql
  489. \fB\-\-line\-numbers\fR
  490. .sp
  491. Write line numbers for errors\&. Disable this with
  492. \fB\-\-skip\-line\-numbers\fR\&.
  493. .RE
  494. .sp
  495. .RS 4
  496. .ie n \{\
  497. \h'-04'\(bu\h'+03'\c
  498. .\}
  499. .el \{\
  500. .sp -1
  501. .IP \(bu 2.3
  502. .\}
  503. .\" mysql: local-infile option
  504. .\" local-infile option: mysql
  505. \fB\-\-local\-infile[={0|1}]\fR
  506. .sp
  507. Enable or disable
  508. LOCAL
  509. capability for
  510. LOAD DATA INFILE\&. With no value, the option enables
  511. LOCAL\&. The option may be given as
  512. \fB\-\-local\-infile=0\fR
  513. or
  514. \fB\-\-local\-infile=1\fR
  515. to explicitly disable or enable
  516. LOCAL\&. Enabling
  517. LOCAL
  518. has no effect if the server does not also support it\&.
  519. .RE
  520. .sp
  521. .RS 4
  522. .ie n \{\
  523. \h'-04'\(bu\h'+03'\c
  524. .\}
  525. .el \{\
  526. .sp -1
  527. .IP \(bu 2.3
  528. .\}
  529. .\" mysql: named-commands option
  530. .\" named-commands option: mysql
  531. \fB\-\-named\-commands\fR,
  532. \fB\-G\fR
  533. .sp
  534. Enable named
  535. \fBmysql\fR
  536. commands\&. Long\-format commands are allowed, not just short\-format commands\&. For example,
  537. quit
  538. and
  539. \eq
  540. both are recognized\&. Use
  541. \fB\-\-skip\-named\-commands\fR
  542. to disable named commands\&. See
  543. the section called \(lqMYSQL COMMANDS\(rq\&.
  544. .RE
  545. .sp
  546. .RS 4
  547. .ie n \{\
  548. \h'-04'\(bu\h'+03'\c
  549. .\}
  550. .el \{\
  551. .sp -1
  552. .IP \(bu 2.3
  553. .\}
  554. .\" mysql: no-auto-rehash option
  555. .\" no-auto-rehash option: mysql
  556. \fB\-\-no\-auto\-rehash\fR,
  557. \fB\-A\fR
  558. .sp
  559. This has the same effect as
  560. \fB\-skip\-auto\-rehash\fR\&. See the description for
  561. \fB\-\-auto\-rehash\fR\&.
  562. .RE
  563. .sp
  564. .RS 4
  565. .ie n \{\
  566. \h'-04'\(bu\h'+03'\c
  567. .\}
  568. .el \{\
  569. .sp -1
  570. .IP \(bu 2.3
  571. .\}
  572. .\" mysql: no-beep option
  573. .\" no-beep option: mysql
  574. \fB\-\-no\-beep\fR,
  575. \fB\-b\fR
  576. .sp
  577. Do not beep when errors occur\&.
  578. .RE
  579. .sp
  580. .RS 4
  581. .ie n \{\
  582. \h'-04'\(bu\h'+03'\c
  583. .\}
  584. .el \{\
  585. .sp -1
  586. .IP \(bu 2.3
  587. .\}
  588. .\" mysql: no-named-commands option
  589. .\" no-named-commands option: mysql
  590. \fB\-\-no\-named\-commands\fR,
  591. \fB\-g\fR
  592. .sp
  593. Deprecated, use
  594. \fB\-\-disable\-named\-commands\fR
  595. instead\&.
  596. \fB\-\-no\-named\-commands\fR
  597. is removed in MySQL 5\&.5\&.
  598. .RE
  599. .sp
  600. .RS 4
  601. .ie n \{\
  602. \h'-04'\(bu\h'+03'\c
  603. .\}
  604. .el \{\
  605. .sp -1
  606. .IP \(bu 2.3
  607. .\}
  608. .\" mysql: no-pager option
  609. .\" no-pager option: mysql
  610. \fB\-\-no\-pager\fR
  611. .sp
  612. Deprecated form of
  613. \fB\-\-skip\-pager\fR\&. See the
  614. \fB\-\-pager\fR
  615. option\&.
  616. \fB\-\-no\-pager\fR
  617. is removed in MySQL 5\&.5\&.
  618. .RE
  619. .sp
  620. .RS 4
  621. .ie n \{\
  622. \h'-04'\(bu\h'+03'\c
  623. .\}
  624. .el \{\
  625. .sp -1
  626. .IP \(bu 2.3
  627. .\}
  628. .\" mysql: no-tee option
  629. .\" no-tee option: mysql
  630. \fB\-\-no\-tee\fR
  631. .sp
  632. Deprecated form of
  633. \fB\-\-skip\-tee\fR\&. See the
  634. \fB\-\-tee\fR
  635. option\&.
  636. \fB\-\-no\-tee\fR
  637. is removed in MySQL 5\&.5\&.
  638. .RE
  639. .sp
  640. .RS 4
  641. .ie n \{\
  642. \h'-04'\(bu\h'+03'\c
  643. .\}
  644. .el \{\
  645. .sp -1
  646. .IP \(bu 2.3
  647. .\}
  648. .\" mysql: one-database option
  649. .\" one-database option: mysql
  650. \fB\-\-one\-database\fR,
  651. \fB\-o\fR
  652. .sp
  653. Ignore statements except those for the default database named on the command line\&. This is useful for skipping updates to other databases in the binary log\&.
  654. .RE
  655. .sp
  656. .RS 4
  657. .ie n \{\
  658. \h'-04'\(bu\h'+03'\c
  659. .\}
  660. .el \{\
  661. .sp -1
  662. .IP \(bu 2.3
  663. .\}
  664. .\" mysql: pager option
  665. .\" pager option: mysql
  666. \fB\-\-pager[=\fR\fB\fIcommand\fR\fR\fB]\fR
  667. .sp
  668. Use the given command for paging query output\&. If the command is omitted, the default pager is the value of your
  669. PAGER
  670. environment variable\&. Valid pagers are
  671. \fBless\fR,
  672. \fBmore\fR,
  673. \fBcat [> filename]\fR, and so forth\&. This option works only on Unix and only in interactive mode\&. To disable paging, use
  674. \fB\-\-skip\-pager\fR\&.
  675. the section called \(lqMYSQL COMMANDS\(rq, discusses output paging further\&.
  676. .RE
  677. .sp
  678. .RS 4
  679. .ie n \{\
  680. \h'-04'\(bu\h'+03'\c
  681. .\}
  682. .el \{\
  683. .sp -1
  684. .IP \(bu 2.3
  685. .\}
  686. .\" mysql: password option
  687. .\" password option: mysql
  688. \fB\-\-password[=\fR\fB\fIpassword\fR\fR\fB]\fR,
  689. \fB\-p[\fR\fB\fIpassword\fR\fR\fB]\fR
  690. .sp
  691. The password to use when connecting to the server\&. If you use the short option form (\fB\-p\fR), you
  692. \fIcannot\fR
  693. have a space between the option and the password\&. If you omit the
  694. \fIpassword\fR
  695. value following the
  696. \fB\-\-password\fR
  697. or
  698. \fB\-p\fR
  699. option on the command line,
  700. \fBmysql\fR
  701. prompts for one\&.
  702. .sp
  703. Specifying a password on the command line should be considered insecure\&. See
  704. Section\ \&5.3.2.2, \(lqEnd-User Guidelines for Password Security\(rq\&. You can use an option file to avoid giving the password on the command line\&.
  705. .RE
  706. .sp
  707. .RS 4
  708. .ie n \{\
  709. \h'-04'\(bu\h'+03'\c
  710. .\}
  711. .el \{\
  712. .sp -1
  713. .IP \(bu 2.3
  714. .\}
  715. .\" mysql: pipe option
  716. .\" pipe option: mysql
  717. \fB\-\-pipe\fR,
  718. \fB\-W\fR
  719. .sp
  720. On Windows, connect to the server via a named pipe\&. This option applies only if the server supports named\-pipe connections\&.
  721. .RE
  722. .sp
  723. .RS 4
  724. .ie n \{\
  725. \h'-04'\(bu\h'+03'\c
  726. .\}
  727. .el \{\
  728. .sp -1
  729. .IP \(bu 2.3
  730. .\}
  731. .\" mysql: port option
  732. .\" port option: mysql
  733. \fB\-\-port=\fR\fB\fIport_num\fR\fR,
  734. \fB\-P \fR\fB\fIport_num\fR\fR
  735. .sp
  736. The TCP/IP port number to use for the connection\&.
  737. .RE
  738. .sp
  739. .RS 4
  740. .ie n \{\
  741. \h'-04'\(bu\h'+03'\c
  742. .\}
  743. .el \{\
  744. .sp -1
  745. .IP \(bu 2.3
  746. .\}
  747. .\" mysql: prompt option
  748. .\" prompt option: mysql
  749. \fB\-\-prompt=\fR\fB\fIformat_str\fR\fR
  750. .sp
  751. Set the prompt to the specified format\&. The default is
  752. mysql>\&. The special sequences that the prompt can contain are described in
  753. the section called \(lqMYSQL COMMANDS\(rq\&.
  754. .RE
  755. .sp
  756. .RS 4
  757. .ie n \{\
  758. \h'-04'\(bu\h'+03'\c
  759. .\}
  760. .el \{\
  761. .sp -1
  762. .IP \(bu 2.3
  763. .\}
  764. .\" mysql: protocol option
  765. .\" protocol option: mysql
  766. \fB\-\-protocol={TCP|SOCKET|PIPE|MEMORY}\fR
  767. .sp
  768. The connection protocol to use for connecting to the server\&. It is useful when the other connection parameters normally would cause a protocol to be used other than the one you want\&. For details on the allowable values, see
  769. Section\ \&4.2.2, \(lqConnecting to the MySQL Server\(rq\&.
  770. .RE
  771. .sp
  772. .RS 4
  773. .ie n \{\
  774. \h'-04'\(bu\h'+03'\c
  775. .\}
  776. .el \{\
  777. .sp -1
  778. .IP \(bu 2.3
  779. .\}
  780. .\" mysql: quick option
  781. .\" quick option: mysql
  782. \fB\-\-quick\fR,
  783. \fB\-q\fR
  784. .sp
  785. Do not cache each query result, print each row as it is received\&. This may slow down the server if the output is suspended\&. With this option,
  786. \fBmysql\fR
  787. does not use the history file\&.
  788. .RE
  789. .sp
  790. .RS 4
  791. .ie n \{\
  792. \h'-04'\(bu\h'+03'\c
  793. .\}
  794. .el \{\
  795. .sp -1
  796. .IP \(bu 2.3
  797. .\}
  798. .\" mysql: raw option
  799. .\" raw option: mysql
  800. \fB\-\-raw\fR,
  801. \fB\-r\fR
  802. .sp
  803. For tabular output, the
  804. \(lqboxing\(rq
  805. around columns enables one column value to be distinguished from another\&. For nontabular output (such as is produced in batch mode or when the
  806. \fB\-\-batch\fR
  807. or
  808. \fB\-\-silent\fR
  809. option is given), special characters are escaped in the output so they can be identified easily\&. Newline, tab,
  810. NUL, and backslash are written as
  811. \en,
  812. \et,
  813. \e0, and
  814. \e\e\&. The
  815. \fB\-\-raw\fR
  816. option disables this character escaping\&.
  817. .sp
  818. The following example demonstrates tabular versus nontabular output and the use of raw mode to disable escaping:
  819. .sp
  820. .if n \{\
  821. .RS 4
  822. .\}
  823. .nf
  824. % \fBmysql\fR
  825. mysql> SELECT CHAR(92);
  826. +\-\-\-\-\-\-\-\-\-\-+
  827. | CHAR(92) |
  828. +\-\-\-\-\-\-\-\-\-\-+
  829. | \e |
  830. +\-\-\-\-\-\-\-\-\-\-+
  831. % \fBmysql \-s\fR
  832. mysql> SELECT CHAR(92);
  833. CHAR(92)
  834. \e\e
  835. % \fBmysql \-s \-r\fR
  836. mysql> SELECT CHAR(92);
  837. CHAR(92)
  838. \e
  839. .fi
  840. .if n \{\
  841. .RE
  842. .\}
  843. .RE
  844. .sp
  845. .RS 4
  846. .ie n \{\
  847. \h'-04'\(bu\h'+03'\c
  848. .\}
  849. .el \{\
  850. .sp -1
  851. .IP \(bu 2.3
  852. .\}
  853. .\" mysql: reconnect option
  854. .\" reconnect option: mysql
  855. \fB\-\-reconnect\fR
  856. .sp
  857. If the connection to the server is lost, automatically try to reconnect\&. A single reconnect attempt is made each time the connection is lost\&. To suppress reconnection behavior, use
  858. \fB\-\-skip\-reconnect\fR\&.
  859. .RE
  860. .sp
  861. .RS 4
  862. .ie n \{\
  863. \h'-04'\(bu\h'+03'\c
  864. .\}
  865. .el \{\
  866. .sp -1
  867. .IP \(bu 2.3
  868. .\}
  869. .\" mysql: safe-updates option
  870. .\" safe-updates option: mysql
  871. .\" mysql: i-am-a-dummy option
  872. .\" i-am-a-dummy option: mysql
  873. \fB\-\-safe\-updates\fR,
  874. \fB\-\-i\-am\-a\-dummy\fR,
  875. \fB\-U\fR
  876. .sp
  877. Allow only those
  878. UPDATE
  879. and
  880. DELETE
  881. statements that specify which rows to modify by using key values\&. If you have set this option in an option file, you can override it by using
  882. \fB\-\-safe\-updates\fR
  883. on the command line\&. See
  884. the section called \(lqMYSQL TIPS\(rq, for more information about this option\&.
  885. .RE
  886. .sp
  887. .RS 4
  888. .ie n \{\
  889. \h'-04'\(bu\h'+03'\c
  890. .\}
  891. .el \{\
  892. .sp -1
  893. .IP \(bu 2.3
  894. .\}
  895. .\" mysql: secure-auth option
  896. .\" secure-auth option: mysql
  897. \fB\-\-secure\-auth\fR
  898. .sp
  899. Do not send passwords to the server in old (pre\-4\&.1\&.1) format\&. This prevents connections except for servers that use the newer password format\&.
  900. .RE
  901. .sp
  902. .RS 4
  903. .ie n \{\
  904. \h'-04'\(bu\h'+03'\c
  905. .\}
  906. .el \{\
  907. .sp -1
  908. .IP \(bu 2.3
  909. .\}
  910. .\" mysql: show-warnings option
  911. .\" show-warnings option: mysql
  912. \fB\-\-show\-warnings\fR
  913. .sp
  914. Cause warnings to be shown after each statement if there are any\&. This option applies to interactive and batch mode\&.
  915. .RE
  916. .sp
  917. .RS 4
  918. .ie n \{\
  919. \h'-04'\(bu\h'+03'\c
  920. .\}
  921. .el \{\
  922. .sp -1
  923. .IP \(bu 2.3
  924. .\}
  925. .\" mysql: sigint-ignore option
  926. .\" sigint-ignore option: mysql
  927. \fB\-\-sigint\-ignore\fR
  928. .sp
  929. Ignore
  930. SIGINT
  931. signals (typically the result of typing Control\-C)\&.
  932. .RE
  933. .sp
  934. .RS 4
  935. .ie n \{\
  936. \h'-04'\(bu\h'+03'\c
  937. .\}
  938. .el \{\
  939. .sp -1
  940. .IP \(bu 2.3
  941. .\}
  942. .\" mysql: silent option
  943. .\" silent option: mysql
  944. \fB\-\-silent\fR,
  945. \fB\-s\fR
  946. .sp
  947. Silent mode\&. Produce less output\&. This option can be given multiple times to produce less and less output\&.
  948. .sp
  949. This option results in nontabular output format and escaping of special characters\&. Escaping may be disabled by using raw mode; see the description for the
  950. \fB\-\-raw\fR
  951. option\&.
  952. .RE
  953. .sp
  954. .RS 4
  955. .ie n \{\
  956. \h'-04'\(bu\h'+03'\c
  957. .\}
  958. .el \{\
  959. .sp -1
  960. .IP \(bu 2.3
  961. .\}
  962. .\" mysql: skip-column-names option
  963. .\" skip-column-names option: mysql
  964. \fB\-\-skip\-column\-names\fR,
  965. \fB\-N\fR
  966. .sp
  967. Do not write column names in results\&.
  968. .RE
  969. .sp
  970. .RS 4
  971. .ie n \{\
  972. \h'-04'\(bu\h'+03'\c
  973. .\}
  974. .el \{\
  975. .sp -1
  976. .IP \(bu 2.3
  977. .\}
  978. .\" mysql: skip-line-numbers option
  979. .\" skip-line-numbers option: mysql
  980. \fB\-\-skip\-line\-numbers\fR,
  981. \fB\-L\fR
  982. .sp
  983. Do not write line numbers for errors\&. Useful when you want to compare result files that include error messages\&.
  984. .RE
  985. .sp
  986. .RS 4
  987. .ie n \{\
  988. \h'-04'\(bu\h'+03'\c
  989. .\}
  990. .el \{\
  991. .sp -1
  992. .IP \(bu 2.3
  993. .\}
  994. .\" mysql: socket option
  995. .\" socket option: mysql
  996. \fB\-\-socket=\fR\fB\fIpath\fR\fR,
  997. \fB\-S \fR\fB\fIpath\fR\fR
  998. .sp
  999. For connections to
  1000. localhost, the Unix socket file to use, or, on Windows, the name of the named pipe to use\&.
  1001. .RE
  1002. .sp
  1003. .RS 4
  1004. .ie n \{\
  1005. \h'-04'\(bu\h'+03'\c
  1006. .\}
  1007. .el \{\
  1008. .sp -1
  1009. .IP \(bu 2.3
  1010. .\}
  1011. .\" mysql: SSL options
  1012. .\" SSL options: mysql
  1013. \fB\-\-ssl*\fR
  1014. .sp
  1015. Options that begin with
  1016. \fB\-\-ssl\fR
  1017. specify whether to connect to the server via SSL and indicate where to find SSL keys and certificates\&. See
  1018. Section\ \&5.5.6.3, \(lqSSL Command Options\(rq\&.
  1019. .RE
  1020. .sp
  1021. .RS 4
  1022. .ie n \{\
  1023. \h'-04'\(bu\h'+03'\c
  1024. .\}
  1025. .el \{\
  1026. .sp -1
  1027. .IP \(bu 2.3
  1028. .\}
  1029. .\" mysql: table option
  1030. .\" table option: mysql
  1031. \fB\-\-table\fR,
  1032. \fB\-t\fR
  1033. .sp
  1034. Display output in table format\&. This is the default for interactive use, but can be used to produce table output in batch mode\&.
  1035. .RE
  1036. .sp
  1037. .RS 4
  1038. .ie n \{\
  1039. \h'-04'\(bu\h'+03'\c
  1040. .\}
  1041. .el \{\
  1042. .sp -1
  1043. .IP \(bu 2.3
  1044. .\}
  1045. .\" mysql: tee option
  1046. .\" tee option: mysql
  1047. \fB\-\-tee=\fR\fB\fIfile_name\fR\fR
  1048. .sp
  1049. Append a copy of output to the given file\&. This option works only in interactive mode\&.
  1050. the section called \(lqMYSQL COMMANDS\(rq, discusses tee files further\&.
  1051. .RE
  1052. .sp
  1053. .RS 4
  1054. .ie n \{\
  1055. \h'-04'\(bu\h'+03'\c
  1056. .\}
  1057. .el \{\
  1058. .sp -1
  1059. .IP \(bu 2.3
  1060. .\}
  1061. .\" mysql: unbuffered option
  1062. .\" unbuffered option: mysql
  1063. \fB\-\-unbuffered\fR,
  1064. \fB\-n\fR
  1065. .sp
  1066. Flush the buffer after each query\&.
  1067. .RE
  1068. .sp
  1069. .RS 4
  1070. .ie n \{\
  1071. \h'-04'\(bu\h'+03'\c
  1072. .\}
  1073. .el \{\
  1074. .sp -1
  1075. .IP \(bu 2.3
  1076. .\}
  1077. .\" mysql: user option
  1078. .\" user option: mysql
  1079. \fB\-\-user=\fR\fB\fIuser_name\fR\fR,
  1080. \fB\-u \fR\fB\fIuser_name\fR\fR
  1081. .sp
  1082. The MySQL user name to use when connecting to the server\&.
  1083. .RE
  1084. .sp
  1085. .RS 4
  1086. .ie n \{\
  1087. \h'-04'\(bu\h'+03'\c
  1088. .\}
  1089. .el \{\
  1090. .sp -1
  1091. .IP \(bu 2.3
  1092. .\}
  1093. .\" mysql: verbose option
  1094. .\" verbose option: mysql
  1095. \fB\-\-verbose\fR,
  1096. \fB\-v\fR
  1097. .sp
  1098. Verbose mode\&. Produce more output about what the program does\&. This option can be given multiple times to produce more and more output\&. (For example,
  1099. \fB\-v \-v \-v\fR
  1100. produces table output format even in batch mode\&.)
  1101. .RE
  1102. .sp
  1103. .RS 4
  1104. .ie n \{\
  1105. \h'-04'\(bu\h'+03'\c
  1106. .\}
  1107. .el \{\
  1108. .sp -1
  1109. .IP \(bu 2.3
  1110. .\}
  1111. .\" mysql: version option
  1112. .\" version option: mysql
  1113. \fB\-\-version\fR,
  1114. \fB\-V\fR
  1115. .sp
  1116. Display version information and exit\&.
  1117. .RE
  1118. .sp
  1119. .RS 4
  1120. .ie n \{\
  1121. \h'-04'\(bu\h'+03'\c
  1122. .\}
  1123. .el \{\
  1124. .sp -1
  1125. .IP \(bu 2.3
  1126. .\}
  1127. .\" mysql: vertical option
  1128. .\" vertical option: mysql
  1129. \fB\-\-vertical\fR,
  1130. \fB\-E\fR
  1131. .sp
  1132. Print query output rows vertically (one line per column value)\&. Without this option, you can specify vertical output for individual statements by terminating them with
  1133. \eG\&.
  1134. .RE
  1135. .sp
  1136. .RS 4
  1137. .ie n \{\
  1138. \h'-04'\(bu\h'+03'\c
  1139. .\}
  1140. .el \{\
  1141. .sp -1
  1142. .IP \(bu 2.3
  1143. .\}
  1144. .\" mysql: wait option
  1145. .\" wait option: mysql
  1146. \fB\-\-wait\fR,
  1147. \fB\-w\fR
  1148. .sp
  1149. If the connection cannot be established, wait and retry instead of aborting\&.
  1150. .RE
  1151. .sp
  1152. .RS 4
  1153. .ie n \{\
  1154. \h'-04'\(bu\h'+03'\c
  1155. .\}
  1156. .el \{\
  1157. .sp -1
  1158. .IP \(bu 2.3
  1159. .\}
  1160. .\" mysql: xml option
  1161. .\" xml option: mysql
  1162. \fB\-\-xml\fR,
  1163. \fB\-X\fR
  1164. .sp
  1165. Produce XML output\&.
  1166. .if n \{\
  1167. .sp
  1168. .\}
  1169. .RS 4
  1170. .it 1 an-trap
  1171. .nr an-no-space-flag 1
  1172. .nr an-break-flag 1
  1173. .br
  1174. .ps +1
  1175. \fBNote\fR
  1176. .ps -1
  1177. .br
  1178. Prior to MySQL 5\&.1\&.12, there was no differentiation in the output when using this option between columns containing the
  1179. NULL
  1180. value and columns containing the string literal
  1181. \'NULL\'; both were represented as
  1182. .sp .5v
  1183. .RE
  1184. .sp
  1185. .if n \{\
  1186. .RS 4
  1187. .\}
  1188. .nf
  1189. <field name="\fIcolumn_name\fR">NULL</field>
  1190. .fi
  1191. .if n \{\
  1192. .RE
  1193. .\}
  1194. .sp
  1195. Beginning with MySQL 5\&.1\&.12, the output when
  1196. \fB\-\-xml\fR
  1197. is used with
  1198. \fBmysql\fR
  1199. matches that of
  1200. \fBmysqldump \fR\fB\fB\-\-xml\fR\fR\&. See
  1201. \fBmysqldump\fR(1)
  1202. for details\&.
  1203. .sp
  1204. Beginning with MySQL 5\&.1\&.18, the XML output also uses an XML namespace, as shown here:
  1205. .sp
  1206. .if n \{\
  1207. .RS 4
  1208. .\}
  1209. .nf
  1210. shell> \fBmysql \-\-xml \-uroot \-e "SHOW VARIABLES LIKE \'version%\'"\fR
  1211. <?xml version="1\&.0"?>
  1212. <resultset statement="SHOW VARIABLES LIKE \'version%\'" xmlns:xsi="http://www\&.w3\&.org/2001/XMLSchema\-instance">
  1213. <row>
  1214. <field name="Variable_name">version</field>
  1215. <field name="Value">5\&.0\&.40\-debug</field>
  1216. </row>
  1217. <row>
  1218. <field name="Variable_name">version_comment</field>
  1219. <field name="Value">Source distribution</field>
  1220. </row>
  1221. <row>
  1222. <field name="Variable_name">version_compile_machine</field>
  1223. <field name="Value">i686</field>
  1224. </row>
  1225. <row>
  1226. <field name="Variable_name">version_compile_os</field>
  1227. <field name="Value">suse\-linux\-gnu</field>
  1228. </row>
  1229. </resultset>
  1230. .fi
  1231. .if n \{\
  1232. .RE
  1233. .\}
  1234. .sp
  1235. (See
  1236. \m[blue]\fBBug#25946\fR\m[]\&\s-2\u[1]\d\s+2\&.)
  1237. .RE
  1238. .PP
  1239. You can also set the following variables by using
  1240. \fB\-\-\fR\fB\fIvar_name\fR\fR\fB=\fR\fB\fIvalue\fR\fR\&. The
  1241. \fB\-\-set\-variable\fR
  1242. format is deprecated and is removed in MySQL 5\&.5\&.
  1243. .sp
  1244. .RS 4
  1245. .ie n \{\
  1246. \h'-04'\(bu\h'+03'\c
  1247. .\}
  1248. .el \{\
  1249. .sp -1
  1250. .IP \(bu 2.3
  1251. .\}
  1252. .\" timeout: connect_timeout variable
  1253. .\" connect_timeout variable
  1254. connect_timeout
  1255. .sp
  1256. The number of seconds before connection timeout\&. (Default value is
  1257. 0\&.)
  1258. .RE
  1259. .sp
  1260. .RS 4
  1261. .ie n \{\
  1262. \h'-04'\(bu\h'+03'\c
  1263. .\}
  1264. .el \{\
  1265. .sp -1
  1266. .IP \(bu 2.3
  1267. .\}
  1268. .\" max_allowed_packet variable
  1269. max_allowed_packet
  1270. .sp
  1271. The maximum packet length to send to or receive from the server\&. (Default value is 16MB\&.)
  1272. .RE
  1273. .sp
  1274. .RS 4
  1275. .ie n \{\
  1276. \h'-04'\(bu\h'+03'\c
  1277. .\}
  1278. .el \{\
  1279. .sp -1
  1280. .IP \(bu 2.3
  1281. .\}
  1282. .\" max_join_size variable
  1283. max_join_size
  1284. .sp
  1285. The automatic limit for rows in a join when using
  1286. \fB\-\-safe\-updates\fR\&. (Default value is 1,000,000\&.)
  1287. .RE
  1288. .sp
  1289. .RS 4
  1290. .ie n \{\
  1291. \h'-04'\(bu\h'+03'\c
  1292. .\}
  1293. .el \{\
  1294. .sp -1
  1295. .IP \(bu 2.3
  1296. .\}
  1297. .\" net_buffer_length variable
  1298. net_buffer_length
  1299. .sp
  1300. The buffer size for TCP/IP and socket communication\&. (Default value is 16KB\&.)
  1301. .RE
  1302. .sp
  1303. .RS 4
  1304. .ie n \{\
  1305. \h'-04'\(bu\h'+03'\c
  1306. .\}
  1307. .el \{\
  1308. .sp -1
  1309. .IP \(bu 2.3
  1310. .\}
  1311. .\" select_limit variable
  1312. select_limit
  1313. .sp
  1314. The automatic limit for
  1315. SELECT
  1316. statements when using
  1317. \fB\-\-safe\-updates\fR\&. (Default value is 1,000\&.)
  1318. .RE
  1319. .\" MYSQL_HISTFILE environment variable
  1320. .\" environment variable: MYSQL_HISTFILE
  1321. .\" HOME environment variable
  1322. .\" environment variable: HOME
  1323. .\" mysql history file
  1324. .\" command-line history: mysql
  1325. .\" .mysql_history file
  1326. .PP
  1327. On Unix, the
  1328. \fBmysql\fR
  1329. client writes a record of executed statements to a history file\&. By default, this file is named
  1330. \&.mysql_history
  1331. and is created in your home directory\&. To specify a different file, set the value of the
  1332. MYSQL_HISTFILE
  1333. environment variable\&.
  1334. .PP
  1335. The
  1336. \&.mysql_history
  1337. 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
  1338. Section\ \&5.3.2.2, \(lqEnd-User Guidelines for Password Security\(rq\&.
  1339. .PP
  1340. If you do not want to maintain a history file, first remove
  1341. \&.mysql_history
  1342. if it exists, and then use either of the following techniques:
  1343. .sp
  1344. .RS 4
  1345. .ie n \{\
  1346. \h'-04'\(bu\h'+03'\c
  1347. .\}
  1348. .el \{\
  1349. .sp -1
  1350. .IP \(bu 2.3
  1351. .\}
  1352. Set the
  1353. MYSQL_HISTFILE
  1354. variable to
  1355. /dev/null\&. To cause this setting to take effect each time you log in, put the setting in one of your shell\'s startup files\&.
  1356. .RE
  1357. .sp
  1358. .RS 4
  1359. .ie n \{\
  1360. \h'-04'\(bu\h'+03'\c
  1361. .\}
  1362. .el \{\
  1363. .sp -1
  1364. .IP \(bu 2.3
  1365. .\}
  1366. Create
  1367. \&.mysql_history
  1368. as a symbolic link to
  1369. /dev/null:
  1370. .sp
  1371. .if n \{\
  1372. .RS 4
  1373. .\}
  1374. .nf
  1375. shell> \fBln \-s /dev/null $HOME/\&.mysql_history\fR
  1376. .fi
  1377. .if n \{\
  1378. .RE
  1379. .\}
  1380. .sp
  1381. You need do this only once\&.
  1382. .RE
  1383. .SH "MYSQL COMMANDS"
  1384. .PP
  1385. \fBmysql\fR
  1386. sends each SQL statement that you issue to the server to be executed\&. There is also a set of commands that
  1387. \fBmysql\fR
  1388. itself interprets\&. For a list of these commands, type
  1389. help
  1390. or
  1391. \eh
  1392. at the
  1393. mysql>
  1394. prompt:
  1395. .\" mysql commands: list of
  1396. .sp
  1397. .if n \{\
  1398. .RS 4
  1399. .\}
  1400. .nf
  1401. mysql> \fBhelp\fR
  1402. List of all MySQL commands:
  1403. Note that all text commands must be first on line and end with \';\'
  1404. ? (\e?) Synonym for `help\'\&.
  1405. clear (\ec) Clear command\&.
  1406. connect (\er) Reconnect to the server\&. Optional arguments are db and host\&.
  1407. delimiter (\ed) Set statement delimiter\&.
  1408. edit (\ee) Edit command with $EDITOR\&.
  1409. ego (\eG) Send command to mysql server, display result vertically\&.
  1410. exit (\eq) Exit mysql\&. Same as quit\&.
  1411. go (\eg) Send command to mysql server\&.
  1412. help (\eh) Display this help\&.
  1413. nopager (\en) Disable pager, print to stdout\&.
  1414. notee (\et) Don\'t write into outfile\&.
  1415. pager (\eP) Set PAGER [to_pager]\&. Print the query results via PAGER\&.
  1416. print (\ep) Print current command\&.
  1417. prompt (\eR) Change your mysql prompt\&.
  1418. quit (\eq) Quit mysql\&.
  1419. rehash (\e#) Rebuild completion hash\&.
  1420. source (\e\&.) Execute an SQL script file\&. Takes a file name as an argument\&.
  1421. status (\es) Get status information from the server\&.
  1422. system (\e!) Execute a system shell command\&.
  1423. tee (\eT) Set outfile [to_outfile]\&. Append everything into given
  1424. outfile\&.
  1425. use (\eu) Use another database\&. Takes database name as argument\&.
  1426. charset (\eC) Switch to another charset\&. Might be needed for processing
  1427. binlog with multi\-byte charsets\&.
  1428. warnings (\eW) Show warnings after every statement\&.
  1429. nowarning (\ew) Don\'t show warnings after every statement\&.
  1430. For server side help, type \'help contents\'
  1431. .fi
  1432. .if n \{\
  1433. .RE
  1434. .\}
  1435. .PP
  1436. Each command has both a long and short form\&. The long form is not case sensitive; the short form is\&. The long form can be followed by an optional semicolon terminator, but the short form should not\&.
  1437. .PP
  1438. The use of short\-form commands within multi\-line
  1439. /* \&.\&.\&. */
  1440. comments is not supported\&.
  1441. .sp
  1442. .RS 4
  1443. .ie n \{\
  1444. \h'-04'\(bu\h'+03'\c
  1445. .\}
  1446. .el \{\
  1447. .sp -1
  1448. .IP \(bu 2.3
  1449. .\}
  1450. .\" mysql: help command
  1451. .\" help command: mysql
  1452. \fBhelp [\fR\fB\fIarg\fR\fR\fB]\fR,
  1453. \fB\eh [\fR\fB\fIarg\fR\fR\fB]\fR,
  1454. \fB\e? [\fR\fB\fIarg\fR\fR\fB]\fR,
  1455. \fB? [\fR\fB\fIarg\fR\fR\fB]\fR
  1456. .sp
  1457. Display a help message listing the available
  1458. \fBmysql\fR
  1459. commands\&.
  1460. .sp
  1461. If you provide an argument to the
  1462. help
  1463. command,
  1464. \fBmysql\fR
  1465. uses it as a search string to access server\-side help from the contents of the MySQL Reference Manual\&. For more information, see
  1466. the section called \(lqMYSQL SERVER-SIDE HELP\(rq\&.
  1467. .RE
  1468. .sp
  1469. .RS 4
  1470. .ie n \{\
  1471. \h'-04'\(bu\h'+03'\c
  1472. .\}
  1473. .el \{\
  1474. .sp -1
  1475. .IP \(bu 2.3
  1476. .\}
  1477. .\" mysql: charset command
  1478. .\" charset command: mysql
  1479. \fBcharset \fR\fB\fIcharset_name\fR\fR,
  1480. \fB\eC \fR\fB\fIcharset_name\fR\fR
  1481. .sp
  1482. Change the default character set and issue a
  1483. SET NAMES
  1484. statement\&. This enables the character set to remain synchronized on the client and server if
  1485. \fBmysql\fR
  1486. is run with auto\-reconnect enabled (which is not recommended), because the specified character set is used for reconnects\&. This command was added in MySQL 5\&.1\&.7\&.
  1487. .RE
  1488. .sp
  1489. .RS 4
  1490. .ie n \{\
  1491. \h'-04'\(bu\h'+03'\c
  1492. .\}
  1493. .el \{\
  1494. .sp -1
  1495. .IP \(bu 2.3
  1496. .\}
  1497. .\" mysql: clear command
  1498. .\" clear command: mysql
  1499. \fBclear\fR,
  1500. \fB\ec\fR
  1501. .sp
  1502. Clear the current input\&. Use this if you change your mind about executing the statement that you are entering\&.
  1503. .RE
  1504. .sp
  1505. .RS 4
  1506. .ie n \{\
  1507. \h'-04'\(bu\h'+03'\c
  1508. .\}
  1509. .el \{\
  1510. .sp -1
  1511. .IP \(bu 2.3
  1512. .\}
  1513. .\" mysql: connect command
  1514. .\" connect command: mysql
  1515. \fBconnect [\fR\fB\fIdb_name\fR\fR\fB \fR\fB\fIhost_name\fR\fR\fB]]\fR,
  1516. \fB\er [\fR\fB\fIdb_name\fR\fR\fB \fR\fB\fIhost_name\fR\fR\fB]]\fR
  1517. .sp
  1518. Reconnect to the server\&. The optional database name and host name arguments may be given to specify the default database or the host where the server is running\&. If omitted, the current values are used\&.
  1519. .RE
  1520. .sp
  1521. .RS 4
  1522. .ie n \{\
  1523. \h'-04'\(bu\h'+03'\c
  1524. .\}
  1525. .el \{\
  1526. .sp -1
  1527. .IP \(bu 2.3
  1528. .\}
  1529. .\" mysql: delimiter command
  1530. .\" delimiter command: mysql
  1531. \fBdelimiter \fR\fB\fIstr\fR\fR,
  1532. \fB\ed \fR\fB\fIstr\fR\fR
  1533. .sp
  1534. Change the string that
  1535. \fBmysql\fR
  1536. interprets as the separator between SQL statements\&. The default is the semicolon character (\(lq;\(rq)\&.
  1537. .sp
  1538. The delimiter can be specified as an unquoted or quoted argument\&. Quoting can be done with either single quote (\') or douple quote (") characters\&. To include a quote within a quoted string, either quote the string with the other quote character or escape the quote with a backslash (\(lq\e\(rq) character\&. Backslash should be avoided outside of quoted strings because it is the escape character for MySQL\&. For an unquoted argument, the delmiter is read up to the first space or end of line\&. For a quoted argument, the delimiter is read up to the matching quote on the line\&.
  1539. .sp
  1540. When the delimiter recognized by
  1541. \fBmysql\fR
  1542. is set to something other than the default of
  1543. \(lq;\(rq, instances of that character are sent to the server without interpretation\&. However, the server itself still interprets
  1544. \(lq;\(rq
  1545. as a statement delimiter and processes statements accordingly\&. This behavior on the server side comes into play for multiple\-statement execution (see
  1546. Section\ \&21.9.12, \(lqC API Support for Multiple Statement Execution\(rq), and for parsing the body of stored procedures and functions, triggers, and events (see
  1547. Section\ \&19.1, \(lqDefining Stored Programs\(rq)\&.
  1548. .RE
  1549. .sp
  1550. .RS 4
  1551. .ie n \{\
  1552. \h'-04'\(bu\h'+03'\c
  1553. .\}
  1554. .el \{\
  1555. .sp -1
  1556. .IP \(bu 2.3
  1557. .\}
  1558. .\" mysql: edit command
  1559. .\" edit command: mysql
  1560. \fBedit\fR,
  1561. \fB\ee\fR
  1562. .sp
  1563. Edit the current input statement\&.
  1564. \fBmysql\fR
  1565. checks the values of the
  1566. EDITOR
  1567. and
  1568. VISUAL
  1569. environment variables to determine which editor to use\&. The default editor is
  1570. \fBvi\fR
  1571. if neither variable is set\&.
  1572. .sp
  1573. The
  1574. \fBedit\fR
  1575. command works only in Unix\&.
  1576. .RE
  1577. .sp
  1578. .RS 4
  1579. .ie n \{\
  1580. \h'-04'\(bu\h'+03'\c
  1581. .\}
  1582. .el \{\
  1583. .sp -1
  1584. .IP \(bu 2.3
  1585. .\}
  1586. .\" mysql: ego command
  1587. .\" ego command: mysql
  1588. \fBego\fR,
  1589. \fB\eG\fR
  1590. .sp
  1591. Send the current statement to the server to be executed and display the result using vertical format\&.
  1592. .RE
  1593. .sp
  1594. .RS 4
  1595. .ie n \{\
  1596. \h'-04'\(bu\h'+03'\c
  1597. .\}
  1598. .el \{\
  1599. .sp -1
  1600. .IP \(bu 2.3
  1601. .\}
  1602. .\" mysql: exit command
  1603. .\" exit command: mysql
  1604. \fBexit\fR,
  1605. \fB\eq\fR
  1606. .sp
  1607. Exit
  1608. \fBmysql\fR\&.
  1609. .RE
  1610. .sp
  1611. .RS 4
  1612. .ie n \{\
  1613. \h'-04'\(bu\h'+03'\c
  1614. .\}
  1615. .el \{\
  1616. .sp -1
  1617. .IP \(bu 2.3
  1618. .\}
  1619. .\" mysql: go command
  1620. .\" go command: mysql
  1621. \fBgo\fR,
  1622. \fB\eg\fR
  1623. .sp
  1624. Send the current statement to the server to be executed\&.
  1625. .RE
  1626. .sp
  1627. .RS 4
  1628. .ie n \{\
  1629. \h'-04'\(bu\h'+03'\c
  1630. .\}
  1631. .el \{\
  1632. .sp -1
  1633. .IP \(bu 2.3
  1634. .\}
  1635. .\" mysql: nopager command
  1636. .\" nopager command: mysql
  1637. \fBnopager\fR,
  1638. \fB\en\fR
  1639. .sp
  1640. Disable output paging\&. See the description for
  1641. \fBpager\fR\&.
  1642. .sp
  1643. The
  1644. \fBnopager\fR
  1645. command works only in Unix\&.
  1646. .RE
  1647. .sp
  1648. .RS 4
  1649. .ie n \{\
  1650. \h'-04'\(bu\h'+03'\c
  1651. .\}
  1652. .el \{\
  1653. .sp -1
  1654. .IP \(bu 2.3
  1655. .\}
  1656. .\" mysql: notee command
  1657. .\" notee command: mysql
  1658. \fBnotee\fR,
  1659. \fB\et\fR
  1660. .sp
  1661. Disable output copying to the tee file\&. See the description for
  1662. \fBtee\fR\&.
  1663. .RE
  1664. .sp
  1665. .RS 4
  1666. .ie n \{\
  1667. \h'-04'\(bu\h'+03'\c
  1668. .\}
  1669. .el \{\
  1670. .sp -1
  1671. .IP \(bu 2.3
  1672. .\}
  1673. .\" mysql: nowarning command
  1674. .\" nowarning command: mysql
  1675. \fBnowarning\fR,
  1676. \fB\ew\fR
  1677. .sp
  1678. Enable display of warnings after each statement\&.
  1679. .RE
  1680. .sp
  1681. .RS 4
  1682. .ie n \{\
  1683. \h'-04'\(bu\h'+03'\c
  1684. .\}
  1685. .el \{\
  1686. .sp -1
  1687. .IP \(bu 2.3
  1688. .\}
  1689. .\" mysql: pager command
  1690. .\" pager command: mysql
  1691. \fBpager [\fR\fB\fIcommand\fR\fR\fB]\fR,
  1692. \fB\eP [\fR\fB\fIcommand\fR\fR\fB]\fR
  1693. .sp
  1694. Enable output paging\&. By using the
  1695. \fB\-\-pager\fR
  1696. option when you invoke
  1697. \fBmysql\fR, it is possible to browse or search query results in interactive mode with Unix programs such as
  1698. \fBless\fR,
  1699. \fBmore\fR, or any other similar program\&. If you specify no value for the option,
  1700. \fBmysql\fR
  1701. checks the value of the
  1702. PAGER
  1703. environment variable and sets the pager to that\&. Pager functionality works only in interactive mode\&.
  1704. .sp
  1705. Output paging can be enabled interactively with the
  1706. \fBpager\fR
  1707. command and disabled with
  1708. \fBnopager\fR\&. The command takes an optional argument; if given, the paging program is set to that\&. With no argument, the pager is set to the pager that was set on the command line, or
  1709. stdout
  1710. if no pager was specified\&.
  1711. .sp
  1712. Output paging works only in Unix because it uses the
  1713. popen()
  1714. function, which does not exist on Windows\&. For Windows, the
  1715. \fBtee\fR
  1716. option can be used instead to save query output, although it is not as convenient as
  1717. \fBpager\fR
  1718. for browsing output in some situations\&.
  1719. .RE
  1720. .sp
  1721. .RS 4
  1722. .ie n \{\
  1723. \h'-04'\(bu\h'+03'\c
  1724. .\}
  1725. .el \{\
  1726. .sp -1
  1727. .IP \(bu 2.3
  1728. .\}
  1729. .\" mysql: print command
  1730. .\" print command: mysql
  1731. \fBprint\fR,
  1732. \fB\ep\fR
  1733. .sp
  1734. Print the current input statement without executing it\&.
  1735. .RE
  1736. .sp
  1737. .RS 4
  1738. .ie n \{\
  1739. \h'-04'\(bu\h'+03'\c
  1740. .\}
  1741. .el \{\
  1742. .sp -1
  1743. .IP \(bu 2.3
  1744. .\}
  1745. .\" mysql: prompt command
  1746. .\" prompt command: mysql
  1747. \fBprompt [\fR\fB\fIstr\fR\fR\fB]\fR,
  1748. \fB\eR [\fR\fB\fIstr\fR\fR\fB]\fR
  1749. .sp
  1750. Reconfigure the
  1751. \fBmysql\fR
  1752. prompt to the given string\&. The special character sequences that can be used in the prompt are described later in this section\&.
  1753. .sp
  1754. If you specify the
  1755. prompt
  1756. command with no argument,
  1757. \fBmysql\fR
  1758. resets the prompt to the default of
  1759. mysql>\&.
  1760. .RE
  1761. .sp
  1762. .RS 4
  1763. .ie n \{\
  1764. \h'-04'\(bu\h'+03'\c
  1765. .\}
  1766. .el \{\
  1767. .sp -1
  1768. .IP \(bu 2.3
  1769. .\}
  1770. .\" mysql: quit command
  1771. .\" quit command: mysql
  1772. \fBquit\fR,
  1773. \fB\eq\fR
  1774. .sp
  1775. Exit
  1776. \fBmysql\fR\&.
  1777. .RE
  1778. .sp
  1779. .RS 4
  1780. .ie n \{\
  1781. \h'-04'\(bu\h'+03'\c
  1782. .\}
  1783. .el \{\
  1784. .sp -1
  1785. .IP \(bu 2.3
  1786. .\}
  1787. .\" mysql: rehash command
  1788. .\" rehash command: mysql
  1789. \fBrehash\fR,
  1790. \fB\e#\fR
  1791. .sp
  1792. Rebuild the completion hash that enables database, table, and column name completion while you are entering statements\&. (See the description for the
  1793. \fB\-\-auto\-rehash\fR
  1794. option\&.)
  1795. .RE
  1796. .sp
  1797. .RS 4
  1798. .ie n \{\
  1799. \h'-04'\(bu\h'+03'\c
  1800. .\}
  1801. .el \{\
  1802. .sp -1
  1803. .IP \(bu 2.3
  1804. .\}
  1805. .\" mysql: source command
  1806. .\" source command: mysql
  1807. \fBsource \fR\fB\fIfile_name\fR\fR,
  1808. \fB\e\&. \fR\fB\fIfile_name\fR\fR
  1809. .sp
  1810. Read the named file and executes the statements contained therein\&. On Windows, you can specify path name separators as
  1811. /
  1812. or
  1813. \e\e\&.
  1814. .RE
  1815. .sp
  1816. .RS 4
  1817. .ie n \{\
  1818. \h'-04'\(bu\h'+03'\c
  1819. .\}
  1820. .el \{\
  1821. .sp -1
  1822. .IP \(bu 2.3
  1823. .\}
  1824. .\" mysql: status command
  1825. .\" status command: mysql
  1826. \fBstatus\fR,
  1827. \fB\es\fR
  1828. .sp
  1829. Provide status information about the connection and the server you are using\&. If you are running in
  1830. \fB\-\-safe\-updates\fR
  1831. mode,
  1832. status
  1833. also prints the values for the
  1834. \fBmysql\fR
  1835. variables that affect your queries\&.
  1836. .RE
  1837. .sp
  1838. .RS 4
  1839. .ie n \{\
  1840. \h'-04'\(bu\h'+03'\c
  1841. .\}
  1842. .el \{\
  1843. .sp -1
  1844. .IP \(bu 2.3
  1845. .\}
  1846. .\" mysql: system command
  1847. .\" system command: mysql
  1848. \fBsystem \fR\fB\fIcommand\fR\fR,
  1849. \fB\e! \fR\fB\fIcommand\fR\fR
  1850. .sp
  1851. Execute the given command using your default command interpreter\&.
  1852. .sp
  1853. The
  1854. \fBsystem\fR
  1855. command works only in Unix\&.
  1856. .RE
  1857. .sp
  1858. .RS 4
  1859. .ie n \{\
  1860. \h'-04'\(bu\h'+03'\c
  1861. .\}
  1862. .el \{\
  1863. .sp -1
  1864. .IP \(bu 2.3
  1865. .\}
  1866. .\" mysql: tee command
  1867. .\" tee command: mysql
  1868. \fBtee [\fR\fB\fIfile_name\fR\fR\fB]\fR,
  1869. \fB\eT [\fR\fB\fIfile_name\fR\fR\fB]\fR
  1870. .sp
  1871. By using the
  1872. \fB\-\-tee\fR
  1873. option when you invoke
  1874. \fBmysql\fR, you can log statements and their output\&. All the data displayed on the screen is appended into a given file\&. This can be very useful for debugging purposes also\&.
  1875. \fBmysql\fR
  1876. flushes results to the file after each statement, just before it prints its next prompt\&. Tee functionality works only in interactive mode\&.
  1877. .sp
  1878. You can enable this feature interactively with the
  1879. \fBtee\fR
  1880. command\&. Without a parameter, the previous file is used\&. The
  1881. \fBtee\fR
  1882. file can be disabled with the
  1883. \fBnotee\fR
  1884. command\&. Executing
  1885. \fBtee\fR
  1886. again re\-enables logging\&.
  1887. .RE
  1888. .sp
  1889. .RS 4
  1890. .ie n \{\
  1891. \h'-04'\(bu\h'+03'\c
  1892. .\}
  1893. .el \{\
  1894. .sp -1
  1895. .IP \(bu 2.3
  1896. .\}
  1897. .\" mysql: use command
  1898. .\" use command: mysql
  1899. \fBuse \fR\fB\fIdb_name\fR\fR,
  1900. \fB\eu \fR\fB\fIdb_name\fR\fR
  1901. .sp
  1902. Use
  1903. \fIdb_name\fR
  1904. as the default database\&.
  1905. .RE
  1906. .sp
  1907. .RS 4
  1908. .ie n \{\
  1909. \h'-04'\(bu\h'+03'\c
  1910. .\}
  1911. .el \{\
  1912. .sp -1
  1913. .IP \(bu 2.3
  1914. .\}
  1915. .\" mysql: warnings command
  1916. .\" warnings command: mysql
  1917. \fBwarnings\fR,
  1918. \fB\eW\fR
  1919. .sp
  1920. Enable display of warnings after each statement (if there are any)\&.
  1921. .RE
  1922. .PP
  1923. Here are a few tips about the
  1924. \fBpager\fR
  1925. command:
  1926. .sp
  1927. .RS 4
  1928. .ie n \{\
  1929. \h'-04'\(bu\h'+03'\c
  1930. .\}
  1931. .el \{\
  1932. .sp -1
  1933. .IP \(bu 2.3
  1934. .\}
  1935. You can use it to write to a file and the results go only to the file:
  1936. .sp
  1937. .if n \{\
  1938. .RS 4
  1939. .\}
  1940. .nf
  1941. mysql> \fBpager cat > /tmp/log\&.txt\fR
  1942. .fi
  1943. .if n \{\
  1944. .RE
  1945. .\}
  1946. .sp
  1947. You can also pass any options for the program that you want to use as your pager:
  1948. .sp
  1949. .if n \{\
  1950. .RS 4
  1951. .\}
  1952. .nf
  1953. mysql> \fBpager less \-n \-i \-S\fR
  1954. .fi
  1955. .if n \{\
  1956. .RE
  1957. .\}
  1958. .RE
  1959. .sp
  1960. .RS 4
  1961. .ie n \{\
  1962. \h'-04'\(bu\h'+03'\c
  1963. .\}
  1964. .el \{\
  1965. .sp -1
  1966. .IP \(bu 2.3
  1967. .\}
  1968. In the preceding example, note the
  1969. \fB\-S\fR
  1970. option\&. You may find it very useful for browsing wide query results\&. Sometimes a very wide result set is difficult to read on the screen\&. The
  1971. \fB\-S\fR
  1972. option to
  1973. \fBless\fR
  1974. can make the result set much more readable because you can scroll it horizontally using the left\-arrow and right\-arrow keys\&. You can also use
  1975. \fB\-S\fR
  1976. interactively within
  1977. \fBless\fR
  1978. to switch the horizontal\-browse mode on and off\&. For more information, read the
  1979. \fBless\fR
  1980. manual page:
  1981. .sp
  1982. .if n \{\
  1983. .RS 4
  1984. .\}
  1985. .nf
  1986. shell> \fBman less\fR
  1987. .fi
  1988. .if n \{\
  1989. .RE
  1990. .\}
  1991. .RE
  1992. .sp
  1993. .RS 4
  1994. .ie n \{\
  1995. \h'-04'\(bu\h'+03'\c
  1996. .\}
  1997. .el \{\
  1998. .sp -1
  1999. .IP \(bu 2.3
  2000. .\}
  2001. The
  2002. \fB\-F\fR
  2003. and
  2004. \fB\-X\fR
  2005. options may be used with
  2006. \fBless\fR
  2007. to cause it to exit if output fits on one screen, which is convenient when no scrolling is necessary:
  2008. .sp
  2009. .if n \{\
  2010. .RS 4
  2011. .\}
  2012. .nf
  2013. mysql> \fBpager less \-n \-i \-S \-F \-X\fR
  2014. .fi
  2015. .if n \{\
  2016. .RE
  2017. .\}
  2018. .RE
  2019. .sp
  2020. .RS 4
  2021. .ie n \{\
  2022. \h'-04'\(bu\h'+03'\c
  2023. .\}
  2024. .el \{\
  2025. .sp -1
  2026. .IP \(bu 2.3
  2027. .\}
  2028. You can specify very complex pager commands for handling query output:
  2029. .sp
  2030. .if n \{\
  2031. .RS 4
  2032. .\}
  2033. .nf
  2034. mysql> \fBpager cat | tee /dr1/tmp/res\&.txt \e\fR
  2035. \fB| tee /dr2/tmp/res2\&.txt | less \-n \-i \-S\fR
  2036. .fi
  2037. .if n \{\
  2038. .RE
  2039. .\}
  2040. .sp
  2041. In this example, the command would send query results to two files in two different directories on two different file systems mounted on
  2042. /dr1
  2043. and
  2044. /dr2, yet still display the results onscreen via
  2045. \fBless\fR\&.
  2046. .RE
  2047. .PP
  2048. You can also combine the
  2049. \fBtee\fR
  2050. and
  2051. \fBpager\fR
  2052. functions\&. Have a
  2053. \fBtee\fR
  2054. file enabled and
  2055. \fBpager\fR
  2056. set to
  2057. \fBless\fR, and you are able to browse the results using the
  2058. \fBless\fR
  2059. program and still have everything appended into a file the same time\&. The difference between the Unix
  2060. \fBtee\fR
  2061. used with the
  2062. \fBpager\fR
  2063. command and the
  2064. \fBmysql\fR
  2065. built\-in
  2066. \fBtee\fR
  2067. command is that the built\-in
  2068. \fBtee\fR
  2069. works even if you do not have the Unix
  2070. \fBtee\fR
  2071. available\&. The built\-in
  2072. \fBtee\fR
  2073. also logs everything that is printed on the screen, whereas the Unix
  2074. \fBtee\fR
  2075. used with
  2076. \fBpager\fR
  2077. does not log quite that much\&. Additionally,
  2078. \fBtee\fR
  2079. file logging can be turned on and off interactively from within
  2080. \fBmysql\fR\&. This is useful when you want to log some queries to a file, but not others\&.
  2081. .\" mysql prompt command
  2082. .PP
  2083. The
  2084. \fBprompt\fR
  2085. command reconfigures the default
  2086. mysql>
  2087. prompt\&. The string for defining the prompt can contain the following special sequences\&.
  2088. .TS
  2089. allbox tab(:);
  2090. l l
  2091. l l
  2092. l l
  2093. l l
  2094. l l
  2095. l l
  2096. l l
  2097. l l
  2098. l l
  2099. l l
  2100. l l
  2101. l l
  2102. l l
  2103. l l
  2104. l l
  2105. l l
  2106. l l
  2107. l l
  2108. l l
  2109. l l
  2110. l l
  2111. l l
  2112. l l
  2113. l l
  2114. l l
  2115. l l
  2116. l l
  2117. l l
  2118. l l.
  2119. T{
  2120. \fBOption\fR
  2121. T}:T{
  2122. \fBDescription\fR
  2123. T}
  2124. T{
  2125. \ec
  2126. T}:T{
  2127. A counter that increments for each statement you issue
  2128. T}
  2129. T{
  2130. \eD
  2131. T}:T{
  2132. The full current date
  2133. T}
  2134. T{
  2135. \ed
  2136. T}:T{
  2137. The default database
  2138. T}
  2139. T{
  2140. \eh
  2141. T}:T{
  2142. The server host
  2143. T}
  2144. T{
  2145. \el
  2146. T}:T{
  2147. The current delimiter (new in 5\&.1\&.12)
  2148. T}
  2149. T{
  2150. \em
  2151. T}:T{
  2152. Minutes of the current time
  2153. T}
  2154. T{
  2155. \en
  2156. T}:T{
  2157. A newline character
  2158. T}
  2159. T{
  2160. \eO
  2161. T}:T{
  2162. The current month in three\-letter format (Jan, Feb, \&...)
  2163. T}
  2164. T{
  2165. \eo
  2166. T}:T{
  2167. The current month in numeric format
  2168. T}
  2169. T{
  2170. \eP
  2171. T}:T{
  2172. am/pm
  2173. T}
  2174. T{
  2175. \ep
  2176. T}:T{
  2177. The current TCP/IP port or socket file
  2178. T}
  2179. T{
  2180. \eR
  2181. T}:T{
  2182. The current time, in 24\-hour military time (0\(en23)
  2183. T}
  2184. T{
  2185. \er
  2186. T}:T{
  2187. The current time, standard 12\-hour time (1\(en12)
  2188. T}
  2189. T{
  2190. \eS
  2191. T}:T{
  2192. Semicolon
  2193. T}
  2194. T{
  2195. \es
  2196. T}:T{
  2197. Seconds of the current time
  2198. T}
  2199. T{
  2200. \et
  2201. T}:T{
  2202. A tab character
  2203. T}
  2204. T{
  2205. \eU
  2206. T}:T{
  2207. .PP
  2208. Your full
  2209. \fIuser_name\fR@\fIhost_name\fR
  2210. account name
  2211. T}
  2212. T{
  2213. \eu
  2214. T}:T{
  2215. Your user name
  2216. T}
  2217. T{
  2218. \ev
  2219. T}:T{
  2220. The server version
  2221. T}
  2222. T{
  2223. \ew
  2224. T}:T{
  2225. The current day of the week in three\-letter format (Mon, Tue, \&...)
  2226. T}
  2227. T{
  2228. \eY
  2229. T}:T{
  2230. The current year, four digits
  2231. T}
  2232. T{
  2233. \ey
  2234. T}:T{
  2235. The current year, two digits
  2236. T}
  2237. T{
  2238. \e_
  2239. T}:T{
  2240. A space
  2241. T}
  2242. T{
  2243. \e\ \&
  2244. T}:T{
  2245. A space (a space follows the backslash)
  2246. T}
  2247. T{
  2248. \e\'
  2249. T}:T{
  2250. Single quote
  2251. T}
  2252. T{
  2253. \e"
  2254. T}:T{
  2255. Double quote
  2256. T}
  2257. T{
  2258. \e\e
  2259. T}:T{
  2260. A literal \(lq\e\(rq backslash character
  2261. T}
  2262. T{
  2263. \e\fIx\fR
  2264. T}:T{
  2265. .PP
  2266. \fIx\fR, for any
  2267. \(lq\fIx\fR\(rq
  2268. not listed above
  2269. T}
  2270. .TE
  2271. .sp 1
  2272. .PP
  2273. You can set the prompt in several ways:
  2274. .sp
  2275. .RS 4
  2276. .ie n \{\
  2277. \h'-04'\(bu\h'+03'\c
  2278. .\}
  2279. .el \{\
  2280. .sp -1
  2281. .IP \(bu 2.3
  2282. .\}
  2283. \fIUse an environment variable\&.\fR
  2284. You can set the
  2285. MYSQL_PS1
  2286. environment variable to a prompt string\&. For example:
  2287. .sp
  2288. .if n \{\
  2289. .RS 4
  2290. .\}
  2291. .nf
  2292. shell> \fBexport MYSQL_PS1="(\eu@\eh) [\ed]> "\fR
  2293. .fi
  2294. .if n \{\
  2295. .RE
  2296. .\}
  2297. .RE
  2298. .sp
  2299. .RS 4
  2300. .ie n \{\
  2301. \h'-04'\(bu\h'+03'\c
  2302. .\}
  2303. .el \{\
  2304. .sp -1
  2305. .IP \(bu 2.3
  2306. .\}
  2307. \fIUse a command\-line option\&.\fR
  2308. You can set the
  2309. \fB\-\-prompt\fR
  2310. option on the command line to
  2311. \fBmysql\fR\&. For example:
  2312. .sp
  2313. .if n \{\
  2314. .RS 4
  2315. .\}
  2316. .nf
  2317. shell> \fBmysql \-\-prompt="(\eu@\eh) [\ed]> "\fR
  2318. (user@host) [database]>
  2319. .fi
  2320. .if n \{\
  2321. .RE
  2322. .\}
  2323. .RE
  2324. .sp
  2325. .RS 4
  2326. .ie n \{\
  2327. \h'-04'\(bu\h'+03'\c
  2328. .\}
  2329. .el \{\
  2330. .sp -1
  2331. .IP \(bu 2.3
  2332. .\}
  2333. \fIUse an option file\&.\fR
  2334. You can set the
  2335. prompt
  2336. option in the
  2337. [mysql]
  2338. group of any MySQL option file, such as
  2339. /etc/my\&.cnf
  2340. or the
  2341. \&.my\&.cnf
  2342. file in your home directory\&. For example:
  2343. .sp
  2344. .if n \{\
  2345. .RS 4
  2346. .\}
  2347. .nf
  2348. [mysql]
  2349. prompt=(\e\eu@\e\eh) [\e\ed]>\e\e_
  2350. .fi
  2351. .if n \{\
  2352. .RE
  2353. .\}
  2354. .sp
  2355. In this example, note that the backslashes are doubled\&. If you set the prompt using the
  2356. prompt
  2357. 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 allowable 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
  2358. Section\ \&4.2.3.3, \(lqUsing Option Files\(rq\&.) The overlap may cause you problems if you use single backslashes\&. For example,
  2359. \es
  2360. 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
  2361. HH:MM:SS>
  2362. format:
  2363. .sp
  2364. .if n \{\
  2365. .RS 4
  2366. .\}
  2367. .nf
  2368. [mysql]
  2369. prompt="\e\er:\e\em:\e\es> "
  2370. .fi
  2371. .if n \{\
  2372. .RE
  2373. .\}
  2374. .RE
  2375. .sp
  2376. .RS 4
  2377. .ie n \{\
  2378. \h'-04'\(bu\h'+03'\c
  2379. .\}
  2380. .el \{\
  2381. .sp -1
  2382. .IP \(bu 2.3
  2383. .\}
  2384. \fISet the prompt interactively\&.\fR
  2385. You can change your prompt interactively by using the
  2386. prompt
  2387. (or
  2388. \eR) command\&. For example:
  2389. .sp
  2390. .if n \{\
  2391. .RS 4
  2392. .\}
  2393. .nf
  2394. mysql> \fBprompt (\eu@\eh) [\ed]>\e_\fR
  2395. PROMPT set to \'(\eu@\eh) [\ed]>\e_\'
  2396. (\fIuser\fR@\fIhost\fR) [\fIdatabase\fR]>
  2397. (\fIuser\fR@\fIhost\fR) [\fIdatabase\fR]> prompt
  2398. Returning to default PROMPT of mysql>
  2399. mysql>
  2400. .fi
  2401. .if n \{\
  2402. .RE
  2403. .\}
  2404. .RE
  2405. .SH "MYSQL SERVER-SIDE HELP"
  2406. .sp
  2407. .if n \{\
  2408. .RS 4
  2409. .\}
  2410. .nf
  2411. mysql> \fBhelp \fR\fB\fIsearch_string\fR\fR
  2412. .fi
  2413. .if n \{\
  2414. .RE
  2415. .\}
  2416. .PP
  2417. If you provide an argument to the
  2418. help
  2419. command,
  2420. \fBmysql\fR
  2421. uses it as a search string to access server\-side help from the contents of the MySQL Reference Manual\&. The proper operation of this command requires that the help tables in the
  2422. mysql
  2423. database be initialized with help topic information (see
  2424. Section\ \&5.1.9, \(lqServer-Side Help\(rq)\&.
  2425. .PP
  2426. If there is no match for the search string, the search fails:
  2427. .sp
  2428. .if n \{\
  2429. .RS 4
  2430. .\}
  2431. .nf
  2432. mysql> \fBhelp me\fR
  2433. Nothing found
  2434. Please try to run \'help contents\' for a list of all accessible topics
  2435. .fi
  2436. .if n \{\
  2437. .RE
  2438. .\}
  2439. .PP
  2440. Use
  2441. \fBhelp contents\fR
  2442. to see a list of the help categories:
  2443. .sp
  2444. .if n \{\
  2445. .RS 4
  2446. .\}
  2447. .nf
  2448. mysql> \fBhelp contents\fR
  2449. You asked for help about help category: "Contents"
  2450. For more information, type \'help <item>\', where <item> is one of the
  2451. following categories:
  2452. Account Management
  2453. Administration
  2454. Data Definition
  2455. Data Manipulation
  2456. Data Types
  2457. Functions
  2458. Functions and Modifiers for Use with GROUP BY
  2459. Geographic Features
  2460. Language Structure
  2461. Plugins
  2462. Storage Engines
  2463. Stored Routines
  2464. Table Maintenance
  2465. Transactions
  2466. Triggers
  2467. .fi
  2468. .if n \{\
  2469. .RE
  2470. .\}
  2471. .PP
  2472. If the search string matches multiple items,
  2473. \fBmysql\fR
  2474. shows a list of matching topics:
  2475. .sp
  2476. .if n \{\
  2477. .RS 4
  2478. .\}
  2479. .nf
  2480. mysql> \fBhelp logs\fR
  2481. Many help items for your request exist\&.
  2482. To make a more specific request, please type \'help <item>\',
  2483. where <item> is one of the following topics:
  2484. SHOW
  2485. SHOW BINARY LOGS
  2486. SHOW ENGINE
  2487. SHOW LOGS
  2488. .fi
  2489. .if n \{\
  2490. .RE
  2491. .\}
  2492. .PP
  2493. Use a topic as the search string to see the help entry for that topic:
  2494. .sp
  2495. .if n \{\
  2496. .RS 4
  2497. .\}
  2498. .nf
  2499. mysql> \fBhelp show binary logs\fR
  2500. Name: \'SHOW BINARY LOGS\'
  2501. Description:
  2502. Syntax:
  2503. SHOW BINARY LOGS
  2504. SHOW MASTER LOGS
  2505. Lists the binary log files on the server\&. This statement is used as
  2506. part of the procedure described in [purge\-binary\-logs], that shows how
  2507. to determine which logs can be purged\&.
  2508. mysql> SHOW BINARY LOGS;
  2509. +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-+
  2510. | Log_name | File_size |
  2511. +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-+
  2512. | binlog\&.000015 | 724935 |
  2513. | binlog\&.000016 | 733481 |
  2514. +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-+
  2515. .fi
  2516. .if n \{\
  2517. .RE
  2518. .\}
  2519. .SH "EXECUTING SQL STATEMENTS FROM A TEXT FILE"
  2520. .\" executing SQL statements from text files
  2521. .\" importing: data
  2522. .\" data: importing
  2523. .\" files: text
  2524. .\" text files: importing
  2525. .\" source (mysql client command)
  2526. .\" \. (mysql client command)
  2527. .\" mysql source (command for reading from text files)
  2528. .\" mysql \. (command for reading from text files)
  2529. .PP
  2530. The
  2531. \fBmysql\fR
  2532. client typically is used interactively, like this:
  2533. .sp
  2534. .if n \{\
  2535. .RS 4
  2536. .\}
  2537. .nf
  2538. shell> \fBmysql \fR\fB\fIdb_name\fR\fR
  2539. .fi
  2540. .if n \{\
  2541. .RE
  2542. .\}
  2543. .PP
  2544. However, it is also possible to put your SQL statements in a file and then tell
  2545. \fBmysql\fR
  2546. to read its input from that file\&. To do so, create a text file
  2547. \fItext_file\fR
  2548. that contains the statements you wish to execute\&. Then invoke
  2549. \fBmysql\fR
  2550. as shown here:
  2551. .sp
  2552. .if n \{\
  2553. .RS 4
  2554. .\}
  2555. .nf
  2556. shell> \fBmysql \fR\fB\fIdb_name\fR\fR\fB < \fR\fB\fItext_file\fR\fR
  2557. .fi
  2558. .if n \{\
  2559. .RE
  2560. .\}
  2561. .PP
  2562. If you place a
  2563. USE \fIdb_name\fR
  2564. statement as the first statement in the file, it is unnecessary to specify the database name on the command line:
  2565. .sp
  2566. .if n \{\
  2567. .RS 4
  2568. .\}
  2569. .nf
  2570. shell> \fBmysql < text_file\fR
  2571. .fi
  2572. .if n \{\
  2573. .RE
  2574. .\}
  2575. .PP
  2576. If you are already running
  2577. \fBmysql\fR, you can execute an SQL script file using the
  2578. source
  2579. command or
  2580. \e\&.
  2581. command:
  2582. .sp
  2583. .if n \{\
  2584. .RS 4
  2585. .\}
  2586. .nf
  2587. mysql> \fBsource \fR\fB\fIfile_name\fR\fR
  2588. mysql> \fB\e\&. \fR\fB\fIfile_name\fR\fR
  2589. .fi
  2590. .if n \{\
  2591. .RE
  2592. .\}
  2593. .PP
  2594. Sometimes you may want your script to display progress information to the user\&. For this you can insert statements like this:
  2595. .sp
  2596. .if n \{\
  2597. .RS 4
  2598. .\}
  2599. .nf
  2600. SELECT \'<info_to_display>\' AS \' \';
  2601. .fi
  2602. .if n \{\
  2603. .RE
  2604. .\}
  2605. .PP
  2606. The statement shown outputs
  2607. <info_to_display>\&.
  2608. .PP
  2609. You can also invoke
  2610. \fBmysql\fR
  2611. with the
  2612. \fB\-\-verbose\fR
  2613. option, which causes each statement to be displayed before the result that it produces\&.
  2614. .PP
  2615. As of MySQL 5\&.1\&.23,
  2616. \fBmysql\fR
  2617. ignores Unicode byte order mark (BOM) characters at the beginning of input files\&. Previously, it read them and sent them to the server, resulting in a syntax error\&. Presence of a BOM does not cause
  2618. \fBmysql\fR
  2619. to change its default character set\&. To do that, invoke
  2620. \fBmysql\fR
  2621. with an option such as
  2622. \fB\-\-default\-character\-set=utf8\fR\&.
  2623. .PP
  2624. For more information about batch mode, see
  2625. Section\ \&3.5, \(lqUsing mysql in Batch Mode\(rq\&.
  2626. .SH "MYSQL TIPS"
  2627. .PP
  2628. This section describes some techniques that can help you use
  2629. \fBmysql\fR
  2630. more effectively\&.
  2631. .SS "Displaying Query Results Vertically"
  2632. .PP
  2633. Some query results are much more readable when displayed vertically, instead of in the usual horizontal table format\&. Queries can be displayed vertically by terminating the query with \eG instead of a semicolon\&. For example, longer text values that include newlines often are much easier to read with vertical output:
  2634. .sp
  2635. .if n \{\
  2636. .RS 4
  2637. .\}
  2638. .nf
  2639. mysql> \fBSELECT * FROM mails WHERE LENGTH(txt) < 300 LIMIT 300,1\eG\fR
  2640. *************************** 1\&. row ***************************
  2641. msg_nro: 3068
  2642. date: 2000\-03\-01 23:29:50
  2643. time_zone: +0200
  2644. mail_from: Monty
  2645. reply: monty@no\&.spam\&.com
  2646. mail_to: "Thimble Smith" <tim@no\&.spam\&.com>
  2647. sbj: UTF\-8
  2648. txt: >>>>> "Thimble" == Thimble Smith writes:
  2649. Thimble> Hi\&. I think this is a good idea\&. Is anyone familiar
  2650. Thimble> with UTF\-8 or Unicode? Otherwise, I\'ll put this on my
  2651. Thimble> TODO list and see what happens\&.
  2652. Yes, please do that\&.
  2653. Regards,
  2654. Monty
  2655. file: inbox\-jani\-1
  2656. hash: 190402944
  2657. 1 row in set (0\&.09 sec)
  2658. .fi
  2659. .if n \{\
  2660. .RE
  2661. .\}
  2662. .SS "Using the \-\-safe\-updates Option"
  2663. .\" safe-updates option
  2664. .PP
  2665. For beginners, a useful startup option is
  2666. \fB\-\-safe\-updates\fR
  2667. (or
  2668. \fB\-\-i\-am\-a\-dummy\fR, which has the same effect)\&. It is helpful for cases when you might have issued a
  2669. DELETE FROM \fItbl_name\fR
  2670. statement but forgotten the
  2671. WHERE
  2672. clause\&. Normally, such a statement deletes all rows from the table\&. With
  2673. \fB\-\-safe\-updates\fR, you can delete rows only by specifying the key values that identify them\&. This helps prevent accidents\&.
  2674. .PP
  2675. When you use the
  2676. \fB\-\-safe\-updates\fR
  2677. option,
  2678. \fBmysql\fR
  2679. issues the following statement when it connects to the MySQL server:
  2680. .sp
  2681. .if n \{\
  2682. .RS 4
  2683. .\}
  2684. .nf
  2685. SET sql_safe_updates=1, sql_select_limit=1000, sql_max_join_size=1000000;
  2686. .fi
  2687. .if n \{\
  2688. .RE
  2689. .\}
  2690. .PP
  2691. See
  2692. Section\ \&5.1.5, \(lqSession System Variables\(rq\&.
  2693. .PP
  2694. The
  2695. SET
  2696. statement has the following effects:
  2697. .sp
  2698. .RS 4
  2699. .ie n \{\
  2700. \h'-04'\(bu\h'+03'\c
  2701. .\}
  2702. .el \{\
  2703. .sp -1
  2704. .IP \(bu 2.3
  2705. .\}
  2706. You are not allowed to execute an
  2707. UPDATE
  2708. or
  2709. DELETE
  2710. statement unless you specify a key constraint in the
  2711. WHERE
  2712. clause or provide a
  2713. LIMIT
  2714. clause (or both)\&. For example:
  2715. .sp
  2716. .if n \{\
  2717. .RS 4
  2718. .\}
  2719. .nf
  2720. UPDATE \fItbl_name\fR SET \fInot_key_column\fR=\fIval\fR WHERE \fIkey_column\fR=\fIval\fR;
  2721. UPDATE \fItbl_name\fR SET \fInot_key_column\fR=\fIval\fR LIMIT 1;
  2722. .fi
  2723. .if n \{\
  2724. .RE
  2725. .\}
  2726. .RE
  2727. .sp
  2728. .RS 4
  2729. .ie n \{\
  2730. \h'-04'\(bu\h'+03'\c
  2731. .\}
  2732. .el \{\
  2733. .sp -1
  2734. .IP \(bu 2.3
  2735. .\}
  2736. The server limits all large
  2737. SELECT
  2738. results to 1,000 rows unless the statement includes a
  2739. LIMIT
  2740. clause\&.
  2741. .RE
  2742. .sp
  2743. .RS 4
  2744. .ie n \{\
  2745. \h'-04'\(bu\h'+03'\c
  2746. .\}
  2747. .el \{\
  2748. .sp -1
  2749. .IP \(bu 2.3
  2750. .\}
  2751. The server aborts multiple\-table
  2752. SELECT
  2753. statements that probably need to examine more than 1,000,000 row combinations\&.
  2754. .RE
  2755. .PP
  2756. To specify limits different from 1,000 and 1,000,000, you can override the defaults by using the
  2757. \fB\-\-select_limit\fR
  2758. and
  2759. \fB\-\-max_join_size\fR
  2760. options:
  2761. .sp
  2762. .if n \{\
  2763. .RS 4
  2764. .\}
  2765. .nf
  2766. shell> \fBmysql \-\-safe\-updates \-\-select_limit=500 \-\-max_join_size=10000\fR
  2767. .fi
  2768. .if n \{\
  2769. .RE
  2770. .\}
  2771. .SS "Disabling mysql Auto\-Reconnect"
  2772. .PP
  2773. If the
  2774. \fBmysql\fR
  2775. client loses its connection to the server while sending a statement, it immediately and automatically tries to reconnect once to the server and send the statement again\&. However, even if
  2776. \fBmysql\fR
  2777. succeeds in reconnecting, your first connection has ended and all your previous session objects and settings are lost: temporary tables, the autocommit mode, and user\-defined and session variables\&. Also, any current transaction rolls back\&. This behavior may be dangerous for you, as in the following example where the server was shut down and restarted between the first and second statements without you knowing it:
  2778. .sp
  2779. .if n \{\
  2780. .RS 4
  2781. .\}
  2782. .nf
  2783. mysql> \fBSET @a=1;\fR
  2784. Query OK, 0 rows affected (0\&.05 sec)
  2785. mysql> \fBINSERT INTO t VALUES(@a);\fR
  2786. ERROR 2006: MySQL server has gone away
  2787. No connection\&. Trying to reconnect\&.\&.\&.
  2788. Connection id: 1
  2789. Current database: test
  2790. Query OK, 1 row affected (1\&.30 sec)
  2791. mysql> \fBSELECT * FROM t;\fR
  2792. +\-\-\-\-\-\-+
  2793. | a |
  2794. +\-\-\-\-\-\-+
  2795. | NULL |
  2796. +\-\-\-\-\-\-+
  2797. 1 row in set (0\&.05 sec)
  2798. .fi
  2799. .if n \{\
  2800. .RE
  2801. .\}
  2802. .PP
  2803. The
  2804. @a
  2805. user variable has been lost with the connection, and after the reconnection it is undefined\&. If it is important to have
  2806. \fBmysql\fR
  2807. terminate with an error if the connection has been lost, you can start the
  2808. \fBmysql\fR
  2809. client with the
  2810. \fB\-\-skip\-reconnect\fR
  2811. option\&.
  2812. .PP
  2813. For more information about auto\-reconnect and its effect on state information when a reconnection occurs, see
  2814. Section\ \&21.9.11, \(lqControlling Automatic Reconnection Behavior\(rq\&.
  2815. .SH "COPYRIGHT"
  2816. .br
  2817. .PP
  2818. Copyright 2007-2008 MySQL AB, 2008-2010 Sun Microsystems, Inc.
  2819. .PP
  2820. This documentation is free software; you can redistribute it and/or modify it only under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License.
  2821. .PP
  2822. This documentation is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  2823. .PP
  2824. You should have received a copy of the GNU General Public License along with the program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or see http://www.gnu.org/licenses/.
  2825. .sp
  2826. .SH "NOTES"
  2827. .IP " 1." 4
  2828. Bug#25946
  2829. .RS 4
  2830. \%http://bugs.mysql.com/bug.php?id=25946
  2831. .RE
  2832. .SH "SEE ALSO"
  2833. For more information, please refer to the MySQL Reference Manual,
  2834. which may already be installed locally and which is also available
  2835. online at http://dev.mysql.com/doc/.
  2836. .SH AUTHOR
  2837. Sun Microsystems, Inc. (http://www.mysql.com/).