Code which you issue in MySQL Shell is stored in the history, which can then be accessed using the up and down arrow keys. You can also search the history using the incremental history search feature. To search the history, use Ctrl+R to search backwards, or Ctrl+S to search forwards through the history. Once the search is active, typing characters searches for any strings that match them in the history and displays the first match. Use Ctrl+S or Ctrl+R to search for further matches to the current search term. Typing more characters further refines the search. During a search you can press the arrow keys to continue stepping through the history from the current search result. Press Enter to accept the displayed match. Use Ctrl+C to cancel the search.
history.maxSize MySQL Shell configuration
option sets the maximum number of entries to store in the history.
The default is 1000. If the number of history entries exceeds the
configured maximum, the oldest entries are removed and discarded.
If the maximum is set to 0, no history entries are stored.
By default the history is not saved between sessions, so when you
exit MySQL Shell the history of what you issued during the
current session is lost. You can save your history between
sessions by enabling the MySQL Shell
history.autoSave option. For example, to make
this change permanent issue:
mysqlsh-js> \option --persist history.autoSave=1
history.autoSave option is enabled the
history is stored in the MySQL Shell configuration path, which is
~/.mysqlsh directory on Linux and macOS,
%AppData%\MySQL\mysqlsh folder on
Windows. This path can be overridden on all platforms by defining
the environment variable
MYSQLSH_USER_CONFIG_HOME. The saved history is
created automatically by MySQL Shell and is readable only by the
owner user. If the history file cannot be read or written to,
MySQL Shell logs an error message and skips the read or write
operation. Prior to version 8.0.16, history entries were saved to
history file, which contained the
code issued in all of the MySQL Shell languages. In MySQL Shell
version 8.0.16 and later, the history is split per active language
and the files are named
Issuing the MySQL Shell
\history command shows
history entries in the order that they were issued, together with
their history entry number, which can be used with the
command. You can
manually delete individual history entries, a specified numeric
range of history entries, or the tail of the history. You can
\history clear to delete the entire
history manually. When you exit MySQL Shell, if the
history.autoSave configuration option has been
true, the history entries that remain in
the history file are saved, and their numbering is reset to start
at 1. If the
configuration option is set to
false, which is
the default, the history file is cleared.
Only code which you type interactively at the MySQL Shell prompt
is added to the history. Code that is executed indirectly or
internally, for example when the
command is executed, is not added to the history. When you issue
multi-line code, the new line characters are stripped in the
history entry. If the same code is issued multiple times it is
only stored in the history once, reducing duplication.
You can customize the entries that are added to the history using
--histignore command option. Additionally,
when using MySQL Shell in SQL mode, you can configure strings
which should not be added to the history. This history ignore list
is also applied when you use the
with a query to execute single SQL statements while another
language is active.
By default strings that match the glob patterns
not added to the history. To configure further strings to match
use either the
--histignore command option, or
Multiple strings can be specified, separated by a colon (:). The
history matching uses case-insensitive glob pattern like matching.
Supported wildcards are * (match any 0 or more characters) and ?
(match exactly 1 character). The default strings are specified as
Note that regardless of the filters set in the history ignore list, the last executed statement is always available to be recalled by pressing the Up arrow, so that you can make corrections without retyping all the input. If filtering applies to the last executed statement, it is removed from the history as soon as another statement is entered, or if you exit MySQL Shell immediately after executing the statement.