url
stringlengths 45
122
| content
stringlengths 380
3.07M
|
---|---|
https://dev.mysql.com/doc/refman/8.4/en/thread-pool-operation.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="thread-pool-operation">
</a>
7.6.3.3 Thread Pool Operation
</h4>
</div>
</div>
</div>
<p>
The thread pool consists of a number of thread groups, each of
which manages a set of client connections. As connections are
established, the thread pool assigns them to thread groups in
round-robin fashion.
</p>
<p>
The thread pool exposes system variables that may be used to
configure its operation:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="link" href="server-system-variables.html#sysvar_thread_pool_algorithm">
<code class="literal">
thread_pool_algorithm
</code>
</a>
: The
concurrency algorithm to use for scheduling.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="server-system-variables.html#sysvar_thread_pool_dedicated_listeners">
<code class="literal">
thread_pool_dedicated_listeners
</code>
</a>
:
Dedicates a listener thread in each thread group to listen
for incoming statements from connections assigned to the
group.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="server-system-variables.html#sysvar_thread_pool_high_priority_connection">
<code class="literal">
thread_pool_high_priority_connection
</code>
</a>
:
How to schedule statement execution for a session.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="server-system-variables.html#sysvar_thread_pool_longrun_trx_limit">
<code class="literal">
thread_pool_longrun_trx_limit
</code>
</a>
:
How long to wait while threads using all of
<a class="link" href="server-system-variables.html#sysvar_thread_pool_max_transactions_limit">
<code class="literal">
thread_pool_max_transactions_limit
</code>
</a>
have been executing before suspending the limit for the
group.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="server-system-variables.html#sysvar_thread_pool_max_active_query_threads">
<code class="literal">
thread_pool_max_active_query_threads
</code>
</a>
:
How many active threads per group to permit.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="server-system-variables.html#sysvar_thread_pool_max_transactions_limit">
<code class="literal">
thread_pool_max_transactions_limit
</code>
</a>
:
The maximum number of transactions permitted by the thread
pool plugin.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="server-system-variables.html#sysvar_thread_pool_max_unused_threads">
<code class="literal">
thread_pool_max_unused_threads
</code>
</a>
:
How many sleeping threads to permit.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="server-system-variables.html#sysvar_thread_pool_prio_kickup_timer">
<code class="literal">
thread_pool_prio_kickup_timer
</code>
</a>
:
How long before the thread pool moves a statement awaiting
execution from the low-priority queue to the high-priority
queue.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="server-system-variables.html#sysvar_thread_pool_query_threads_per_group">
<code class="literal">
thread_pool_query_threads_per_group
</code>
</a>
:
The number of query threads permitted in a thread group (the
default is a single query thread). Consider increasing the
value if you experience slower response times due to
long-running transactions.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="server-system-variables.html#sysvar_thread_pool_size">
<code class="literal">
thread_pool_size
</code>
</a>
: The
number of thread groups in the thread pool. This is the most
important parameter controlling thread pool performance.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="server-system-variables.html#sysvar_thread_pool_stall_limit">
<code class="literal">
thread_pool_stall_limit
</code>
</a>
:
The time before an executing statement is considered to be
stalled.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="server-system-variables.html#sysvar_thread_pool_transaction_delay">
<code class="literal">
thread_pool_transaction_delay
</code>
</a>
:
The delay period before starting a new transaction.
</p>
</li>
</ul>
</div>
<p>
To configure the number of thread groups, use the
<a class="link" href="server-system-variables.html#sysvar_thread_pool_size">
<code class="literal">
thread_pool_size
</code>
</a>
system
variable. The default number of groups is 16. For guidelines on
setting this variable, see
<a class="xref" href="thread-pool-tuning.html" title="7.6.3.4 Thread Pool Tuning">
Section 7.6.3.4, “Thread Pool Tuning”
</a>
.
</p>
<p>
The maximum number of threads per group is 4096 (or 4095 on some
systems where one thread is used internally).
</p>
<p>
The thread pool separates connections and threads, so there is
no fixed relationship between connections and the threads that
execute statements received from those connections. This differs
from the default thread-handling model that associates one
thread with one connection such that a given thread executes all
statements from its connection.
</p>
<p>
By default, the thread pool tries to ensure a maximum of one
thread executing in each group at any time, but sometimes
permits more threads to execute temporarily for best
performance:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Each thread group has a listener thread that listens for
incoming statements from the connections assigned to the
group. When a statement arrives, the thread group either
begins executing it immediately or queues it for later
execution:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
Immediate execution occurs if the statement is the only
one received, and there are no statements queued or
currently executing.
</p>
<p>
Immediate execution can be delayed by configuring
<code class="literal">
thread_pool_transaction_delay
</code>
, which
has a throttling effect on transactions. For more
information, refer to the description of this variable
in the discussion that follows.
</p>
</li>
<li class="listitem">
<p>
Queuing occurs if the statement cannot begin executing
immediately due to concurrently queued or executing
statements.
</p>
</li>
</ul>
</div>
</li>
<li class="listitem">
<p>
The
<a class="link" href="server-system-variables.html#sysvar_thread_pool_transaction_delay">
<code class="literal">
thread_pool_transaction_delay
</code>
</a>
variable specifies a transaction delay in milliseconds.
Worker threads sleep for the specified period before
executing a new transaction.
</p>
<p>
A transaction delay can be used in cases where parallel
transactions affect the performance of other operations due
to resource contention. For example, if parallel
transactions affect index creation or an online buffer pool
resizing operation, you can configure a transaction delay to
reduce resource contention while those operations are
running. The delay has a throttling effect on transactions.
</p>
<p>
The
<code class="literal">
thread_pool_transaction_delay
</code>
setting
does not affect queries issued from a privileged connection
(a connection assigned to the
<code class="literal">
Admin
</code>
thread group). These queries are not subject to a configured
transaction delay.
</p>
</li>
<li class="listitem">
<p>
If immediate execution occurs, the listener thread performs
it. (This means that temporarily no thread in the group is
listening.) If the statement finishes quickly, the executing
thread returns to listening for statements. Otherwise, the
thread pool considers the statement stalled and starts
another thread as a listener thread (creating it if
necessary). To ensure that no thread group becomes blocked
by stalled statements, the thread pool has a background
thread that regularly monitors thread group states.
</p>
<p>
By using the listening thread to execute a statement that
can begin immediately, there is no need to create an
additional thread if the statement finishes quickly. This
ensures the most efficient execution possible in the case of
a low number of concurrent threads.
</p>
<p>
When the thread pool plugin starts, it creates one thread
per group (the listener thread), plus the background thread.
Additional threads are created as necessary to execute
statements.
</p>
</li>
<li class="listitem">
<p>
The value of the
<a class="link" href="server-system-variables.html#sysvar_thread_pool_stall_limit">
<code class="literal">
thread_pool_stall_limit
</code>
</a>
system variable determines the meaning of
<span class="quote">
“
<span class="quote">
finishes
quickly
</span>
”
</span>
in the previous item. The default time
before threads are considered stalled is 60ms but can be set
to a maximum of 6s. This parameter is configurable to enable
you to strike a balance appropriate for the server work
load. Short wait values permit threads to start more
quickly. Short values are also better for avoiding deadlock
situations. Long wait values are useful for workloads that
include long-running statements, to avoid starting too many
new statements while the current ones execute.
</p>
</li>
<li class="listitem">
<p>
If
<a class="link" href="server-system-variables.html#sysvar_thread_pool_max_active_query_threads">
<code class="literal">
thread_pool_max_active_query_threads
</code>
</a>
is 0, the default algorithm applies as just described for
determining the maximum number of active threads per group.
The default algorithm takes stalled threads into account and
may temporarily permit more active threads. If
<a class="link" href="server-system-variables.html#sysvar_thread_pool_max_active_query_threads">
<code class="literal">
thread_pool_max_active_query_threads
</code>
</a>
is greater than 0, it places a limit on the number of active
threads per group.
</p>
</li>
<li class="listitem">
<p>
The thread pool focuses on limiting the number of concurrent
short-running statements. Before an executing statement
reaches the stall time, it prevents other statements from
beginning to execute. If the statement executes past the
stall time, it is permitted to continue but no longer
prevents other statements from starting. In this way, the
thread pool tries to ensure that in each thread group there
is never more than one short-running statement, although
there might be multiple long-running statements. It is
undesirable to let long-running statements prevent other
statements from executing because there is no limit on the
amount of waiting that might be necessary. For example, on a
replication source server, a thread that is sending binary
log events to a replica effectively runs forever.
</p>
</li>
<li class="listitem">
<p>
A statement becomes blocked if it encounters a disk I/O
operation or a user level lock (row lock or table lock). The
block would cause the thread group to become unused, so
there are callbacks to the thread pool to ensure that the
thread pool can immediately start a new thread in this group
to execute another statement. When a blocked thread returns,
the thread pool permits it to restart immediately.
</p>
</li>
<li class="listitem">
<p>
There are two queues, a high-priority queue and a
low-priority queue. The first statement in a transaction
goes to the low-priority queue. Any following statements for
the transaction go to the high-priority queue if the
transaction is ongoing (statements for it have begun
executing), or to the low-priority queue otherwise. Queue
assignment can be affected by enabling the
<a class="link" href="server-system-variables.html#sysvar_thread_pool_high_priority_connection">
<code class="literal">
thread_pool_high_priority_connection
</code>
</a>
system variable, which causes all queued statements for a
session to go into the high-priority queue.
</p>
<p>
Statements for a nontransactional storage engine, or a
transactional engine if
<a class="link" href="server-system-variables.html#sysvar_autocommit">
<code class="literal">
autocommit
</code>
</a>
is enabled, are
treated as low-priority statements because in this case each
statement is a transaction. Thus, given a mix of statements
for
<code class="literal">
InnoDB
</code>
and
<code class="literal">
MyISAM
</code>
tables, the thread pool prioritizes those for
<code class="literal">
InnoDB
</code>
over those for
<code class="literal">
MyISAM
</code>
unless
<a class="link" href="server-system-variables.html#sysvar_autocommit">
<code class="literal">
autocommit
</code>
</a>
is enabled. With
<a class="link" href="server-system-variables.html#sysvar_autocommit">
<code class="literal">
autocommit
</code>
</a>
enabled, all
statements have low priority.
</p>
</li>
<li class="listitem">
<p>
When the thread group selects a queued statement for
execution, it first looks in the high-priority queue, then
in the low-priority queue. If a statement is found, it is
removed from its queue and begins to execute.
</p>
</li>
<li class="listitem">
<p>
If a statement stays in the low-priority queue too long, the
thread pool moves to the high-priority queue. The value of
the
<a class="link" href="server-system-variables.html#sysvar_thread_pool_prio_kickup_timer">
<code class="literal">
thread_pool_prio_kickup_timer
</code>
</a>
system variable controls the time before movement. For each
thread group, a maximum of one statement per 10ms (100 per
second) is moved from the low-priority queue to the
high-priority queue.
</p>
</li>
<li class="listitem">
<p>
The thread pool reuses the most active threads to obtain a
much better use of CPU caches. This is a small adjustment
that has a great impact on performance.
</p>
</li>
<li class="listitem">
<p>
While a thread executes a statement from a user connection,
Performance Schema instrumentation accounts thread activity
to the user connection. Otherwise, Performance Schema
accounts activity to the thread pool.
</p>
</li>
</ul>
</div>
<p>
Here are examples of conditions under which a thread group might
have multiple threads started to execute statements:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
One thread begins executing a statement, but runs long
enough to be considered stalled. The thread group permits
another thread to begin executing another statement even
through the first thread is still executing.
</p>
</li>
<li class="listitem">
<p>
One thread begins executing a statement, then becomes
blocked and reports this back to the thread pool. The thread
group permits another thread to begin executing another
statement.
</p>
</li>
<li class="listitem">
<p>
One thread begins executing a statement, becomes blocked,
but does not report back that it is blocked because the
block does not occur in code that has been instrumented with
thread pool callbacks. In this case, the thread appears to
the thread group to be still running. If the block lasts
long enough for the statement to be considered stalled, the
group permits another thread to begin executing another
statement.
</p>
</li>
</ul>
</div>
<p>
The thread pool is designed to be scalable across an increasing
number of connections. It is also designed to avoid deadlocks
that can arise from limiting the number of actively executing
statements. It is important that threads that do not report back
to the thread pool do not prevent other statements from
executing and thus cause the thread pool to become deadlocked.
Examples of such statements follow:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Long-running statements. These would lead to all resources
used by only a few statements and they could prevent all
others from accessing the server.
</p>
</li>
<li class="listitem">
<p>
Binary log dump threads that read the binary log and send it
to replicas. This is a kind of long-running
<span class="quote">
“
<span class="quote">
statement
</span>
”
</span>
that runs for a very long time, and
that should not prevent other statements from executing.
</p>
</li>
<li class="listitem">
<p>
Statements blocked on a row lock, table lock, sleep, or any
other blocking activity that has not been reported back to
the thread pool by MySQL Server or a storage engine.
</p>
</li>
</ul>
</div>
<p>
In each case, to prevent deadlock, the statement is moved to the
stalled category when it does not complete quickly, so that the
thread group can permit another statement to begin executing.
With this design, when a thread executes or becomes blocked for
an extended time, the thread pool moves the thread to the
stalled category and for the rest of the statement's execution,
it does not prevent other statements from executing.
</p>
<p>
The maximum number of threads that can occur is the sum of
<a class="link" href="server-system-variables.html#sysvar_max_connections">
<code class="literal">
max_connections
</code>
</a>
and
<a class="link" href="server-system-variables.html#sysvar_thread_pool_size">
<code class="literal">
thread_pool_size
</code>
</a>
. This can
happen in a situation where all connections are in execution
mode and an extra thread is created per group to listen for more
statements. This is not necessarily a state that happens often,
but it is theoretically possible.
</p>
<h5>
<a name="privileged-connections">
</a>
Privileged Connections
</h5>
<p>
If the limit defined by
<a class="link" href="server-system-variables.html#sysvar_thread_pool_max_transactions_limit">
<code class="literal">
thread_pool_max_transactions_limit
</code>
</a>
has been reached and new connections or new transactions using
existing connections appear to hang until one or more existing
transactions are completed, in spite of any adjustments made to
<a class="link" href="server-system-variables.html#sysvar_thread_pool_longrun_trx_limit">
<code class="literal">
thread_pool_longrun_trx_limit
</code>
</a>
,
so that all existing connections are blocked or long-running,
the only way to access the server may be to use a privileged
connection.
</p>
<p>
To establish a privileged connection, the user initiating the
connection must have the
<a class="link" href="privileges-provided.html#priv_tp-connection-admin">
<code class="literal">
TP_CONNECTION_ADMIN
</code>
</a>
privilege. A
privileged connection ignores the limit defined by
<a class="link" href="server-system-variables.html#sysvar_thread_pool_max_transactions_limit">
<code class="literal">
thread_pool_max_transactions_limit
</code>
</a>
and permits connecting to the server to increase the limit,
remove the limit, or kill running transactions.
<a class="link" href="privileges-provided.html#priv_tp-connection-admin">
<code class="literal">
TP_CONNECTION_ADMIN
</code>
</a>
privilege
must be granted explicitly. It is not granted to any user by
default.
</p>
<p>
A privileged connection can execute statements and start
transactions, and is assigned to a thread group designated as
the
<code class="literal">
Admin
</code>
thread group.
</p>
<p>
When querying the
<a class="link" href="performance-schema-tp-thread-group-stats-table.html" title="29.12.16.3 The tp_thread_group_stats Table">
<code class="literal">
performance_schema.tp_thread_group_stats
</code>
</a>
table, which reports statistics per thread group,
<code class="literal">
Admin
</code>
thread group statistics are reported in
the last row of the result set. For example, if
<code class="literal">
SELECT
* FROM performance_schema.tp_thread_group_stats
</code>
returns 17 rows (one row per thread group), the
<code class="literal">
Admin
</code>
thread group statistics are reported in
the 17th row.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/selinux-troubleshooting.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="selinux-troubleshooting">
</a>
8.7.6 Troubleshooting SELinux
</h3>
</div>
</div>
</div>
<a class="indexterm" name="idm46045231512576">
</a>
<p>
Troubleshooting SELinux typically involves placing SELinux into
permissive mode, rerunning problematic operations, checking for
access denial messages in the SELinux audit log, and placing
SELinux back into enforcing mode after problems are resolved.
</p>
<p>
To avoid placing the entire system into permissive mode using
<span class="command">
<strong>
setenforce
</strong>
</span>
, you can permit only the MySQL
service to run permissively by placing its SELinux domain
(
<code class="filename">
mysqld_t
</code>
) into permissive mode using the
<span class="command">
<strong>
semanage
</strong>
</span>
command:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa72910845"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal">semanage permissive <span class="token property">-a</span> mysqld_t</code></pre>
</div>
<p>
When you are finished troubleshooting, use this command to place
the
<code class="literal">
mysqld_t
</code>
domain back into enforcing mode:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa10145374"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal">semanage permissive <span class="token property">-d</span> mysqld_t</code></pre>
</div>
<p>
SELinux writes logs for denied operations to
<code class="filename">
/var/log/audit/audit.log
</code>
. You can check for
denials by searching for
<span class="quote">
“
<span class="quote">
denied
</span>
”
</span>
messages.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-simple"><div class="docs-select-all right" id="sa54104283"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-simple">grep "denied" <span class="token operator">/</span>var<span class="token operator">/</span>log<span class="token operator">/</span>audit<span class="token operator">/</span>audit<span class="token punctuation">.</span>log</code></pre>
</div>
<p>
The following sections describes a few common areas where
SELinux-related issues may be encountered.
</p>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h4 class="title">
<a name="selinux-troubleshooting-file-contexts">
</a>
File Contexts
</h4>
</div>
</div>
</div>
<p>
If a MySQL directory or file has an incorrect SELinux context,
access may be denied. This issue can occur if MySQL is
configured to read from or write to a non-default directory or
file. For example, if you configure MySQL to use a non-default
data directory, the directory may not have the expected SELinux
context.
</p>
<p>
Attempting to start the MySQL service on a non-default data
directory with an invalid SELinux context causes the following
startup failure.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa61082054"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$> </span><span class="token command">systemctl</span> start mysql<span class="token punctuation">.</span>service
Job for mysqld<span class="token punctuation">.</span>service failed because the control process exited with error code<span class="token punctuation">.</span>
See <span class="token atrule">"systemctl status mysqld.service"</span> and <span class="token atrule">"journalctl -xe"</span> for details<span class="token punctuation">.</span></code></pre>
</div>
<p>
In this case, a
<span class="quote">
“
<span class="quote">
denial
</span>
”
</span>
message is logged to
<code class="filename">
/var/log/audit/audit.log
</code>
:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa2640654"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$> </span><span class="token command">grep</span> <span class="token atrule">"denied"</span> /var/log/audit/audit<span class="token punctuation">.</span>log
type<span class="token attr-value"><span class="token punctuation">=</span>AVC</span> msg<span class="token attr-value"><span class="token punctuation">=</span>audit(1587133719.786:194):</span> avc<span class="token punctuation">:</span> denied <span class="token punctuation">{</span> write <span class="token punctuation">}</span> for pid<span class="token attr-value"><span class="token punctuation">=</span>7133</span> comm=<span class="token atrule">"mysqld"</span>
name=<span class="token atrule">"mysql"</span> dev=<span class="token atrule">"dm-0"</span> ino<span class="token attr-value"><span class="token punctuation">=</span>51347078</span> scontext<span class="token attr-value"><span class="token punctuation">=</span>system_u:system_r:mysqld_t:s0</span>
tcontext<span class="token attr-value"><span class="token punctuation">=</span>unconfined_u:object_r:default_t:s0</span> tclass<span class="token attr-value"><span class="token punctuation">=</span>dir</span> permissive<span class="token attr-value"><span class="token punctuation">=</span>0</span></code></pre>
</div>
<p>
For information about setting the proper SELinux context for
MySQL directories and files, see
<a class="xref" href="selinux-file-context.html" title="8.7.4 SELinux File Context">
Section 8.7.4, “SELinux File Context”
</a>
.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h4 class="title">
<a name="selinux-troubleshooting-port-access">
</a>
Port Access
</h4>
</div>
</div>
</div>
<p>
SELinux expects services such as MySQL Server to use specific
ports. Changing ports without updating the SELinux policies may
cause a service failure.
</p>
<p>
The
<code class="literal">
mysqld_port_t
</code>
port type defines the ports
that the MySQL listens on. If you configure the MySQL Server to
use a non-default port, such as port 3307, and do not update the
policy to reflect the change, the MySQL service fails to start:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa52647986"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$> </span><span class="token command">systemctl</span> start mysqld<span class="token punctuation">.</span>service
Job for mysqld<span class="token punctuation">.</span>service failed because the control process exited with error code<span class="token punctuation">.</span>
See <span class="token atrule">"systemctl status mysqld.service"</span> and <span class="token atrule">"journalctl -xe"</span> for details<span class="token punctuation">.</span></code></pre>
</div>
<p>
In this case, a denial message is logged to
<code class="filename">
/var/log/audit/audit.log
</code>
:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa95531422"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$> </span><span class="token command">grep</span> <span class="token atrule">"denied"</span> /var/log/audit/audit<span class="token punctuation">.</span>log
type<span class="token attr-value"><span class="token punctuation">=</span>AVC</span> msg<span class="token attr-value"><span class="token punctuation">=</span>audit(1587134375.845:198):</span> avc<span class="token punctuation">:</span> denied <span class="token punctuation">{</span> name_bind <span class="token punctuation">}</span> for pid<span class="token attr-value"><span class="token punctuation">=</span>7340</span>
comm=<span class="token atrule">"mysqld"</span> src<span class="token attr-value"><span class="token punctuation">=</span>3307</span> scontext<span class="token attr-value"><span class="token punctuation">=</span>system_u:system_r:mysqld_t:s0</span>
tcontext<span class="token attr-value"><span class="token punctuation">=</span>system_u:object_r:unreserved_port_t:s0</span> tclass<span class="token attr-value"><span class="token punctuation">=</span>tcp_socket</span> permissive<span class="token attr-value"><span class="token punctuation">=</span>0</span></code></pre>
</div>
<p>
For information about setting the proper SELinux port context
for MySQL, see
<a class="xref" href="selinux-context-tcp-port.html" title="8.7.5 SELinux TCP Port Context">
Section 8.7.5, “SELinux TCP Port Context”
</a>
.
Similar port access issues can occur when enabling MySQL
features that use ports that are not defined with the required
context. For more information, see
<a class="xref" href="selinux-context-mysql-feature-ports.html" title="8.7.5.2 Setting the TCP Port Context for MySQL Features">
Section 8.7.5.2, “Setting the TCP Port Context for MySQL Features”
</a>
.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h4 class="title">
<a name="selinux-troubleshooting-app-changes">
</a>
Application Changes
</h4>
</div>
</div>
</div>
<p>
SELinux may not be aware of application changes. For example, a
new release, an application extension, or a new feature may
access system resources in a way that is not permitted by
SELinux, resulting in access denials. In such cases, you can use
the
<span class="command">
<strong>
audit2allow
</strong>
</span>
utility to create custom
policies to permit access where it is required. The typical
method for creating custom policies is to change the SELinux
mode to permissive, identify access denial messages in the
SELinux audit log, and use the
<span class="command">
<strong>
audit2allow
</strong>
</span>
utility to create custom policies to permit access.
</p>
<p>
For information about using the
<span class="command">
<strong>
audit2allow
</strong>
</span>
utility, refer to your distribution's SELinux documentation.
</p>
<p>
If you encounter access issues for MySQL that you believe should
be handled by standard MySQL SELinux policy modules, please open
a bug report in your distribution's bug tracking system.
</p>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/performance-schema-stage-tables.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="performance-schema-stage-tables">
</a>
29.12.5 Performance Schema Stage Event Tables
</h3>
</div>
</div>
</div>
<div class="toc">
<dl class="toc">
<dt>
<span class="section">
<a href="performance-schema-events-stages-current-table.html">
29.12.5.1 The events_stages_current Table
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="performance-schema-events-stages-history-table.html">
29.12.5.2 The events_stages_history Table
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="performance-schema-events-stages-history-long-table.html">
29.12.5.3 The events_stages_history_long Table
</a>
</span>
</dt>
</dl>
</div>
<p>
The Performance Schema instruments stages, which are steps
during the statement-execution process, such as parsing a
statement, opening a table, or performing a
<code class="literal">
filesort
</code>
operation. Stages correspond to the
thread states displayed by
<a class="link" href="show-processlist.html" title="15.7.7.31 SHOW PROCESSLIST Statement">
<code class="literal">
SHOW
PROCESSLIST
</code>
</a>
or that are visible in the Information
Schema
<a class="link" href="information-schema-processlist-table.html" title="28.3.23 The INFORMATION_SCHEMA PROCESSLIST Table">
<code class="literal">
PROCESSLIST
</code>
</a>
table. Stages
begin and end when state values change.
</p>
<p>
Within the event hierarchy, wait events nest within stage
events, which nest within statement events, which nest within
transaction events.
</p>
<p>
These tables store stage events:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="link" href="performance-schema-events-stages-current-table.html" title="29.12.5.1 The events_stages_current Table">
<code class="literal">
events_stages_current
</code>
</a>
: The
current stage event for each thread.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="performance-schema-events-stages-history-table.html" title="29.12.5.2 The events_stages_history Table">
<code class="literal">
events_stages_history
</code>
</a>
: The most
recent stage events that have ended per thread.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="performance-schema-events-stages-history-long-table.html" title="29.12.5.3 The events_stages_history_long Table">
<code class="literal">
events_stages_history_long
</code>
</a>
: The
most recent stage events that have ended globally (across
all threads).
</p>
</li>
</ul>
</div>
<p>
The following sections describe the stage event tables. There
are also summary tables that aggregate information about stage
events; see
<a class="xref" href="performance-schema-stage-summary-tables.html" title="29.12.20.2 Stage Summary Tables">
Section 29.12.20.2, “Stage Summary Tables”
</a>
.
</p>
<p>
For more information about the relationship between the three
stage event tables, see
<a class="xref" href="performance-schema-event-tables.html" title="29.9 Performance Schema Tables for Current and Historical Events">
Section 29.9, “Performance Schema Tables for Current and Historical Events”
</a>
.
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="xref" href="performance-schema-stage-tables.html#stage-event-configuration" title="Configuring Stage Event Collection">
Configuring Stage Event Collection
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="performance-schema-stage-tables.html#stage-event-progress" title="Stage Event Progress Information">
Stage Event Progress Information
</a>
</p>
</li>
</ul>
</div>
<h4>
<a name="stage-event-configuration">
</a>
Configuring Stage Event Collection
</h4>
<p>
To control whether to collect stage events, set the state of the
relevant instruments and consumers:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
The
<a class="link" href="performance-schema-setup-instruments-table.html" title="29.12.2.3 The setup_instruments Table">
<code class="literal">
setup_instruments
</code>
</a>
table
contains instruments with names that begin with
<code class="literal">
stage
</code>
. Use these instruments to enable or
disable collection of individual stage event classes.
</p>
</li>
<li class="listitem">
<p>
The
<a class="link" href="performance-schema-setup-consumers-table.html" title="29.12.2.2 The setup_consumers Table">
<code class="literal">
setup_consumers
</code>
</a>
table
contains consumer values with names corresponding to the
current and historical stage event table names. Use these
consumers to filter collection of stage events.
</p>
</li>
</ul>
</div>
<p>
Other than those instruments that provide statement progress
information, the stage instruments are disabled by default. For
example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa44753526"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token keyword">NAME</span><span class="token punctuation">,</span> ENABLED<span class="token punctuation">,</span> TIMED
<span class="token keyword">FROM</span> performance_schema<span class="token punctuation">.</span>setup_instruments
<span class="token keyword">WHERE</span> <span class="token keyword">NAME</span> <span class="token operator">RLIKE</span> <span class="token string">'stage/sql/[a-c]'</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> NAME <span class="token punctuation">|</span> ENABLED <span class="token punctuation">|</span> TIMED <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> stage/sql/After create <span class="token punctuation">|</span> NO <span class="token punctuation">|</span> NO <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> stage/sql/allocating local table <span class="token punctuation">|</span> NO <span class="token punctuation">|</span> NO <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> stage/sql/altering table <span class="token punctuation">|</span> NO <span class="token punctuation">|</span> NO <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> stage/sql/committing alter table to storage engine <span class="token punctuation">|</span> NO <span class="token punctuation">|</span> NO <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> stage/sql/Changing master <span class="token punctuation">|</span> NO <span class="token punctuation">|</span> NO <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> stage/sql/Checking master version <span class="token punctuation">|</span> NO <span class="token punctuation">|</span> NO <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> stage/sql/checking permissions <span class="token punctuation">|</span> NO <span class="token punctuation">|</span> NO <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> stage/sql/cleaning up <span class="token punctuation">|</span> NO <span class="token punctuation">|</span> NO <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> stage/sql/closing tables <span class="token punctuation">|</span> NO <span class="token punctuation">|</span> NO <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> stage/sql/Connecting to master <span class="token punctuation">|</span> NO <span class="token punctuation">|</span> NO <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> stage/sql/converting HEAP to MyISAM <span class="token punctuation">|</span> NO <span class="token punctuation">|</span> NO <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> stage/sql/Copying to group table <span class="token punctuation">|</span> NO <span class="token punctuation">|</span> NO <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> stage/sql/Copying to tmp table <span class="token punctuation">|</span> NO <span class="token punctuation">|</span> NO <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> stage/sql/copy to tmp table <span class="token punctuation">|</span> NO <span class="token punctuation">|</span> NO <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> stage/sql/Creating sort index <span class="token punctuation">|</span> NO <span class="token punctuation">|</span> NO <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> stage/sql/creating table <span class="token punctuation">|</span> NO <span class="token punctuation">|</span> NO <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> stage/sql/Creating tmp table <span class="token punctuation">|</span> NO <span class="token punctuation">|</span> NO <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
<p>
Stage event instruments that provide statement progress
information are enabled and timed by default:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa88807775"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token keyword">NAME</span><span class="token punctuation">,</span> ENABLED<span class="token punctuation">,</span> TIMED
<span class="token keyword">FROM</span> performance_schema<span class="token punctuation">.</span>setup_instruments
<span class="token keyword">WHERE</span> ENABLED<span class="token operator">=</span><span class="token string">'YES'</span> <span class="token operator">AND</span> <span class="token keyword">NAME</span> <span class="token operator">LIKE</span> <span class="token string">"stage/%"</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> NAME <span class="token punctuation">|</span> ENABLED <span class="token punctuation">|</span> TIMED <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> stage/sql/copy to tmp table <span class="token punctuation">|</span> YES <span class="token punctuation">|</span> YES <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> stage/sql/Applying batch of row changes (write) <span class="token punctuation">|</span> YES <span class="token punctuation">|</span> YES <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> stage/sql/Applying batch of row changes (update) <span class="token punctuation">|</span> YES <span class="token punctuation">|</span> YES <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> stage/sql/Applying batch of row changes (delete) <span class="token punctuation">|</span> YES <span class="token punctuation">|</span> YES <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> stage/innodb/alter table (end) <span class="token punctuation">|</span> YES <span class="token punctuation">|</span> YES <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> stage/innodb/alter table (flush) <span class="token punctuation">|</span> YES <span class="token punctuation">|</span> YES <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> stage/innodb/alter table (insert) <span class="token punctuation">|</span> YES <span class="token punctuation">|</span> YES <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> stage/innodb/alter table (log apply index) <span class="token punctuation">|</span> YES <span class="token punctuation">|</span> YES <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> stage/innodb/alter table (log apply table) <span class="token punctuation">|</span> YES <span class="token punctuation">|</span> YES <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> stage/innodb/alter table (merge sort) <span class="token punctuation">|</span> YES <span class="token punctuation">|</span> YES <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> stage/innodb/alter table (read PK and internal sort) <span class="token punctuation">|</span> YES <span class="token punctuation">|</span> YES <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> stage/innodb/buffer pool load <span class="token punctuation">|</span> YES <span class="token punctuation">|</span> YES <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> stage/innodb/clone (file copy) <span class="token punctuation">|</span> YES <span class="token punctuation">|</span> YES <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> stage/innodb/clone (redo copy) <span class="token punctuation">|</span> YES <span class="token punctuation">|</span> YES <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> stage/innodb/clone (page copy) <span class="token punctuation">|</span> YES <span class="token punctuation">|</span> YES <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
<p>
The stage consumers are disabled by default:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa87869710"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token operator">*</span>
<span class="token keyword">FROM</span> performance_schema<span class="token punctuation">.</span>setup_consumers
<span class="token keyword">WHERE</span> <span class="token keyword">NAME</span> <span class="token operator">LIKE</span> <span class="token string">'events_stages%'</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> NAME <span class="token punctuation">|</span> ENABLED <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> events_stages_current <span class="token punctuation">|</span> NO <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> events_stages_history <span class="token punctuation">|</span> NO <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> events_stages_history_long <span class="token punctuation">|</span> NO <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
<p>
To control stage event collection at server startup, use lines
like these in your
<code class="filename">
my.cnf
</code>
file:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Enable:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-ini"><div class="docs-select-all right" id="sa18643036"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-ini"><span class="token selector">[mysqld]</span>
<span class="token constant">performance-schema-instrument</span><span class="token attr-value"><span class="token punctuation">=</span>'stage/%=ON'</span>
<span class="token constant">performance-schema-consumer-events-stages-current</span><span class="token attr-value"><span class="token punctuation">=</span>ON</span>
<span class="token constant">performance-schema-consumer-events-stages-history</span><span class="token attr-value"><span class="token punctuation">=</span>ON</span>
<span class="token constant">performance-schema-consumer-events-stages-history-long</span><span class="token attr-value"><span class="token punctuation">=</span>ON</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
Disable:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-ini"><div class="docs-select-all right" id="sa80493868"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-ini"><span class="token selector">[mysqld]</span>
<span class="token constant">performance-schema-instrument</span><span class="token attr-value"><span class="token punctuation">=</span>'stage/%=OFF'</span>
<span class="token constant">performance-schema-consumer-events-stages-current</span><span class="token attr-value"><span class="token punctuation">=</span>OFF</span>
<span class="token constant">performance-schema-consumer-events-stages-history</span><span class="token attr-value"><span class="token punctuation">=</span>OFF</span>
<span class="token constant">performance-schema-consumer-events-stages-history-long</span><span class="token attr-value"><span class="token punctuation">=</span>OFF</span></code></pre>
</div>
</li>
</ul>
</div>
<p>
To control stage event collection at runtime, update the
<a class="link" href="performance-schema-setup-instruments-table.html" title="29.12.2.3 The setup_instruments Table">
<code class="literal">
setup_instruments
</code>
</a>
and
<a class="link" href="performance-schema-setup-consumers-table.html" title="29.12.2.2 The setup_consumers Table">
<code class="literal">
setup_consumers
</code>
</a>
tables:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Enable:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa33264932"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">UPDATE</span> performance_schema<span class="token punctuation">.</span>setup_instruments
<span class="token keyword">SET</span> ENABLED <span class="token operator">=</span> <span class="token string">'YES'</span><span class="token punctuation">,</span> TIMED <span class="token operator">=</span> <span class="token string">'YES'</span>
<span class="token keyword">WHERE</span> <span class="token keyword">NAME</span> <span class="token operator">LIKE</span> <span class="token string">'stage/%'</span><span class="token punctuation">;</span>
<span class="token keyword">UPDATE</span> performance_schema<span class="token punctuation">.</span>setup_consumers
<span class="token keyword">SET</span> ENABLED <span class="token operator">=</span> <span class="token string">'YES'</span>
<span class="token keyword">WHERE</span> <span class="token keyword">NAME</span> <span class="token operator">LIKE</span> <span class="token string">'events_stages%'</span><span class="token punctuation">;</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
Disable:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa78760998"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">UPDATE</span> performance_schema<span class="token punctuation">.</span>setup_instruments
<span class="token keyword">SET</span> ENABLED <span class="token operator">=</span> <span class="token string">'NO'</span><span class="token punctuation">,</span> TIMED <span class="token operator">=</span> <span class="token string">'NO'</span>
<span class="token keyword">WHERE</span> <span class="token keyword">NAME</span> <span class="token operator">LIKE</span> <span class="token string">'stage/%'</span><span class="token punctuation">;</span>
<span class="token keyword">UPDATE</span> performance_schema<span class="token punctuation">.</span>setup_consumers
<span class="token keyword">SET</span> ENABLED <span class="token operator">=</span> <span class="token string">'NO'</span>
<span class="token keyword">WHERE</span> <span class="token keyword">NAME</span> <span class="token operator">LIKE</span> <span class="token string">'events_stages%'</span><span class="token punctuation">;</span></code></pre>
</div>
</li>
</ul>
</div>
<p>
To collect only specific stage events, enable only the
corresponding stage instruments. To collect stage events only
for specific stage event tables, enable the stage instruments
but only the stage consumers corresponding to the desired
tables.
</p>
<p>
For additional information about configuring event collection,
see
<a class="xref" href="performance-schema-startup-configuration.html" title="29.3 Performance Schema Startup Configuration">
Section 29.3, “Performance Schema Startup Configuration”
</a>
,
and
<a class="xref" href="performance-schema-runtime-configuration.html" title="29.4 Performance Schema Runtime Configuration">
Section 29.4, “Performance Schema Runtime Configuration”
</a>
.
</p>
<h4>
<a name="stage-event-progress">
</a>
Stage Event Progress Information
</h4>
<p>
The Performance Schema stage event tables contain two columns
that, taken together, provide a stage progress indicator for
each row:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
WORK_COMPLETED
</code>
: The number of work units
completed for the stage
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
WORK_ESTIMATED
</code>
: The number of work units
expected for the stage
</p>
</li>
</ul>
</div>
<p>
Each column is
<code class="literal">
NULL
</code>
if no progress
information is provided for an instrument. Interpretation of the
information, if it is available, depends entirely on the
instrument implementation. The Performance Schema tables provide
a container to store progress data, but make no assumptions
about the semantics of the metric itself:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
A
<span class="quote">
“
<span class="quote">
work unit
</span>
”
</span>
is an integer metric that
increases over time during execution, such as the number of
bytes, rows, files, or tables processed. The definition of
<span class="quote">
“
<span class="quote">
work unit
</span>
”
</span>
for a particular instrument is left
to the instrumentation code providing the data.
</p>
</li>
<li class="listitem">
<p>
The
<code class="literal">
WORK_COMPLETED
</code>
value can increase one
or many units at a time, depending on the instrumented code.
</p>
</li>
<li class="listitem">
<p>
The
<code class="literal">
WORK_ESTIMATED
</code>
value can change
during the stage, depending on the instrumented code.
</p>
</li>
</ul>
</div>
<p>
Instrumentation for a stage event progress indicator can
implement any of the following behaviors:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
No progress instrumentation
</p>
<p>
This is the most typical case, where no progress data is
provided. The
<code class="literal">
WORK_COMPLETED
</code>
and
<code class="literal">
WORK_ESTIMATED
</code>
columns are both
<code class="literal">
NULL
</code>
.
</p>
</li>
<li class="listitem">
<p>
Unbounded progress instrumentation
</p>
<p>
Only the
<code class="literal">
WORK_COMPLETED
</code>
column is
meaningful. No data is provided for the
<code class="literal">
WORK_ESTIMATED
</code>
column, which displays 0.
</p>
<p>
By querying the
<a class="link" href="performance-schema-events-stages-current-table.html" title="29.12.5.1 The events_stages_current Table">
<code class="literal">
events_stages_current
</code>
</a>
table for
the monitored session, a monitoring application can report
how much work has been performed so far, but cannot report
whether the stage is near completion. Currently, no stages
are instrumented like this.
</p>
</li>
<li class="listitem">
<p>
Bounded progress instrumentation
</p>
<p>
The
<code class="literal">
WORK_COMPLETED
</code>
and
<code class="literal">
WORK_ESTIMATED
</code>
columns are both
meaningful.
</p>
<p>
This type of progress indicator is appropriate for an
operation with a defined completion criterion, such as the
table-copy instrument described later. By querying the
<a class="link" href="performance-schema-events-stages-current-table.html" title="29.12.5.1 The events_stages_current Table">
<code class="literal">
events_stages_current
</code>
</a>
table for
the monitored session, a monitoring application can report
how much work has been performed so far, and can report the
overall completion percentage for the stage, by computing
the
<code class="literal">
WORK_COMPLETED
</code>
/
<code class="literal">
WORK_ESTIMATED
</code>
ratio.
</p>
</li>
</ul>
</div>
<p>
The
<code class="literal">
stage/sql/copy to tmp table
</code>
instrument
illustrates how progress indicators work. During execution of an
<a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
<code class="literal">
ALTER TABLE
</code>
</a>
statement, the
<code class="literal">
stage/sql/copy to tmp table
</code>
stage is used,
and this stage can execute potentially for a long time,
depending on the size of the data to copy.
</p>
<p>
The table-copy task has a defined termination (all rows copied),
and the
<code class="literal">
stage/sql/copy to tmp table
</code>
stage is
instrumented to provided bounded progress information: The work
unit used is number of rows copied,
<code class="literal">
WORK_COMPLETED
</code>
and
<code class="literal">
WORK_ESTIMATED
</code>
are both meaningful, and their
ratio indicates task percentage complete.
</p>
<p>
To enable the instrument and the relevant consumers, execute
these statements:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa16048643"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">UPDATE</span> performance_schema<span class="token punctuation">.</span>setup_instruments
<span class="token keyword">SET</span> ENABLED<span class="token operator">=</span><span class="token string">'YES'</span>
<span class="token keyword">WHERE</span> <span class="token keyword">NAME</span><span class="token operator">=</span><span class="token string">'stage/sql/copy to tmp table'</span><span class="token punctuation">;</span>
<span class="token keyword">UPDATE</span> performance_schema<span class="token punctuation">.</span>setup_consumers
<span class="token keyword">SET</span> ENABLED<span class="token operator">=</span><span class="token string">'YES'</span>
<span class="token keyword">WHERE</span> <span class="token keyword">NAME</span> <span class="token operator">LIKE</span> <span class="token string">'events_stages_%'</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
To see the progress of an ongoing
<a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
<code class="literal">
ALTER
TABLE
</code>
</a>
statement, select from the
<a class="link" href="performance-schema-events-stages-current-table.html" title="29.12.5.1 The events_stages_current Table">
<code class="literal">
events_stages_current
</code>
</a>
table.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/group-replication-fault-tolerance.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="group-replication-fault-tolerance">
</a>
20.1.4.3 Fault-tolerance
</h4>
</div>
</div>
</div>
<p>
MySQL Group Replication builds on an implementation of the Paxos
distributed algorithm to provide distributed coordination
between servers. As such, it requires a majority of servers to
be active to reach quorum and thus make a decision. This has
direct impact on the number of failures the system can tolerate
without compromising itself and its overall functionality. The
number of servers (n) needed to tolerate
<code class="literal">
f
</code>
failures is then
<code class="literal">
n = 2 x f + 1
</code>
.
</p>
<p>
In practice this means that to tolerate one failure the group
must have three servers in it. As such if one server fails,
there are still two servers to form a majority (two out of
three) and allow the system to continue to make decisions
automatically and progress. However, if a second server fails
<span class="emphasis">
<em>
involuntarily
</em>
</span>
, then the group (with one
server left) blocks, because there is no majority to reach a
decision.
</p>
<p>
The following is a small table illustrating the formula above.
</p>
<div class="informaltable">
<table summary="Relationship between replication group size, the number of servers that constitute a majority, and the number of instant failures that can be tolerated.">
<colgroup>
<col style="width: 23%"/>
<col style="width: 18%"/>
<col style="width: 59%"/>
</colgroup>
<thead>
<tr>
<th scope="col">
<p>
Group Size
</p>
</th>
<th scope="col">
<p>
Majority
</p>
</th>
<th scope="col">
<p>
Instant Failures Tolerated
</p>
</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">
<p>
1
</p>
</th>
<td>
<p>
1
</p>
</td>
<td>
<p>
0
</p>
</td>
</tr>
<tr>
<th scope="row">
<p>
2
</p>
</th>
<td>
<p>
2
</p>
</td>
<td>
<p>
0
</p>
</td>
</tr>
<tr>
<th scope="row">
<p>
3
</p>
</th>
<td>
<p>
2
</p>
</td>
<td>
<p>
1
</p>
</td>
</tr>
<tr>
<th scope="row">
<p>
4
</p>
</th>
<td>
<p>
3
</p>
</td>
<td>
<p>
1
</p>
</td>
</tr>
<tr>
<th scope="row">
<p>
5
</p>
</th>
<td>
<p>
3
</p>
</td>
<td>
<p>
2
</p>
</td>
</tr>
<tr>
<th scope="row">
<p>
6
</p>
</th>
<td>
<p>
4
</p>
</td>
<td>
<p>
2
</p>
</td>
</tr>
<tr>
<th scope="row">
<p>
7
</p>
</th>
<td>
<p>
4
</p>
</td>
<td>
<p>
3
</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/reset-persist.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="reset-persist">
</a>
15.7.8.7 RESET PERSIST Statement
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045168346224">
</a>
<a class="indexterm" name="idm46045168345152">
</a>
<a class="indexterm" name="idm46045168344064">
</a>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa20148422"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">RESET</span> <span class="token keyword">PERSIST</span> <span class="token punctuation">[</span><span class="token punctuation">[</span><span class="token keyword">IF</span> <span class="token keyword">EXISTS</span><span class="token punctuation">]</span> <em class="replaceable">system_var_name</em><span class="token punctuation">]</span></code></pre>
</div>
<p>
<a class="link" href="reset-persist.html" title="15.7.8.7 RESET PERSIST Statement">
<code class="literal">
RESET PERSIST
</code>
</a>
removes persisted
global system variable settings from the
<code class="filename">
mysqld-auto.cnf
</code>
option file in the data
directory. Removing a persisted system variable causes the
variable no longer to be initialized from
<code class="filename">
mysqld-auto.cnf
</code>
at server startup. For more
information about persisting system variables and the
<code class="filename">
mysqld-auto.cnf
</code>
file, see
<a class="xref" href="persisted-system-variables.html" title="7.1.9.3 Persisted System Variables">
Section 7.1.9.3, “Persisted System Variables”
</a>
.
</p>
<p>
The privileges required for
<a class="link" href="reset-persist.html" title="15.7.8.7 RESET PERSIST Statement">
<code class="literal">
RESET
PERSIST
</code>
</a>
depend on the type of system variable to be
removed:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
For dynamic system variables, this statement requires the
<a class="link" href="privileges-provided.html#priv_system-variables-admin">
<code class="literal">
SYSTEM_VARIABLES_ADMIN
</code>
</a>
privilege (or the deprecated
<a class="link" href="privileges-provided.html#priv_super">
<code class="literal">
SUPER
</code>
</a>
privilege).
</p>
</li>
<li class="listitem">
<p>
For read-only system variables, this statement requires the
<a class="link" href="privileges-provided.html#priv_system-variables-admin">
<code class="literal">
SYSTEM_VARIABLES_ADMIN
</code>
</a>
and
<a class="link" href="privileges-provided.html#priv_persist-ro-variables-admin">
<code class="literal">
PERSIST_RO_VARIABLES_ADMIN
</code>
</a>
privileges.
</p>
</li>
</ul>
</div>
<p>
See
<a class="xref" href="system-variable-privileges.html" title="7.1.9.1 System Variable Privileges">
Section 7.1.9.1, “System Variable Privileges”
</a>
.
</p>
<p>
Depending on whether the variable name and
<code class="literal">
IF
EXISTS
</code>
clauses are present, the
<a class="link" href="reset-persist.html" title="15.7.8.7 RESET PERSIST Statement">
<code class="literal">
RESET PERSIST
</code>
</a>
statement has these
forms:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
To remove all persisted variables from
<code class="filename">
mysqld-auto.cnf
</code>
, use
<a class="link" href="reset-persist.html" title="15.7.8.7 RESET PERSIST Statement">
<code class="literal">
RESET PERSIST
</code>
</a>
without naming
any system variable:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa99651383"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">RESET</span> <span class="token keyword">PERSIST</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
You must have privileges for removing both dynamic and
read-only system variables if
<code class="filename">
mysqld-auto.cnf
</code>
contains both kinds of
variables.
</p>
</li>
<li class="listitem">
<p>
To remove a specific persisted variable from
<code class="filename">
mysqld-auto.cnf
</code>
, name it in the
statement:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa10801183"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">RESET</span> <span class="token keyword">PERSIST</span> <em class="replaceable">system_var_name</em><span class="token punctuation">;</span></code></pre>
</div>
<p>
This includes plugin system variables, even if the plugin is
not currently installed. If the variable is not present in
the file, an error occurs.
</p>
</li>
<li class="listitem">
<p>
To remove a specific persisted variable from
<code class="filename">
mysqld-auto.cnf
</code>
, but produce a warning
rather than an error if the variable is not present in the
file, add an
<code class="literal">
IF EXISTS
</code>
clause to the
previous syntax:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa43718941"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">RESET</span> <span class="token keyword">PERSIST</span> <span class="token keyword">IF</span> <span class="token keyword">EXISTS</span> <em class="replaceable">system_var_name</em><span class="token punctuation">;</span></code></pre>
</div>
</li>
</ul>
</div>
<p>
<a class="link" href="reset-persist.html" title="15.7.8.7 RESET PERSIST Statement">
<code class="literal">
RESET PERSIST
</code>
</a>
is not affected by
the value of the
<a class="link" href="server-system-variables.html#sysvar_persisted_globals_load">
<code class="literal">
persisted_globals_load
</code>
</a>
system
variable.
</p>
<p>
<a class="link" href="reset-persist.html" title="15.7.8.7 RESET PERSIST Statement">
<code class="literal">
RESET PERSIST
</code>
</a>
affects the
contents of the Performance Schema
<a class="link" href="performance-schema-persisted-variables-table.html" title="29.12.14.1 Performance Schema persisted_variables Table">
<code class="literal">
persisted_variables
</code>
</a>
table because
the table contents correspond to the contents of the
<code class="filename">
mysqld-auto.cnf
</code>
file. On the other hand,
because
<a class="link" href="reset-persist.html" title="15.7.8.7 RESET PERSIST Statement">
<code class="literal">
RESET PERSIST
</code>
</a>
does not
change variable values, it has no effect on the contents of the
Performance Schema
<a class="link" href="performance-schema-variables-info-table.html" title="29.12.14.2 Performance Schema variables_info Table">
<code class="literal">
variables_info
</code>
</a>
table until the server is restarted.
</p>
<p>
For information about
<a class="link" href="reset.html" title="15.7.8.6 RESET Statement">
<code class="literal">
RESET
</code>
</a>
statement variants that clear the state of other server
operations, see
<a class="xref" href="reset.html" title="15.7.8.6 RESET Statement">
Section 15.7.8.6, “RESET Statement”
</a>
.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/dynindex-cfunc.html | <div id="docs-body">
<div class="index">
<div class="titlepage">
<div>
<div>
<h2 class="title">
<a name="dynindex-cfunc">
</a>
C Function Index
</h2>
</div>
</div>
</div>
<div class="indexdiv">
<h3 class="title">
mysql_affected_rows()
</h3>
<dl>
<dt>
<a class="xref" href="call.html" title="15.2.1 CALL Statement">
Section 15.2.1, “CALL Statement”
</a>
</dt>
<dd>
</dd>
<dt>
<a class="xref" href="information-functions.html" title="14.15 Information Functions">
Section 14.15, “Information Functions”
</a>
</dt>
<dd>
</dd>
<dt>
<a class="xref" href="insert.html" title="15.2.7 INSERT Statement">
Section 15.2.7, “INSERT Statement”
</a>
</dt>
<dd>
</dd>
<dt>
<a class="xref" href="replace.html" title="15.2.12 REPLACE Statement">
Section 15.2.12, “REPLACE Statement”
</a>
</dt>
<dd>
</dd>
</dl>
</div>
<div class="indexdiv">
<h3 class="title">
mysql_bind_param()
</h3>
<dl>
<dt>
<a class="xref" href="query-attributes.html" title="11.6 Query Attributes">
Section 11.6, “Query Attributes”
</a>
</dt>
<dd>
</dd>
</dl>
</div>
<div class="indexdiv">
<h3 class="title">
mysql_change_user()
</h3>
<dl>
<dt>
<a class="xref" href="mysql-commands.html" title="6.5.1.2 mysql Client Commands">
Section 6.5.1.2, “mysql Client Commands”
</a>
</dt>
<dd>
</dd>
</dl>
</div>
<div class="indexdiv">
<h3 class="title">
mysql_close()
</h3>
<dl>
<dt>
<a class="xref" href="communication-errors.html" title="B.3.2.9 Communication Errors and Aborted Connections">
Section B.3.2.9, “Communication Errors and Aborted Connections”
</a>
</dt>
<dd>
</dd>
</dl>
</div>
<div class="indexdiv">
<h3 class="title">
mysql_errno()
</h3>
<dl>
<dt>
<a class="xref" href="audit-log-file-formats.html" title="8.4.5.4 Audit Log File Formats">
Section 8.4.5.4, “Audit Log File Formats”
</a>
</dt>
<dd>
</dd>
<dt>
<a class="xref" href="error-interfaces.html" title="B.2 Error Information Interfaces">
Section B.2, “Error Information Interfaces”
</a>
</dt>
<dd>
</dd>
<dt>
<a class="xref" href="signal.html" title="15.6.7.5 SIGNAL Statement">
Section 15.6.7.5, “SIGNAL Statement”
</a>
</dt>
<dd>
</dd>
</dl>
</div>
<div class="indexdiv">
<h3 class="title">
mysql_error()
</h3>
<dl>
<dt>
<a class="xref" href="error-interfaces.html" title="B.2 Error Information Interfaces">
Section B.2, “Error Information Interfaces”
</a>
</dt>
<dd>
</dd>
<dt>
<a class="xref" href="signal.html" title="15.6.7.5 SIGNAL Statement">
Section 15.6.7.5, “SIGNAL Statement”
</a>
</dt>
<dd>
</dd>
</dl>
</div>
<div class="indexdiv">
<h3 class="title">
mysql_escape_string()
</h3>
<dl>
<dt>
<a class="xref" href="secure-client-programming.html" title="8.1.7 Client Programming Security Guidelines">
Section 8.1.7, “Client Programming Security Guidelines”
</a>
</dt>
<dd>
</dd>
</dl>
</div>
<div class="indexdiv">
<h3 class="title">
mysql_fetch_row()
</h3>
<dl>
<dt>
<a class="xref" href="federated-description.html" title="18.8.1 FEDERATED Storage Engine Overview">
Section 18.8.1, “FEDERATED Storage Engine Overview”
</a>
</dt>
<dd>
</dd>
</dl>
</div>
<div class="indexdiv">
<h3 class="title">
mysql_free_result()
</h3>
<dl>
<dt>
<a class="xref" href="commands-out-of-sync.html" title="B.3.2.12 Commands out of sync">
Section B.3.2.12, “Commands out of sync”
</a>
</dt>
<dd>
</dd>
</dl>
</div>
<div class="indexdiv">
<h3 class="title">
mysql_get_character_set_info()
</h3>
<dl>
<dt>
<a class="xref" href="adding-collation-choosing-id.html" title="12.14.2 Choosing a Collation ID">
Section 12.14.2, “Choosing a Collation ID”
</a>
</dt>
<dd>
</dd>
</dl>
</div>
<div class="indexdiv">
<h3 class="title">
mysql_info()
</h3>
<dl>
<dt>
<a class="xref" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
Section 15.1.9, “ALTER TABLE Statement”
</a>
</dt>
<dd>
</dd>
<dt>
<a class="xref" href="insert.html" title="15.2.7 INSERT Statement">
Section 15.2.7, “INSERT Statement”
</a>
</dt>
<dd>
</dd>
<dt>
<a class="xref" href="load-data.html" title="15.2.9 LOAD DATA Statement">
Section 15.2.9, “LOAD DATA Statement”
</a>
</dt>
<dd>
</dd>
<dt>
<a class="xref" href="constraint-primary-key.html" title="1.7.3.1 PRIMARY KEY and UNIQUE Index Constraints">
Section 1.7.3.1, “PRIMARY KEY and UNIQUE Index Constraints”
</a>
</dt>
<dd>
</dd>
<dt>
<a class="xref" href="update.html" title="15.2.17 UPDATE Statement">
Section 15.2.17, “UPDATE Statement”
</a>
</dt>
<dd>
</dd>
</dl>
</div>
<div class="indexdiv">
<h3 class="title">
mysql_insert_id()
</h3>
<dl>
<dt>
<a class="xref" href="create-table.html" title="15.1.20 CREATE TABLE Statement">
Section 15.1.20, “CREATE TABLE Statement”
</a>
</dt>
<dd>
</dd>
<dt>
<a class="xref" href="information-functions.html" title="14.15 Information Functions">
Section 14.15, “Information Functions”
</a>
</dt>
<dd>
</dd>
<dt>
<a class="xref" href="insert.html" title="15.2.7 INSERT Statement">
Section 15.2.7, “INSERT Statement”
</a>
</dt>
<dd>
</dd>
<dt>
<a class="xref" href="server-system-variables.html" title="7.1.8 Server System Variables">
Section 7.1.8, “Server System Variables”
</a>
</dt>
<dd>
</dd>
<dt>
<a class="xref" href="example-auto-increment.html" title="5.6.9 Using AUTO_INCREMENT">
Section 5.6.9, “Using AUTO_INCREMENT”
</a>
</dt>
<dd>
</dd>
</dl>
</div>
<div class="indexdiv">
<h3 class="title">
mysql_next_result()
</h3>
<dl>
<dt>
<a class="xref" href="call.html" title="15.2.1 CALL Statement">
Section 15.2.1, “CALL Statement”
</a>
</dt>
<dd>
</dd>
</dl>
</div>
<div class="indexdiv">
<h3 class="title">
mysql_options()
</h3>
<dl>
<dt>
<a class="xref" href="user-names.html" title="8.2.1 Account User Names and Passwords">
Section 8.2.1, “Account User Names and Passwords”
</a>
</dt>
<dd>
</dd>
<dt>
<a class="xref" href="caching-sha2-pluggable-authentication.html" title="8.4.1.2 Caching SHA-2 Pluggable Authentication">
Section 8.4.1.2, “Caching SHA-2 Pluggable Authentication”
</a>
</dt>
<dd>
</dd>
<dt>
<a class="xref" href="cleartext-pluggable-authentication.html" title="8.4.1.4 Client-Side Cleartext Pluggable Authentication">
Section 8.4.1.4, “Client-Side Cleartext Pluggable Authentication”
</a>
</dt>
<dd>
</dd>
<dt>
<a class="xref" href="charset-connection.html" title="12.4 Connection Character Sets and Collations">
Section 12.4, “Connection Character Sets and Collations”
</a>
</dt>
<dd>
</dd>
<dt>
<a class="xref" href="connection-compression-control.html" title="6.2.8 Connection Compression Control">
Section 6.2.8, “Connection Compression Control”
</a>
</dt>
<dd>
</dd>
<dt>
<a class="xref" href="mysql-command-options.html" title="6.5.1.1 mysql Client Options">
Section 6.5.1.1, “mysql Client Options”
</a>
</dt>
<dd>
</dd>
<dt>
<a class="xref" href="gone-away.html" title="B.3.2.7 MySQL server has gone away">
Section B.3.2.7, “MySQL server has gone away”
</a>
</dt>
<dd>
</dd>
<dt>
<a class="xref" href="mysql-migrate-keyring.html" title="6.6.8 mysql_migrate_keyring — Keyring Key Migration Utility">
Section 6.6.8, “mysql_migrate_keyring — Keyring Key Migration Utility”
</a>
</dt>
<dd>
</dd>
<dt>
<a class="xref" href="mysql-secure-installation.html" title="6.4.2 mysql_secure_installation — Improve MySQL Installation Security">
Section 6.4.2, “mysql_secure_installation — Improve MySQL Installation Security”
</a>
</dt>
<dd>
</dd>
<dt>
<a class="xref" href="mysqladmin.html" title="6.5.2 mysqladmin — A MySQL Server Administration Program">
Section 6.5.2, “mysqladmin — A MySQL Server Administration Program”
</a>
</dt>
<dd>
</dd>
<dt>
<a class="xref" href="mysqlbinlog.html" title="6.6.9 mysqlbinlog — Utility for Processing Binary Log Files">
Section 6.6.9, “mysqlbinlog — Utility for Processing Binary Log Files”
</a>
</dt>
<dd>
</dd>
<dt>
<a class="xref" href="mysqlcheck.html" title="6.5.3 mysqlcheck — A Table Maintenance Program">
Section 6.5.3, “mysqlcheck — A Table Maintenance Program”
</a>
</dt>
<dd>
</dd>
<dt>
<a class="xref" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
Section 6.5.4, “mysqldump — A Database Backup Program”
</a>
</dt>
<dd>
</dd>
<dt>
<a class="xref" href="mysqlimport.html" title="6.5.5 mysqlimport — A Data Import Program">
Section 6.5.5, “mysqlimport — A Data Import Program”
</a>
</dt>
<dd>
</dd>
<dt>
<a class="xref" href="mysqlshow.html" title="6.5.6 mysqlshow — Display Database, Table, and Column Information">
Section 6.5.6, “mysqlshow — Display Database, Table, and Column Information”
</a>
</dt>
<dd>
</dd>
<dt>
<a class="xref" href="mysqlslap.html" title="6.5.7 mysqlslap — A Load Emulation Client">
Section 6.5.7, “mysqlslap — A Load Emulation Client”
</a>
</dt>
<dd>
</dd>
<dt>
<a class="xref" href="performance-schema-connection-attribute-tables.html" title="29.12.9 Performance Schema Connection Attribute Tables">
Section 29.12.9, “Performance Schema Connection Attribute Tables”
</a>
</dt>
<dd>
</dd>
<dt>
<a class="xref" href="pluggable-authentication.html" title="8.2.17 Pluggable Authentication">
Section 8.2.17, “Pluggable Authentication”
</a>
</dt>
<dd>
</dd>
<dt>
<a class="xref" href="load-data-local-security.html" title="8.1.6 Security Considerations for LOAD DATA LOCAL">
Section 8.1.6, “Security Considerations for LOAD DATA LOCAL”
</a>
</dt>
<dd>
</dd>
<dt>
<a class="xref" href="expired-password-handling.html" title="8.2.16 Server Handling of Expired Passwords">
Section 8.2.16, “Server Handling of Expired Passwords”
</a>
</dt>
<dd>
</dd>
<dt>
<a class="xref" href="sha256-pluggable-authentication.html" title="8.4.1.3 SHA-256 Pluggable Authentication">
Section 8.4.1.3, “SHA-256 Pluggable Authentication”
</a>
</dt>
<dd>
</dd>
<dt>
<a class="xref" href="multiple-server-clients.html" title="7.8.4 Using Client Programs in a Multiple-Server Environment">
Section 7.8.4, “Using Client Programs in a Multiple-Server Environment”
</a>
</dt>
<dd>
</dd>
</dl>
</div>
<div class="indexdiv">
<h3 class="title">
mysql_options4()
</h3>
<dl>
<dt>
<a class="xref" href="multifactor-authentication.html" title="8.2.18 Multifactor Authentication">
Section 8.2.18, “Multifactor Authentication”
</a>
</dt>
<dd>
</dd>
<dt>
<a class="xref" href="performance-schema-connection-attribute-tables.html" title="29.12.9 Performance Schema Connection Attribute Tables">
Section 29.12.9, “Performance Schema Connection Attribute Tables”
</a>
</dt>
<dd>
</dd>
</dl>
</div>
<div class="indexdiv">
<h3 class="title">
mysql_ping()
</h3>
<dl>
<dt>
<a class="xref" href="gone-away.html" title="B.3.2.7 MySQL server has gone away">
Section B.3.2.7, “MySQL server has gone away”
</a>
</dt>
<dd>
</dd>
</dl>
</div>
<div class="indexdiv">
<h3 class="title">
mysql_query()
</h3>
<dl>
<dt>
<a class="xref" href="call.html" title="15.2.1 CALL Statement">
Section 15.2.1, “CALL Statement”
</a>
</dt>
<dd>
</dd>
</dl>
</div>
<div class="indexdiv">
<h3 class="title">
mysql_real_connect()
</h3>
<dl>
<dt>
<a class="xref" href="call.html" title="15.2.1 CALL Statement">
Section 15.2.1, “CALL Statement”
</a>
</dt>
<dd>
</dd>
<dt>
<a class="xref" href="connecting-using-dns-srv.html" title="6.2.6 Connecting to the Server Using DNS SRV Records">
Section 6.2.6, “Connecting to the Server Using DNS SRV Records”
</a>
</dt>
<dd>
</dd>
<dt>
<a class="xref" href="functions.html" title="Chapter 14 Functions and Operators">
Chapter 14,
<i>
Functions and Operators
</i>
</a>
</dt>
<dd>
</dd>
<dt>
<a class="xref" href="information-functions.html" title="14.15 Information Functions">
Section 14.15, “Information Functions”
</a>
</dt>
<dd>
</dd>
<dt>
<a class="xref" href="insert-on-duplicate.html" title="15.2.7.2 INSERT ... ON DUPLICATE KEY UPDATE Statement">
Section 15.2.7.2, “INSERT ... ON DUPLICATE KEY UPDATE Statement”
</a>
</dt>
<dd>
</dd>
<dt>
<a class="xref" href="insert.html" title="15.2.7 INSERT Statement">
Section 15.2.7, “INSERT Statement”
</a>
</dt>
<dd>
</dd>
<dt>
<a class="xref" href="mysql-command-options.html" title="6.5.1.1 mysql Client Options">
Section 6.5.1.1, “mysql Client Options”
</a>
</dt>
<dd>
</dd>
<dt>
<a class="xref" href="sql-prepared-statements.html" title="15.5 Prepared Statements">
Section 15.5, “Prepared Statements”
</a>
</dt>
<dd>
</dd>
<dt>
<a class="xref" href="expired-password-handling.html" title="8.2.16 Server Handling of Expired Passwords">
Section 8.2.16, “Server Handling of Expired Passwords”
</a>
</dt>
<dd>
</dd>
<dt>
<a class="xref" href="server-system-variables.html" title="7.1.8 Server System Variables">
Section 7.1.8, “Server System Variables”
</a>
</dt>
<dd>
</dd>
<dt>
<a class="xref" href="stored-routines-syntax.html" title="27.2.1 Stored Routine Syntax">
Section 27.2.1, “Stored Routine Syntax”
</a>
</dt>
<dd>
</dd>
<dt>
<a class="xref" href="unix-signal-response.html" title="6.10 Unix Signal Handling in MySQL">
Section 6.10, “Unix Signal Handling in MySQL”
</a>
</dt>
<dd>
</dd>
<dt>
<a class="xref" href="multiple-server-clients.html" title="7.8.4 Using Client Programs in a Multiple-Server Environment">
Section 7.8.4, “Using Client Programs in a Multiple-Server Environment”
</a>
</dt>
<dd>
</dd>
</dl>
</div>
<div class="indexdiv">
<h3 class="title">
mysql_real_connect_dns_srv()
</h3>
<dl>
<dt>
<a class="xref" href="connecting-using-dns-srv.html" title="6.2.6 Connecting to the Server Using DNS SRV Records">
Section 6.2.6, “Connecting to the Server Using DNS SRV Records”
</a>
</dt>
<dd>
</dd>
<dt>
<a class="xref" href="mysql-command-options.html" title="6.5.1.1 mysql Client Options">
Section 6.5.1.1, “mysql Client Options”
</a>
</dt>
<dd>
</dd>
</dl>
</div>
<div class="indexdiv">
<h3 class="title">
mysql_real_escape_string_quote()
</h3>
<dl>
<dt>
<a class="xref" href="secure-client-programming.html" title="8.1.7 Client Programming Security Guidelines">
Section 8.1.7, “Client Programming Security Guidelines”
</a>
</dt>
<dd>
</dd>
<dt>
<a class="xref" href="populating-spatial-columns.html" title="13.4.7 Populating Spatial Columns">
Section 13.4.7, “Populating Spatial Columns”
</a>
</dt>
<dd>
</dd>
<dt>
<a class="xref" href="string-literals.html" title="11.1.1 String Literals">
Section 11.1.1, “String Literals”
</a>
</dt>
<dd>
</dd>
</dl>
</div>
<div class="indexdiv">
<h3 class="title">
mysql_real_query()
</h3>
<dl>
<dt>
<a class="xref" href="call.html" title="15.2.1 CALL Statement">
Section 15.2.1, “CALL Statement”
</a>
</dt>
<dd>
</dd>
<dt>
<a class="xref" href="federated-description.html" title="18.8.1 FEDERATED Storage Engine Overview">
Section 18.8.1, “FEDERATED Storage Engine Overview”
</a>
</dt>
<dd>
</dd>
</dl>
</div>
<div class="indexdiv">
<h3 class="title">
mysql_session_track_get_first()
</h3>
<dl>
<dt>
<a class="xref" href="session-state-tracking.html" title="7.1.18 Server Tracking of Client Session State">
Section 7.1.18, “Server Tracking of Client Session State”
</a>
</dt>
<dd>
</dd>
</dl>
</div>
<div class="indexdiv">
<h3 class="title">
mysql_session_track_get_next()
</h3>
<dl>
<dt>
<a class="xref" href="session-state-tracking.html" title="7.1.18 Server Tracking of Client Session State">
Section 7.1.18, “Server Tracking of Client Session State”
</a>
</dt>
<dd>
</dd>
</dl>
</div>
<div class="indexdiv">
<h3 class="title">
mysql_shutdown()
</h3>
<dl>
<dt>
<a class="xref" href="privileges-provided.html" title="8.2.2 Privileges Provided by MySQL">
Section 8.2.2, “Privileges Provided by MySQL”
</a>
</dt>
<dd>
</dd>
</dl>
</div>
<div class="indexdiv">
<h3 class="title">
mysql_sqlstate()
</h3>
<dl>
<dt>
<a class="xref" href="error-interfaces.html" title="B.2 Error Information Interfaces">
Section B.2, “Error Information Interfaces”
</a>
</dt>
<dd>
</dd>
<dt>
<a class="xref" href="signal.html" title="15.6.7.5 SIGNAL Statement">
Section 15.6.7.5, “SIGNAL Statement”
</a>
</dt>
<dd>
</dd>
</dl>
</div>
<div class="indexdiv">
<h3 class="title">
mysql_stmt_attr_set()
</h3>
<dl>
<dt>
<a class="xref" href="cursor-restrictions.html" title="15.6.6.5 Restrictions on Server-Side Cursors">
Section 15.6.6.5, “Restrictions on Server-Side Cursors”
</a>
</dt>
<dd>
</dd>
</dl>
</div>
<div class="indexdiv">
<h3 class="title">
mysql_stmt_close()
</h3>
<dl>
<dt>
<a class="xref" href="performance-schema-prepared-statements-instances-table.html" title="29.12.6.4 The prepared_statements_instances Table">
Section 29.12.6.4, “The prepared_statements_instances Table”
</a>
</dt>
<dd>
</dd>
</dl>
</div>
<div class="indexdiv">
<h3 class="title">
mysql_stmt_errno()
</h3>
<dl>
<dt>
<a class="xref" href="error-interfaces.html" title="B.2 Error Information Interfaces">
Section B.2, “Error Information Interfaces”
</a>
</dt>
<dd>
</dd>
</dl>
</div>
<div class="indexdiv">
<h3 class="title">
mysql_stmt_error()
</h3>
<dl>
<dt>
<a class="xref" href="error-interfaces.html" title="B.2 Error Information Interfaces">
Section B.2, “Error Information Interfaces”
</a>
</dt>
<dd>
</dd>
</dl>
</div>
<div class="indexdiv">
<h3 class="title">
mysql_stmt_execute()
</h3>
<dl>
<dt>
<a class="xref" href="performance-schema-prepared-statements-instances-table.html" title="29.12.6.4 The prepared_statements_instances Table">
Section 29.12.6.4, “The prepared_statements_instances Table”
</a>
</dt>
<dd>
</dd>
</dl>
</div>
<div class="indexdiv">
<h3 class="title">
mysql_stmt_next_result()
</h3>
<dl>
<dt>
<a class="xref" href="call.html" title="15.2.1 CALL Statement">
Section 15.2.1, “CALL Statement”
</a>
</dt>
<dd>
</dd>
</dl>
</div>
<div class="indexdiv">
<h3 class="title">
mysql_stmt_prepare()
</h3>
<dl>
<dt>
<a class="xref" href="statement-caching.html" title="10.10.3 Caching of Prepared Statements and Stored Programs">
Section 10.10.3, “Caching of Prepared Statements and Stored Programs”
</a>
</dt>
<dd>
</dd>
<dt>
<a class="xref" href="sql-prepared-statements.html" title="15.5 Prepared Statements">
Section 15.5, “Prepared Statements”
</a>
</dt>
<dd>
</dd>
<dt>
<a class="xref" href="performance-schema-prepared-statements-instances-table.html" title="29.12.6.4 The prepared_statements_instances Table">
Section 29.12.6.4, “The prepared_statements_instances Table”
</a>
</dt>
<dd>
</dd>
</dl>
</div>
<div class="indexdiv">
<h3 class="title">
mysql_stmt_send_long_data()
</h3>
<dl>
<dt>
<a class="xref" href="server-system-variables.html" title="7.1.8 Server System Variables">
Section 7.1.8, “Server System Variables”
</a>
</dt>
<dd>
</dd>
</dl>
</div>
<div class="indexdiv">
<h3 class="title">
mysql_stmt_sqlstate()
</h3>
<dl>
<dt>
<a class="xref" href="error-interfaces.html" title="B.2 Error Information Interfaces">
Section B.2, “Error Information Interfaces”
</a>
</dt>
<dd>
</dd>
</dl>
</div>
<div class="indexdiv">
<h3 class="title">
mysql_store_result()
</h3>
<dl>
<dt>
<a class="xref" href="commands-out-of-sync.html" title="B.3.2.12 Commands out of sync">
Section B.3.2.12, “Commands out of sync”
</a>
</dt>
<dd>
</dd>
<dt>
<a class="xref" href="federated-description.html" title="18.8.1 FEDERATED Storage Engine Overview">
Section 18.8.1, “FEDERATED Storage Engine Overview”
</a>
</dt>
<dd>
</dd>
<dt>
<a class="xref" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
Section 6.5.1, “mysql — The MySQL Command-Line Client”
</a>
</dt>
<dd>
</dd>
</dl>
</div>
<div class="indexdiv">
<h3 class="title">
mysql_use_result()
</h3>
<dl>
<dt>
<a class="xref" href="commands-out-of-sync.html" title="B.3.2.12 Commands out of sync">
Section B.3.2.12, “Commands out of sync”
</a>
</dt>
<dd>
</dd>
<dt>
<a class="xref" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
Section 6.5.1, “mysql — The MySQL Command-Line Client”
</a>
</dt>
<dd>
</dd>
<dt>
<a class="xref" href="out-of-memory.html" title="B.3.2.6 Out of memory">
Section B.3.2.6, “Out of memory”
</a>
</dt>
<dd>
</dd>
</dl>
</div>
<div class="indexdiv">
<h3 class="title">
mysql_warning_count()
</h3>
<dl>
<dt>
<a class="xref" href="error-interfaces.html" title="B.2 Error Information Interfaces">
Section B.2, “Error Information Interfaces”
</a>
</dt>
<dd>
</dd>
<dt>
<a class="xref" href="show-warnings.html" title="15.7.7.42 SHOW WARNINGS Statement">
Section 15.7.7.42, “SHOW WARNINGS Statement”
</a>
</dt>
<dd>
</dd>
</dl>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/innodb-index-types.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="innodb-index-types">
</a>
17.6.2.1 Clustered and Secondary Indexes
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045165869152">
</a>
<a class="indexterm" name="idm46045165867696">
</a>
<a class="indexterm" name="idm46045165866208">
</a>
<a class="indexterm" name="idm46045165864720">
</a>
<p>
Each
<code class="literal">
InnoDB
</code>
table has a special index called
the clustered index that stores row data. Typically, the clustered
index is synonymous with the primary key. To get the best
performance from queries, inserts, and other database operations,
it is important to understand how
<code class="literal">
InnoDB
</code>
uses
the clustered index to optimize the common lookup and DML
operations.
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
When you define a
<code class="literal">
PRIMARY KEY
</code>
on a table,
<code class="literal">
InnoDB
</code>
uses it as the clustered index. A
primary key should be defined for each table. If there is no
logical unique and non-null column or set of columns to use a
the primary key, add an auto-increment column. Auto-increment
column values are unique and are added automatically as new
rows are inserted.
</p>
</li>
<li class="listitem">
<p>
If you do not define a
<code class="literal">
PRIMARY KEY
</code>
for a
table,
<code class="literal">
InnoDB
</code>
uses the first
<code class="literal">
UNIQUE
</code>
index with all key columns defined
as
<code class="literal">
NOT NULL
</code>
as the clustered index.
</p>
</li>
<li class="listitem">
<p>
If a table has no
<code class="literal">
PRIMARY KEY
</code>
or suitable
<code class="literal">
UNIQUE
</code>
index,
<code class="literal">
InnoDB
</code>
generates a hidden clustered index named
<code class="literal">
GEN_CLUST_INDEX
</code>
on a synthetic column that
contains row ID values. The rows are ordered by the row ID
that
<code class="literal">
InnoDB
</code>
assigns. The row ID is a 6-byte
field that increases monotonically as new rows are inserted.
Thus, the rows ordered by the row ID are physically in order
of insertion.
</p>
</li>
</ul>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="innodb-index-types-query-performance">
</a>
How the Clustered Index Speeds Up Queries
</h5>
</div>
</div>
</div>
<p>
Accessing a row through the clustered index is fast because the
index search leads directly to the page that contains the row
data. If a table is large, the clustered index architecture
often saves a disk I/O operation when compared to storage
organizations that store row data using a different page from
the index record.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="innodb-index-types-secondary-clustered">
</a>
How Secondary Indexes Relate to the Clustered Index
</h5>
</div>
</div>
</div>
<p>
Indexes other than the clustered index are known as secondary
indexes. In
<code class="literal">
InnoDB
</code>
, each record in a
secondary index contains the primary key columns for the row, as
well as the columns specified for the secondary index.
<code class="literal">
InnoDB
</code>
uses this primary key value to search
for the row in the clustered index.
</p>
<p>
If the primary key is long, the secondary indexes use more
space, so it is advantageous to have a short primary key.
</p>
<p>
For guidelines to take advantage of
<code class="literal">
InnoDB
</code>
clustered and secondary indexes, see
<a class="xref" href="optimization-indexes.html" title="10.3 Optimization and Indexes">
Section 10.3, “Optimization and Indexes”
</a>
.
</p>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/timestamp-lookups.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="timestamp-lookups">
</a>
10.3.14 Indexed Lookups from TIMESTAMP Columns
</h3>
</div>
</div>
</div>
<a class="indexterm" name="idm46045226923264">
</a>
<a class="indexterm" name="idm46045226921808">
</a>
<p>
Temporal values are stored in
<a class="link" href="datetime.html" title="13.2.2 The DATE, DATETIME, and TIMESTAMP Types">
<code class="literal">
TIMESTAMP
</code>
</a>
columns as UTC values,
and values inserted into and retrieved from
<a class="link" href="datetime.html" title="13.2.2 The DATE, DATETIME, and TIMESTAMP Types">
<code class="literal">
TIMESTAMP
</code>
</a>
columns are converted
between the session time zone and UTC. (This is the same type of
conversion performed by the
<a class="link" href="date-and-time-functions.html#function_convert-tz">
<code class="literal">
CONVERT_TZ()
</code>
</a>
function. If the
session time zone is UTC, there is effectively no time zone
conversion.)
</p>
<a class="indexterm" name="idm46045226915888">
</a>
<p>
Due to conventions for local time zone changes such as Daylight
Saving Time (DST), conversions between UTC and non-UTC time
zones are not one-to-one in both directions. UTC values that are
distinct may not be distinct in another time zone. The following
example shows distinct UTC values that become identical in a
non-UTC time zone:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa29605482"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> tstable <span class="token punctuation">(</span>ts <span class="token datatype">TIMESTAMP</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">SET</span> time_zone <span class="token operator">=</span> <span class="token string">'UTC'</span><span class="token punctuation">;</span> <span class="token comment" spellcheck="true">-- insert UTC values</span>
<span class="token prompt">mysql></span> <span class="token keyword">INSERT</span> <span class="token keyword">INTO</span> tstable <span class="token keyword">VALUES</span>
<span class="token punctuation">(</span><span class="token string">'2018-10-28 00:30:00'</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token punctuation">(</span><span class="token string">'2018-10-28 01:30:00'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> ts <span class="token keyword">FROM</span> tstable<span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> ts <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 2018<span class="token punctuation">-</span>10<span class="token punctuation">-</span>28 00:30:00 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 2018<span class="token punctuation">-</span>10<span class="token punctuation">-</span>28 01:30:00 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token prompt">mysql></span> <span class="token keyword">SET</span> time_zone <span class="token operator">=</span> <span class="token string">'MET'</span><span class="token punctuation">;</span> <span class="token comment" spellcheck="true">-- retrieve non-UTC values</span>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> ts <span class="token keyword">FROM</span> tstable<span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> ts <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 2018<span class="token punctuation">-</span>10<span class="token punctuation">-</span>28 02:30:00 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 2018<span class="token punctuation">-</span>10<span class="token punctuation">-</span>28 02:30:00 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
To use named time zones such as
<code class="literal">
'MET'
</code>
or
<code class="literal">
'Europe/Amsterdam'
</code>
, the time zone tables
must be properly set up. For instructions, see
<a class="xref" href="time-zone-support.html" title="7.1.15 MySQL Server Time Zone Support">
Section 7.1.15, “MySQL Server Time Zone Support”
</a>
.
</p>
</div>
<p>
You can see that the two distinct UTC values are the same when
converted to the
<code class="literal">
'MET'
</code>
time zone. This
phenomenon can lead to different results for a given
<a class="link" href="datetime.html" title="13.2.2 The DATE, DATETIME, and TIMESTAMP Types">
<code class="literal">
TIMESTAMP
</code>
</a>
column query, depending
on whether the optimizer uses an index to execute the query.
</p>
<p>
Suppose that a query selects values from the table shown earlier
using a
<code class="literal">
WHERE
</code>
clause to search the
<code class="literal">
ts
</code>
column for a single specific value such as
a user-provided timestamp literal:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa84873753"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> ts <span class="token keyword">FROM</span> tstable
<span class="token keyword">WHERE</span> ts <span class="token operator">=</span> <span class="token string">'<em class="replaceable">literal</em>'</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
Suppose further that the query executes under these conditions:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
The session time zone is not UTC and has a DST shift. For
example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa86783854"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SET</span> time_zone <span class="token operator">=</span> <span class="token string">'MET'</span><span class="token punctuation">;</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
Unique UTC values stored in the
<a class="link" href="datetime.html" title="13.2.2 The DATE, DATETIME, and TIMESTAMP Types">
<code class="literal">
TIMESTAMP
</code>
</a>
column are not
unique in the session time zone due to DST shifts. (The
example shown earlier illustrates how this can occur.)
</p>
</li>
<li class="listitem">
<p>
The query specifies a search value that is within the hour
of entry into DST in the session time zone.
</p>
</li>
</ul>
</div>
<p>
Under those conditions, the comparison in the
<code class="literal">
WHERE
</code>
clause occurs in different ways for
nonindexed and indexed lookups and leads to different results:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
If there is no index or the optimizer cannot use it,
comparisons occur in the session time zone. The optimizer
performs a table scan in which it retrieves each
<code class="literal">
ts
</code>
column value, converts it from UTC to
the session time zone, and compares it to the search value
(also interpreted in the session time zone):
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa25368158"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> ts <span class="token keyword">FROM</span> tstable
<span class="token keyword">WHERE</span> ts <span class="token operator">=</span> <span class="token string">'2018-10-28 02:30:00'</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> ts <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 2018<span class="token punctuation">-</span>10<span class="token punctuation">-</span>28 02:30:00 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 2018<span class="token punctuation">-</span>10<span class="token punctuation">-</span>28 02:30:00 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
<p>
Because the stored
<code class="literal">
ts
</code>
values are
converted to the session time zone, it is possible for the
query to return two timestamp values that are distinct as
UTC values but equal in the session time zone: One value
that occurs before the DST shift when clocks are changed,
and one value that was occurs after the DST shift.
</p>
</li>
<li class="listitem">
<p>
If there is a usable index, comparisons occur in UTC. The
optimizer performs an index scan, first converting the
search value from the session time zone to UTC, then
comparing the result to the UTC index entries:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa76770608"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">ALTER</span> <span class="token keyword">TABLE</span> tstable <span class="token keyword">ADD</span> <span class="token keyword">INDEX</span> <span class="token punctuation">(</span>ts<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> ts <span class="token keyword">FROM</span> tstable
<span class="token keyword">WHERE</span> ts <span class="token operator">=</span> <span class="token string">'2018-10-28 02:30:00'</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> ts <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 2018<span class="token punctuation">-</span>10<span class="token punctuation">-</span>28 02:30:00 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
<p>
In this case, the (converted) search value is matched only
to index entries, and because the index entries for the
distinct stored UTC values are also distinct, the search
value can match only one of them.
</p>
</li>
</ul>
</div>
<p>
Due to different optimizer operation for nonindexed and indexed
lookups, the query produces different results in each case. The
result from the nonindexed lookup returns all values that match
in the session time zone. The indexed lookup cannot do so:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
It is performed within the storage engine, which knows only
about UTC values.
</p>
</li>
<li class="listitem">
<p>
For the two distinct session time zone values that map to
the same UTC value, the indexed lookup matches only the
corresponding UTC index entry and returns only a single row.
</p>
</li>
</ul>
</div>
<p>
In the preceding discussion, the data set stored in
<code class="literal">
tstable
</code>
happens to consist of distinct UTC
values. In such cases, all index-using queries of the form shown
match at most one index entry.
</p>
<p>
If the index is not
<code class="literal">
UNIQUE
</code>
, it is possible
for the table (and the index) to store multiple instances of a
given UTC value. For example, the
<code class="literal">
ts
</code>
column
might contain multiple instances of the UTC value
<code class="literal">
'2018-10-28 00:30:00'
</code>
. In this case, the
index-using query would return each of them (converted to the
MET value
<code class="literal">
'2018-10-28 02:30:00'
</code>
in the result
set). It remains true that index-using queries match the
converted search value to a single value in the UTC index
entries, rather than matching multiple UTC values that convert
to the search value in the session time zone.
</p>
<p>
If it is important to return all
<code class="literal">
ts
</code>
values
that match in the session time zone, the workaround is to
suppress use of the index with an
<code class="literal">
IGNORE
INDEX
</code>
hint:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa21713766"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> ts <span class="token keyword">FROM</span> tstable
<span class="token keyword">IGNORE</span> <span class="token keyword">INDEX</span> <span class="token punctuation">(</span>ts<span class="token punctuation">)</span>
<span class="token keyword">WHERE</span> ts <span class="token operator">=</span> <span class="token string">'2018-10-28 02:30:00'</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> ts <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 2018<span class="token punctuation">-</span>10<span class="token punctuation">-</span>28 02:30:00 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 2018<span class="token punctuation">-</span>10<span class="token punctuation">-</span>28 02:30:00 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
<p>
The same lack of one-to-one mapping for time zone conversions in
both directions occurs in other contexts as well, such as
conversions performed with the
<a class="link" href="date-and-time-functions.html#function_from-unixtime">
<code class="literal">
FROM_UNIXTIME()
</code>
</a>
and
<a class="link" href="date-and-time-functions.html#function_unix-timestamp">
<code class="literal">
UNIX_TIMESTAMP()
</code>
</a>
functions. See
<a class="xref" href="date-and-time-functions.html" title="14.7 Date and Time Functions">
Section 14.7, “Date and Time Functions”
</a>
.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/audit-log-filter-definitions.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="audit-log-filter-definitions">
</a>
8.4.5.8 Writing Audit Log Filter Definitions
</h4>
</div>
</div>
</div>
<p>
Filter definitions are
<a class="link" href="json.html" title="13.5 The JSON Data Type">
<code class="literal">
JSON
</code>
</a>
values. For information about using
<a class="link" href="json.html" title="13.5 The JSON Data Type">
<code class="literal">
JSON
</code>
</a>
data in MySQL, see
<a class="xref" href="json.html" title="13.5 The JSON Data Type">
Section 13.5, “The JSON Data Type”
</a>
.
</p>
<p>
Filter definitions have this form, where
<em class="replaceable">
<code>
actions
</code>
</em>
indicates how filtering takes
place:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-json"><div class="docs-select-all right" id="sa48588991"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token punctuation">{</span> <span class="token property">"filter"</span><span class="token operator">:</span> <em class="replaceable">actions</em> <span class="token punctuation">}</span></code></pre>
</div>
<p>
The following discussion describes permitted constructs in
filter definitions.
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="xref" href="audit-log-filter-definitions.html#audit-log-filtering-enabling-logging" title="Logging All Events">
Logging All Events
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="audit-log-filter-definitions.html#audit-log-filtering-class-logging" title="Logging Specific Event Classes">
Logging Specific Event Classes
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="audit-log-filter-definitions.html#audit-log-filtering-subclass-logging" title="Logging Specific Event Subclasses">
Logging Specific Event Subclasses
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="audit-log-filter-definitions.html#audit-log-filtering-inclusive-exclusive" title="Inclusive and Exclusive Logging">
Inclusive and Exclusive Logging
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="audit-log-filter-definitions.html#audit-log-filtering-event-fields" title="Testing Event Field Values">
Testing Event Field Values
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="audit-log-filter-definitions.html#audit-log-filtering-blocking-events" title="Blocking Execution of Specific Events">
Blocking Execution of Specific Events
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="audit-log-filter-definitions.html#audit-log-filtering-logical-operators" title="Logical Operators">
Logical Operators
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="audit-log-filter-definitions.html#audit-log-filtering-predefined-variables" title="Referencing Predefined Variables">
Referencing Predefined Variables
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="audit-log-filter-definitions.html#audit-log-filtering-predefined-functions" title="Referencing Predefined Functions">
Referencing Predefined Functions
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="audit-log-filter-definitions.html#audit-log-filtering-field-replacement" title="Replacement of Event Field Values">
Replacement of Event Field Values
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="audit-log-filter-definitions.html#audit-log-filtering-filter-replacement" title="Replacing a User Filter">
Replacing a User Filter
</a>
</p>
</li>
</ul>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="audit-log-filtering-enabling-logging">
</a>
Logging All Events
</h5>
</div>
</div>
</div>
<p>
To explicitly enable or disable logging of all events, use a
<code class="literal">
log
</code>
item in the filter:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-json"><div class="docs-select-all right" id="sa91955043"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token punctuation">{</span>
<span class="token property">"filter"</span><span class="token operator">:</span> <span class="token punctuation">{</span> <span class="token property">"log"</span><span class="token operator">:</span> <span class="token boolean">true</span> <span class="token punctuation">}</span>
<span class="token punctuation">}</span></code></pre>
</div>
<p>
The
<code class="literal">
log
</code>
value can be either
<code class="literal">
true
</code>
or
<code class="literal">
false
</code>
.
</p>
<p>
The preceding filter enables logging of all events. It is
equivalent to:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-json"><div class="docs-select-all right" id="sa12962291"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token punctuation">{</span>
<span class="token property">"filter"</span><span class="token operator">:</span> <span class="token punctuation">{</span> <span class="token punctuation">}</span>
<span class="token punctuation">}</span></code></pre>
</div>
<p>
Logging behavior depends on the
<code class="literal">
log
</code>
value
and whether
<code class="literal">
class
</code>
or
<code class="literal">
event
</code>
items are specified:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
With
<code class="literal">
log
</code>
specified, its given value is
used.
</p>
</li>
<li class="listitem">
<p>
Without
<code class="literal">
log
</code>
specified, logging is
<code class="literal">
true
</code>
if no
<code class="literal">
class
</code>
or
<code class="literal">
event
</code>
item is specified, and
<code class="literal">
false
</code>
otherwise (in which case,
<code class="literal">
class
</code>
or
<code class="literal">
event
</code>
can
include their own
<code class="literal">
log
</code>
item).
</p>
</li>
</ul>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="audit-log-filtering-class-logging">
</a>
Logging Specific Event Classes
</h5>
</div>
</div>
</div>
<p>
To log events of a specific class, use a
<code class="literal">
class
</code>
item in the filter, with its
<code class="literal">
name
</code>
field denoting the name of the class
to log:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-json"><div class="docs-select-all right" id="sa94303265"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token punctuation">{</span>
<span class="token property">"filter"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"class"</span><span class="token operator">:</span> <span class="token punctuation">{</span> <span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"connection"</span> <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span></code></pre>
</div>
<p>
The
<code class="literal">
name
</code>
value can be
<code class="literal">
connection
</code>
,
<code class="literal">
general
</code>
, or
<code class="literal">
table_access
</code>
to log connection, general, or
table-access events, respectively.
</p>
<p>
The preceding filter enables logging of events in the
<code class="literal">
connection
</code>
class. It is equivalent to the
following filter with
<code class="literal">
log
</code>
items made
explicit:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-json"><div class="docs-select-all right" id="sa15188825"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token punctuation">{</span>
<span class="token property">"filter"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"log"</span><span class="token operator">:</span> <span class="token boolean">false</span><span class="token punctuation">,</span>
<span class="token property">"class"</span><span class="token operator">:</span> <span class="token punctuation">{</span> <span class="token property">"log"</span><span class="token operator">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span>
<span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"connection"</span> <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span></code></pre>
</div>
<p>
To enable logging of multiple classes, define the
<code class="literal">
class
</code>
value as a
<a class="link" href="json.html" title="13.5 The JSON Data Type">
<code class="literal">
JSON
</code>
</a>
array element that names
the classes:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-json"><div class="docs-select-all right" id="sa12421093"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token punctuation">{</span>
<span class="token property">"filter"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"class"</span><span class="token operator">:</span> <span class="token punctuation">[</span>
<span class="token punctuation">{</span> <span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"connection"</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token punctuation">{</span> <span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"general"</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token punctuation">{</span> <span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"table_access"</span> <span class="token punctuation">}</span>
<span class="token punctuation">]</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span></code></pre>
</div>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
When multiple instances of a given item appear at the same
level within a filter definition, the item values can be
combined into a single instance of that item within an array
value. The preceding definition can be written like this:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-json"><div class="docs-select-all right" id="sa87807845"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token punctuation">{</span>
<span class="token property">"filter"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"class"</span><span class="token operator">:</span> <span class="token punctuation">[</span>
<span class="token punctuation">{</span> <span class="token property">"name"</span><span class="token operator">:</span> <span class="token punctuation">[</span> <span class="token string">"connection"</span><span class="token punctuation">,</span> <span class="token string">"general"</span><span class="token punctuation">,</span> <span class="token string">"table_access"</span> <span class="token punctuation">]</span> <span class="token punctuation">}</span>
<span class="token punctuation">]</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span></code></pre>
</div>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="audit-log-filtering-subclass-logging">
</a>
Logging Specific Event Subclasses
</h5>
</div>
</div>
</div>
<p>
To select specific event subclasses, use an
<code class="literal">
event
</code>
item containing a
<code class="literal">
name
</code>
item that names the subclasses. The
default action for events selected by an
<code class="literal">
event
</code>
item is to log them. For example,
this filter enables logging for the named event subclasses:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-json"><div class="docs-select-all right" id="sa69789163"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token punctuation">{</span>
<span class="token property">"filter"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"class"</span><span class="token operator">:</span> <span class="token punctuation">[</span>
<span class="token punctuation">{</span>
<span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"connection"</span><span class="token punctuation">,</span>
<span class="token property">"event"</span><span class="token operator">:</span> <span class="token punctuation">[</span>
<span class="token punctuation">{</span> <span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"connect"</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token punctuation">{</span> <span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"disconnect"</span> <span class="token punctuation">}</span>
<span class="token punctuation">]</span>
<span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token punctuation">{</span> <span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"general"</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token punctuation">{</span>
<span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"table_access"</span><span class="token punctuation">,</span>
<span class="token property">"event"</span><span class="token operator">:</span> <span class="token punctuation">[</span>
<span class="token punctuation">{</span> <span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"insert"</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token punctuation">{</span> <span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"delete"</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token punctuation">{</span> <span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"update"</span> <span class="token punctuation">}</span>
<span class="token punctuation">]</span>
<span class="token punctuation">}</span>
<span class="token punctuation">]</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span></code></pre>
</div>
<p>
The
<code class="literal">
event
</code>
item can also contain explicit
<code class="literal">
log
</code>
items to indicate whether to log
qualifying events. This
<code class="literal">
event
</code>
item selects
multiple events and explicitly indicates logging behavior for
them:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-json"><div class="docs-select-all right" id="sa50537859"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token property">"event"</span><span class="token operator">:</span> <span class="token punctuation">[</span>
<span class="token punctuation">{</span> <span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"read"</span><span class="token punctuation">,</span> <span class="token property">"log"</span><span class="token operator">:</span> <span class="token boolean">false</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token punctuation">{</span> <span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"insert"</span><span class="token punctuation">,</span> <span class="token property">"log"</span><span class="token operator">:</span> <span class="token boolean">true</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token punctuation">{</span> <span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"delete"</span><span class="token punctuation">,</span> <span class="token property">"log"</span><span class="token operator">:</span> <span class="token boolean">true</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token punctuation">{</span> <span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"update"</span><span class="token punctuation">,</span> <span class="token property">"log"</span><span class="token operator">:</span> <span class="token boolean">true</span> <span class="token punctuation">}</span>
<span class="token punctuation">]</span></code></pre>
</div>
<p>
The
<code class="literal">
event
</code>
item can also indicate whether to
block qualifying events, if it contains an
<code class="literal">
abort
</code>
item. For details, see
<a class="xref" href="audit-log-filter-definitions.html#audit-log-filtering-blocking-events" title="Blocking Execution of Specific Events">
Blocking Execution of Specific Events
</a>
.
</p>
<p>
<a class="xref" href="audit-log-filter-definitions.html#audit-log-event-subclass-combinations" title="Table 8.34 Event Class and Subclass Combinations">
Table 8.34, “Event Class and Subclass Combinations”
</a>
describes the permitted subclass values for each event class.
</p>
<div class="table">
<a name="audit-log-event-subclass-combinations">
</a>
<p class="title">
<b>
Table 8.34 Event Class and Subclass Combinations
</b>
</p>
<div class="table-contents">
<table summary="Permitted combiniations of event class and subclass values.">
<colgroup>
<col style="width: 20%"/>
<col style="width: 20%"/>
<col style="width: 60%"/>
</colgroup>
<thead>
<tr>
<th scope="col">
Event Class
</th>
<th scope="col">
Event Subclass
</th>
<th scope="col">
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">
<code class="literal">
connection
</code>
</th>
<td>
<code class="literal">
connect
</code>
</td>
<td>
Connection initiation (successful or unsuccessful)
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
connection
</code>
</th>
<td>
<code class="literal">
change_user
</code>
</td>
<td>
User re-authentication with different user/password during session
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
connection
</code>
</th>
<td>
<code class="literal">
disconnect
</code>
</td>
<td>
Connection termination
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
general
</code>
</th>
<td>
<code class="literal">
status
</code>
</td>
<td>
General operation information
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
message
</code>
</th>
<td>
<code class="literal">
internal
</code>
</td>
<td>
Internally generated message
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
message
</code>
</th>
<td>
<code class="literal">
user
</code>
</td>
<td>
Message generated by
<a class="link" href="audit-api-message-emit.html#function_audit-api-message-emit-udf">
<code class="literal">
audit_api_message_emit_udf()
</code>
</a>
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
table_access
</code>
</th>
<td>
<code class="literal">
read
</code>
</td>
<td>
Table read statements, such as
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
or
<a class="link" href="insert-select.html" title="15.2.7.1 INSERT ... SELECT Statement">
<code class="literal">
INSERT
INTO ... SELECT
</code>
</a>
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
table_access
</code>
</th>
<td>
<code class="literal">
delete
</code>
</td>
<td>
Table delete statements, such as
<a class="link" href="delete.html" title="15.2.2 DELETE Statement">
<code class="literal">
DELETE
</code>
</a>
or
<a class="link" href="truncate-table.html" title="15.1.37 TRUNCATE TABLE Statement">
<code class="literal">
TRUNCATE TABLE
</code>
</a>
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
table_access
</code>
</th>
<td>
<code class="literal">
insert
</code>
</td>
<td>
Table insert statements, such as
<a class="link" href="insert.html" title="15.2.7 INSERT Statement">
<code class="literal">
INSERT
</code>
</a>
or
<a class="link" href="replace.html" title="15.2.12 REPLACE Statement">
<code class="literal">
REPLACE
</code>
</a>
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
table_access
</code>
</th>
<td>
<code class="literal">
update
</code>
</td>
<td>
Table update statements, such as
<a class="link" href="update.html" title="15.2.17 UPDATE Statement">
<code class="literal">
UPDATE
</code>
</a>
</td>
</tr>
</tbody>
</table>
</div>
<div class="table-contents">
<table cellpadding="0" cellspacing="0" style="position: fixed; top: 0px; display: none; left: 401px; width: 739px;">
<thead>
<tr>
<th scope="col" style="width: 147.594px;">
Event Class
</th>
<th scope="col" style="width: 147.594px;">
Event Subclass
</th>
<th scope="col" style="width: 442.812px;">
Description
</th>
</tr>
</thead>
</table>
</div>
</div>
<br class="table-break"/>
<p>
<a class="xref" href="audit-log-filter-definitions.html#audit-log-event-subclass-log-abort" title="Table 8.35 Log and Abort Characteristics Per Event Class and Subclass Combination">
Table 8.35, “Log and Abort Characteristics Per Event Class and Subclass Combination”
</a>
describes
for each event subclass whether it can be logged or aborted.
</p>
<div class="table">
<a name="audit-log-event-subclass-log-abort">
</a>
<p class="title">
<b>
Table 8.35 Log and Abort Characteristics Per Event Class and Subclass Combination
</b>
</p>
<div class="table-contents">
<table summary="Log and abort characteristics for event class and subclass combinations.">
<colgroup>
<col style="width: 20%"/>
<col style="width: 20%"/>
<col style="width: 30%"/>
<col style="width: 30%"/>
</colgroup>
<thead>
<tr>
<th scope="col">
Event Class
</th>
<th scope="col">
Event Subclass
</th>
<th scope="col">
Can be Logged
</th>
<th scope="col">
Can be Aborted
</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">
<code class="literal">
connection
</code>
</th>
<td>
<code class="literal">
connect
</code>
</td>
<td>
Yes
</td>
<td>
No
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
connection
</code>
</th>
<td>
<code class="literal">
change_user
</code>
</td>
<td>
Yes
</td>
<td>
No
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
connection
</code>
</th>
<td>
<code class="literal">
disconnect
</code>
</td>
<td>
Yes
</td>
<td>
No
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
general
</code>
</th>
<td>
<code class="literal">
status
</code>
</td>
<td>
Yes
</td>
<td>
No
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
message
</code>
</th>
<td>
<code class="literal">
internal
</code>
</td>
<td>
Yes
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
message
</code>
</th>
<td>
<code class="literal">
user
</code>
</td>
<td>
Yes
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
table_access
</code>
</th>
<td>
<code class="literal">
read
</code>
</td>
<td>
Yes
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
table_access
</code>
</th>
<td>
<code class="literal">
delete
</code>
</td>
<td>
Yes
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
table_access
</code>
</th>
<td>
<code class="literal">
insert
</code>
</td>
<td>
Yes
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
table_access
</code>
</th>
<td>
<code class="literal">
update
</code>
</td>
<td>
Yes
</td>
<td>
Yes
</td>
</tr>
</tbody>
</table>
</div>
<div class="table-contents">
<table cellpadding="0" cellspacing="0" style="position: fixed; top: 0px; display: none; left: 401px; width: 558px;">
<thead>
<tr>
<th scope="col" style="width: 111.453px;">
Event Class
</th>
<th scope="col" style="width: 111.453px;">
Event Subclass
</th>
<th scope="col" style="width: 167.172px;">
Can be Logged
</th>
<th scope="col" style="width: 167.188px;">
Can be Aborted
</th>
</tr>
</thead>
</table>
</div>
</div>
<br class="table-break"/>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="audit-log-filtering-inclusive-exclusive">
</a>
Inclusive and Exclusive Logging
</h5>
</div>
</div>
</div>
<p>
A filter can be defined in inclusive or exclusive mode:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Inclusive mode logs only explicitly specified items.
</p>
</li>
<li class="listitem">
<p>
Exclusive mode logs everything but explicitly specified
items.
</p>
</li>
</ul>
</div>
<p>
To perform inclusive logging, disable logging globally and
enable logging for specific classes. This filter logs
<code class="literal">
connect
</code>
and
<code class="literal">
disconnect
</code>
events in the
<code class="literal">
connection
</code>
class, and events
in the
<code class="literal">
general
</code>
class:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-json"><div class="docs-select-all right" id="sa91814338"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token punctuation">{</span>
<span class="token property">"filter"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"log"</span><span class="token operator">:</span> <span class="token boolean">false</span><span class="token punctuation">,</span>
<span class="token property">"class"</span><span class="token operator">:</span> <span class="token punctuation">[</span>
<span class="token punctuation">{</span>
<span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"connection"</span><span class="token punctuation">,</span>
<span class="token property">"event"</span><span class="token operator">:</span> <span class="token punctuation">[</span>
<span class="token punctuation">{</span> <span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"connect"</span><span class="token punctuation">,</span> <span class="token property">"log"</span><span class="token operator">:</span> <span class="token boolean">true</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token punctuation">{</span> <span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"disconnect"</span><span class="token punctuation">,</span> <span class="token property">"log"</span><span class="token operator">:</span> <span class="token boolean">true</span> <span class="token punctuation">}</span>
<span class="token punctuation">]</span>
<span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token punctuation">{</span> <span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"general"</span><span class="token punctuation">,</span> <span class="token property">"log"</span><span class="token operator">:</span> <span class="token boolean">true</span> <span class="token punctuation">}</span>
<span class="token punctuation">]</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span></code></pre>
</div>
<p>
To perform exclusive logging, enable logging globally and
disable logging for specific classes. This filter logs
everything except events in the
<code class="literal">
general
</code>
class:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-json"><div class="docs-select-all right" id="sa54411983"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token punctuation">{</span>
<span class="token property">"filter"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"log"</span><span class="token operator">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span>
<span class="token property">"class"</span><span class="token operator">:</span>
<span class="token punctuation">{</span> <span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"general"</span><span class="token punctuation">,</span> <span class="token property">"log"</span><span class="token operator">:</span> <span class="token boolean">false</span> <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span></code></pre>
</div>
<p>
This filter logs
<code class="literal">
change_user
</code>
events in the
<code class="literal">
connection
</code>
class,
<code class="literal">
message
</code>
events, and
<code class="literal">
table_access
</code>
events, by virtue of
<span class="emphasis">
<em>
not
</em>
</span>
logging everything else:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-json"><div class="docs-select-all right" id="sa30320516"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token punctuation">{</span>
<span class="token property">"filter"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"log"</span><span class="token operator">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span>
<span class="token property">"class"</span><span class="token operator">:</span> <span class="token punctuation">[</span>
<span class="token punctuation">{</span>
<span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"connection"</span><span class="token punctuation">,</span>
<span class="token property">"event"</span><span class="token operator">:</span> <span class="token punctuation">[</span>
<span class="token punctuation">{</span> <span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"connect"</span><span class="token punctuation">,</span> <span class="token property">"log"</span><span class="token operator">:</span> <span class="token boolean">false</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token punctuation">{</span> <span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"disconnect"</span><span class="token punctuation">,</span> <span class="token property">"log"</span><span class="token operator">:</span> <span class="token boolean">false</span> <span class="token punctuation">}</span>
<span class="token punctuation">]</span>
<span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token punctuation">{</span> <span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"general"</span><span class="token punctuation">,</span> <span class="token property">"log"</span><span class="token operator">:</span> <span class="token boolean">false</span> <span class="token punctuation">}</span>
<span class="token punctuation">]</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span></code></pre>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="audit-log-filtering-event-fields">
</a>
Testing Event Field Values
</h5>
</div>
</div>
</div>
<p>
To enable logging based on specific event field values,
specify a
<code class="literal">
field
</code>
item within the
<code class="literal">
log
</code>
item that indicates the field name and
its expected value:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-json"><div class="docs-select-all right" id="sa39632174"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token punctuation">{</span>
<span class="token property">"filter"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"class"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"general"</span><span class="token punctuation">,</span>
<span class="token property">"event"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"status"</span><span class="token punctuation">,</span>
<span class="token property">"log"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"field"</span><span class="token operator">:</span> <span class="token punctuation">{</span> <span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"general_command.str"</span><span class="token punctuation">,</span> <span class="token property">"value"</span><span class="token operator">:</span> <span class="token string">"Query"</span> <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span></code></pre>
</div>
<p>
Each event contains event class-specific fields that can be
accessed from within a filter to perform custom filtering.
</p>
<p>
An event in the
<code class="literal">
connection
</code>
class indicates
when a connection-related activity occurs during a session,
such as a user connecting to or disconnecting from the server.
<a class="xref" href="audit-log-filter-definitions.html#audit-log-connection-event-fields" title="Table 8.36 Connection Event Fields">
Table 8.36, “Connection Event Fields”
</a>
indicates
the permitted fields for
<code class="literal">
connection
</code>
events.
</p>
<div class="table">
<a name="audit-log-connection-event-fields">
</a>
<p class="title">
<b>
Table 8.36 Connection Event Fields
</b>
</p>
<div class="table-contents">
<table summary="Permitted fields for connection events.">
<colgroup>
<col style="width: 35%"/>
<col style="width: 20%"/>
<col style="width: 45%"/>
</colgroup>
<thead>
<tr>
<th scope="col">
Field Name
</th>
<th scope="col">
Field Type
</th>
<th scope="col">
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">
<code class="literal">
status
</code>
</th>
<td>
integer
</td>
<td>
<p class="valid-value">
Event status:
</p>
<p class="valid-value">
0: OK
</p>
<p class="valid-value">
Otherwise: Failed
</p>
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
connection_id
</code>
</th>
<td>
unsigned integer
</td>
<td>
Connection ID
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
user.str
</code>
</th>
<td>
string
</td>
<td>
User name specified during authentication
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
user.length
</code>
</th>
<td>
unsigned integer
</td>
<td>
User name length
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
priv_user.str
</code>
</th>
<td>
string
</td>
<td>
Authenticated user name (account user name)
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
priv_user.length
</code>
</th>
<td>
unsigned integer
</td>
<td>
Authenticated user name length
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
external_user.str
</code>
</th>
<td>
string
</td>
<td>
External user name (provided by third-party authentication plugin)
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
external_user.length
</code>
</th>
<td>
unsigned integer
</td>
<td>
External user name length
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
proxy_user.str
</code>
</th>
<td>
string
</td>
<td>
Proxy user name
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
proxy_user.length
</code>
</th>
<td>
unsigned integer
</td>
<td>
Proxy user name length
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
host.str
</code>
</th>
<td>
string
</td>
<td>
Connected user host
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
host.length
</code>
</th>
<td>
unsigned integer
</td>
<td>
Connected user host length
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
ip.str
</code>
</th>
<td>
string
</td>
<td>
Connected user IP address
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
ip.length
</code>
</th>
<td>
unsigned integer
</td>
<td>
Connected user IP address length
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
database.str
</code>
</th>
<td>
string
</td>
<td>
Database name specified at connect time
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
database.length
</code>
</th>
<td>
unsigned integer
</td>
<td>
Database name length
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
connection_type
</code>
</th>
<td>
integer
</td>
<td>
<p class="valid-value">
Connection type:
</p>
<p class="valid-value">
0 or
<code class="literal">
"::undefined"
</code>
: Undefined
</p>
<p class="valid-value">
1 or
<code class="literal">
"::tcp/ip"
</code>
: TCP/IP
</p>
<p class="valid-value">
2 or
<code class="literal">
"::socket"
</code>
: Socket
</p>
<p class="valid-value">
3 or
<code class="literal">
"::named_pipe"
</code>
: Named pipe
</p>
<p class="valid-value">
4 or
<code class="literal">
"::ssl"
</code>
: TCP/IP with
encryption
</p>
<p class="valid-value">
5 or
<code class="literal">
"::shared_memory"
</code>
: Shared
memory
</p>
</td>
</tr>
</tbody>
</table>
</div>
<div class="table-contents">
<table cellpadding="0" cellspacing="0" style="position: fixed; top: 0px; display: none; left: 401px; width: 739px;">
<thead>
<tr>
<th scope="col" style="width: 258.297px;">
Field Name
</th>
<th scope="col" style="width: 147.594px;">
Field Type
</th>
<th scope="col" style="width: 332.109px;">
Description
</th>
</tr>
</thead>
</table>
</div>
</div>
<br class="table-break"/>
<p>
The
<code class="literal">
"::
<em class="replaceable">
<code>
xxx
</code>
</em>
"
</code>
values are symbolic pseudo-constants that may be given instead
of the literal numeric values. They must be quoted as strings
and are case-sensitive.
</p>
<p>
An event in the
<code class="literal">
general
</code>
class indicates the
status code of an operation and its details.
<a class="xref" href="audit-log-filter-definitions.html#audit-log-general-event-fields" title="Table 8.37 General Event Fields">
Table 8.37, “General Event Fields”
</a>
indicates the
permitted fields for
<code class="literal">
general
</code>
events.
</p>
<div class="table">
<a name="audit-log-general-event-fields">
</a>
<p class="title">
<b>
Table 8.37 General Event Fields
</b>
</p>
<div class="table-contents">
<table summary="Permitted field types for general events.">
<colgroup>
<col style="width: 35%"/>
<col style="width: 20%"/>
<col style="width: 45%"/>
</colgroup>
<thead>
<tr>
<th scope="col">
Field Name
</th>
<th scope="col">
Field Type
</th>
<th scope="col">
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">
<code class="literal">
general_error_code
</code>
</th>
<td>
integer
</td>
<td>
<p class="valid-value">
Event status:
</p>
<p class="valid-value">
0: OK
</p>
<p class="valid-value">
Otherwise: Failed
</p>
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
general_thread_id
</code>
</th>
<td>
unsigned integer
</td>
<td>
Connection/thread ID
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
general_user.str
</code>
</th>
<td>
string
</td>
<td>
User name specified during authentication
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
general_user.length
</code>
</th>
<td>
unsigned integer
</td>
<td>
User name length
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
general_command.str
</code>
</th>
<td>
string
</td>
<td>
Command name
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
general_command.length
</code>
</th>
<td>
unsigned integer
</td>
<td>
Command name length
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
general_query.str
</code>
</th>
<td>
string
</td>
<td>
SQL statement text
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
general_query.length
</code>
</th>
<td>
unsigned integer
</td>
<td>
SQL statement text length
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
general_host.str
</code>
</th>
<td>
string
</td>
<td>
Host name
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
general_host.length
</code>
</th>
<td>
unsigned integer
</td>
<td>
Host name length
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
general_sql_command.str
</code>
</th>
<td>
string
</td>
<td>
SQL command type name
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
general_sql_command.length
</code>
</th>
<td>
unsigned integer
</td>
<td>
SQL command type name length
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
general_external_user.str
</code>
</th>
<td>
string
</td>
<td>
External user name (provided by third-party authentication plugin)
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
general_external_user.length
</code>
</th>
<td>
unsigned integer
</td>
<td>
External user name length
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
general_ip.str
</code>
</th>
<td>
string
</td>
<td>
Connected user IP address
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
general_ip.length
</code>
</th>
<td>
unsigned integer
</td>
<td>
Connection user IP address length
</td>
</tr>
</tbody>
</table>
</div>
<div class="table-contents">
<table cellpadding="0" cellspacing="0" style="position: fixed; top: 0px; display: none; left: 401px; width: 739px;">
<thead>
<tr>
<th scope="col" style="width: 258.297px;">
Field Name
</th>
<th scope="col" style="width: 147.594px;">
Field Type
</th>
<th scope="col" style="width: 332.109px;">
Description
</th>
</tr>
</thead>
</table>
</div>
</div>
<br class="table-break"/>
<p>
<code class="literal">
general_command.str
</code>
indicates a command
name:
<code class="literal">
Query
</code>
,
<code class="literal">
Execute
</code>
,
<code class="literal">
Quit
</code>
, or
<code class="literal">
Change user
</code>
.
</p>
<p>
A
<code class="literal">
general
</code>
event with the
<code class="literal">
general_command.str
</code>
field set to
<code class="literal">
Query
</code>
or
<code class="literal">
Execute
</code>
contains
<code class="literal">
general_sql_command.str
</code>
set to a
value that specifies the type of SQL command:
<code class="literal">
alter_db
</code>
,
<code class="literal">
alter_db_upgrade
</code>
,
<code class="literal">
admin_commands
</code>
, and so forth. The available
<code class="literal">
general_sql_command.str
</code>
values can be seen
as the last components of the Performance Schema instruments
displayed by this statement:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa18676532"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token keyword">NAME</span> <span class="token keyword">FROM</span> performance_schema<span class="token punctuation">.</span>setup_instruments
<span class="token keyword">WHERE</span> <span class="token keyword">NAME</span> <span class="token operator">LIKE</span> <span class="token string">'statement/sql/%'</span> <span class="token keyword">ORDER</span> <span class="token keyword">BY</span> <span class="token keyword">NAME</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> NAME <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> statement/sql/alter_db <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> statement/sql/alter_db_upgrade <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> statement/sql/alter_event <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> statement/sql/alter_function <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> statement/sql/alter_instance <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> statement/sql/alter_procedure <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> statement/sql/alter_server <span class="token punctuation">|</span></span>
<span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span></code></pre>
</div>
<p>
An event in the
<code class="literal">
table_access
</code>
class provides
information about a specific type of access to a table.
<a class="xref" href="audit-log-filter-definitions.html#audit-log-table-access-event-fields" title="Table 8.38 Table-Access Event Fields">
Table 8.38, “Table-Access Event Fields”
</a>
indicates the permitted fields for
<code class="literal">
table_access
</code>
events.
</p>
<div class="table">
<a name="audit-log-table-access-event-fields">
</a>
<p class="title">
<b>
Table 8.38 Table-Access Event Fields
</b>
</p>
<div class="table-contents">
<table summary="Permitted fields for table-access events.">
<colgroup>
<col style="width: 35%"/>
<col style="width: 20%"/>
<col style="width: 45%"/>
</colgroup>
<thead>
<tr>
<th scope="col">
Field Name
</th>
<th scope="col">
Field Type
</th>
<th scope="col">
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">
<code class="literal">
connection_id
</code>
</th>
<td>
unsigned integer
</td>
<td>
Event connection ID
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
sql_command_id
</code>
</th>
<td>
integer
</td>
<td>
SQL command ID
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
query.str
</code>
</th>
<td>
string
</td>
<td>
SQL statement text
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
query.length
</code>
</th>
<td>
unsigned integer
</td>
<td>
SQL statement text length
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
table_database.str
</code>
</th>
<td>
string
</td>
<td>
Database name associated with event
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
table_database.length
</code>
</th>
<td>
unsigned integer
</td>
<td>
Database name length
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
table_name.str
</code>
</th>
<td>
string
</td>
<td>
Table name associated with event
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
table_name.length
</code>
</th>
<td>
unsigned integer
</td>
<td>
Table name length
</td>
</tr>
</tbody>
</table>
</div>
</div>
<br class="table-break"/>
<p>
The following list shows which statements produce which
table-access events:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
read
</code>
event:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
<code class="literal">
SELECT
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
INSERT ... SELECT
</code>
(for tables
referenced in
<code class="literal">
SELECT
</code>
clause)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
REPLACE ... SELECT
</code>
(for tables
referenced in
<code class="literal">
SELECT
</code>
clause)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
UPDATE ... WHERE
</code>
(for tables
referenced in
<code class="literal">
WHERE
</code>
clause)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
HANDLER ... READ
</code>
</p>
</li>
</ul>
</div>
</li>
<li class="listitem">
<p>
<code class="literal">
delete
</code>
event:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
<code class="literal">
DELETE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
TRUNCATE TABLE
</code>
</p>
</li>
</ul>
</div>
</li>
<li class="listitem">
<p>
<code class="literal">
insert
</code>
event:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
<code class="literal">
INSERT
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
INSERT ... SELECT
</code>
(for table
referenced in
<code class="literal">
INSERT
</code>
clause)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
REPLACE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
REPLACE ... SELECT
</code>
(for table
referenced in
<code class="literal">
REPLACE
</code>
clause
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
LOAD DATA
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
LOAD XML
</code>
</p>
</li>
</ul>
</div>
</li>
<li class="listitem">
<p>
<code class="literal">
update
</code>
event:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
<code class="literal">
UPDATE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
UPDATE ... WHERE
</code>
(for tables
referenced in
<code class="literal">
UPDATE
</code>
clause)
</p>
</li>
</ul>
</div>
</li>
</ul>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="audit-log-filtering-blocking-events">
</a>
Blocking Execution of Specific Events
</h5>
</div>
</div>
</div>
<p>
<code class="literal">
event
</code>
items can include an
<code class="literal">
abort
</code>
item that indicates whether to
prevent qualifying events from executing.
<code class="literal">
abort
</code>
enables rules to be written that
block execution of specific SQL statements.
</p>
<div class="important" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Important
</div>
<p>
It is theoretically possible for a user with sufficient
permissions to mistakenly create an
<code class="literal">
abort
</code>
item in the audit log filter that prevents themselves and
other administrators from accessing the system. The
<a class="link" href="privileges-provided.html#priv_audit-abort-exempt">
<code class="literal">
AUDIT_ABORT_EXEMPT
</code>
</a>
privilege is available to permit a user account’s queries
to always be executed even if an
<code class="literal">
abort
</code>
item would block them. Accounts with this privilege can
therefore be used to regain access to a system following an
audit misconfiguration. The query is still logged in the
audit log, but instead of being rejected, it is permitted
due to the privilege.
</p>
<p>
Accounts created with the
<a class="link" href="privileges-provided.html#priv_system-user">
<code class="literal">
SYSTEM_USER
</code>
</a>
privilege have
the
<a class="link" href="privileges-provided.html#priv_audit-abort-exempt">
<code class="literal">
AUDIT_ABORT_EXEMPT
</code>
</a>
privilege assigned automatically when they are created. The
<a class="link" href="privileges-provided.html#priv_audit-abort-exempt">
<code class="literal">
AUDIT_ABORT_EXEMPT
</code>
</a>
privilege
is also assigned to existing accounts with the
<a class="link" href="privileges-provided.html#priv_system-user">
<code class="literal">
SYSTEM_USER
</code>
</a>
privilege when you carry out an upgrade procedure, if no
existing accounts have that privilege assigned.
</p>
</div>
<p>
The
<code class="literal">
abort
</code>
item must appear within an
<code class="literal">
event
</code>
item. For example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-json"><div class="docs-select-all right" id="sa48748913"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token property">"event"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"name"</span><span class="token operator">:</span> <em class="replaceable">qualifying event subclass names</em>
<span class="token property">"abort"</span><span class="token operator">:</span> <em class="replaceable">condition</em>
<span class="token punctuation">}</span></code></pre>
</div>
<p>
For event subclasses selected by the
<code class="literal">
name
</code>
item, the
<code class="literal">
abort
</code>
action is true or false,
depending on
<em class="replaceable">
<code>
condition
</code>
</em>
evaluation.
If the condition evaluates to true, the event is blocked.
Otherwise, the event continues executing.
</p>
<p>
The
<em class="replaceable">
<code>
condition
</code>
</em>
specification can be
as simple as
<code class="literal">
true
</code>
or
<code class="literal">
false
</code>
, or it can be more complex such that
evaluation depends on event characteristics.
</p>
<p>
This filter blocks
<a class="link" href="insert.html" title="15.2.7 INSERT Statement">
<code class="literal">
INSERT
</code>
</a>
,
<a class="link" href="update.html" title="15.2.17 UPDATE Statement">
<code class="literal">
UPDATE
</code>
</a>
, and
<a class="link" href="delete.html" title="15.2.2 DELETE Statement">
<code class="literal">
DELETE
</code>
</a>
statements:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-json"><div class="docs-select-all right" id="sa75702508"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token punctuation">{</span>
<span class="token property">"filter"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"class"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"table_access"</span><span class="token punctuation">,</span>
<span class="token property">"event"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"name"</span><span class="token operator">:</span> <span class="token punctuation">[</span> <span class="token string">"insert"</span><span class="token punctuation">,</span> <span class="token string">"update"</span><span class="token punctuation">,</span> <span class="token string">"delete"</span> <span class="token punctuation">]</span><span class="token punctuation">,</span>
<span class="token property">"abort"</span><span class="token operator">:</span> <span class="token boolean">true</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span></code></pre>
</div>
<p>
This more complex filter blocks the same statements, but only
for a specific table
(
<code class="literal">
finances.bank_account
</code>
):
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-json"><div class="docs-select-all right" id="sa39253436"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token punctuation">{</span>
<span class="token property">"filter"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"class"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"table_access"</span><span class="token punctuation">,</span>
<span class="token property">"event"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"name"</span><span class="token operator">:</span> <span class="token punctuation">[</span> <span class="token string">"insert"</span><span class="token punctuation">,</span> <span class="token string">"update"</span><span class="token punctuation">,</span> <span class="token string">"delete"</span> <span class="token punctuation">]</span><span class="token punctuation">,</span>
<span class="token property">"abort"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"and"</span><span class="token operator">:</span> <span class="token punctuation">[</span>
<span class="token punctuation">{</span> <span class="token property">"field"</span><span class="token operator">:</span> <span class="token punctuation">{</span> <span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"table_database.str"</span><span class="token punctuation">,</span> <span class="token property">"value"</span><span class="token operator">:</span> <span class="token string">"finances"</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token punctuation">{</span> <span class="token property">"field"</span><span class="token operator">:</span> <span class="token punctuation">{</span> <span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"table_name.str"</span><span class="token punctuation">,</span> <span class="token property">"value"</span><span class="token operator">:</span> <span class="token string">"bank_account"</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span>
<span class="token punctuation">]</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span></code></pre>
</div>
<p>
Statements matched and blocked by the filter return an error
to the client:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-none"><div class="docs-select-all right" id="sa1077529"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-none">ERROR 1045 (28000): Statement was aborted by an audit log filter</code></pre>
</div>
<p>
Not all events can be blocked (see
<a class="xref" href="audit-log-filter-definitions.html#audit-log-event-subclass-log-abort" title="Table 8.35 Log and Abort Characteristics Per Event Class and Subclass Combination">
Table 8.35, “Log and Abort Characteristics Per Event Class and Subclass Combination”
</a>
). For an
event that cannot be blocked, the audit log writes a warning
to the error log rather than blocking it.
</p>
<p>
For attempts to define a filter in which the
<code class="literal">
abort
</code>
item appears elsewhere than in an
<code class="literal">
event
</code>
item, an error occurs.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="audit-log-filtering-logical-operators">
</a>
Logical Operators
</h5>
</div>
</div>
</div>
<p>
Logical operators (
<code class="literal">
and
</code>
,
<code class="literal">
or
</code>
,
<code class="literal">
not
</code>
) permit
construction of complex conditions, enabling more advanced
filtering configurations to be written. The following
<code class="literal">
log
</code>
item logs only
<code class="literal">
general
</code>
events with
<code class="literal">
general_command
</code>
fields having a specific
value and length:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-json"><div class="docs-select-all right" id="sa79765543"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token punctuation">{</span>
<span class="token property">"filter"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"class"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"general"</span><span class="token punctuation">,</span>
<span class="token property">"event"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"status"</span><span class="token punctuation">,</span>
<span class="token property">"log"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"or"</span><span class="token operator">:</span> <span class="token punctuation">[</span>
<span class="token punctuation">{</span>
<span class="token property">"and"</span><span class="token operator">:</span> <span class="token punctuation">[</span>
<span class="token punctuation">{</span> <span class="token property">"field"</span><span class="token operator">:</span> <span class="token punctuation">{</span> <span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"general_command.str"</span><span class="token punctuation">,</span> <span class="token property">"value"</span><span class="token operator">:</span> <span class="token string">"Query"</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token punctuation">{</span> <span class="token property">"field"</span><span class="token operator">:</span> <span class="token punctuation">{</span> <span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"general_command.length"</span><span class="token punctuation">,</span> <span class="token property">"value"</span><span class="token operator">:</span> <span class="token number">5</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span>
<span class="token punctuation">]</span>
<span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token punctuation">{</span>
<span class="token property">"and"</span><span class="token operator">:</span> <span class="token punctuation">[</span>
<span class="token punctuation">{</span> <span class="token property">"field"</span><span class="token operator">:</span> <span class="token punctuation">{</span> <span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"general_command.str"</span><span class="token punctuation">,</span> <span class="token property">"value"</span><span class="token operator">:</span> <span class="token string">"Execute"</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token punctuation">{</span> <span class="token property">"field"</span><span class="token operator">:</span> <span class="token punctuation">{</span> <span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"general_command.length"</span><span class="token punctuation">,</span> <span class="token property">"value"</span><span class="token operator">:</span> <span class="token number">7</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span>
<span class="token punctuation">]</span>
<span class="token punctuation">}</span>
<span class="token punctuation">]</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span></code></pre>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="audit-log-filtering-predefined-variables">
</a>
Referencing Predefined Variables
</h5>
</div>
</div>
</div>
<p>
To refer to a predefined variable in a
<code class="literal">
log
</code>
condition, use a
<code class="literal">
variable
</code>
item, which takes
<code class="literal">
name
</code>
and
<code class="literal">
value
</code>
items and
tests equality of the named variable against a given value:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-json"><div class="docs-select-all right" id="sa79822112"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token property">"variable"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"<em class="replaceable">variable_name</em>"</span><span class="token punctuation">,</span>
<span class="token property">"value"</span><span class="token operator">:</span> <em class="replaceable">comparison_value</em>
<span class="token punctuation">}</span></code></pre>
</div>
<p>
This is true if
<em class="replaceable">
<code>
variable_name
</code>
</em>
has
the value
<em class="replaceable">
<code>
comparison_value
</code>
</em>
, false
otherwise.
</p>
<p>
Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-json"><div class="docs-select-all right" id="sa57733275"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token punctuation">{</span>
<span class="token property">"filter"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"class"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"general"</span><span class="token punctuation">,</span>
<span class="token property">"event"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"status"</span><span class="token punctuation">,</span>
<span class="token property">"log"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"variable"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"audit_log_connection_policy_value"</span><span class="token punctuation">,</span>
<span class="token property">"value"</span><span class="token operator">:</span> "<span class="token operator">:</span><span class="token operator">:</span>none"
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span></code></pre>
</div>
<p>
Each predefined variable corresponds to a system variable. By
writing a filter that tests a predefined variable, you can
modify filter operation by setting the corresponding system
variable, without having to redefine the filter. For example,
by writing a filter that tests the value of the
<code class="literal">
audit_log_connection_policy_value
</code>
predefined variable, you can modify filter operation by
changing the value of the
<a class="link" href="audit-log-reference.html#sysvar_audit_log_connection_policy">
<code class="literal">
audit_log_connection_policy
</code>
</a>
system variable.
</p>
<a class="indexterm" name="idm46045236677040">
</a>
<p>
The
<code class="literal">
audit_log_
<em class="replaceable">
<code>
xxx
</code>
</em>
_policy
</code>
system variables are used for the deprecated legacy mode audit
log (see
<a class="xref" href="audit-log-legacy-filtering.html" title="8.4.5.10 Legacy Mode Audit Log Filtering">
Section 8.4.5.10, “Legacy Mode Audit Log Filtering”
</a>
). With
rule-based audit log filtering, those variables remain visible
(for example, using
<a class="link" href="show-variables.html" title="15.7.7.41 SHOW VARIABLES Statement">
<code class="literal">
SHOW
VARIABLES
</code>
</a>
), but changes to them have no effect
unless you write filters containing constructs that refer to
them.
</p>
<p>
The following list describes the permitted predefined
variables for
<code class="literal">
variable
</code>
items:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
audit_log_connection_policy_value
</code>
</p>
<p>
This variable corresponds to the value of the
<a class="link" href="audit-log-reference.html#sysvar_audit_log_connection_policy">
<code class="literal">
audit_log_connection_policy
</code>
</a>
system variable. The value is an unsigned integer.
<a class="xref" href="audit-log-filter-definitions.html#audit-log-connection-policy-value-values" title="Table 8.39 audit_log_connection_policy_value Values">
Table 8.39, “audit_log_connection_policy_value Values”
</a>
shows the permitted values and the corresponding
<a class="link" href="audit-log-reference.html#sysvar_audit_log_connection_policy">
<code class="literal">
audit_log_connection_policy
</code>
</a>
values.
</p>
<div class="table">
<a name="audit-log-connection-policy-value-values">
</a>
<p class="title">
<b>
Table 8.39 audit_log_connection_policy_value Values
</b>
</p>
<div class="table-contents">
<table summary="Permitted audit_log_connection_policy_value values and the corresponding audit_log_connection_policy values.">
<colgroup>
<col style="width: 20%"/>
<col style="width: 80%"/>
</colgroup>
<thead>
<tr>
<th>
Value
</th>
<th>
Corresponding audit_log_connection_policy Value
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<code class="literal">
0
</code>
or
<code class="literal">
"::none"
</code>
</td>
<td>
<code class="literal">
NONE
</code>
</td>
</tr>
<tr>
<td>
<code class="literal">
1
</code>
or
<code class="literal">
"::errors"
</code>
</td>
<td>
<code class="literal">
ERRORS
</code>
</td>
</tr>
<tr>
<td>
<code class="literal">
2
</code>
or
<code class="literal">
"::all"
</code>
</td>
<td>
<code class="literal">
ALL
</code>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<br class="table-break"/>
<p>
The
<code class="literal">
"::
<em class="replaceable">
<code>
xxx
</code>
</em>
"
</code>
values are symbolic pseudo-constants that may be given
instead of the literal numeric values. They must be quoted
as strings and are case-sensitive.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
audit_log_policy_value
</code>
</p>
<p>
This variable corresponds to the value of the
<a class="link" href="audit-log-reference.html#sysvar_audit_log_policy">
<code class="literal">
audit_log_policy
</code>
</a>
system
variable. The value is an unsigned integer.
<a class="xref" href="audit-log-filter-definitions.html#audit-log-policy-value-values" title="Table 8.40 audit_log_policy_value Values">
Table 8.40, “audit_log_policy_value Values”
</a>
shows the
permitted values and the corresponding
<a class="link" href="audit-log-reference.html#sysvar_audit_log_policy">
<code class="literal">
audit_log_policy
</code>
</a>
values.
</p>
<div class="table">
<a name="audit-log-policy-value-values">
</a>
<p class="title">
<b>
Table 8.40 audit_log_policy_value Values
</b>
</p>
<div class="table-contents">
<table summary="Permitted audit_log_policy_value values and the corresponding audit_log_policy values.">
<colgroup>
<col style="width: 20%"/>
<col style="width: 80%"/>
</colgroup>
<thead>
<tr>
<th>
Value
</th>
<th>
Corresponding audit_log_policy Value
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<code class="literal">
0
</code>
or
<code class="literal">
"::none"
</code>
</td>
<td>
<code class="literal">
NONE
</code>
</td>
</tr>
<tr>
<td>
<code class="literal">
1
</code>
or
<code class="literal">
"::logins"
</code>
</td>
<td>
<code class="literal">
LOGINS
</code>
</td>
</tr>
<tr>
<td>
<code class="literal">
2
</code>
or
<code class="literal">
"::all"
</code>
</td>
<td>
<code class="literal">
ALL
</code>
</td>
</tr>
<tr>
<td>
<code class="literal">
3
</code>
or
<code class="literal">
"::queries"
</code>
</td>
<td>
<code class="literal">
QUERIES
</code>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<br class="table-break"/>
<p>
The
<code class="literal">
"::
<em class="replaceable">
<code>
xxx
</code>
</em>
"
</code>
values are symbolic pseudo-constants that may be given
instead of the literal numeric values. They must be quoted
as strings and are case-sensitive.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
audit_log_statement_policy_value
</code>
</p>
<p>
This variable corresponds to the value of the
<a class="link" href="audit-log-reference.html#sysvar_audit_log_statement_policy">
<code class="literal">
audit_log_statement_policy
</code>
</a>
system variable. The value is an unsigned integer.
<a class="xref" href="audit-log-filter-definitions.html#audit-log-statement-policy-value-values" title="Table 8.41 audit_log_statement_policy_value Values">
Table 8.41, “audit_log_statement_policy_value Values”
</a>
shows the permitted values and the corresponding
<a class="link" href="audit-log-reference.html#sysvar_audit_log_statement_policy">
<code class="literal">
audit_log_statement_policy
</code>
</a>
values.
</p>
<div class="table">
<a name="audit-log-statement-policy-value-values">
</a>
<p class="title">
<b>
Table 8.41 audit_log_statement_policy_value Values
</b>
</p>
<div class="table-contents">
<table summary="Permitted audit_log_statement_policy_value values and the corresponding audit_log_statement_policy values.">
<colgroup>
<col style="width: 20%"/>
<col style="width: 80%"/>
</colgroup>
<thead>
<tr>
<th>
Value
</th>
<th>
Corresponding audit_log_statement_policy Value
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<code class="literal">
0
</code>
or
<code class="literal">
"::none"
</code>
</td>
<td>
<code class="literal">
NONE
</code>
</td>
</tr>
<tr>
<td>
<code class="literal">
1
</code>
or
<code class="literal">
"::errors"
</code>
</td>
<td>
<code class="literal">
ERRORS
</code>
</td>
</tr>
<tr>
<td>
<code class="literal">
2
</code>
or
<code class="literal">
"::all"
</code>
</td>
<td>
<code class="literal">
ALL
</code>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<br class="table-break"/>
<p>
The
<code class="literal">
"::
<em class="replaceable">
<code>
xxx
</code>
</em>
"
</code>
values are symbolic pseudo-constants that may be given
instead of the literal numeric values. They must be quoted
as strings and are case-sensitive.
</p>
</li>
</ul>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="audit-log-filtering-predefined-functions">
</a>
Referencing Predefined Functions
</h5>
</div>
</div>
</div>
<p>
To refer to a predefined function in a
<code class="literal">
log
</code>
condition, use a
<code class="literal">
function
</code>
item, which takes
<code class="literal">
name
</code>
and
<code class="literal">
args
</code>
items to
specify the function name and its arguments, respectively:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-json"><div class="docs-select-all right" id="sa27559230"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token property">"function"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"<em class="replaceable">function_name</em>"</span><span class="token punctuation">,</span>
<span class="token property">"args"</span><span class="token operator">:</span> <em class="replaceable">arguments</em>
<span class="token punctuation">}</span></code></pre>
</div>
<p>
The
<code class="literal">
name
</code>
item should specify the function
name only, without parentheses or the argument list.
</p>
<p>
The
<code class="literal">
args
</code>
item must satisfy these
conditions:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
If the function takes no arguments, no
<code class="literal">
args
</code>
item should be given.
</p>
</li>
<li class="listitem">
<p>
If the function does take arguments, an
<code class="literal">
args
</code>
item is needed, and the arguments
must be given in the order listed in the function
description. Arguments can refer to predefined variables,
event fields, or string or numeric constants.
</p>
</li>
</ul>
</div>
<p>
If the number of arguments is incorrect or the arguments are
not of the correct data types required by the function an
error occurs.
</p>
<p>
Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-json"><div class="docs-select-all right" id="sa19814026"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token punctuation">{</span>
<span class="token property">"filter"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"class"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"general"</span><span class="token punctuation">,</span>
<span class="token property">"event"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"status"</span><span class="token punctuation">,</span>
<span class="token property">"log"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"function"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"find_in_include_list"</span><span class="token punctuation">,</span>
<span class="token property">"args"</span><span class="token operator">:</span> <span class="token punctuation">[</span> <span class="token punctuation">{</span> <span class="token property">"string"</span><span class="token operator">:</span> <span class="token punctuation">[</span> <span class="token punctuation">{</span> <span class="token property">"field"</span><span class="token operator">:</span> <span class="token string">"user.str"</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token punctuation">{</span> <span class="token property">"string"</span><span class="token operator">:</span> <span class="token string">"@"</span><span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token punctuation">{</span> <span class="token property">"field"</span><span class="token operator">:</span> <span class="token string">"host.str"</span> <span class="token punctuation">}</span> <span class="token punctuation">]</span> <span class="token punctuation">}</span> <span class="token punctuation">]</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span></code></pre>
</div>
<p>
The preceding filter determines whether to log
<code class="literal">
general
</code>
class
<code class="literal">
status
</code>
events depending on whether the current user is found in the
<a class="link" href="audit-log-reference.html#sysvar_audit_log_include_accounts">
<code class="literal">
audit_log_include_accounts
</code>
</a>
system variable. That user is constructed using fields in the
event.
</p>
<p>
The following list describes the permitted predefined
functions for
<code class="literal">
function
</code>
items:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
audit_log_exclude_accounts_is_null()
</code>
</p>
<p>
Checks whether the
<a class="link" href="audit-log-reference.html#sysvar_audit_log_exclude_accounts">
<code class="literal">
audit_log_exclude_accounts
</code>
</a>
system variable is
<code class="literal">
NULL
</code>
. This function
can be helpful when defining filters that correspond to
the legacy audit log implementation.
</p>
<p>
Arguments:
</p>
<p>
None.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
audit_log_include_accounts_is_null()
</code>
</p>
<p>
Checks whether the
<a class="link" href="audit-log-reference.html#sysvar_audit_log_include_accounts">
<code class="literal">
audit_log_include_accounts
</code>
</a>
system variable is
<code class="literal">
NULL
</code>
. This function
can be helpful when defining filters that correspond to
the legacy audit log implementation.
</p>
<p>
Arguments:
</p>
<p>
None.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
debug_sleep(millisec)
</code>
</p>
<p>
Sleeps for the given number of milliseconds. This function
is used during performance measurement.
</p>
<p>
<code class="literal">
debug_sleep()
</code>
is available for debug
builds only.
</p>
<p>
Arguments:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
<em class="replaceable">
<code>
millisec
</code>
</em>
: An unsigned
integer that specifies the number of milliseconds to
sleep.
</p>
</li>
</ul>
</div>
</li>
<li class="listitem">
<p>
<code class="literal">
find_in_exclude_list(account)
</code>
</p>
<p>
Checks whether an account string exists in the audit log
exclude list (the value of the
<a class="link" href="audit-log-reference.html#sysvar_audit_log_exclude_accounts">
<code class="literal">
audit_log_exclude_accounts
</code>
</a>
system variable).
</p>
<p>
Arguments:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
<em class="replaceable">
<code>
account
</code>
</em>
: A string that
specifies the user account name.
</p>
</li>
</ul>
</div>
</li>
<li class="listitem">
<p>
<code class="literal">
find_in_include_list(account)
</code>
</p>
<p>
Checks whether an account string exists in the audit log
include list (the value of the
<a class="link" href="audit-log-reference.html#sysvar_audit_log_include_accounts">
<code class="literal">
audit_log_include_accounts
</code>
</a>
system variable).
</p>
<p>
Arguments:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
<em class="replaceable">
<code>
account
</code>
</em>
: A string that
specifies the user account name.
</p>
</li>
</ul>
</div>
</li>
<li class="listitem">
<p>
<code class="literal">
query_digest([str])
</code>
</p>
<p>
This function has differing behavior depending on whether
an argument is given:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
With no argument,
<code class="literal">
query_digest
</code>
returns the statement digest value corresponding to
the statement literal text in the current event.
</p>
</li>
<li class="listitem">
<p>
With an argument,
<code class="literal">
query_digest
</code>
returns a Boolean indicating whether the argument is
equal to the current statement digest.
</p>
</li>
</ul>
</div>
<p>
Arguments:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
<em class="replaceable">
<code>
str
</code>
</em>
: This argument is
optional. If given, it specifies a statement digest to
be compared against the digest for the statement in
the current event.
</p>
</li>
</ul>
</div>
<p>
Examples:
</p>
<p>
This
<code class="literal">
function
</code>
item includes no
argument, so
<code class="literal">
query_digest
</code>
returns the
current statement digest as a string:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-json"><div class="docs-select-all right" id="sa99762375"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token property">"function"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"query_digest"</span>
<span class="token punctuation">}</span></code></pre>
</div>
<p>
This
<code class="literal">
function
</code>
item includes an
argument, so
<code class="literal">
query_digest
</code>
returns a
Boolean indicating whether the argument equals the current
statement digest:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-json"><div class="docs-select-all right" id="sa29059560"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token property">"function"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"query_digest"</span><span class="token punctuation">,</span>
<span class="token property">"args"</span><span class="token operator">:</span> <span class="token string">"SELECT ?"</span>
<span class="token punctuation">}</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
<code class="literal">
string_find(text, substr)
</code>
</p>
<p>
Checks whether the
<code class="literal">
substr
</code>
value is
contained in the
<code class="literal">
text
</code>
value. This
search is case-sensitive.
</p>
<p>
Arguments:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
<em class="replaceable">
<code>
text
</code>
</em>
: The text string to
search.
</p>
</li>
<li class="listitem">
<p>
<em class="replaceable">
<code>
substr
</code>
</em>
: The substring to
search for in
<em class="replaceable">
<code>
text
</code>
</em>
.
</p>
</li>
</ul>
</div>
</li>
</ul>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="audit-log-filtering-field-replacement">
</a>
Replacement of Event Field Values
</h5>
</div>
</div>
</div>
<a class="indexterm" name="idm46045236524048">
</a>
<a class="indexterm" name="idm46045236522560">
</a>
<p>
Audit filter definitions support replacement of certain audit
event fields, so that logged events contain the replacement
value rather than the original value. This capability enables
logged audit records to include statement digests rather than
literal statements, which can be useful for MySQL deployments
for which statements may expose sensitive values.
</p>
<p>
Field replacement in audit events works like this:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Field replacements are specified in audit filter
definitions, so audit log filtering must be enabled as
described in
<a class="xref" href="audit-log-filtering.html" title="8.4.5.7 Audit Log Filtering">
Section 8.4.5.7, “Audit Log Filtering”
</a>
.
</p>
</li>
<li class="listitem">
<p>
Not all fields can be replaced.
<a class="xref" href="audit-log-filter-definitions.html#audit-log-replaceable-event-fields" title="Table 8.42 Event Fields Subject to Replacement">
Table 8.42, “Event Fields Subject to Replacement”
</a>
shows
which fields are replaceable in which event classes.
</p>
<div class="table">
<a name="audit-log-replaceable-event-fields">
</a>
<p class="title">
<b>
Table 8.42 Event Fields Subject to Replacement
</b>
</p>
<div class="table-contents">
<table summary="Event fields that are subject to replacement during event filtering.">
<colgroup>
<col style="width: 50%"/>
<col style="width: 50%"/>
</colgroup>
<thead>
<tr>
<th>
Event Class
</th>
<th>
Field Name
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<code class="literal">
general
</code>
</td>
<td>
<code class="literal">
general_query.str
</code>
</td>
</tr>
<tr>
<td>
<code class="literal">
table_access
</code>
</td>
<td>
<code class="literal">
query.str
</code>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<br class="table-break"/>
</li>
<li class="listitem">
<p>
Replacement is conditional. Each replacement specification
in a filter definition includes a condition, enabling a
replaceable field to be changed, or left unchanged,
depending on the condition result.
</p>
</li>
<li class="listitem">
<p>
If replacement occurs, the replacement specification
indicates the replacement value using a function that is
permitted for that purpose.
</p>
</li>
</ul>
</div>
<p>
As
<a class="xref" href="audit-log-filter-definitions.html#audit-log-replaceable-event-fields" title="Table 8.42 Event Fields Subject to Replacement">
Table 8.42, “Event Fields Subject to Replacement”
</a>
shows,
currently the only replaceable fields are those that contain
statement text (which occurs in events of the
<code class="literal">
general
</code>
and
<code class="literal">
table_access
</code>
classes). In addition, the only function permitted for
specifying the replacement value is
<code class="literal">
query_digest
</code>
. This means that the only
permitted replacement operation is to replace statement
literal text by its corresponding digest.
</p>
<p>
Because field replacement occurs at an early auditing stage
(during filtering), the choice of whether to write statement
literal text or digest values applies regardless of log format
written later (that is, whether the audit log plugin produces
XML or JSON output).
</p>
<p>
Field replacement can take place at differing levels of event
granularity:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
To perform field replacement for all events in a class,
filter events at the class level.
</p>
</li>
<li class="listitem">
<p>
To perform replacement on a more fine-grained basis,
include additional event-selection items. For example, you
can perform field replacement only for specific subclasses
of a given event class, or only in events for which fields
have certain characteristics.
</p>
</li>
</ul>
</div>
<p>
Within a filter definition, specify field replacement by
including a
<code class="literal">
print
</code>
item, which has this
syntax:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-json"><div class="docs-select-all right" id="sa35257113"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token property">"print"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"field"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"<em class="replaceable">field_name</em>"</span><span class="token punctuation">,</span>
<span class="token property">"print"</span><span class="token operator">:</span> <em class="replaceable">condition</em><span class="token punctuation">,</span>
<span class="token property">"replace"</span><span class="token operator">:</span> <em class="replaceable">replacement_value</em>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span></code></pre>
</div>
<p>
Within the
<code class="literal">
print
</code>
item, its
<code class="literal">
field
</code>
item takes these three items to
indicate how whether and how replacement occurs:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
name
</code>
: The field for which replacement
(potentially) occurs.
<em class="replaceable">
<code>
field_name
</code>
</em>
must be one of those
shown in
<a class="xref" href="audit-log-filter-definitions.html#audit-log-replaceable-event-fields" title="Table 8.42 Event Fields Subject to Replacement">
Table 8.42, “Event Fields Subject to Replacement”
</a>
.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
print
</code>
: The condition that determines
whether to retain the original field value or replace it:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
If
<em class="replaceable">
<code>
condition
</code>
</em>
evaluates to
<code class="literal">
true
</code>
, the field remains unchanged.
</p>
</li>
<li class="listitem">
<p>
If
<em class="replaceable">
<code>
condition
</code>
</em>
evaluates to
<code class="literal">
false
</code>
, replacement occurs, using
the value of the
<code class="literal">
replace
</code>
item.
</p>
</li>
</ul>
</div>
<p>
To unconditionally replace a field, specify the condition
like this:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-json"><div class="docs-select-all right" id="sa26942317"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token property">"print"</span><span class="token operator">:</span> <span class="token boolean">false</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
<code class="literal">
replace
</code>
: The replacement value to use
when the
<code class="literal">
print
</code>
condition evaluates to
<code class="literal">
false
</code>
. Specify
<em class="replaceable">
<code>
replacement_value
</code>
</em>
using a
<code class="literal">
function
</code>
item.
</p>
</li>
</ul>
</div>
<p>
For example, this filter definition applies to all events in
the
<code class="literal">
general
</code>
class, replacing the statement
literal text with its digest:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-json"><div class="docs-select-all right" id="sa32299153"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token punctuation">{</span>
<span class="token property">"filter"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"class"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"general"</span><span class="token punctuation">,</span>
<span class="token property">"print"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"field"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"general_query.str"</span><span class="token punctuation">,</span>
<span class="token property">"print"</span><span class="token operator">:</span> <span class="token boolean">false</span><span class="token punctuation">,</span>
<span class="token property">"replace"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"function"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"query_digest"</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span></code></pre>
</div>
<p>
The preceding filter uses this
<code class="literal">
print
</code>
item
to unconditionally replace the statement literal text
contained in
<code class="literal">
general_query.str
</code>
by its
digest value:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-json"><div class="docs-select-all right" id="sa2927293"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token property">"print"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"field"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"general_query.str"</span><span class="token punctuation">,</span>
<span class="token property">"print"</span><span class="token operator">:</span> <span class="token boolean">false</span><span class="token punctuation">,</span>
<span class="token property">"replace"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"function"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"query_digest"</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span></code></pre>
</div>
<p>
<code class="literal">
print
</code>
items can be written different ways
to implement different replacement strategies. The
<code class="literal">
replace
</code>
item just shown specifies the
replacement text using this
<code class="literal">
function
</code>
construct to return a string representing the current
statement digest:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-json"><div class="docs-select-all right" id="sa18790036"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token property">"function"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"query_digest"</span>
<span class="token punctuation">}</span></code></pre>
</div>
<p>
The
<code class="literal">
query_digest
</code>
function can also be used
in another way, as a comparator that returns a Boolean, which
enables its use in the
<code class="literal">
print
</code>
condition. To
do this, provide an argument that specifies a comparison
statement digest:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-json"><div class="docs-select-all right" id="sa46413687"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token property">"function"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"query_digest"</span><span class="token punctuation">,</span>
<span class="token property">"args"</span><span class="token operator">:</span> <span class="token string">"<em class="replaceable">digest</em>"</span>
<span class="token punctuation">}</span></code></pre>
</div>
<p>
In this case,
<code class="literal">
query_digest
</code>
returns
<code class="literal">
true
</code>
or
<code class="literal">
false
</code>
depending
on whether the current statement digest is the same as the
comparison digest. Using
<code class="literal">
query_digest
</code>
this
way enables filter definitions to detect statements that match
particular digests. The condition in the following construct
is true only for statements that have a digest equal to
<code class="literal">
SELECT ?
</code>
, thus effecting replacement only
for statements that do not match the digest:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-json"><div class="docs-select-all right" id="sa63530766"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token property">"print"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"field"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"general_query.str"</span><span class="token punctuation">,</span>
<span class="token property">"print"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"function"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"query_digest"</span><span class="token punctuation">,</span>
<span class="token property">"args"</span><span class="token operator">:</span> <span class="token string">"SELECT ?"</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token property">"replace"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"function"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"query_digest"</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span></code></pre>
</div>
<p>
To perform replacement only for statements that do match the
digest, use
<code class="literal">
not
</code>
to invert the condition:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-json"><div class="docs-select-all right" id="sa96041431"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token property">"print"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"field"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"general_query.str"</span><span class="token punctuation">,</span>
<span class="token property">"print"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"not"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"function"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"query_digest"</span><span class="token punctuation">,</span>
<span class="token property">"args"</span><span class="token operator">:</span> <span class="token string">"SELECT ?"</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token property">"replace"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"function"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"query_digest"</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span></code></pre>
</div>
<p>
Suppose that you want the audit log to contain only statement
digests and not literal statements. To achieve this, you must
perform replacement on all events that contain statement text;
that is, events in the
<code class="literal">
general
</code>
and
<code class="literal">
table_access
</code>
classes. An earlier filter
definition showed how to unconditionally replace statement
text for
<code class="literal">
general
</code>
events. To do the same for
<code class="literal">
table_access
</code>
events, use a filter that is
similar but changes the class from
<code class="literal">
general
</code>
to
<code class="literal">
table_access
</code>
and the field name from
<code class="literal">
general_query.str
</code>
to
<code class="literal">
query.str
</code>
:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-json"><div class="docs-select-all right" id="sa97549721"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token punctuation">{</span>
<span class="token property">"filter"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"class"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"table_access"</span><span class="token punctuation">,</span>
<span class="token property">"print"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"field"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"query.str"</span><span class="token punctuation">,</span>
<span class="token property">"print"</span><span class="token operator">:</span> <span class="token boolean">false</span><span class="token punctuation">,</span>
<span class="token property">"replace"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"function"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"query_digest"</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span></code></pre>
</div>
<p>
Combining the
<code class="literal">
general
</code>
and
<code class="literal">
table_access
</code>
filters results in a single
filter that performs replacement for all statement
text-containing events:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-json"><div class="docs-select-all right" id="sa22015932"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token punctuation">{</span>
<span class="token property">"filter"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"class"</span><span class="token operator">:</span> <span class="token punctuation">[</span>
<span class="token punctuation">{</span>
<span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"general"</span><span class="token punctuation">,</span>
<span class="token property">"print"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"field"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"general_query.str"</span><span class="token punctuation">,</span>
<span class="token property">"print"</span><span class="token operator">:</span> <span class="token boolean">false</span><span class="token punctuation">,</span>
<span class="token property">"replace"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"function"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"query_digest"</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token punctuation">{</span>
<span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"table_access"</span><span class="token punctuation">,</span>
<span class="token property">"print"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"field"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"query.str"</span><span class="token punctuation">,</span>
<span class="token property">"print"</span><span class="token operator">:</span> <span class="token boolean">false</span><span class="token punctuation">,</span>
<span class="token property">"replace"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"function"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"query_digest"</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">]</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span></code></pre>
</div>
<p>
To perform replacement on only some events within a class, add
items to the filter that indicate more specifically when
replacement occurs. The following filter applies to events in
the
<code class="literal">
table_access
</code>
class, but performs
replacement only for
<code class="literal">
insert
</code>
and
<code class="literal">
update
</code>
events (leaving
<code class="literal">
read
</code>
and
<code class="literal">
delete
</code>
events
unchanged):
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-json"><div class="docs-select-all right" id="sa90839186"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token punctuation">{</span>
<span class="token property">"filter"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"class"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"table_access"</span><span class="token punctuation">,</span>
<span class="token property">"event"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"name"</span><span class="token operator">:</span> <span class="token punctuation">[</span>
<span class="token string">"insert"</span><span class="token punctuation">,</span>
<span class="token string">"update"</span>
<span class="token punctuation">]</span><span class="token punctuation">,</span>
<span class="token property">"print"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"field"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"query.str"</span><span class="token punctuation">,</span>
<span class="token property">"print"</span><span class="token operator">:</span> <span class="token boolean">false</span><span class="token punctuation">,</span>
<span class="token property">"replace"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"function"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"query_digest"</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span></code></pre>
</div>
<p>
This filter performs replacement for
<code class="literal">
general
</code>
class events corresponding to the
listed account-management statements (the effect being to hide
credential and data values in the statements):
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-json"><div class="docs-select-all right" id="sa40469679"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token punctuation">{</span>
<span class="token property">"filter"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"class"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"general"</span><span class="token punctuation">,</span>
<span class="token property">"event"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"status"</span><span class="token punctuation">,</span>
<span class="token property">"print"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"field"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"general_query.str"</span><span class="token punctuation">,</span>
<span class="token property">"print"</span><span class="token operator">:</span> <span class="token boolean">false</span><span class="token punctuation">,</span>
<span class="token property">"replace"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"function"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"query_digest"</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token property">"log"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"or"</span><span class="token operator">:</span> <span class="token punctuation">[</span>
<span class="token punctuation">{</span>
<span class="token property">"field"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"general_sql_command.str"</span><span class="token punctuation">,</span>
<span class="token property">"value"</span><span class="token operator">:</span> <span class="token string">"alter_user"</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token punctuation">{</span>
<span class="token property">"field"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"general_sql_command.str"</span><span class="token punctuation">,</span>
<span class="token property">"value"</span><span class="token operator">:</span> <span class="token string">"alter_user_default_role"</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token punctuation">{</span>
<span class="token property">"field"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"general_sql_command.str"</span><span class="token punctuation">,</span>
<span class="token property">"value"</span><span class="token operator">:</span> <span class="token string">"create_role"</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token punctuation">{</span>
<span class="token property">"field"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"general_sql_command.str"</span><span class="token punctuation">,</span>
<span class="token property">"value"</span><span class="token operator">:</span> <span class="token string">"create_user"</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">]</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span></code></pre>
</div>
<p>
For information about the possible
<code class="literal">
general_sql_command.str
</code>
values, see
<a class="xref" href="audit-log-filter-definitions.html#audit-log-filtering-event-fields" title="Testing Event Field Values">
Testing Event Field Values
</a>
.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="audit-log-filtering-filter-replacement">
</a>
Replacing a User Filter
</h5>
</div>
</div>
</div>
<p>
In some cases, the filter definition can be changed
dynamically. To do this, define a
<code class="literal">
filter
</code>
configuration within an existing
<code class="literal">
filter
</code>
.
For example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-json"><div class="docs-select-all right" id="sa8866616"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token punctuation">{</span>
<span class="token property">"filter"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"id"</span><span class="token operator">:</span> <span class="token string">"main"</span><span class="token punctuation">,</span>
<span class="token property">"class"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"table_access"</span><span class="token punctuation">,</span>
<span class="token property">"event"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"name"</span><span class="token operator">:</span> <span class="token punctuation">[</span> <span class="token string">"update"</span><span class="token punctuation">,</span> <span class="token string">"delete"</span> <span class="token punctuation">]</span><span class="token punctuation">,</span>
<span class="token property">"log"</span><span class="token operator">:</span> <span class="token boolean">false</span><span class="token punctuation">,</span>
<span class="token property">"filter"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"class"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"general"</span><span class="token punctuation">,</span>
<span class="token property">"event"</span> <span class="token operator">:</span> <span class="token punctuation">{</span> <span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"status"</span><span class="token punctuation">,</span>
<span class="token property">"filter"</span><span class="token operator">:</span> <span class="token punctuation">{</span> <span class="token property">"ref"</span><span class="token operator">:</span> <span class="token string">"main"</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span>
<span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token property">"activate"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"or"</span><span class="token operator">:</span> <span class="token punctuation">[</span>
<span class="token punctuation">{</span> <span class="token property">"field"</span><span class="token operator">:</span> <span class="token punctuation">{</span> <span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"table_name.str"</span><span class="token punctuation">,</span> <span class="token property">"value"</span><span class="token operator">:</span> <span class="token string">"temp_1"</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token punctuation">{</span> <span class="token property">"field"</span><span class="token operator">:</span> <span class="token punctuation">{</span> <span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"table_name.str"</span><span class="token punctuation">,</span> <span class="token property">"value"</span><span class="token operator">:</span> <span class="token string">"temp_2"</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span>
<span class="token punctuation">]</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span></code></pre>
</div>
<p>
A new filter is activated when the
<code class="literal">
activate
</code>
item within a subfilter evaluates to
<code class="literal">
true
</code>
.
Using
<code class="literal">
activate
</code>
in a top-level
<code class="literal">
filter
</code>
is not permitted.
</p>
<p>
A new filter can be replaced with the original one by using a
<code class="literal">
ref
</code>
item inside the subfilter to refer to
the original filter
<code class="literal">
id
</code>
.
</p>
<p>
The filter shown operates like this:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
The
<code class="literal">
main
</code>
filter waits for
<code class="literal">
table_access
</code>
events, either
<code class="literal">
update
</code>
or
<code class="literal">
delete
</code>
.
</p>
</li>
<li class="listitem">
<p>
If the
<code class="literal">
update
</code>
or
<code class="literal">
delete
</code>
<code class="literal">
table_access
</code>
event occurs on the
<code class="literal">
temp_1
</code>
or
<code class="literal">
temp_2
</code>
table, the filter is replaced
with the internal one (without an
<code class="literal">
id
</code>
,
since there is no need to refer to it explicitly).
</p>
</li>
<li class="listitem">
<p>
If the end of the command is signalled
(
<code class="literal">
general
</code>
/
<code class="literal">
status
</code>
event), an entry is written to the audit log file and the
filter is replaced with the
<code class="literal">
main
</code>
filter.
</p>
</li>
</ul>
</div>
<p>
The filter is useful to log statements that update or delete
anything from the
<code class="literal">
temp_1
</code>
or
<code class="literal">
temp_2
</code>
tables, such as this one:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa91475053"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">UPDATE</span> temp_1<span class="token punctuation">,</span> temp_3 <span class="token keyword">SET</span> temp_1<span class="token punctuation">.</span>a<span class="token operator">=</span><span class="token number">21</span><span class="token punctuation">,</span> temp_3<span class="token punctuation">.</span>a<span class="token operator">=</span><span class="token number">23</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
The statement generates multiple
<code class="literal">
table_access
</code>
events, but the audit log file
contains only
<code class="literal">
general
</code>
/
<code class="literal">
status
</code>
entries.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
Any
<code class="literal">
id
</code>
values used in the definition are
evaluated with respect only to that definition. They have
nothing to do with the value of the
<a class="link" href="audit-log-reference.html#sysvar_audit_log_filter_id">
<code class="literal">
audit_log_filter_id
</code>
</a>
system
variable.
</p>
</div>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/mysqldump.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="mysqldump">
</a>
6.5.4 mysqldump — A Database Backup Program
</h3>
</div>
</div>
</div>
<a class="indexterm" name="idm46045314765984">
</a>
<a class="indexterm" name="idm46045314765072">
</a>
<a class="indexterm" name="idm46045314763712">
</a>
<a class="indexterm" name="idm46045314762352">
</a>
<a class="indexterm" name="idm46045314760992">
</a>
<p>
The
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
client utility performs
<a class="link" href="glossary.html#glos_logical_backup" title="logical backup">
logical backups
</a>
,
producing a set of SQL statements that can be executed to
reproduce the original database object definitions and table
data. It dumps one or more MySQL databases for backup or
transfer to another SQL server. The
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
command can also generate output in CSV, other delimited text,
or XML format.
</p>
<div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Tip
</div>
<p>
Consider using the
<a class="ulink" href="/doc/mysql-shell/8.4/en/mysql-shell-utilities-dump-instance-schema.html" target="_top">
MySQL Shell dump utilities
</a>
, which provide parallel dumping with multiple threads, file compression, and progress information display, as well as cloud features such as Oracle Cloud Infrastructure Object Storage streaming, and MySQL HeatWave Service compatibility checks and modifications. Dumps can be easily imported into a MySQL Server instance or a MySQL HeatWave Service DB System using the
<a class="ulink" href="/doc/mysql-shell/8.4/en/mysql-shell-utilities-load-dump.html" target="_top">
MySQL Shell load dump utilities
</a>
. Installation instructions for MySQL Shell can be found
<a class="ulink" href="/doc/mysql-shell/8.4/en/mysql-shell-install.html" target="_top">
here
</a>
.
</p>
</div>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="xref" href="mysqldump.html#mysqldump-performance" title="Performance and Scalability Considerations">
Performance and Scalability Considerations
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="mysqldump.html#mysqldump-syntax" title="Invocation Syntax">
Invocation Syntax
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="mysqldump.html#mysqldump-option-summary" title="Option Syntax - Alphabetical Summary">
Option Syntax - Alphabetical Summary
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="mysqldump.html#mysqldump-connection-options" title="Connection Options">
Connection Options
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="mysqldump.html#mysqldump-option-file-options" title="Option-File Options">
Option-File Options
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="mysqldump.html#mysqldump-ddl-options" title="DDL Options">
DDL Options
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="mysqldump.html#mysqldump-debug-options" title="Debug Options">
Debug Options
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="mysqldump.html#mysqldump-help-options" title="Help Options">
Help Options
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="mysqldump.html#mysqldump-i18n-options" title="Internationalization Options">
Internationalization Options
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="mysqldump.html#mysqldump-replication-options" title="Replication Options">
Replication Options
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="mysqldump.html#mysqldump-format-options" title="Format Options">
Format Options
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="mysqldump.html#mysqldump-filter-options" title="Filtering Options">
Filtering Options
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="mysqldump.html#mysqldump-performance-options" title="Performance Options">
Performance Options
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="mysqldump.html#mysqldump-transaction-options" title="Transactional Options">
Transactional Options
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="mysqldump.html#mysqldump-option-groups" title="Option Groups">
Option Groups
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="mysqldump.html#mysqldump-option-examples" title="Examples">
Examples
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="mysqldump.html#mysqldump-restrictions" title="Restrictions">
Restrictions
</a>
</p>
</li>
</ul>
</div>
<p>
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
requires at least the
<a class="link" href="privileges-provided.html#priv_select">
<code class="literal">
SELECT
</code>
</a>
privilege for dumped
tables,
<a class="link" href="privileges-provided.html#priv_show-view">
<code class="literal">
SHOW VIEW
</code>
</a>
for dumped
views,
<a class="link" href="privileges-provided.html#priv_trigger">
<code class="literal">
TRIGGER
</code>
</a>
for dumped
triggers,
<a class="link" href="privileges-provided.html#priv_lock-tables">
<code class="literal">
LOCK TABLES
</code>
</a>
if the
<a class="link" href="mysqldump.html#option_mysqldump_single-transaction">
<code class="option">
--single-transaction
</code>
</a>
option is
not used,
<a class="link" href="privileges-provided.html#priv_process">
<code class="literal">
PROCESS
</code>
</a>
if the
<a class="link" href="mysqldump.html#option_mysqldump_no-tablespaces">
<code class="option">
--no-tablespaces
</code>
</a>
option is not used, and the
<a class="link" href="privileges-provided.html#priv_reload">
<code class="literal">
RELOAD
</code>
</a>
or
<a class="link" href="privileges-provided.html#priv_flush-tables">
<code class="literal">
FLUSH_TABLES
</code>
</a>
privilege with
<a class="link" href="mysqldump.html#option_mysqldump_single-transaction">
<code class="option">
--single-transaction
</code>
</a>
if both
<a class="link" href="replication-options-gtids.html#sysvar_gtid_mode">
<code class="literal">
gtid_mode=ON
</code>
</a>
and
<a class="link" href="replication-options-gtids.html#sysvar_gtid_purged">
<code class="literal">
gtid_purged=ON|AUTO
</code>
</a>
.
Certain options might require other privileges as noted in the
option descriptions.
</p>
<p>
To reload a dump file, you must have the privileges required to
execute the statements that it contains, such as the appropriate
<code class="literal">
CREATE
</code>
privileges for objects created by
those statements.
</p>
<p>
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
output can include
<a class="link" href="alter-database.html" title="15.1.2 ALTER DATABASE Statement">
<code class="literal">
ALTER DATABASE
</code>
</a>
statements that
change the database collation. These may be used when dumping
stored programs to preserve their character encodings. To reload
a dump file containing such statements, the
<code class="literal">
ALTER
</code>
privilege for the affected database is
required.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
A dump made using PowerShell on Windows with output
redirection creates a file that has UTF-16 encoding:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa57488097"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal">mysqldump <span class="token punctuation">[</span>options<span class="token punctuation">]</span> > dump<span class="token punctuation">.</span>sql</code></pre>
</div>
<p>
However, UTF-16 is not permitted as a connection character set
(see
<a class="xref" href="charset-connection.html#charset-connection-impermissible-client-charset" title="Impermissible Client Character Sets">
Impermissible Client Character Sets
</a>
),
so the dump file cannot be loaded correctly. To work around
this issue, use the
<code class="option">
--result-file
</code>
option,
which creates the output in ASCII format:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa20903536"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal">mysqldump <span class="token punctuation">[</span>options<span class="token punctuation">]</span> <span class="token constant">--result-file</span><span class="token attr-value"><span class="token punctuation">=</span>dump.sql</span></code></pre>
</div>
</div>
<p>
It is not recommended to load a dump file when GTIDs are enabled
on the server (
<a class="link" href="replication-options-gtids.html#sysvar_gtid_mode">
<code class="literal">
gtid_mode=ON
</code>
</a>
),
if your dump file includes system tables.
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
issues DML instructions for the
system tables which use the non-transactional MyISAM storage
engine, and this combination is not permitted when GTIDs are
enabled.
</p>
<h4>
<a name="mysqldump-performance">
</a>
Performance and Scalability Considerations
</h4>
<p>
<code class="literal">
mysqldump
</code>
advantages include the convenience
and flexibility of viewing or even editing the output before
restoring. You can clone databases for development and DBA work,
or produce slight variations of an existing database for
testing. It is not intended as a fast or scalable solution for
backing up substantial amounts of data. With large data sizes,
even if the backup step takes a reasonable time, restoring the
data can be very slow because replaying the SQL statements
involves disk I/O for insertion, index creation, and so on.
</p>
<p>
For large-scale backup and restore, a
<a class="link" href="glossary.html#glos_physical" title="physical">
physical
</a>
backup is more
appropriate, to copy the data files in their original format so
that they can be restored quickly.
</p>
<p>
If your tables are primarily
<a class="link" href="innodb-storage-engine.html" title="Chapter 17 The InnoDB Storage Engine">
<code class="literal">
InnoDB
</code>
</a>
tables, or if you have a mix of
<code class="literal">
InnoDB
</code>
and
<a class="link" href="myisam-storage-engine.html" title="18.2 The MyISAM Storage Engine">
<code class="literal">
MyISAM
</code>
</a>
tables, consider using
<span class="command">
<strong>
mysqlbackup
</strong>
</span>
, which is available as part of
MySQL Enterprise. This tool provides high performance for
<code class="literal">
InnoDB
</code>
backups with minimal disruption; it
can also back up tables from
<code class="literal">
MyISAM
</code>
and other
storage engines; it also provides a number of convenient options
to accommodate different backup scenarios. See
<a class="xref" href="mysql-enterprise-backup.html" title="32.1 MySQL Enterprise Backup Overview">
Section 32.1, “MySQL Enterprise Backup Overview”
</a>
.
</p>
<p>
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
can retrieve and dump table
contents row by row, or it can retrieve the entire content from
a table and buffer it in memory before dumping it. Buffering in
memory can be a problem if you are dumping large tables. To dump
tables row by row, use the
<a class="link" href="mysqldump.html#option_mysqldump_quick">
<code class="option">
--quick
</code>
</a>
option (or
<a class="link" href="mysqldump.html#option_mysqldump_opt">
<code class="option">
--opt
</code>
</a>
, which enables
<a class="link" href="mysqldump.html#option_mysqldump_quick">
<code class="option">
--quick
</code>
</a>
). The
<a class="link" href="mysqldump.html#option_mysqldump_opt">
<code class="option">
--opt
</code>
</a>
option (and hence
<a class="link" href="mysqldump.html#option_mysqldump_quick">
<code class="option">
--quick
</code>
</a>
) is enabled by
default, so to enable memory buffering, use
<a class="link" href="mysqldump.html#option_mysqldump_quick">
<code class="option">
--skip-quick
</code>
</a>
.
</p>
<p>
If you are using a recent version of
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
to generate a dump to be reloaded
into a very old MySQL server, use the
<a class="link" href="mysqldump.html#option_mysqldump_skip-opt">
<code class="option">
--skip-opt
</code>
</a>
option instead of
the
<a class="link" href="mysqldump.html#option_mysqldump_opt">
<code class="option">
--opt
</code>
</a>
or
<a class="link" href="mysqldump.html#option_mysqldump_extended-insert">
<code class="option">
--extended-insert
</code>
</a>
option.
</p>
<p>
For additional information about
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
,
see
<a class="xref" href="using-mysqldump.html" title="9.4 Using mysqldump for Backups">
Section 9.4, “Using mysqldump for Backups”
</a>
.
</p>
<h4>
<a name="mysqldump-syntax">
</a>
Invocation Syntax
</h4>
<p>
There are in general three ways to use
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
—in order to dump a set of one
or more tables, a set of one or more complete databases, or an
entire MySQL server—as shown here:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa83684617"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal">mysqldump <span class="token punctuation">[</span><em class="replaceable">options</em><span class="token punctuation">]</span> <em class="replaceable">db_name</em> <span class="token punctuation">[</span><em class="replaceable">tbl_name</em> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">]</span>
mysqldump <span class="token punctuation">[</span><em class="replaceable">options</em><span class="token punctuation">]</span> <span class="token property">--databases</span> <em class="replaceable">db_name</em> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
mysqldump <span class="token punctuation">[</span><em class="replaceable">options</em><span class="token punctuation">]</span> <span class="token property">--all-databases</span></code></pre>
</div>
<p>
To dump entire databases, do not name any tables following
<em class="replaceable">
<code>
db_name
</code>
</em>
, or use the
<a class="link" href="mysqldump.html#option_mysqldump_databases">
<code class="option">
--databases
</code>
</a>
or
<a class="link" href="mysqldump.html#option_mysqldump_all-databases">
<code class="option">
--all-databases
</code>
</a>
option.
</p>
<p>
To see a list of the options your version of
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
supports, issue the command
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
<a class="link" href="mysqldump.html#option_mysqldump_help">
<code class="option">
--help
</code>
</a>
.
</p>
<h4>
<a name="mysqldump-option-summary">
</a>
Option Syntax - Alphabetical Summary
</h4>
<p>
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
supports the following options,
which can be specified on the command line or in the
<code class="literal">
[mysqldump]
</code>
and
<code class="literal">
[client]
</code>
groups of an option file. For information about option files
used by MySQL programs, see
<a class="xref" href="option-files.html" title="6.2.2.2 Using Option Files">
Section 6.2.2.2, “Using Option Files”
</a>
.
</p>
<div class="table">
<a name="idm46045314657248">
</a>
<p class="title">
<b>
Table 6.13 mysqldump Options
</b>
</p>
<div class="table-contents">
<table frame="box" rules="all" summary="Command-line options available for mysqldump.">
<colgroup>
<col style="width: 35%"/>
<col style="width: 64%"/>
</colgroup>
<thead>
<tr>
<th>
Option Name
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_add-drop-database">
--add-drop-database
</a>
</td>
<td>
Add DROP DATABASE statement before each CREATE DATABASE statement
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_add-drop-table">
--add-drop-table
</a>
</td>
<td>
Add DROP TABLE statement before each CREATE TABLE statement
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_add-drop-trigger">
--add-drop-trigger
</a>
</td>
<td>
Add DROP TRIGGER statement before each CREATE TRIGGER statement
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_add-locks">
--add-locks
</a>
</td>
<td>
Surround each table dump with LOCK TABLES and UNLOCK TABLES statements
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_all-databases">
--all-databases
</a>
</td>
<td>
Dump all tables in all databases
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_allow-keywords">
--allow-keywords
</a>
</td>
<td>
Allow creation of column names that are keywords
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_apply-replica-statements">
--apply-replica-statements
</a>
</td>
<td>
Include STOP REPLICA prior to CHANGE REPLICATION SOURCE TO statement and START REPLICA at end of output
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_apply-slave-statements">
--apply-slave-statements
</a>
</td>
<td>
Include STOP SLAVE prior to CHANGE MASTER statement and START SLAVE at end of output
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_bind-address">
--bind-address
</a>
</td>
<td>
Use specified network interface to connect to MySQL Server
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_character-sets-dir">
--character-sets-dir
</a>
</td>
<td>
Directory where character sets are installed
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_column-statistics">
--column-statistics
</a>
</td>
<td>
Write ANALYZE TABLE statements to generate statistics histograms
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_comments">
--comments
</a>
</td>
<td>
Add comments to dump file
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_compact">
--compact
</a>
</td>
<td>
Produce more compact output
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_compatible">
--compatible
</a>
</td>
<td>
Produce output that is more compatible with other database systems or with older MySQL servers
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_complete-insert">
--complete-insert
</a>
</td>
<td>
Use complete INSERT statements that include column names
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_compress">
--compress
</a>
</td>
<td>
Compress all information sent between client and server
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_compression-algorithms">
--compression-algorithms
</a>
</td>
<td>
Permitted compression algorithms for connections to server
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_create-options">
--create-options
</a>
</td>
<td>
Include all MySQL-specific table options in CREATE TABLE statements
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_databases">
--databases
</a>
</td>
<td>
Interpret all name arguments as database names
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_debug">
--debug
</a>
</td>
<td>
Write debugging log
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_debug-check">
--debug-check
</a>
</td>
<td>
Print debugging information when program exits
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_debug-info">
--debug-info
</a>
</td>
<td>
Print debugging information, memory, and CPU statistics when program exits
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_default-auth">
--default-auth
</a>
</td>
<td>
Authentication plugin to use
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_default-character-set">
--default-character-set
</a>
</td>
<td>
Specify default character set
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_defaults-extra-file">
--defaults-extra-file
</a>
</td>
<td>
Read named option file in addition to usual option files
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_defaults-file">
--defaults-file
</a>
</td>
<td>
Read only named option file
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_defaults-group-suffix">
--defaults-group-suffix
</a>
</td>
<td>
Option group suffix value
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_delete-master-logs">
--delete-master-logs
</a>
</td>
<td>
On a replication source server, delete the binary logs after performing the dump operation
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_delete-source-logs">
--delete-source-logs
</a>
</td>
<td>
On a replication source server, delete the binary logs after performing the dump operation
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_disable-keys">
--disable-keys
</a>
</td>
<td>
For each table, surround INSERT statements with statements to disable and enable keys
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_dump-date">
--dump-date
</a>
</td>
<td>
Include dump date as "Dump completed on" comment if --comments is given
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_dump-replica">
--dump-replica
</a>
</td>
<td>
Include CHANGE REPLICATION SOURCE TO statement that lists binary log coordinates of replica's source
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_dump-slave">
--dump-slave
</a>
</td>
<td>
Include CHANGE MASTER statement that lists binary log coordinates of replica's source
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_enable-cleartext-plugin">
--enable-cleartext-plugin
</a>
</td>
<td>
Enable cleartext authentication plugin
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_events">
--events
</a>
</td>
<td>
Dump events from dumped databases
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_extended-insert">
--extended-insert
</a>
</td>
<td>
Use multiple-row INSERT syntax
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_fields">
--fields-enclosed-by
</a>
</td>
<td>
This option is used with the --tab option and has the same meaning as the corresponding clause for LOAD DATA
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_fields">
--fields-escaped-by
</a>
</td>
<td>
This option is used with the --tab option and has the same meaning as the corresponding clause for LOAD DATA
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_fields">
--fields-optionally-enclosed-by
</a>
</td>
<td>
This option is used with the --tab option and has the same meaning as the corresponding clause for LOAD DATA
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_fields">
--fields-terminated-by
</a>
</td>
<td>
This option is used with the --tab option and has the same meaning as the corresponding clause for LOAD DATA
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_flush-logs">
--flush-logs
</a>
</td>
<td>
Flush MySQL server log files before starting dump
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_flush-privileges">
--flush-privileges
</a>
</td>
<td>
Emit a FLUSH PRIVILEGES statement after dumping mysql database
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_force">
--force
</a>
</td>
<td>
Continue even if an SQL error occurs during a table dump
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_get-server-public-key">
--get-server-public-key
</a>
</td>
<td>
Request RSA public key from server
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_help">
--help
</a>
</td>
<td>
Display help message and exit
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_hex-blob">
--hex-blob
</a>
</td>
<td>
Dump binary columns using hexadecimal notation
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_host">
--host
</a>
</td>
<td>
Host on which MySQL server is located
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_ignore-error">
--ignore-error
</a>
</td>
<td>
Ignore specified errors
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_ignore-table">
--ignore-table
</a>
</td>
<td>
Do not dump given table
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_ignore-views">
--ignore-views
</a>
</td>
<td>
Skip dumping table views
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_include-master-host-port">
--include-master-host-port
</a>
</td>
<td>
Include MASTER_HOST/MASTER_PORT options in CHANGE MASTER statement produced with --dump-slave
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_include-source-host-port">
--include-source-host-port
</a>
</td>
<td>
Include SOURCE_HOST and SOURCE_PORT options in CHANGE REPLICATION SOURCE TO statement produced with --dump-replica
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_init-command">
--init-command
</a>
</td>
<td>
Single SQL statement to execute after connecting or re-connecting to MySQL server; resets existing defined commands
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_init-command-add">
--init-command-add
</a>
</td>
<td>
Add an additional SQL statement to execute after connecting or re-connecting to MySQL server
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_insert-ignore">
--insert-ignore
</a>
</td>
<td>
Write INSERT IGNORE rather than INSERT statements
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_lines-terminated-by">
--lines-terminated-by
</a>
</td>
<td>
This option is used with the --tab option and has the same meaning as the corresponding clause for LOAD DATA
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_lock-all-tables">
--lock-all-tables
</a>
</td>
<td>
Lock all tables across all databases
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_lock-tables">
--lock-tables
</a>
</td>
<td>
Lock all tables before dumping them
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_log-error">
--log-error
</a>
</td>
<td>
Append warnings and errors to named file
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_login-path">
--login-path
</a>
</td>
<td>
Read login path options from .mylogin.cnf
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_master-data">
--master-data
</a>
</td>
<td>
Write the binary log file name and position to the output
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_max-allowed-packet">
--max-allowed-packet
</a>
</td>
<td>
Maximum packet length to send to or receive from server
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_mysqld-long-query-time">
--mysqld-long-query-time
</a>
</td>
<td>
Session value for slow query threshold
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_net-buffer-length">
--net-buffer-length
</a>
</td>
<td>
Buffer size for TCP/IP and socket communication
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_network-timeout">
--network-timeout
</a>
</td>
<td>
Increase network timeouts to permit larger table dumps
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_no-autocommit">
--no-autocommit
</a>
</td>
<td>
Enclose the INSERT statements for each dumped table within SET autocommit = 0 and COMMIT statements
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_no-create-db">
--no-create-db
</a>
</td>
<td>
Do not write CREATE DATABASE statements
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_no-create-info">
--no-create-info
</a>
</td>
<td>
Do not write CREATE TABLE statements that re-create each dumped table
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_no-data">
--no-data
</a>
</td>
<td>
Do not dump table contents
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_no-defaults">
--no-defaults
</a>
</td>
<td>
Read no option files
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_no-login-paths">
--no-login-paths
</a>
</td>
<td>
Do not read login paths from the login path file
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_no-set-names">
--no-set-names
</a>
</td>
<td>
Same as --skip-set-charset
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_no-tablespaces">
--no-tablespaces
</a>
</td>
<td>
Do not write any CREATE LOGFILE GROUP or CREATE TABLESPACE statements in output
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_opt">
--opt
</a>
</td>
<td>
Shorthand for --add-drop-table --add-locks --create-options --disable-keys --extended-insert --lock-tables --quick --set-charset
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_order-by-primary">
--order-by-primary
</a>
</td>
<td>
Dump each table's rows sorted by its primary key, or by its first unique index
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_output-as-version">
--output-as-version
</a>
</td>
<td>
Determines replica and event terminology used in dumps; for compatibility with older versions
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_password">
--password
</a>
</td>
<td>
Password to use when connecting to server
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_password1">
--password1
</a>
</td>
<td>
First multifactor authentication password to use when connecting to server
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_password2">
--password2
</a>
</td>
<td>
Second multifactor authentication password to use when connecting to server
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_password3">
--password3
</a>
</td>
<td>
Third multifactor authentication password to use when connecting to server
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_pipe">
--pipe
</a>
</td>
<td>
Connect to server using named pipe (Windows only)
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_plugin-authentication-kerberos-client-mode">
--plugin-authentication-kerberos-client-mode
</a>
</td>
<td>
Permit GSSAPI pluggable authentication through the MIT Kerberos library on Windows
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_plugin-dir">
--plugin-dir
</a>
</td>
<td>
Directory where plugins are installed
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_port">
--port
</a>
</td>
<td>
TCP/IP port number for connection
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_print-defaults">
--print-defaults
</a>
</td>
<td>
Print default options
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_protocol">
--protocol
</a>
</td>
<td>
Transport protocol to use
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_quick">
--quick
</a>
</td>
<td>
Retrieve rows for a table from the server a row at a time
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_quote-names">
--quote-names
</a>
</td>
<td>
Quote identifiers within backtick characters
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_replace">
--replace
</a>
</td>
<td>
Write REPLACE statements rather than INSERT statements
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_result-file">
--result-file
</a>
</td>
<td>
Direct output to a given file
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_routines">
--routines
</a>
</td>
<td>
Dump stored routines (procedures and functions) from dumped databases
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_server-public-key-path">
--server-public-key-path
</a>
</td>
<td>
Path name to file containing RSA public key
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_set-charset">
--set-charset
</a>
</td>
<td>
Add SET NAMES default_character_set to output
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_set-gtid-purged">
--set-gtid-purged
</a>
</td>
<td>
Whether to add SET @@GLOBAL.GTID_PURGED to output
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_shared-memory-base-name">
--shared-memory-base-name
</a>
</td>
<td>
Shared-memory name for shared-memory connections (Windows only)
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_show-create-skip-secondary-engine">
--show-create-skip-secondary-engine
</a>
</td>
<td>
Exclude SECONDARY ENGINE clause from CREATE TABLE statements
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_single-transaction">
--single-transaction
</a>
</td>
<td>
Issue a BEGIN SQL statement before dumping data from server
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_add-drop-table">
--skip-add-drop-table
</a>
</td>
<td>
Do not add a DROP TABLE statement before each CREATE TABLE statement
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_add-locks">
--skip-add-locks
</a>
</td>
<td>
Do not add locks
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_skip-comments">
--skip-comments
</a>
</td>
<td>
Do not add comments to dump file
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_compact">
--skip-compact
</a>
</td>
<td>
Do not produce more compact output
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_disable-keys">
--skip-disable-keys
</a>
</td>
<td>
Do not disable keys
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_extended-insert">
--skip-extended-insert
</a>
</td>
<td>
Turn off extended-insert
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_skip-generated-invisible-primary-key">
--skip-generated-invisible-primary-key
</a>
</td>
<td>
Do not include generated invisible primary keys in dump file
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_skip-opt">
--skip-opt
</a>
</td>
<td>
Turn off options set by --opt
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_quick">
--skip-quick
</a>
</td>
<td>
Do not retrieve rows for a table from the server a row at a time
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_quote-names">
--skip-quote-names
</a>
</td>
<td>
Do not quote identifiers
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_set-charset">
--skip-set-charset
</a>
</td>
<td>
Do not write SET NAMES statement
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_triggers">
--skip-triggers
</a>
</td>
<td>
Do not dump triggers
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_tz-utc">
--skip-tz-utc
</a>
</td>
<td>
Turn off tz-utc
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_socket">
--socket
</a>
</td>
<td>
Unix socket file or Windows named pipe to use
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_source-data">
--source-data
</a>
</td>
<td>
Write the binary log file name and position to the output
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_ssl">
--ssl-ca
</a>
</td>
<td>
File that contains list of trusted SSL Certificate Authorities
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_ssl">
--ssl-capath
</a>
</td>
<td>
Directory that contains trusted SSL Certificate Authority certificate files
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_ssl">
--ssl-cert
</a>
</td>
<td>
File that contains X.509 certificate
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_ssl">
--ssl-cipher
</a>
</td>
<td>
Permissible ciphers for connection encryption
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_ssl">
--ssl-crl
</a>
</td>
<td>
File that contains certificate revocation lists
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_ssl">
--ssl-crlpath
</a>
</td>
<td>
Directory that contains certificate revocation-list files
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_ssl-fips-mode">
--ssl-fips-mode
</a>
</td>
<td>
Whether to enable FIPS mode on client side
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_ssl">
--ssl-key
</a>
</td>
<td>
File that contains X.509 key
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_ssl">
--ssl-mode
</a>
</td>
<td>
Desired security state of connection to server
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_ssl">
--ssl-session-data
</a>
</td>
<td>
File that contains SSL session data
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_ssl">
--ssl-session-data-continue-on-failed-reuse
</a>
</td>
<td>
Whether to establish connections if session reuse fails
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_tab">
--tab
</a>
</td>
<td>
Produce tab-separated data files
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_tables">
--tables
</a>
</td>
<td>
Override --databases or -B option
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_tls-ciphersuites">
--tls-ciphersuites
</a>
</td>
<td>
Permissible TLSv1.3 ciphersuites for encrypted connections
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_tls-sni-servername">
--tls-sni-servername
</a>
</td>
<td>
Server name supplied by the client
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_tls-version">
--tls-version
</a>
</td>
<td>
Permissible TLS protocols for encrypted connections
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_triggers">
--triggers
</a>
</td>
<td>
Dump triggers for each dumped table
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_tz-utc">
--tz-utc
</a>
</td>
<td>
Add SET TIME_ZONE='+00:00' to dump file
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_user">
--user
</a>
</td>
<td>
MySQL user name to use when connecting to server
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_verbose">
--verbose
</a>
</td>
<td>
Verbose mode
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_version">
--version
</a>
</td>
<td>
Display version information and exit
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_where">
--where
</a>
</td>
<td>
Dump only rows selected by given WHERE condition
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_xml">
--xml
</a>
</td>
<td>
Produce XML output
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqldump.html#option_mysqldump_zstd-compression-level">
--zstd-compression-level
</a>
</td>
<td>
Compression level for connections to server that use zstd compression
</td>
</tr>
</tbody>
</table>
</div>
<div class="table-contents">
<table cellpadding="0" cellspacing="0" style="position: fixed; top: 0px; display: none; left: 401px; width: 739px;">
<thead>
<tr>
<th style="width: 260.906px;">
Option Name
</th>
<th style="width: 477.094px;">
Description
</th>
</tr>
</thead>
</table>
</div>
</div>
<br class="table-break"/>
<h4>
<a name="mysqldump-connection-options">
</a>
Connection Options
</h4>
<p>
The
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
command logs into a MySQL
server to extract information. The following options specify how
to connect to the MySQL server, either on the same machine or a
remote system.
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a name="option_mysqldump_bind-address">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_bind-address">
<code class="option">
--bind-address=
<em class="replaceable">
<code>
ip_address
</code>
</em>
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for bind-address">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--bind-address=ip_address
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045314269280">
</a>
<a class="indexterm" name="idm46045314267792">
</a>
<p>
On a computer having multiple network interfaces, use this
option to select which interface to use for connecting to
the MySQL server.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_compress">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_compress">
<code class="option">
--compress
</code>
</a>
,
<code class="option">
-C
</code>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for compress">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--compress[={OFF|ON}]
</code>
</td>
</tr>
<tr>
<th>
Deprecated
</th>
<td>
Yes
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
Boolean
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
OFF
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045314251088">
</a>
<a class="indexterm" name="idm46045314249600">
</a>
<p>
Compress all information sent between the client and the
server if possible. See
<a class="xref" href="connection-compression-control.html" title="6.2.8 Connection Compression Control">
Section 6.2.8, “Connection Compression Control”
</a>
.
</p>
<p>
This option is deprecated. Expect it to be removed in a
future version of MySQL. See
<a class="xref" href="connection-compression-control.html#connection-compression-legacy-configuration" title="Configuring Legacy Connection Compression">
Configuring Legacy Connection Compression
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_compression-algorithms">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_compression-algorithms">
<code class="option">
--compression-algorithms=
<em class="replaceable">
<code>
value
</code>
</em>
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for compression-algorithms">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--compression-algorithms=value
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
Set
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
uncompressed
</code>
</td>
</tr>
<tr>
<th>
Valid Values
</th>
<td>
<p class="valid-value">
<code class="literal">
zlib
</code>
</p>
<p class="valid-value">
<code class="literal">
zstd
</code>
</p>
<p class="valid-value">
<code class="literal">
uncompressed
</code>
</p>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045314228416">
</a>
<a class="indexterm" name="idm46045314226912">
</a>
<p>
The permitted compression algorithms for connections to the
server. The available algorithms are the same as for the
<a class="link" href="server-system-variables.html#sysvar_protocol_compression_algorithms">
<code class="literal">
protocol_compression_algorithms
</code>
</a>
system variable. The default value is
<code class="literal">
uncompressed
</code>
.
</p>
<p>
For more information, see
<a class="xref" href="connection-compression-control.html" title="6.2.8 Connection Compression Control">
Section 6.2.8, “Connection Compression Control”
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_default-auth">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_default-auth">
<code class="option">
--default-auth=
<em class="replaceable">
<code>
plugin
</code>
</em>
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for default-auth">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--default-auth=plugin
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
String
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045314211600">
</a>
<a class="indexterm" name="idm46045314210112">
</a>
<p>
A hint about which client-side authentication plugin to use.
See
<a class="xref" href="pluggable-authentication.html" title="8.2.17 Pluggable Authentication">
Section 8.2.17, “Pluggable Authentication”
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_enable-cleartext-plugin">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_enable-cleartext-plugin">
<code class="option">
--enable-cleartext-plugin
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for enable-cleartext-plugin">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--enable-cleartext-plugin
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
Boolean
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
FALSE
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045314195056">
</a>
<a class="indexterm" name="idm46045314193552">
</a>
<p>
Enable the
<code class="literal">
mysql_clear_password
</code>
cleartext
authentication plugin. (See
<a class="xref" href="cleartext-pluggable-authentication.html" title="8.4.1.4 Client-Side Cleartext Pluggable Authentication">
Section 8.4.1.4, “Client-Side Cleartext Pluggable Authentication”
</a>
.)
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_get-server-public-key">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_get-server-public-key">
<code class="option">
--get-server-public-key
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for get-server-public-key">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--get-server-public-key
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
Boolean
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045314180448">
</a>
<a class="indexterm" name="idm46045314178944">
</a>
<p>
Request from the server the public key required for RSA key
pair-based password exchange. This option applies to clients
that authenticate with the
<code class="literal">
caching_sha2_password
</code>
authentication
plugin. For that plugin, the server does not send the public
key unless requested. This option is ignored for accounts
that do not authenticate with that plugin. It is also
ignored if RSA-based password exchange is not used, as is
the case when the client connects to the server using a
secure connection.
</p>
<p>
If
<a class="link" href="mysqldump.html#option_mysqldump_server-public-key-path">
<code class="option">
--server-public-key-path=
<em class="replaceable">
<code>
file_name
</code>
</em>
</code>
</a>
is given and specifies a valid public key file, it takes
precedence over
<a class="link" href="mysqldump.html#option_mysqldump_get-server-public-key">
<code class="option">
--get-server-public-key
</code>
</a>
.
</p>
<p>
For information about the
<code class="literal">
caching_sha2_password
</code>
plugin, see
<a class="xref" href="caching-sha2-pluggable-authentication.html" title="8.4.1.2 Caching SHA-2 Pluggable Authentication">
Section 8.4.1.2, “Caching SHA-2 Pluggable Authentication”
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_host">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_host">
<code class="option">
--host=
<em class="replaceable">
<code>
host_name
</code>
</em>
</code>
</a>
,
<code class="option">
-h
<em class="replaceable">
<code>
host_name
</code>
</em>
</code>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for host">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--host
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045314162000">
</a>
<a class="indexterm" name="idm46045314160512">
</a>
<p>
Dump data from the MySQL server on the given host. The
default host is
<code class="literal">
localhost
</code>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_login-path">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_login-path">
<code class="option">
--login-path=
<em class="replaceable">
<code>
name
</code>
</em>
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for login-path">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--login-path=name
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
String
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045314147760">
</a>
<a class="indexterm" name="idm46045314146272">
</a>
<p>
Read options from the named login path in the
<code class="filename">
.mylogin.cnf
</code>
login path file. A
<span class="quote">
“
<span class="quote">
login path
</span>
”
</span>
is an option group containing
options that specify which MySQL server to connect to and
which account to authenticate as. To create or modify a
login path file, use the
<a class="link" href="mysql-config-editor.html" title="6.6.7 mysql_config_editor — MySQL Configuration Utility">
<span class="command">
<strong>
mysql_config_editor
</strong>
</span>
</a>
utility. See
<a class="xref" href="mysql-config-editor.html" title="6.6.7 mysql_config_editor — MySQL Configuration Utility">
Section 6.6.7, “mysql_config_editor — MySQL Configuration Utility”
</a>
.
</p>
<p>
For additional information about this and other option-file
options, see
<a class="xref" href="option-file-options.html" title="6.2.2.3 Command-Line Options that Affect Option-File Handling">
Section 6.2.2.3, “Command-Line Options that Affect Option-File Handling”
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_no-login-paths">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_no-login-paths">
<code class="option">
--no-login-paths
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for no-login-paths">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--no-login-paths
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045314132128">
</a>
<a class="indexterm" name="idm46045314130640">
</a>
<p>
Skips reading options from the login path file.
</p>
<p>
See
<a class="link" href="mysqldump.html#option_mysqldump_login-path">
<code class="option">
--login-path
</code>
</a>
for
related information.
</p>
<p>
For additional information about this and other option-file
options, see
<a class="xref" href="option-file-options.html" title="6.2.2.3 Command-Line Options that Affect Option-File Handling">
Section 6.2.2.3, “Command-Line Options that Affect Option-File Handling”
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_password">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_password">
<code class="option">
--password[=
<em class="replaceable">
<code>
password
</code>
</em>
]
</code>
</a>
,
<code class="option">
-p[
<em class="replaceable">
<code>
password
</code>
</em>
]
</code>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for password">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--password[=password]
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
String
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045314115040">
</a>
<a class="indexterm" name="idm46045314113552">
</a>
<p>
The password of the MySQL account used for connecting to the
server. The password value is optional. If not given,
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
prompts for one. If given,
there must be
<span class="emphasis">
<em>
no space
</em>
</span>
between
<a class="link" href="mysqldump.html#option_mysqldump_password">
<code class="option">
--password=
</code>
</a>
or
<code class="option">
-p
</code>
and the password following it. If no
password option is specified, the default is to send no
password.
</p>
<p>
Specifying a password on the command line should be
considered insecure. To avoid giving the password on the
command line, use an option file. See
<a class="xref" href="password-security-user.html" title="8.1.2.1 End-User Guidelines for Password Security">
Section 8.1.2.1, “End-User Guidelines for Password Security”
</a>
.
</p>
<p>
To explicitly specify that there is no password and that
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
should not prompt for one, use
the
<a class="link" href="mysqldump.html#option_mysqldump_password">
<code class="option">
--skip-password
</code>
</a>
option.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_password1">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_password1">
<code class="option">
--password1[=
<em class="replaceable">
<code>
pass_val
</code>
</em>
]
</code>
</a>
</p>
<a class="indexterm" name="idm46045314101616">
</a>
<p>
The password for multifactor authentication factor 1 of the
MySQL account used for connecting to the server. The
password value is optional. If not given,
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
prompts for one. If given,
there must be
<span class="emphasis">
<em>
no space
</em>
</span>
between
<a class="link" href="mysqldump.html#option_mysqldump_password1">
<code class="option">
--password1=
</code>
</a>
and the
password following it. If no password option is specified,
the default is to send no password.
</p>
<p>
Specifying a password on the command line should be
considered insecure. To avoid giving the password on the
command line, use an option file. See
<a class="xref" href="password-security-user.html" title="8.1.2.1 End-User Guidelines for Password Security">
Section 8.1.2.1, “End-User Guidelines for Password Security”
</a>
.
</p>
<p>
To explicitly specify that there is no password and that
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
should not prompt for one, use
the
<a class="link" href="mysqldump.html#option_mysqldump_password1">
<code class="option">
--skip-password1
</code>
</a>
option.
</p>
<p>
<a class="link" href="mysqldump.html#option_mysqldump_password1">
<code class="option">
--password1
</code>
</a>
and
<a class="link" href="mysqldump.html#option_mysqldump_password">
<code class="option">
--password
</code>
</a>
are synonymous,
as are
<a class="link" href="mysqldump.html#option_mysqldump_password1">
<code class="option">
--skip-password1
</code>
</a>
and
<a class="link" href="mysqldump.html#option_mysqldump_password">
<code class="option">
--skip-password
</code>
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_password2">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_password2">
<code class="option">
--password2[=
<em class="replaceable">
<code>
pass_val
</code>
</em>
]
</code>
</a>
</p>
<a class="indexterm" name="idm46045314086064">
</a>
<p>
The password for multifactor authentication factor 2 of the
MySQL account used for connecting to the server. The
semantics of this option are similar to the semantics for
<a class="link" href="mysqldump.html#option_mysqldump_password1">
<code class="option">
--password1
</code>
</a>
; see the
description of that option for details.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_password3">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_password3">
<code class="option">
--password3[=
<em class="replaceable">
<code>
pass_val
</code>
</em>
]
</code>
</a>
</p>
<a class="indexterm" name="idm46045314080704">
</a>
<p>
The password for multifactor authentication factor 3 of the
MySQL account used for connecting to the server. The
semantics of this option are similar to the semantics for
<a class="link" href="mysqldump.html#option_mysqldump_password1">
<code class="option">
--password1
</code>
</a>
; see the
description of that option for details.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_pipe">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_pipe">
<code class="option">
--pipe
</code>
</a>
,
<code class="option">
-W
</code>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for pipe">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--pipe
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
String
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045314067904">
</a>
<a class="indexterm" name="idm46045314066416">
</a>
<p>
On Windows, connect to the server using a named pipe. This
option applies only if the server was started with the
<a class="link" href="server-system-variables.html#sysvar_named_pipe">
<code class="literal">
named_pipe
</code>
</a>
system variable
enabled to support named-pipe connections. In addition, the
user making the connection must be a member of the Windows
group specified by the
<a class="link" href="server-system-variables.html#sysvar_named_pipe_full_access_group">
<code class="literal">
named_pipe_full_access_group
</code>
</a>
system variable.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_plugin-authentication-kerberos-client-mode">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_plugin-authentication-kerberos-client-mode">
<code class="option">
--plugin-authentication-kerberos-client-mode=
<em class="replaceable">
<code>
value
</code>
</em>
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for plugin-authentication-kerberos-client-mode">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--plugin-authentication-kerberos-client-mode
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
String
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
SSPI
</code>
</td>
</tr>
<tr>
<th>
Valid Values
</th>
<td>
<code class="literal">
GSSAPI
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045314046480">
</a>
<a class="indexterm" name="idm46045314044960">
</a>
<p>
On Windows, the
<code class="literal">
authentication_kerberos_client
</code>
authentication plugin supports this plugin option. It
provides two possible values that the client user can set at
runtime:
<code class="literal">
SSPI
</code>
and
<code class="literal">
GSSAPI
</code>
.
</p>
<p>
The default value for the client-side plugin option uses
Security Support Provider Interface (SSPI), which is capable
of acquiring credentials from the Windows in-memory cache.
Alternatively, the client user can select a mode that
supports Generic Security Service Application Program
Interface (GSSAPI) through the MIT Kerberos library on
Windows. GSSAPI is capable of acquiring cached credentials
previously generated by using the
<span class="command">
<strong>
kinit
</strong>
</span>
command.
</p>
<p>
For more information, see
<a class="link" href="kerberos-pluggable-authentication.html#kerberos-usage-win-gssapi-client-commands">
Commands
for Windows Clients in GSSAPI Mode
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_plugin-dir">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_plugin-dir">
<code class="option">
--plugin-dir=
<em class="replaceable">
<code>
dir_name
</code>
</em>
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for plugin-dir">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--plugin-dir=dir_name
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
Directory name
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045314027584">
</a>
<a class="indexterm" name="idm46045314026096">
</a>
<p>
The directory in which to look for plugins. Specify this
option if the
<a class="link" href="mysqldump.html#option_mysqldump_default-auth">
<code class="option">
--default-auth
</code>
</a>
option is
used to specify an authentication plugin but
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
does not find it. See
<a class="xref" href="pluggable-authentication.html" title="8.2.17 Pluggable Authentication">
Section 8.2.17, “Pluggable Authentication”
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_port">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_port">
<code class="option">
--port=
<em class="replaceable">
<code>
port_num
</code>
</em>
</code>
</a>
,
<code class="option">
-P
<em class="replaceable">
<code>
port_num
</code>
</em>
</code>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for port">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--port=port_num
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
Numeric
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
3306
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045314007968">
</a>
<a class="indexterm" name="idm46045314006480">
</a>
<p>
For TCP/IP connections, the port number to use.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_protocol">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_protocol">
<code class="option">
--protocol={TCP|SOCKET|PIPE|MEMORY}
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for protocol">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--protocol=type
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
String
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
[see text]
</code>
</td>
</tr>
<tr>
<th>
Valid Values
</th>
<td>
<p class="valid-value">
<code class="literal">
TCP
</code>
</p>
<p class="valid-value">
<code class="literal">
SOCKET
</code>
</p>
<p class="valid-value">
<code class="literal">
PIPE
</code>
</p>
<p class="valid-value">
<code class="literal">
MEMORY
</code>
</p>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045313986624">
</a>
<a class="indexterm" name="idm46045313985136">
</a>
<p>
The transport protocol to use for connecting to the server.
It is useful when the other connection parameters normally
result in use of a protocol other than the one you want. For
details on the permissible values, see
<a class="xref" href="transport-protocols.html" title="6.2.7 Connection Transport Protocols">
Section 6.2.7, “Connection Transport Protocols”
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_server-public-key-path">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_server-public-key-path">
<code class="option">
--server-public-key-path=
<em class="replaceable">
<code>
file_name
</code>
</em>
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for server-public-key-path">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--server-public-key-path=file_name
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
File name
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045313972272">
</a>
<a class="indexterm" name="idm46045313970768">
</a>
<p>
The path name to a file in PEM format containing a
client-side copy of the public key required by the server
for RSA key pair-based password exchange. This option
applies to clients that authenticate with the
<code class="literal">
sha256_password
</code>
(deprecated) or
<code class="literal">
caching_sha2_password
</code>
authentication
plugin. This option is ignored for accounts that do not
authenticate with one of those plugins. It is also ignored
if RSA-based password exchange is not used, as is the case
when the client connects to the server using a secure
connection.
</p>
<p>
If
<a class="link" href="mysqldump.html#option_mysqldump_server-public-key-path">
<code class="option">
--server-public-key-path=
<em class="replaceable">
<code>
file_name
</code>
</em>
</code>
</a>
is given and specifies a valid public key file, it takes
precedence over
<a class="link" href="mysqldump.html#option_mysqldump_get-server-public-key">
<code class="option">
--get-server-public-key
</code>
</a>
.
</p>
<p>
For
<code class="literal">
sha256_password
</code>
(deprecated), this
option applies only if MySQL was built using OpenSSL.
</p>
<p>
For information about the
<code class="literal">
sha256_password
</code>
and
<code class="literal">
caching_sha2_password
</code>
plugins, see
<a class="xref" href="sha256-pluggable-authentication.html" title="8.4.1.3 SHA-256 Pluggable Authentication">
Section 8.4.1.3, “SHA-256 Pluggable Authentication”
</a>
, and
<a class="xref" href="caching-sha2-pluggable-authentication.html" title="8.4.1.2 Caching SHA-2 Pluggable Authentication">
Section 8.4.1.2, “Caching SHA-2 Pluggable Authentication”
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_socket">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_socket">
<code class="option">
--socket=
<em class="replaceable">
<code>
path
</code>
</em>
</code>
</a>
,
<code class="option">
-S
<em class="replaceable">
<code>
path
</code>
</em>
</code>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for socket">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--socket={file_name|pipe_name}
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
String
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045313948816">
</a>
<a class="indexterm" name="idm46045313947328">
</a>
<p>
For connections to
<code class="literal">
localhost
</code>
, the Unix
socket file to use, or, on Windows, the name of the named
pipe to use.
</p>
<p>
On Windows, this option applies only if the server was
started with the
<a class="link" href="server-system-variables.html#sysvar_named_pipe">
<code class="literal">
named_pipe
</code>
</a>
system variable enabled to support named-pipe connections.
In addition, the user making the connection must be a member
of the Windows group specified by the
<a class="link" href="server-system-variables.html#sysvar_named_pipe_full_access_group">
<code class="literal">
named_pipe_full_access_group
</code>
</a>
system variable.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_ssl">
</a>
<code class="option">
--ssl*
</code>
</p>
<a class="indexterm" name="idm46045313939744">
</a>
<a class="indexterm" name="idm46045313938256">
</a>
<p>
Options that begin with
<code class="option">
--ssl
</code>
specify
whether to connect to the server using encryption and
indicate where to find SSL keys and certificates. See
<a class="xref" href="connection-options.html#encrypted-connection-options" title="Command Options for Encrypted Connections">
Command Options for Encrypted Connections
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_ssl-fips-mode">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_ssl-fips-mode">
<code class="option">
--ssl-fips-mode={OFF|ON|STRICT}
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for ssl-fips-mode">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--ssl-fips-mode={OFF|ON|STRICT}
</code>
</td>
</tr>
<tr>
<th>
Deprecated
</th>
<td>
Yes
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
Enumeration
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
OFF
</code>
</td>
</tr>
<tr>
<th>
Valid Values
</th>
<td>
<p class="valid-value">
<code class="literal">
OFF
</code>
</p>
<p class="valid-value">
<code class="literal">
ON
</code>
</p>
<p class="valid-value">
<code class="literal">
STRICT
</code>
</p>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045313916112">
</a>
<a class="indexterm" name="idm46045313914624">
</a>
<p>
Controls whether to enable FIPS mode on the client side. The
<a class="link" href="mysqldump.html#option_mysqldump_ssl-fips-mode">
<code class="option">
--ssl-fips-mode
</code>
</a>
option
differs from other
<code class="option">
--ssl-
<em class="replaceable">
<code>
xxx
</code>
</em>
</code>
options in that it is not used to establish encrypted
connections, but rather to affect which cryptographic
operations to permit. See
<a class="xref" href="fips-mode.html" title="8.8 FIPS Support">
Section 8.8, “FIPS Support”
</a>
.
</p>
<p>
These
<a class="link" href="mysqldump.html#option_mysqldump_ssl-fips-mode">
<code class="option">
--ssl-fips-mode
</code>
</a>
values are permitted:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
<code class="literal">
OFF
</code>
: Disable FIPS mode.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ON
</code>
: Enable FIPS mode.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
STRICT
</code>
: Enable
<span class="quote">
“
<span class="quote">
strict
</span>
”
</span>
FIPS mode.
</p>
</li>
</ul>
</div>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
If the OpenSSL FIPS Object Module is not available, the
only permitted value for
<a class="link" href="mysqldump.html#option_mysqldump_ssl-fips-mode">
<code class="option">
--ssl-fips-mode
</code>
</a>
is
<code class="literal">
OFF
</code>
. In this case, setting
<a class="link" href="mysqldump.html#option_mysqldump_ssl-fips-mode">
<code class="option">
--ssl-fips-mode
</code>
</a>
to
<code class="literal">
ON
</code>
or
<code class="literal">
STRICT
</code>
causes
the client to produce a warning at startup and to operate
in non-FIPS mode.
</p>
</div>
<p>
This option is deprecated. Expect it to be removed in a
future version of MySQL.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_tls-ciphersuites">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_tls-ciphersuites">
<code class="option">
--tls-ciphersuites=
<em class="replaceable">
<code>
ciphersuite_list
</code>
</em>
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for tls-ciphersuites">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--tls-ciphersuites=ciphersuite_list
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
String
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045313887664">
</a>
<a class="indexterm" name="idm46045313886176">
</a>
<p>
The permissible ciphersuites for encrypted connections that
use TLSv1.3. The value is a list of one or more
colon-separated ciphersuite names. The ciphersuites that can
be named for this option depend on the SSL library used to
compile MySQL. For details, see
<a class="xref" href="encrypted-connection-protocols-ciphers.html" title="8.3.2 Encrypted Connection TLS Protocols and Ciphers">
Section 8.3.2, “Encrypted Connection TLS Protocols and Ciphers”
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_tls-sni-servername">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_tls-sni-servername">
<code class="option">
--tls-sni-servername=
<em class="replaceable">
<code>
server_name
</code>
</em>
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for tls-sni-servername">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--tls-sni-servername=server_name
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
String
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045313873184">
</a>
<a class="indexterm" name="idm46045313871680">
</a>
<p>
When specified, the name is passed to the
<code class="literal">
libmysqlclient
</code>
C API library using the
<code class="literal">
MYSQL_OPT_TLS_SNI_SERVERNAME
</code>
option of
<a class="ulink" href="/doc/c-api/8.4/en/mysql-options.html" target="_top">
<code class="literal">
mysql_options()
</code>
</a>
. The server
name is not case-sensitive. To show which server name the
client specified for the current session, if any, check the
<a class="link" href="server-status-variables.html#statvar_Tls_sni_server_name">
<code class="literal">
Tls_sni_server_name
</code>
</a>
status
variable.
</p>
<p>
Server Name Indication (SNI) is an extension to the TLS
protocol (OpenSSL must be compiled using TLS extensions for
this option to function). The MySQL implementation of SNI
represents the client-side only.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_tls-version">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_tls-version">
<code class="option">
--tls-version=
<em class="replaceable">
<code>
protocol_list
</code>
</em>
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for tls-version">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--tls-version=protocol_list
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
String
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<p class="valid-value">
<code class="literal">
TLSv1,TLSv1.1,TLSv1.2,TLSv1.3
</code>
(OpenSSL 1.1.1 or higher)
</p>
<p class="valid-value">
<code class="literal">
TLSv1,TLSv1.1,TLSv1.2
</code>
(otherwise)
</p>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045313850736">
</a>
<a class="indexterm" name="idm46045313849248">
</a>
<p>
The permissible TLS protocols for encrypted connections. The
value is a list of one or more comma-separated protocol
names. The protocols that can be named for this option
depend on the SSL library used to compile MySQL. For
details, see
<a class="xref" href="encrypted-connection-protocols-ciphers.html" title="8.3.2 Encrypted Connection TLS Protocols and Ciphers">
Section 8.3.2, “Encrypted Connection TLS Protocols and Ciphers”
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_user">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_user">
<code class="option">
--user=
<em class="replaceable">
<code>
user_name
</code>
</em>
</code>
</a>
,
<code class="option">
-u
<em class="replaceable">
<code>
user_name
</code>
</em>
</code>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for user">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--user=user_name
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
String
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045313835680">
</a>
<a class="indexterm" name="idm46045313834192">
</a>
<p>
The user name of the MySQL account to use for connecting to
the server.
</p>
<p>
If you are using the
<code class="literal">
Rewriter
</code>
plugin, you
should grant this user the
<a class="link" href="privileges-provided.html#priv_skip-query-rewrite">
<code class="literal">
SKIP_QUERY_REWRITE
</code>
</a>
privilege.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_zstd-compression-level">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_zstd-compression-level">
<code class="option">
--zstd-compression-level=
<em class="replaceable">
<code>
level
</code>
</em>
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for zstd-compression-level">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--zstd-compression-level=#
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
Integer
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045313819680">
</a>
<a class="indexterm" name="idm46045313818176">
</a>
<p>
The compression level to use for connections to the server
that use the
<code class="literal">
zstd
</code>
compression algorithm.
The permitted levels are from 1 to 22, with larger values
indicating increasing levels of compression. The default
<code class="literal">
zstd
</code>
compression level is 3. The
compression level setting has no effect on connections that
do not use
<code class="literal">
zstd
</code>
compression.
</p>
<p>
For more information, see
<a class="xref" href="connection-compression-control.html" title="6.2.8 Connection Compression Control">
Section 6.2.8, “Connection Compression Control”
</a>
.
</p>
</li>
</ul>
</div>
<h4>
<a name="mysqldump-option-file-options">
</a>
Option-File Options
</h4>
<p>
These options are used to control which option files to read.
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a name="option_mysqldump_defaults-extra-file">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_defaults-extra-file">
<code class="option">
--defaults-extra-file=
<em class="replaceable">
<code>
file_name
</code>
</em>
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for defaults-extra-file">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--defaults-extra-file=file_name
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
File name
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045313800496">
</a>
<a class="indexterm" name="idm46045313798992">
</a>
<p>
Read this option file after the global option file but (on
Unix) before the user option file. If the file does not
exist or is otherwise inaccessible, an error occurs. If
<em class="replaceable">
<code>
file_name
</code>
</em>
is not an absolute path
name, it is interpreted relative to the current directory.
</p>
<p>
For additional information about this and other option-file
options, see
<a class="xref" href="option-file-options.html" title="6.2.2.3 Command-Line Options that Affect Option-File Handling">
Section 6.2.2.3, “Command-Line Options that Affect Option-File Handling”
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_defaults-file">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_defaults-file">
<code class="option">
--defaults-file=
<em class="replaceable">
<code>
file_name
</code>
</em>
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for defaults-file">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--defaults-file=file_name
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
File name
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045313785088">
</a>
<a class="indexterm" name="idm46045313783600">
</a>
<p>
Use only the given option file. If the file does not exist
or is otherwise inaccessible, an error occurs. If
<em class="replaceable">
<code>
file_name
</code>
</em>
is not an absolute path
name, it is interpreted relative to the current directory.
</p>
<p>
Exception: Even with
<a class="link" href="option-file-options.html#option_general_defaults-file">
<code class="option">
--defaults-file
</code>
</a>
, client
programs read
<code class="filename">
.mylogin.cnf
</code>
.
</p>
<p>
For additional information about this and other option-file
options, see
<a class="xref" href="option-file-options.html" title="6.2.2.3 Command-Line Options that Affect Option-File Handling">
Section 6.2.2.3, “Command-Line Options that Affect Option-File Handling”
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_defaults-group-suffix">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_defaults-group-suffix">
<code class="option">
--defaults-group-suffix=
<em class="replaceable">
<code>
str
</code>
</em>
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for defaults-group-suffix">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--defaults-group-suffix=str
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
String
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045313767632">
</a>
<a class="indexterm" name="idm46045313766128">
</a>
<p>
Read not only the usual option groups, but also groups with
the usual names and a suffix of
<em class="replaceable">
<code>
str
</code>
</em>
. For example,
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
normally reads the
<code class="literal">
[client]
</code>
and
<code class="literal">
[mysqldump]
</code>
groups. If this option is
given as
<a class="link" href="mysqldump.html#option_mysqldump_defaults-group-suffix">
<code class="option">
--defaults-group-suffix=_other
</code>
</a>
,
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
also reads the
<code class="literal">
[client_other]
</code>
and
<code class="literal">
[mysqldump_other]
</code>
groups.
</p>
<p>
For additional information about this and other option-file
options, see
<a class="xref" href="option-file-options.html" title="6.2.2.3 Command-Line Options that Affect Option-File Handling">
Section 6.2.2.3, “Command-Line Options that Affect Option-File Handling”
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_no-defaults">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_no-defaults">
<code class="option">
--no-defaults
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for no-defaults">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--no-defaults
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045313748352">
</a>
<a class="indexterm" name="idm46045313746864">
</a>
<p>
Do not read any option files. If program startup fails due
to reading unknown options from an option file,
<a class="link" href="mysqldump.html#option_mysqldump_no-defaults">
<code class="option">
--no-defaults
</code>
</a>
can be used
to prevent them from being read.
</p>
<p>
The exception is that the
<code class="filename">
.mylogin.cnf
</code>
file is read in all cases, if it exists. This permits
passwords to be specified in a safer way than on the command
line even when
<a class="link" href="mysqldump.html#option_mysqldump_no-defaults">
<code class="option">
--no-defaults
</code>
</a>
is used. To
create
<code class="filename">
.mylogin.cnf
</code>
, use the
<a class="link" href="mysql-config-editor.html" title="6.6.7 mysql_config_editor — MySQL Configuration Utility">
<span class="command">
<strong>
mysql_config_editor
</strong>
</span>
</a>
utility. See
<a class="xref" href="mysql-config-editor.html" title="6.6.7 mysql_config_editor — MySQL Configuration Utility">
Section 6.6.7, “mysql_config_editor — MySQL Configuration Utility”
</a>
.
</p>
<p>
For additional information about this and other option-file
options, see
<a class="xref" href="option-file-options.html" title="6.2.2.3 Command-Line Options that Affect Option-File Handling">
Section 6.2.2.3, “Command-Line Options that Affect Option-File Handling”
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_print-defaults">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_print-defaults">
<code class="option">
--print-defaults
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for print-defaults">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--print-defaults
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045313729952">
</a>
<a class="indexterm" name="idm46045313728464">
</a>
<p>
Print the program name and all options that it gets from
option files.
</p>
<p>
For additional information about this and other option-file
options, see
<a class="xref" href="option-file-options.html" title="6.2.2.3 Command-Line Options that Affect Option-File Handling">
Section 6.2.2.3, “Command-Line Options that Affect Option-File Handling”
</a>
.
</p>
</li>
</ul>
</div>
<h4>
<a name="mysqldump-ddl-options">
</a>
DDL Options
</h4>
<p>
Usage scenarios for
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
include setting
up an entire new MySQL instance (including database tables), and
replacing data inside an existing instance with existing
databases and tables. The following options let you specify
which things to tear down and set up when restoring a dump, by
encoding various DDL statements within the dump file.
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a name="option_mysqldump_add-drop-database">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_add-drop-database">
<code class="option">
--add-drop-database
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for add-drop-database">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--add-drop-database
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045313714064">
</a>
<a class="indexterm" name="idm46045313712560">
</a>
<p>
Write a
<a class="link" href="drop-database.html" title="15.1.24 DROP DATABASE Statement">
<code class="literal">
DROP DATABASE
</code>
</a>
statement before each
<a class="link" href="create-database.html" title="15.1.12 CREATE DATABASE Statement">
<code class="literal">
CREATE
DATABASE
</code>
</a>
statement. This option is typically used
in conjunction with the
<a class="link" href="mysqldump.html#option_mysqldump_all-databases">
<code class="option">
--all-databases
</code>
</a>
or
<a class="link" href="mysqldump.html#option_mysqldump_databases">
<code class="option">
--databases
</code>
</a>
option because
no
<a class="link" href="create-database.html" title="15.1.12 CREATE DATABASE Statement">
<code class="literal">
CREATE DATABASE
</code>
</a>
statements
are written unless one of those options is specified.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
In MySQL 8.4, the
<code class="literal">
mysql
</code>
schema is considered a system schema that cannot be
dropped by end users. If
<a class="link" href="mysqldump.html#option_mysqldump_add-drop-database">
<code class="option">
--add-drop-database
</code>
</a>
is
used with
<a class="link" href="mysqldump.html#option_mysqldump_all-databases">
<code class="option">
--all-databases
</code>
</a>
or with
<a class="link" href="mysqldump.html#option_mysqldump_databases">
<code class="option">
--databases
</code>
</a>
where the
list of schemas to be dumped includes
<code class="literal">
mysql
</code>
, the dump file contains a
<code class="literal">
DROP DATABASE `mysql`
</code>
statement that
causes an error when the dump file is reloaded.
</p>
<p>
Instead, to use
<a class="link" href="mysqldump.html#option_mysqldump_add-drop-database">
<code class="option">
--add-drop-database
</code>
</a>
, use
<a class="link" href="mysqldump.html#option_mysqldump_databases">
<code class="option">
--databases
</code>
</a>
with a list
of schemas to be dumped, where the list does not include
<code class="literal">
mysql
</code>
.
</p>
</div>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_add-drop-table">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_add-drop-table">
<code class="option">
--add-drop-table
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for add-drop-table">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--add-drop-table
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045313687536">
</a>
<a class="indexterm" name="idm46045313686048">
</a>
<p>
Write a
<a class="link" href="drop-table.html" title="15.1.32 DROP TABLE Statement">
<code class="literal">
DROP TABLE
</code>
</a>
statement
before each
<a class="link" href="create-table.html" title="15.1.20 CREATE TABLE Statement">
<code class="literal">
CREATE TABLE
</code>
</a>
statement.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_add-drop-trigger">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_add-drop-trigger">
<code class="option">
--add-drop-trigger
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for add-drop-trigger">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--add-drop-trigger
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045313673936">
</a>
<a class="indexterm" name="idm46045313672448">
</a>
<p>
Write a
<a class="link" href="drop-trigger.html" title="15.1.34 DROP TRIGGER Statement">
<code class="literal">
DROP TRIGGER
</code>
</a>
statement before each
<a class="link" href="create-trigger.html" title="15.1.22 CREATE TRIGGER Statement">
<code class="literal">
CREATE
TRIGGER
</code>
</a>
statement.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_all-tablespaces">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_all-tablespaces">
<code class="option">
--all-tablespaces
</code>
</a>
,
<code class="option">
-Y
</code>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for all-tablespaces">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--all-tablespaces
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045313659920">
</a>
<a class="indexterm" name="idm46045313658432">
</a>
<p>
Adds to a table dump all SQL statements needed to create any
tablespaces used by an
<a class="link" href="mysql-cluster.html" title="Chapter 25 MySQL NDB Cluster 8.4">
<code class="literal">
NDB
</code>
</a>
table. This information is not otherwise included in the
output from
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
. This option is
currently relevant only to NDB Cluster tables.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_no-create-db">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_no-create-db">
<code class="option">
--no-create-db
</code>
</a>
,
<code class="option">
-n
</code>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for no-create-db">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--no-create-db
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045313645728">
</a>
<a class="indexterm" name="idm46045313644240">
</a>
<p>
Suppress the
<a class="link" href="create-database.html" title="15.1.12 CREATE DATABASE Statement">
<code class="literal">
CREATE DATABASE
</code>
</a>
statements that are otherwise included in the output if the
<a class="link" href="mysqldump.html#option_mysqldump_databases">
<code class="option">
--databases
</code>
</a>
or
<a class="link" href="mysqldump.html#option_mysqldump_all-databases">
<code class="option">
--all-databases
</code>
</a>
option is
given.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_no-create-info">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_no-create-info">
<code class="option">
--no-create-info
</code>
</a>
,
<code class="option">
-t
</code>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for no-create-info">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--no-create-info
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045313630880">
</a>
<a class="indexterm" name="idm46045313629392">
</a>
<p>
Do not write
<a class="link" href="create-table.html" title="15.1.20 CREATE TABLE Statement">
<code class="literal">
CREATE TABLE
</code>
</a>
statements that create each dumped table.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
This option does
<span class="emphasis">
<em>
not
</em>
</span>
exclude
statements creating log file groups or tablespaces from
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
output; however, you can use
the
<a class="link" href="mysqldump.html#option_mysqldump_no-tablespaces">
<code class="option">
--no-tablespaces
</code>
</a>
option for this purpose.
</p>
</div>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_no-tablespaces">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_no-tablespaces">
<code class="option">
--no-tablespaces
</code>
</a>
,
<code class="option">
-y
</code>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for no-tablespaces">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--no-tablespaces
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045313614464">
</a>
<a class="indexterm" name="idm46045313612976">
</a>
<p>
This option suppresses all
<a class="link" href="create-logfile-group.html" title="15.1.16 CREATE LOGFILE GROUP Statement">
<code class="literal">
CREATE
LOGFILE GROUP
</code>
</a>
and
<a class="link" href="create-tablespace.html" title="15.1.21 CREATE TABLESPACE Statement">
<code class="literal">
CREATE
TABLESPACE
</code>
</a>
statements in the output of
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_replace">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_replace">
<code class="option">
--replace
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for replace">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--replace
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045313599472">
</a>
<a class="indexterm" name="idm46045313597984">
</a>
<p>
Write
<a class="link" href="replace.html" title="15.2.12 REPLACE Statement">
<code class="literal">
REPLACE
</code>
</a>
statements
rather than
<a class="link" href="insert.html" title="15.2.7 INSERT Statement">
<code class="literal">
INSERT
</code>
</a>
statements.
</p>
</li>
</ul>
</div>
<h4>
<a name="mysqldump-debug-options">
</a>
Debug Options
</h4>
<p>
The following options print debugging information, encode
debugging information in the dump file, or let the dump
operation proceed regardless of potential problems.
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a name="option_mysqldump_allow-keywords">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_allow-keywords">
<code class="option">
--allow-keywords
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for allow-keywords">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--allow-keywords
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045313583824">
</a>
<a class="indexterm" name="idm46045313582336">
</a>
<p>
Permit creation of column names that are keywords. This
works by prefixing each column name with the table name.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_comments">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_comments">
<code class="option">
--comments
</code>
</a>
,
<code class="option">
-i
</code>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for comments">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--comments
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045313572144">
</a>
<a class="indexterm" name="idm46045313570656">
</a>
<p>
Write additional information in the dump file such as
program version, server version, and host. This option is
enabled by default. To suppress this additional information,
use
<a class="link" href="mysqldump.html#option_mysqldump_skip-comments">
<code class="option">
--skip-comments
</code>
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_debug">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_debug">
<code class="option">
--debug[=
<em class="replaceable">
<code>
debug_options
</code>
</em>
]
</code>
</a>
,
<code class="option">
-#
[
<em class="replaceable">
<code>
debug_options
</code>
</em>
]
</code>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for debug">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--debug[=debug_options]
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
String
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
d:t:o,/tmp/mysqldump.trace
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045313554176">
</a>
<a class="indexterm" name="idm46045313552688">
</a>
<p>
Write a debugging log. A typical
<em class="replaceable">
<code>
debug_options
</code>
</em>
string is
<code class="literal">
d:t:o,
<em class="replaceable">
<code>
file_name
</code>
</em>
</code>
.
The default value is
<code class="literal">
d:t:o,/tmp/mysqldump.trace
</code>
.
</p>
<p>
This option is available only if MySQL was built using
<a class="link" href="source-configuration-options.html#option_cmake_with_debug">
<code class="option">
WITH_DEBUG
</code>
</a>
. MySQL release
binaries provided by Oracle are
<span class="emphasis">
<em>
not
</em>
</span>
built using this option.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_debug-check">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_debug-check">
<code class="option">
--debug-check
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for debug-check">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--debug-check
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
Boolean
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
FALSE
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045313534368">
</a>
<a class="indexterm" name="idm46045313532880">
</a>
<p>
Print some debugging information when the program exits.
</p>
<p>
This option is available only if MySQL was built using
<a class="link" href="source-configuration-options.html#option_cmake_with_debug">
<code class="option">
WITH_DEBUG
</code>
</a>
. MySQL release
binaries provided by Oracle are
<span class="emphasis">
<em>
not
</em>
</span>
built using this option.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_debug-info">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_debug-info">
<code class="option">
--debug-info
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for debug-info">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--debug-info
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
Boolean
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
FALSE
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045313516768">
</a>
<a class="indexterm" name="idm46045313515280">
</a>
<p>
Print debugging information and memory and CPU usage
statistics when the program exits.
</p>
<p>
This option is available only if MySQL was built using
<a class="link" href="source-configuration-options.html#option_cmake_with_debug">
<code class="option">
WITH_DEBUG
</code>
</a>
. MySQL release
binaries provided by Oracle are
<span class="emphasis">
<em>
not
</em>
</span>
built using this option.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_dump-date">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_dump-date">
<code class="option">
--dump-date
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for dump-date">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--dump-date
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
Boolean
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
TRUE
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045313499120">
</a>
<a class="indexterm" name="idm46045313497632">
</a>
<p>
If the
<a class="link" href="mysqldump.html#option_mysqldump_comments">
<code class="option">
--comments
</code>
</a>
option
is given,
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
produces a comment at
the end of the dump of the following form:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-none"><div class="docs-select-all right" id="sa36816070"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-none">-- Dump completed on <em class="replaceable">DATE</em></code></pre>
</div>
<p>
However, the date causes dump files taken at different times
to appear to be different, even if the data are otherwise
identical.
<a class="link" href="mysqldump.html#option_mysqldump_dump-date">
<code class="option">
--dump-date
</code>
</a>
and
<a class="link" href="mysqldump.html#option_mysqldump_dump-date">
<code class="option">
--skip-dump-date
</code>
</a>
control whether the date is added to the comment. The
default is
<a class="link" href="mysqldump.html#option_mysqldump_dump-date">
<code class="option">
--dump-date
</code>
</a>
(include the date in the comment).
<a class="link" href="mysqldump.html#option_mysqldump_dump-date">
<code class="option">
--skip-dump-date
</code>
</a>
suppresses date printing.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_force">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_force">
<code class="option">
--force
</code>
</a>
,
<code class="option">
-f
</code>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for force">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--force
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045313479296">
</a>
<a class="indexterm" name="idm46045313477808">
</a>
<p>
Ignore all errors; continue even if an SQL error occurs
during a table dump.
</p>
<p>
One use for this option is to cause
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
to continue executing even when
it encounters a view that has become invalid because the
definition refers to a table that has been dropped. Without
<code class="option">
--force
</code>
,
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
exits
with an error message. With
<code class="option">
--force
</code>
,
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
prints the error message, but
it also writes an SQL comment containing the view definition
to the dump output and continues executing.
</p>
<p>
If the
<a class="link" href="mysqldump.html#option_mysqldump_ignore-error">
<code class="option">
--ignore-error
</code>
</a>
option is also given to ignore specific errors,
<a class="link" href="mysqldump.html#option_mysqldump_force">
<code class="option">
--force
</code>
</a>
takes precedence.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_log-error">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_log-error">
<code class="option">
--log-error=
<em class="replaceable">
<code>
file_name
</code>
</em>
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for log-error">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--log-error=file_name
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
File name
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045313457920">
</a>
<a class="indexterm" name="idm46045313456432">
</a>
<p>
Log warnings and errors by appending them to the named file.
The default is to do no logging.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_skip-comments">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_skip-comments">
<code class="option">
--skip-comments
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for skip-comments">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--skip-comments
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045313446704">
</a>
<a class="indexterm" name="idm46045313445216">
</a>
<p>
See the description for the
<a class="link" href="mysqldump.html#option_mysqldump_comments">
<code class="option">
--comments
</code>
</a>
option.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_verbose">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_verbose">
<code class="option">
--verbose
</code>
</a>
,
<code class="option">
-v
</code>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for verbose">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--verbose
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045313434128">
</a>
<a class="indexterm" name="idm46045313432640">
</a>
<p>
Verbose mode. Print more information about what the program
does.
</p>
</li>
</ul>
</div>
<h4>
<a name="mysqldump-help-options">
</a>
Help Options
</h4>
<p>
The following options display information about the
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
command itself.
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a name="option_mysqldump_help">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_help">
<code class="option">
--help
</code>
</a>
,
<code class="option">
-?
</code>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for help">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--help
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045313419456">
</a>
<a class="indexterm" name="idm46045313417968">
</a>
<p>
Display a help message and exit.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_version">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_version">
<code class="option">
--version
</code>
</a>
,
<code class="option">
-V
</code>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for version">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--version
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045313407856">
</a>
<a class="indexterm" name="idm46045313406368">
</a>
<p>
Display version information and exit.
</p>
</li>
</ul>
</div>
<h4>
<a name="mysqldump-i18n-options">
</a>
Internationalization Options
</h4>
<p>
The following options change how the
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
command represents character data
with national language settings.
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a name="option_mysqldump_character-sets-dir">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_character-sets-dir">
<code class="option">
--character-sets-dir=
<em class="replaceable">
<code>
dir_name
</code>
</em>
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for character-sets-dir">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--character-sets-dir=dir_name
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
Directory name
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045313390272">
</a>
<a class="indexterm" name="idm46045313388768">
</a>
<p>
The directory where character sets are installed. See
<a class="xref" href="charset-configuration.html" title="12.15 Character Set Configuration">
Section 12.15, “Character Set Configuration”
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_default-character-set">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_default-character-set">
<code class="option">
--default-character-set=
<em class="replaceable">
<code>
charset_name
</code>
</em>
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for default-character-set">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--default-character-set=charset_name
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
String
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
utf8
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045313373584">
</a>
<a class="indexterm" name="idm46045313372080">
</a>
<p>
Use
<em class="replaceable">
<code>
charset_name
</code>
</em>
as the default
character set. See
<a class="xref" href="charset-configuration.html" title="12.15 Character Set Configuration">
Section 12.15, “Character Set Configuration”
</a>
.
If no character set is specified,
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
uses
<code class="literal">
utf8mb4
</code>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_no-set-names">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_no-set-names">
<code class="option">
--no-set-names
</code>
</a>
,
<code class="option">
-N
</code>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for no-set-names">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--no-set-names
</code>
</td>
</tr>
<tr>
<th>
Deprecated
</th>
<td>
Yes
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045313356864">
</a>
<a class="indexterm" name="idm46045313355376">
</a>
<p>
Turns off the
<a class="link" href="mysqldump.html#option_mysqldump_set-charset">
<code class="option">
--set-charset
</code>
</a>
setting, the
same as specifying
<code class="option">
--skip-set-charset
</code>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_set-charset">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_set-charset">
<code class="option">
--set-charset
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for set-charset">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--set-charset
</code>
</td>
</tr>
<tr>
<th>
Disabled by
</th>
<td>
<code class="literal">
skip-set-charset
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045313341824">
</a>
<a class="indexterm" name="idm46045313340336">
</a>
<p>
Write
<a class="link" href="set-names.html" title="15.7.6.3 SET NAMES Statement">
<code class="literal">
SET NAMES
<em class="replaceable">
<code>
default_character_set
</code>
</em>
</code>
</a>
to the output. This option is enabled by default. To
suppress the
<a class="link" href="set-names.html" title="15.7.6.3 SET NAMES Statement">
<code class="literal">
SET NAMES
</code>
</a>
statement, use
<a class="link" href="mysqldump.html#option_mysqldump_set-charset">
<code class="option">
--skip-set-charset
</code>
</a>
.
</p>
</li>
</ul>
</div>
<h4>
<a name="mysqldump-replication-options">
</a>
Replication Options
</h4>
<p>
The
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
command is frequently used to
create an empty instance, or an instance including data, on a
replica server in a replication configuration. The following
options apply to dumping and restoring data on replication
source servers and replicas.
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a name="option_mysqldump_apply-replica-statements">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_apply-replica-statements">
<code class="option">
--apply-replica-statements
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for apply-replica-statements">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--apply-replica-statements
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
Boolean
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
FALSE
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045313318064">
</a>
<a class="indexterm" name="idm46045313316560">
</a>
<p>
For a replica dump produced with the
<a class="link" href="mysqldump.html#option_mysqldump_dump-replica">
<code class="option">
--dump-replica
</code>
</a>
option,
this option adds a
<a class="link" href="stop-replica.html" title="15.4.2.5 STOP REPLICA Statement">
<code class="literal">
STOP
REPLICA
</code>
</a>
statement before the statement with the
binary log coordinates, and a
<a class="link" href="start-replica.html" title="15.4.2.4 START REPLICA Statement">
<code class="literal">
START
REPLICA
</code>
</a>
statement at the end of the output.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_apply-slave-statements">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_apply-slave-statements">
<code class="option">
--apply-slave-statements
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for apply-slave-statements">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--apply-slave-statements
</code>
</td>
</tr>
<tr>
<th>
Deprecated
</th>
<td>
Yes
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
Boolean
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
FALSE
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045313296768">
</a>
<a class="indexterm" name="idm46045313295264">
</a>
<p>
This is a deprecated alias for
<a class="link" href="mysqldump.html#option_mysqldump_apply-replica-statements">
<code class="option">
--apply-replica-statements
</code>
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_delete-source-logs">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_delete-source-logs">
<code class="option">
--delete-source-logs
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for delete-source-logs">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--delete-source-logs
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045313284544">
</a>
<a class="indexterm" name="idm46045313283040">
</a>
<p>
On a replication source server, delete the binary logs by
sending a
<a class="link" href="purge-binary-logs.html" title="15.4.1.1 PURGE BINARY LOGS Statement">
<code class="literal">
PURGE BINARY LOGS
</code>
</a>
statement to the server after performing the dump operation.
The options require the
<a class="link" href="privileges-provided.html#priv_reload">
<code class="literal">
RELOAD
</code>
</a>
privilege as well as
privileges sufficient to execute that statement. This option
automatically enables
<a class="link" href="mysqldump.html#option_mysqldump_source-data">
<code class="option">
--source-data
</code>
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_delete-master-logs">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_delete-master-logs">
<code class="option">
--delete-master-logs
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for delete-master-logs">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--delete-master-logs
</code>
</td>
</tr>
<tr>
<th>
Deprecated
</th>
<td>
Yes
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045313267616">
</a>
<a class="indexterm" name="idm46045313266112">
</a>
<p>
This is a deprecated alias for
<a class="link" href="mysqldump.html#option_mysqldump_delete-source-logs">
<code class="option">
--delete-source-logs
</code>
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_dump-replica">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_dump-replica">
<code class="option">
--dump-replica[=
<em class="replaceable">
<code>
value
</code>
</em>
]
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for dump-replica">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--dump-replica[=value]
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
Numeric
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
1
</code>
</td>
</tr>
<tr>
<th>
Valid Values
</th>
<td>
<p class="valid-value">
<code class="literal">
1
</code>
</p>
<p class="valid-value">
<code class="literal">
2
</code>
</p>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045313246816">
</a>
<a class="indexterm" name="idm46045313245328">
</a>
<p>
This option is similar to
<a class="link" href="mysqldump.html#option_mysqldump_source-data">
<code class="option">
--source-data
</code>
</a>
, except that
it is used to dump a replica server to produce a dump file
that can be used to set up another server as a replica that
has the same source as the dumped server. The option causes
the dump output to include a
<a class="link" href="change-replication-source-to.html" title="15.4.2.2 CHANGE REPLICATION SOURCE TO Statement">
<code class="literal">
CHANGE
REPLICATION SOURCE TO
</code>
</a>
statement that indicates the
binary log coordinates (file name and position) of the
dumped replica's source. The
<a class="link" href="change-replication-source-to.html" title="15.4.2.2 CHANGE REPLICATION SOURCE TO Statement">
<code class="literal">
CHANGE REPLICATION SOURCE TO
</code>
</a>
statement reads the values of
<code class="literal">
Relay_Master_Log_File
</code>
and
<code class="literal">
Exec_Master_Log_Pos
</code>
from the
<a class="link" href="show-replica-status.html" title="15.7.7.35 SHOW REPLICA STATUS Statement">
<code class="literal">
SHOW
REPLICA STATUS
</code>
</a>
output and uses them for
<code class="literal">
SOURCE_LOG_FILE
</code>
and
<code class="literal">
SOURCE_LOG_POS
</code>
respectively. These are
the replication source server coordinates from which the
replica starts replicating.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
Inconsistencies in the sequence of transactions from the
relay log which have been executed can cause the wrong
position to be used. See
<a class="xref" href="replication-features-transaction-inconsistencies.html" title="19.5.1.34 Replication and Transaction Inconsistencies">
Section 19.5.1.34, “Replication and Transaction Inconsistencies”
</a>
for more information.
</p>
</div>
<p>
<code class="option">
--dump-replica
</code>
causes the coordinates from
the source to be used rather than those of the dumped
server, as is done by the
<a class="link" href="mysqldump.html#option_mysqldump_source-data">
<code class="option">
--source-data
</code>
</a>
option. In
addition, specifying this option overrides the
<a class="link" href="mysqldump.html#option_mysqldump_source-data">
<code class="option">
--source-data
</code>
</a>
option.
</p>
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Warning
</div>
<p>
<code class="option">
--dump-replica
</code>
should not be used if the
server where the dump is going to be applied uses
<a class="link" href="replication-options-gtids.html#sysvar_gtid_mode">
<code class="literal">
gtid_mode=ON
</code>
</a>
and
<code class="literal">
SOURCE_AUTO_POSITION=1
</code>
.
</p>
</div>
<p>
The option value is handled the same way as for
<a class="link" href="mysqldump.html#option_mysqldump_source-data">
<code class="option">
--source-data
</code>
</a>
. Setting no
value or 1 causes a
<a class="link" href="change-replication-source-to.html" title="15.4.2.2 CHANGE REPLICATION SOURCE TO Statement">
<code class="literal">
CHANGE REPLICATION
SOURCE TO
</code>
</a>
statement to be written to the dump.
Setting 2 causes the statement to be written but encased in
SQL comments. It has the same effect as
<code class="option">
--source-data
</code>
in terms of enabling or
disabling other options and in how locking is handled.
</p>
<p>
<code class="option">
--dump-replica
</code>
causes
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
to stop the replication SQL
thread before the dump and restart it again after.
</p>
<p>
<code class="option">
--dump-replica
</code>
sends a
<a class="link" href="show-replica-status.html" title="15.7.7.35 SHOW REPLICA STATUS Statement">
<code class="literal">
SHOW
REPLICA STATUS
</code>
</a>
statement to the server to obtain
information, so they require privileges sufficient to
execute that statement.
</p>
<p>
<a class="link" href="mysqldump.html#option_mysqldump_apply-replica-statements">
<code class="option">
--apply-replica-statements
</code>
</a>
and
<a class="link" href="mysqldump.html#option_mysqldump_include-source-host-port">
<code class="option">
--include-source-host-port
</code>
</a>
options can be used in conjunction with
<code class="option">
--dump-replica
</code>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_dump-slave">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_dump-slave">
<code class="option">
--dump-slave[=
<em class="replaceable">
<code>
value
</code>
</em>
]
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for dump-slave">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--dump-slave[=value]
</code>
</td>
</tr>
<tr>
<th>
Deprecated
</th>
<td>
Yes
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
Numeric
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
1
</code>
</td>
</tr>
<tr>
<th>
Valid Values
</th>
<td>
<p class="valid-value">
<code class="literal">
1
</code>
</p>
<p class="valid-value">
<code class="literal">
2
</code>
</p>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045313197840">
</a>
<a class="indexterm" name="idm46045313196352">
</a>
<p>
This is a deprecated alias for
<a class="link" href="mysqldump.html#option_mysqldump_dump-replica">
<code class="option">
--dump-replica
</code>
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_include-source-host-port">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_include-source-host-port">
<code class="option">
--include-source-host-port
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for include-source-host-port">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--include-source-host-port
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
Boolean
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
FALSE
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045313181040">
</a>
<a class="indexterm" name="idm46045313179536">
</a>
<p>
Adds the
<code class="literal">
SOURCE_HOST
</code>
and
<code class="literal">
SOURCE_PORT
</code>
options for the host name and
TCP/IP port number of the replica's source, to the
<a class="link" href="change-replication-source-to.html" title="15.4.2.2 CHANGE REPLICATION SOURCE TO Statement">
<code class="literal">
CHANGE REPLICATION SOURCE TO
</code>
</a>
statement in a replica dump produced with the
<a class="link" href="mysqldump.html#option_mysqldump_dump-replica">
<code class="option">
--dump-replica
</code>
</a>
option.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_include-master-host-port">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_include-master-host-port">
<code class="option">
--include-master-host-port
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for include-master-host-port">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--include-master-host-port
</code>
</td>
</tr>
<tr>
<th>
Deprecated
</th>
<td>
Yes
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
Boolean
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
FALSE
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045313159440">
</a>
<a class="indexterm" name="idm46045313157936">
</a>
<p>
This is a deprecated alias for
<a class="link" href="mysqldump.html#option_mysqldump_include-source-host-port">
<code class="option">
--include-source-host-port
</code>
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_master-data">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_master-data">
<code class="option">
--master-data[=
<em class="replaceable">
<code>
value
</code>
</em>
]
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for master-data">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--master-data[=value]
</code>
</td>
</tr>
<tr>
<th>
Deprecated
</th>
<td>
Yes
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
Numeric
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
1
</code>
</td>
</tr>
<tr>
<th>
Valid Values
</th>
<td>
<p class="valid-value">
<code class="literal">
1
</code>
</p>
<p class="valid-value">
<code class="literal">
2
</code>
</p>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045313136640">
</a>
<a class="indexterm" name="idm46045313135152">
</a>
<p>
This is a deprecated alias for
<a class="link" href="mysqldump.html#option_mysqldump_source-data">
<code class="option">
--source-data
</code>
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_output-as-version">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_output-as-version">
<code class="option">
--output-as-version=
<em class="replaceable">
<code>
value
</code>
</em>
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for output-as-version">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--output-as-version=value
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
Enumeration
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
SERVER
</code>
</td>
</tr>
<tr>
<th>
Valid Values
</th>
<td>
<p class="valid-value">
<code class="literal">
BEFORE_8_0_23
</code>
</p>
<p class="valid-value">
<code class="literal">
BEFORE_8_2_0
</code>
</p>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045313115952">
</a>
<a class="indexterm" name="idm46045313114448">
</a>
<p>
Determines the level of terminology used for statements
relating to replicas and events, making it possible to
create dumps compatible with older versions of MySQL that do
not accept the newer terminology. This option can take any
one of the following values, with effects described as
listed here:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
<code class="literal">
SERVER
</code>
: Reads the server version and
uses the latest versions of statements compatible with
that version. This is the default value.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
BEFORE_8_0_23
</code>
: Replication SQL
statements using deprecated terms such as
<span class="quote">
“
<span class="quote">
slave
</span>
”
</span>
and
<span class="quote">
“
<span class="quote">
master
</span>
”
</span>
are
written to the output in place of those using
<span class="quote">
“
<span class="quote">
replica
</span>
”
</span>
and
<span class="quote">
“
<span class="quote">
source
</span>
”
</span>
, as in
MySQL versions prior to 8.0.23.
</p>
<p>
This option also duplicates the effects of
<code class="literal">
BEFORE_8_2_0
</code>
on the output of
<a class="link" href="show-create-event.html" title="15.7.7.8 SHOW CREATE EVENT Statement">
<code class="literal">
SHOW CREATE EVENT
</code>
</a>
.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
BEFORE_8_2_0
</code>
: This option causes
<a class="link" href="show-create-event.html" title="15.7.7.8 SHOW CREATE EVENT Statement">
<code class="literal">
SHOW CREATE EVENT
</code>
</a>
to
reflect how the event would have been created in a MySQL
server prior to version 8.2.0, displaying
<code class="literal">
DISABLE ON SLAVE
</code>
rather than
<code class="literal">
DISABLE ON REPLICA
</code>
.
</p>
</li>
</ul>
</div>
<p>
This option affects the output from
<a class="link" href="mysqldump.html#option_mysqldump_events">
<code class="option">
--events
</code>
</a>
,
<a class="link" href="mysqldump.html#option_mysqldump_dump-replica">
<code class="option">
--dump-replica
</code>
</a>
,
<a class="link" href="mysqldump.html#option_mysqldump_source-data">
<code class="option">
--source-data
</code>
</a>
,
<a class="link" href="mysqldump.html#option_mysqldump_apply-replica-statements">
<code class="option">
--apply-replica-statements
</code>
</a>
,
and
<a class="link" href="mysqldump.html#option_mysqldump_include-source-host-port">
<code class="option">
--include-source-host-port
</code>
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_source-data">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_source-data">
<code class="option">
--source-data[=
<em class="replaceable">
<code>
value
</code>
</em>
]
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for source-data">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--source-data[=value]
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
Numeric
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
1
</code>
</td>
</tr>
<tr>
<th>
Valid Values
</th>
<td>
<p class="valid-value">
<code class="literal">
1
</code>
</p>
<p class="valid-value">
<code class="literal">
2
</code>
</p>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045313078048">
</a>
<a class="indexterm" name="idm46045313076560">
</a>
<p>
Used to dump a replication source server to produce a dump
file that can be used to set up another server as a replica
of the source. The options cause the dump output to include
a
<a class="link" href="change-replication-source-to.html" title="15.4.2.2 CHANGE REPLICATION SOURCE TO Statement">
<code class="literal">
CHANGE REPLICATION SOURCE
TO
</code>
</a>
statement that indicates the binary log
coordinates (file name and position) of the dumped server.
These are the replication source server coordinates from
which the replica should start replicating after you load
the dump file into the replica.
</p>
<p>
If the option value is 2, the
<a class="link" href="change-replication-source-to.html" title="15.4.2.2 CHANGE REPLICATION SOURCE TO Statement">
<code class="literal">
CHANGE
REPLICATION SOURCE TO
</code>
</a>
statement is written as an
SQL comment, and thus is informative only; it has no effect
when the dump file is reloaded. If the option value is 1,
the statement is not written as a comment and takes effect
when the dump file is reloaded. If no option value is
specified, the default value is 1.
</p>
<p>
<code class="option">
--source-data
</code>
sends a
<a class="link" href="show-binary-log-status.html" title="15.7.7.1 SHOW BINARY LOG STATUS Statement">
<code class="literal">
SHOW BINARY LOG STATUS
</code>
</a>
statement to the server to obtain information, so they
require privileges sufficient to execute that statement.
This option also requires the
<a class="link" href="privileges-provided.html#priv_reload">
<code class="literal">
RELOAD
</code>
</a>
privilege and the
binary log must be enabled.
</p>
<p>
<code class="option">
--source-data
</code>
automatically turns off
<a class="link" href="mysqldump.html#option_mysqldump_lock-tables">
<code class="option">
--lock-tables
</code>
</a>
. They also
turn on
<a class="link" href="mysqldump.html#option_mysqldump_lock-all-tables">
<code class="option">
--lock-all-tables
</code>
</a>
,
unless
<a class="link" href="mysqldump.html#option_mysqldump_single-transaction">
<code class="option">
--single-transaction
</code>
</a>
also
is specified, in which case, a global read lock is acquired
only for a short time at the beginning of the dump (see the
description for
<a class="link" href="mysqldump.html#option_mysqldump_single-transaction">
<code class="option">
--single-transaction
</code>
</a>
). In
all cases, any action on logs happens at the exact moment of
the dump.
</p>
<p>
It is also possible to set up a replica by dumping an
existing replica of the source, using the
<a class="link" href="mysqldump.html#option_mysqldump_dump-replica">
<code class="option">
--dump-replica
</code>
</a>
option,
which overrides
<code class="option">
--source-data
</code>
causing it to
be ignored.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_set-gtid-purged">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_set-gtid-purged">
<code class="option">
--set-gtid-purged=
<em class="replaceable">
<code>
value
</code>
</em>
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for set-gtid-purged">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--set-gtid-purged=value
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
Enumeration
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
AUTO
</code>
</td>
</tr>
<tr>
<th>
Valid Values
</th>
<td>
<p class="valid-value">
<code class="literal">
OFF
</code>
</p>
<p class="valid-value">
<code class="literal">
ON
</code>
</p>
<p class="valid-value">
<code class="literal">
AUTO
</code>
</p>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045313042912">
</a>
<a class="indexterm" name="idm46045313041424">
</a>
<p>
This option is for servers that use GTID-based replication
(
<a class="link" href="replication-options-gtids.html#sysvar_gtid_mode">
<code class="literal">
gtid_mode=ON
</code>
</a>
). It controls
the inclusion of a
<code class="literal">
SET
@@GLOBAL.gtid_purged
</code>
statement in the dump output,
which updates the value of
<a class="link" href="replication-options-gtids.html#sysvar_gtid_purged">
<code class="literal">
gtid_purged
</code>
</a>
on a server
where the dump file is reloaded, to add the GTID set from
the source server's
<a class="link" href="replication-options-gtids.html#sysvar_gtid_executed">
<code class="literal">
gtid_executed
</code>
</a>
system
variable.
<a class="link" href="replication-options-gtids.html#sysvar_gtid_purged">
<code class="literal">
gtid_purged
</code>
</a>
holds
the GTIDs of all transactions that have been applied on the
server, but do not exist on any binary log file on the
server.
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
therefore adds the
GTIDs for the transactions that were executed on the source
server, so that the target server records these transactions
as applied, although it does not have them in its binary
logs.
<code class="option">
--set-gtid-purged
</code>
also controls the
inclusion of a
<code class="literal">
SET
@@SESSION.sql_log_bin=0
</code>
statement, which disables
binary logging while the dump file is being reloaded. This
statement prevents new GTIDs from being generated and
assigned to the transactions in the dump file as they are
executed, so that the original GTIDs for the transactions
are used.
</p>
<p>
If you do not set the
<code class="option">
--set-gtid-purged
</code>
option, the default is that a
<code class="literal">
SET
@@GLOBAL.gtid_purged
</code>
statement is included in the
dump output if GTIDs are enabled on the server you are
backing up, and the set of GTIDs in the global value of the
<a class="link" href="replication-options-gtids.html#sysvar_gtid_executed">
<code class="literal">
gtid_executed
</code>
</a>
system
variable is not empty. A
<code class="literal">
SET
@@SESSION.sql_log_bin=0
</code>
statement is also included
if GTIDs are enabled on the server.
</p>
<p>
You can either replace the value of
<a class="link" href="replication-options-gtids.html#sysvar_gtid_purged">
<code class="literal">
gtid_purged
</code>
</a>
with a
specified GTID set, or add a plus sign (+) to the statement
to append a specified GTID set to the GTID set that is
already held by
<code class="literal">
gtid_purged
</code>
. The
<code class="literal">
SET @@GLOBAL.gtid_purged
</code>
statement
recorded by
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
includes a plus
sign (
<code class="literal">
+
</code>
) in a version-specific comment,
such that MySQL adds the GTID set from the dump file to the
existing
<code class="literal">
gtid_purged
</code>
value.
</p>
<p>
It is important to note that the value that is included by
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
for the
<code class="literal">
SET
@@GLOBAL.gtid_purged
</code>
statement includes the GTIDs
of all transactions in the
<a class="link" href="replication-options-gtids.html#sysvar_gtid_executed">
<code class="literal">
gtid_executed
</code>
</a>
set on the
server, even those that changed suppressed parts of the
database, or other databases on the server that were not
included in a partial dump. This can mean that after the
<a class="link" href="replication-options-gtids.html#sysvar_gtid_purged">
<code class="literal">
gtid_purged
</code>
</a>
value has been
updated on the server where the dump file is replayed, GTIDs
are present that do not relate to any data on the target
server. If you do not replay any further dump files on the
target server, the extraneous GTIDs do not cause any
problems with the future operation of the server, but they
make it harder to compare or reconcile GTID sets on
different servers in the replication topology. If you do
replay a further dump file on the target server that
contains the same GTIDs (for example, another partial dump
from the same origin server), any
<code class="literal">
SET
@@GLOBAL.gtid_purged
</code>
statement in the second dump
file fails. In this case, either remove the statement
manually before replaying the dump file, or output the dump
file without the statement.
</p>
<p>
If the
<code class="literal">
SET @@GLOBAL.gtid_purged
</code>
statement
would not have the desired result on your target server, you
can exclude the statement from the output, or include it but
comment it out so that it is not actioned automatically. You
can also include the statement but manually edit it in the
dump file to achieve the desired result.
</p>
<p>
The possible values for the
<code class="option">
--set-gtid-purged
</code>
option are as follows:
</p>
<div class="variablelist">
<dl class="variablelist">
<dt>
<span class="term">
<code class="literal">
AUTO
</code>
</span>
</dt>
<dd>
<p>
The default value. If GTIDs are enabled on the server
you are backing up and
<a class="link" href="replication-options-gtids.html#sysvar_gtid_executed">
<code class="literal">
gtid_executed
</code>
</a>
is not
empty,
<code class="literal">
SET @@GLOBAL.gtid_purged
</code>
is
added to the output, containing the GTID set from
<a class="link" href="replication-options-gtids.html#sysvar_gtid_executed">
<code class="literal">
gtid_executed
</code>
</a>
. If
GTIDs are enabled,
<code class="literal">
SET
@@SESSION.sql_log_bin=0
</code>
is added to the
output. If GTIDs are not enabled on the server, the
statements are not added to the output.
</p>
</dd>
<dt>
<span class="term">
<code class="literal">
OFF
</code>
</span>
</dt>
<dd>
<p>
<code class="literal">
SET @@GLOBAL.gtid_purged
</code>
is not
added to the output, and
<code class="literal">
SET
@@SESSION.sql_log_bin=0
</code>
is not added to the
output. For a server where GTIDs are not in use, use
this option or
<code class="literal">
AUTO
</code>
. Only use this
option for a server where GTIDs are in use if you are
sure that the required GTID set is already present in
<a class="link" href="replication-options-gtids.html#sysvar_gtid_purged">
<code class="literal">
gtid_purged
</code>
</a>
on the
target server and should not be changed, or if you
plan to identify and add any missing GTIDs manually.
</p>
</dd>
<dt>
<span class="term">
<code class="literal">
ON
</code>
</span>
</dt>
<dd>
<p>
If GTIDs are enabled on the server you are backing up,
<code class="literal">
SET @@GLOBAL.gtid_purged
</code>
is added
to the output (unless
<a class="link" href="replication-options-gtids.html#sysvar_gtid_executed">
<code class="literal">
gtid_executed
</code>
</a>
is
empty), and
<code class="literal">
SET
@@SESSION.sql_log_bin=0
</code>
is added to the
output. An error occurs if you set this option but
GTIDs are not enabled on the server. For a server
where GTIDs are in use, use this option or
<code class="literal">
AUTO
</code>
, unless you are sure that the
GTIDs in
<a class="link" href="replication-options-gtids.html#sysvar_gtid_executed">
<code class="literal">
gtid_executed
</code>
</a>
are not
needed on the target server.
</p>
</dd>
<dt>
<span class="term">
<code class="literal">
COMMENTED
</code>
</span>
</dt>
<dd>
<p>
If GTIDs are enabled on the server you are backing up,
<code class="literal">
SET @@GLOBAL.gtid_purged
</code>
is added
to the output (unless
<a class="link" href="replication-options-gtids.html#sysvar_gtid_executed">
<code class="literal">
gtid_executed
</code>
</a>
is
empty), but it is commented out. This means that the
value of
<a class="link" href="replication-options-gtids.html#sysvar_gtid_executed">
<code class="literal">
gtid_executed
</code>
</a>
is
available in the output, but no action is taken
automatically when the dump file is reloaded.
<code class="literal">
SET @@SESSION.sql_log_bin=0
</code>
is
added to the output, and it is not commented out. With
<code class="literal">
COMMENTED
</code>
, you can control the use
of the
<a class="link" href="replication-options-gtids.html#sysvar_gtid_executed">
<code class="literal">
gtid_executed
</code>
</a>
set manually or through automation. For example, you
might prefer to do this if you are migrating data to
another server that already has different active
databases.
</p>
</dd>
</dl>
</div>
</li>
</ul>
</div>
<h4>
<a name="mysqldump-format-options">
</a>
Format Options
</h4>
<p>
The following options specify how to represent the entire dump
file or certain kinds of data in the dump file. They also
control whether certain optional information is written to the
dump file.
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a name="option_mysqldump_compact">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_compact">
<code class="option">
--compact
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for compact">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--compact
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045312971936">
</a>
<a class="indexterm" name="idm46045312970448">
</a>
<p>
Produce more compact output. This option enables the
<a class="link" href="mysqldump.html#option_mysqldump_add-drop-table">
<code class="option">
--skip-add-drop-table
</code>
</a>
,
<a class="link" href="mysqldump.html#option_mysqldump_add-locks">
<code class="option">
--skip-add-locks
</code>
</a>
,
<a class="link" href="mysqldump.html#option_mysqldump_skip-comments">
<code class="option">
--skip-comments
</code>
</a>
,
<a class="link" href="mysqldump.html#option_mysqldump_disable-keys">
<code class="option">
--skip-disable-keys
</code>
</a>
,
and
<a class="link" href="mysqldump.html#option_mysqldump_set-charset">
<code class="option">
--skip-set-charset
</code>
</a>
options.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_compatible">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_compatible">
<code class="option">
--compatible=
<em class="replaceable">
<code>
name
</code>
</em>
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for compatible">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--compatible=name[,name,...]
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
String
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
''
</code>
</td>
</tr>
<tr>
<th>
Valid Values
</th>
<td>
<p class="valid-value">
<code class="literal">
ansi
</code>
</p>
<p class="valid-value">
<code class="literal">
mysql323
</code>
</p>
<p class="valid-value">
<code class="literal">
mysql40
</code>
</p>
<p class="valid-value">
<code class="literal">
postgresql
</code>
</p>
<p class="valid-value">
<code class="literal">
oracle
</code>
</p>
<p class="valid-value">
<code class="literal">
mssql
</code>
</p>
<p class="valid-value">
<code class="literal">
db2
</code>
</p>
<p class="valid-value">
<code class="literal">
maxdb
</code>
</p>
<p class="valid-value">
<code class="literal">
no_key_options
</code>
</p>
<p class="valid-value">
<code class="literal">
no_table_options
</code>
</p>
<p class="valid-value">
<code class="literal">
no_key_options
</code>
</p>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045312938592">
</a>
<a class="indexterm" name="idm46045312937104">
</a>
<p>
Produce output that is more compatible with other database
systems or with older MySQL servers. The only permitted
value for this option is
<code class="literal">
ansi
</code>
, which has
the same meaning as the corresponding option for setting the
server SQL mode. See
<a class="xref" href="sql-mode.html" title="7.1.11 Server SQL Modes">
Section 7.1.11, “Server SQL Modes”
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_complete-insert">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_complete-insert">
<code class="option">
--complete-insert
</code>
</a>
,
<code class="option">
-c
</code>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for complete-insert">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--complete-insert
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045312925424">
</a>
<a class="indexterm" name="idm46045312923936">
</a>
<p>
Use complete
<a class="link" href="insert.html" title="15.2.7 INSERT Statement">
<code class="literal">
INSERT
</code>
</a>
statements that include column names.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_create-options">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_create-options">
<code class="option">
--create-options
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for create-options">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--create-options
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045312913024">
</a>
<a class="indexterm" name="idm46045312911536">
</a>
<p>
Include all MySQL-specific table options in the
<a class="link" href="create-table.html" title="15.1.20 CREATE TABLE Statement">
<code class="literal">
CREATE TABLE
</code>
</a>
statements.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_fields">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_fields">
<code class="option">
--fields-terminated-by=...
</code>
</a>
,
<a class="link" href="mysqldump.html#option_mysqldump_fields">
<code class="option">
--fields-enclosed-by=...
</code>
</a>
,
<a class="link" href="mysqldump.html#option_mysqldump_fields">
<code class="option">
--fields-optionally-enclosed-by=...
</code>
</a>
,
<a class="link" href="mysqldump.html#option_mysqldump_fields">
<code class="option">
--fields-escaped-by=...
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for fields-terminated-by">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--fields-terminated-by=string
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
String
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045312895696">
</a>
<a class="indexterm" name="idm46045312894192">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for fields-enclosed-by">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--fields-enclosed-by=string
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
String
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045312885104">
</a>
<a class="indexterm" name="idm46045312883600">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for fields-optionally-enclosed-by">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--fields-optionally-enclosed-by=string
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
String
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045312874496">
</a>
<a class="indexterm" name="idm46045312872992">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for fields-escaped-by">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--fields-escaped-by
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
String
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045312863920">
</a>
<a class="indexterm" name="idm46045312862416">
</a>
<p>
These options are used with the
<a class="link" href="mysqldump.html#option_mysqldump_tab">
<code class="option">
--tab
</code>
</a>
option and have the
same meaning as the corresponding
<code class="literal">
FIELDS
</code>
clauses for
<a class="link" href="load-data.html" title="15.2.9 LOAD DATA Statement">
<code class="literal">
LOAD DATA
</code>
</a>
. See
<a class="xref" href="load-data.html" title="15.2.9 LOAD DATA Statement">
Section 15.2.9, “LOAD DATA Statement”
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_hex-blob">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_hex-blob">
<code class="option">
--hex-blob
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for hex-blob">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--hex-blob
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045312849056">
</a>
<a class="indexterm" name="idm46045312847568">
</a>
<p>
Dump binary columns using hexadecimal notation (for example,
<code class="literal">
'abc'
</code>
becomes
<code class="literal">
0x616263
</code>
). The affected data types are
<a class="link" href="binary-varbinary.html" title="13.3.3 The BINARY and VARBINARY Types">
<code class="literal">
BINARY
</code>
</a>
,
<a class="link" href="binary-varbinary.html" title="13.3.3 The BINARY and VARBINARY Types">
<code class="literal">
VARBINARY
</code>
</a>
,
<a class="link" href="blob.html" title="13.3.4 The BLOB and TEXT Types">
<code class="literal">
BLOB
</code>
</a>
types,
<a class="link" href="bit-type.html" title="13.1.5 Bit-Value Type - BIT">
<code class="literal">
BIT
</code>
</a>
, all spatial data types,
and other non-binary data types when used with the
<a class="link" href="charset-binary-set.html" title="12.10.8 The Binary Character Set">
<code class="literal">
binary
</code>
character set
</a>
.
</p>
<p>
The
<a class="link" href="mysqldump.html#option_mysqldump_hex-blob">
<code class="option">
--hex-blob
</code>
</a>
option is
ignored when the
<a class="link" href="mysqldump.html#option_mysqldump_tab">
<code class="option">
--tab
</code>
</a>
is
used.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_lines-terminated-by">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_lines-terminated-by">
<code class="option">
--lines-terminated-by=...
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for lines-terminated-by">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--lines-terminated-by=string
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
String
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045312825280">
</a>
<a class="indexterm" name="idm46045312823776">
</a>
<p>
This option is used with the
<a class="link" href="mysqldump.html#option_mysqldump_tab">
<code class="option">
--tab
</code>
</a>
option and has the
same meaning as the corresponding
<code class="literal">
LINES
</code>
clause for
<a class="link" href="load-data.html" title="15.2.9 LOAD DATA Statement">
<code class="literal">
LOAD DATA
</code>
</a>
. See
<a class="xref" href="load-data.html" title="15.2.9 LOAD DATA Statement">
Section 15.2.9, “LOAD DATA Statement”
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_quote-names">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_quote-names">
<code class="option">
--quote-names
</code>
</a>
,
<code class="option">
-Q
</code>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for quote-names">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--quote-names
</code>
</td>
</tr>
<tr>
<th>
Disabled by
</th>
<td>
<code class="literal">
skip-quote-names
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045312807552">
</a>
<a class="indexterm" name="idm46045312806064">
</a>
<p>
Quote identifiers (such as database, table, and column
names) within
<code class="literal">
`
</code>
characters. If the
<a class="link" href="sql-mode.html#sqlmode_ansi_quotes">
<code class="literal">
ANSI_QUOTES
</code>
</a>
SQL mode is
enabled, identifiers are quoted within
<code class="literal">
"
</code>
characters. This option is enabled by default. It can be
disabled with
<code class="option">
--skip-quote-names
</code>
, but this
option should be given after any option such as
<a class="link" href="mysqldump.html#option_mysqldump_compatible">
<code class="option">
--compatible
</code>
</a>
that may
enable
<a class="link" href="mysqldump.html#option_mysqldump_quote-names">
<code class="option">
--quote-names
</code>
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_result-file">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_result-file">
<code class="option">
--result-file=
<em class="replaceable">
<code>
file_name
</code>
</em>
</code>
</a>
,
<code class="option">
-r
<em class="replaceable">
<code>
file_name
</code>
</em>
</code>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for result-file">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--result-file=file_name
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
File name
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045312788064">
</a>
<a class="indexterm" name="idm46045312786576">
</a>
<p>
Direct output to the named file. The result file is created
and its previous contents overwritten, even if an error
occurs while generating the dump.
</p>
<p>
This option should be used on Windows to prevent newline
<code class="literal">
\n
</code>
characters from being converted to
<code class="literal">
\r\n
</code>
carriage return/newline sequences.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_show-create-skip-secondary-engine">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_show-create-skip-secondary-engine">
<code class="option">
--show-create-skip-secondary-engine=
<em class="replaceable">
<code>
value
</code>
</em>
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for show-create-skip-secondary-engine">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--show-create-skip-secondary-engine
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045312774432">
</a>
<a class="indexterm" name="idm46045312772912">
</a>
<p>
Excludes the
<code class="literal">
SECONDARY ENGINE
</code>
clause from
<a class="link" href="create-table.html" title="15.1.20 CREATE TABLE Statement">
<code class="literal">
CREATE TABLE
</code>
</a>
statements. It
does so by enabling the
<a class="link" href="server-system-variables.html#sysvar_show_create_table_skip_secondary_engine">
<code class="literal">
show_create_table_skip_secondary_engine
</code>
</a>
system variable for the duration of the dump operation.
Alternatively, you can enable the
<a class="link" href="server-system-variables.html#sysvar_show_create_table_skip_secondary_engine">
<code class="literal">
show_create_table_skip_secondary_engine
</code>
</a>
system variable prior to using
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_tab">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_tab">
<code class="option">
--tab=
<em class="replaceable">
<code>
dir_name
</code>
</em>
</code>
</a>
,
<code class="option">
-T
<em class="replaceable">
<code>
dir_name
</code>
</em>
</code>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for tab">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--tab=dir_name
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
Directory name
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045312754112">
</a>
<a class="indexterm" name="idm46045312752624">
</a>
<p>
Produce tab-separated text-format data files. For each
dumped table,
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
creates a
<code class="filename">
<em class="replaceable">
<code>
tbl_name
</code>
</em>
.sql
</code>
file that contains the
<a class="link" href="create-table.html" title="15.1.20 CREATE TABLE Statement">
<code class="literal">
CREATE
TABLE
</code>
</a>
statement that creates the table, and the
server writes a
<code class="filename">
<em class="replaceable">
<code>
tbl_name
</code>
</em>
.txt
</code>
file that contains its data. The option value is the
directory in which to write the files.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
This option should be used only when
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
is run on the same machine as
the
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
server. Because the server
creates
<code class="filename">
*.txt
</code>
files in the directory
that you specify, the directory must be writable by the
server and the MySQL account that you use must have the
<a class="link" href="privileges-provided.html#priv_file">
<code class="literal">
FILE
</code>
</a>
privilege. Because
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
creates
<code class="filename">
*.sql
</code>
in the same directory, it must
be writable by your system login account.
</p>
</div>
<p>
By default, the
<code class="filename">
.txt
</code>
data files are
formatted using tab characters between column values and a
newline at the end of each line. The format can be specified
explicitly using the
<code class="option">
--fields-
<em class="replaceable">
<code>
xxx
</code>
</em>
</code>
and
<a class="link" href="mysqldump.html#option_mysqldump_lines-terminated-by">
<code class="option">
--lines-terminated-by
</code>
</a>
options.
</p>
<p>
Column values are converted to the character set specified
by the
<a class="link" href="mysqldump.html#option_mysqldump_default-character-set">
<code class="option">
--default-character-set
</code>
</a>
option.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_tz-utc">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_tz-utc">
<code class="option">
--tz-utc
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for tz-utc">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--tz-utc
</code>
</td>
</tr>
<tr>
<th>
Disabled by
</th>
<td>
<code class="literal">
skip-tz-utc
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045312723648">
</a>
<a class="indexterm" name="idm46045312722160">
</a>
<p>
This option enables
<a class="link" href="datetime.html" title="13.2.2 The DATE, DATETIME, and TIMESTAMP Types">
<code class="literal">
TIMESTAMP
</code>
</a>
columns to be dumped and reloaded between servers in
different time zones.
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
sets its
connection time zone to UTC and adds
<code class="literal">
SET
TIME_ZONE='+00:00'
</code>
to the dump file. Without this
option,
<a class="link" href="datetime.html" title="13.2.2 The DATE, DATETIME, and TIMESTAMP Types">
<code class="literal">
TIMESTAMP
</code>
</a>
columns are
dumped and reloaded in the time zones local to the source
and destination servers, which can cause the values to
change if the servers are in different time zones.
<code class="option">
--tz-utc
</code>
also protects against changes due
to daylight saving time.
<code class="option">
--tz-utc
</code>
is
enabled by default. To disable it, use
<code class="option">
--skip-tz-utc
</code>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_xml">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_xml">
<code class="option">
--xml
</code>
</a>
,
<code class="option">
-X
</code>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for xml">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--xml
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045312705968">
</a>
<a class="indexterm" name="idm46045312704480">
</a>
<p>
Write dump output as well-formed XML.
</p>
<p>
<span class="bold">
<strong>
<code class="literal">
NULL
</code>
,
<code class="literal">
'NULL'
</code>
, and Empty Values
</strong>
</span>
: For
a column named
<em class="replaceable">
<code>
column_name
</code>
</em>
, the
<code class="literal">
NULL
</code>
value, an empty string, and the
string value
<code class="literal">
'NULL'
</code>
are distinguished
from one another in the output generated by this option as
follows.
</p>
<div class="informaltable">
<table summary="For a column named column_name, the NULL value, an empty string, and the string value 'NULL' are distinguished from one another in the XML output generated by the mysqldump --xml, -X option, as shown in this table.">
<colgroup>
<col style="width: 50%"/>
<col style="width: 50%"/>
</colgroup>
<thead>
<tr>
<th>
Value:
</th>
<th>
XML Representation:
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<code class="literal">
NULL
</code>
(
<span class="emphasis">
<em>
unknown value
</em>
</span>
)
</td>
<td>
<p>
<code class="literal">
<field
name="
<em class="replaceable">
<code>
column_name
</code>
</em>
"
xsi:nil="true" />
</code>
</p>
</td>
</tr>
<tr>
<td>
<code class="literal">
''
</code>
(
<span class="emphasis">
<em>
empty string
</em>
</span>
)
</td>
<td>
<p>
<code class="literal">
<field
name="
<em class="replaceable">
<code>
column_name
</code>
</em>
"></field>
</code>
</p>
</td>
</tr>
<tr>
<td>
<code class="literal">
'NULL'
</code>
(
<span class="emphasis">
<em>
string value
</em>
</span>
)
</td>
<td>
<p>
<code class="literal">
<field
name="
<em class="replaceable">
<code>
column_name
</code>
</em>
">NULL</field>
</code>
</p>
</td>
</tr>
</tbody>
</table>
</div>
<p>
The output from the
<a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
<span class="command">
<strong>
mysql
</strong>
</span>
</a>
client when run
using the
<a class="link" href="mysql-command-options.html#option_mysql_xml">
<code class="option">
--xml
</code>
</a>
option also
follows the preceding rules. (See
<a class="xref" href="mysql-command-options.html" title="6.5.1.1 mysql Client Options">
Section 6.5.1.1, “mysql Client Options”
</a>
.)
</p>
<p>
XML output from
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
includes the
XML namespace, as shown here:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa12943407"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$> </span><span class="token command">mysqldump</span> <span class="token property">--xml</span> <span class="token property">-u</span> root world City
<?xml version=<span class="token atrule">"1.0"</span>?>
<mysqldump xmlns<span class="token punctuation">:</span>xsi=<span class="token atrule">"http://www.w3.org/2001/XMLSchema-instance"</span>>
<database name=<span class="token atrule">"world"</span>>
<table_structure name=<span class="token atrule">"City"</span>>
<field Field=<span class="token atrule">"ID"</span> Type=<span class="token atrule">"int(11)"</span> Null=<span class="token atrule">"NO"</span> Key=<span class="token atrule">"PRI"</span> Extra=<span class="token atrule">"auto_increment"</span> />
<field Field=<span class="token atrule">"Name"</span> Type=<span class="token atrule">"char(35)"</span> Null=<span class="token atrule">"NO"</span> Key=<span class="token atrule">""</span> Default=<span class="token atrule">""</span> Extra=<span class="token atrule">""</span> />
<field Field=<span class="token atrule">"CountryCode"</span> Type=<span class="token atrule">"char(3)"</span> Null=<span class="token atrule">"NO"</span> Key=<span class="token atrule">""</span> Default=<span class="token atrule">""</span> Extra=<span class="token atrule">""</span> />
<field Field=<span class="token atrule">"District"</span> Type=<span class="token atrule">"char(20)"</span> Null=<span class="token atrule">"NO"</span> Key=<span class="token atrule">""</span> Default=<span class="token atrule">""</span> Extra=<span class="token atrule">""</span> />
<field Field=<span class="token atrule">"Population"</span> Type=<span class="token atrule">"int(11)"</span> Null=<span class="token atrule">"NO"</span> Key=<span class="token atrule">""</span> Default=<span class="token atrule">"0"</span> Extra=<span class="token atrule">""</span> />
<key Table=<span class="token atrule">"City"</span> Non_unique=<span class="token atrule">"0"</span> Key_name=<span class="token atrule">"PRIMARY"</span> Seq_in_index=<span class="token atrule">"1"</span> Column_name=<span class="token atrule">"ID"</span>
Collation=<span class="token atrule">"A"</span> Cardinality=<span class="token atrule">"4079"</span> Null=<span class="token atrule">""</span> Index_type=<span class="token atrule">"BTREE"</span> Comment=<span class="token atrule">""</span> />
<options Name=<span class="token atrule">"City"</span> Engine=<span class="token atrule">"MyISAM"</span> Version=<span class="token atrule">"10"</span> Row_format=<span class="token atrule">"Fixed"</span> Rows=<span class="token atrule">"4079"</span>
Avg_row_length=<span class="token atrule">"67"</span> Data_length=<span class="token atrule">"273293"</span> Max_data_length=<span class="token atrule">"18858823439613951"</span>
Index_length=<span class="token atrule">"43008"</span> Data_free=<span class="token atrule">"0"</span> Auto_increment=<span class="token atrule">"4080"</span>
Create_time=<span class="token atrule">"2007-03-31 01:47:01"</span> Update_time=<span class="token atrule">"2007-03-31 01:47:02"</span>
Collation=<span class="token atrule">"latin1_swedish_ci"</span> Create_options=<span class="token atrule">""</span> Comment=<span class="token atrule">""</span> />
</table_structure>
<table_data name=<span class="token atrule">"City"</span>>
<row>
<field name=<span class="token atrule">"ID"</span>>1</field>
<field name=<span class="token atrule">"Name"</span>>Kabul</field>
<field name=<span class="token atrule">"CountryCode"</span>>AFG</field>
<field name=<span class="token atrule">"District"</span>>Kabol</field>
<field name=<span class="token atrule">"Population"</span>>1780000</field>
</row>
<span class="token punctuation"></span><em class="replaceable"><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span></em><span class="token punctuation"></span>
<row>
<field name=<span class="token atrule">"ID"</span>>4079</field>
<field name=<span class="token atrule">"Name"</span>>Rafah</field>
<field name=<span class="token atrule">"CountryCode"</span>>PSE</field>
<field name=<span class="token atrule">"District"</span>>Rafah</field>
<field name=<span class="token atrule">"Population"</span>>92020</field>
</row>
</table_data>
</database>
</mysqldump></code></pre>
</div>
</li>
</ul>
</div>
<h4>
<a name="mysqldump-filter-options">
</a>
Filtering Options
</h4>
<p>
The following options control which kinds of schema objects are
written to the dump file: by category, such as triggers or
events; by name, for example, choosing which databases and
tables to dump; or even filtering rows from the table data using
a
<code class="literal">
WHERE
</code>
clause.
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a name="option_mysqldump_all-databases">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_all-databases">
<code class="option">
--all-databases
</code>
</a>
,
<code class="option">
-A
</code>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for all-databases">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--all-databases
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045312659360">
</a>
<a class="indexterm" name="idm46045312657872">
</a>
<p>
Dump all tables in all databases. This is the same as using
the
<a class="link" href="mysqldump.html#option_mysqldump_databases">
<code class="option">
--databases
</code>
</a>
option and
naming all the databases on the command line.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
See the
<a class="link" href="mysqldump.html#option_mysqldump_add-drop-database">
<code class="option">
--add-drop-database
</code>
</a>
description for information about an incompatibility of
that option with
<a class="link" href="mysqldump.html#option_mysqldump_all-databases">
<code class="option">
--all-databases
</code>
</a>
.
</p>
</div>
<p>
Prior to MySQL 8.4, the
<a class="link" href="mysqldump.html#option_mysqldump_routines">
<code class="option">
--routines
</code>
</a>
and
<a class="link" href="mysqldump.html#option_mysqldump_events">
<code class="option">
--events
</code>
</a>
options for
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
were not required to include
stored routines and events when using the
<a class="link" href="mysqldump.html#option_mysqldump_all-databases">
<code class="option">
--all-databases
</code>
</a>
option:
The dump included the
<code class="literal">
mysql
</code>
system
database, and therefore also the
<code class="literal">
mysql.proc
</code>
and
<code class="literal">
mysql.event
</code>
tables containing stored
routine and event definitions. As of MySQL 8.4,
the
<code class="literal">
mysql.event
</code>
and
<code class="literal">
mysql.proc
</code>
tables are not used.
Definitions for the corresponding objects are stored in data
dictionary tables, but those tables are not dumped. To
include stored routines and events in a dump made using
<a class="link" href="mysqldump.html#option_mysqldump_all-databases">
<code class="option">
--all-databases
</code>
</a>
, use the
<a class="link" href="mysqldump.html#option_mysqldump_routines">
<code class="option">
--routines
</code>
</a>
and
<a class="link" href="mysqldump.html#option_mysqldump_events">
<code class="option">
--events
</code>
</a>
options
explicitly.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_databases">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_databases">
<code class="option">
--databases
</code>
</a>
,
<code class="option">
-B
</code>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for databases">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--databases
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045312632128">
</a>
<a class="indexterm" name="idm46045312630640">
</a>
<p>
Dump several databases. Normally,
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
treats the first name argument
on the command line as a database name and following names
as table names. With this option, it treats all name
arguments as database names.
<a class="link" href="create-database.html" title="15.1.12 CREATE DATABASE Statement">
<code class="literal">
CREATE
DATABASE
</code>
</a>
and
<a class="link" href="use.html" title="15.8.4 USE Statement">
<code class="literal">
USE
</code>
</a>
statements are included in the output before each new
database.
</p>
<p>
This option may be used to dump the
<code class="literal">
performance_schema
</code>
database, which
normally is not dumped even with the
<a class="link" href="mysqldump.html#option_mysqldump_all-databases">
<code class="option">
--all-databases
</code>
</a>
option.
(Also use the
<a class="link" href="mysqldump.html#option_mysqldump_lock-tables">
<code class="option">
--skip-lock-tables
</code>
</a>
option.)
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
See the
<a class="link" href="mysqldump.html#option_mysqldump_add-drop-database">
<code class="option">
--add-drop-database
</code>
</a>
description for information about an incompatibility of
that option with
<a class="link" href="mysqldump.html#option_mysqldump_databases">
<code class="option">
--databases
</code>
</a>
.
</p>
</div>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_events">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_events">
<code class="option">
--events
</code>
</a>
,
<code class="option">
-E
</code>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for events">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--events
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045312610544">
</a>
<a class="indexterm" name="idm46045312609056">
</a>
<p>
Include Event Scheduler events for the dumped databases in
the output. This option requires the
<a class="link" href="privileges-provided.html#priv_event">
<code class="literal">
EVENT
</code>
</a>
privileges for those
databases.
</p>
<p>
The output generated by using
<code class="option">
--events
</code>
contains
<a class="link" href="create-event.html" title="15.1.13 CREATE EVENT Statement">
<code class="literal">
CREATE EVENT
</code>
</a>
statements to create the events.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_ignore-error">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_ignore-error">
<code class="option">
--ignore-error=
<em class="replaceable">
<code>
error[,error]...
</code>
</em>
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for ignore-error">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--ignore-error=error[,error]...
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
String
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045312593360">
</a>
<a class="indexterm" name="idm46045312591872">
</a>
<p>
Ignore the specified errors. The option value is a list of
comma-separated error numbers specifying the errors to
ignore during
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
execution. If the
<a class="link" href="mysqldump.html#option_mysqldump_force">
<code class="option">
--force
</code>
</a>
option is also
given to ignore all errors,
<a class="link" href="mysqldump.html#option_mysqldump_force">
<code class="option">
--force
</code>
</a>
takes precedence.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_ignore-table">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_ignore-table">
<code class="option">
--ignore-table=
<em class="replaceable">
<code>
db_name.tbl_name
</code>
</em>
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for ignore-table">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--ignore-table=db_name.tbl_name
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
String
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045312576528">
</a>
<a class="indexterm" name="idm46045312575040">
</a>
<p>
Do not dump the given table, which must be specified using
both the database and table names. To ignore multiple
tables, use this option multiple times. This option also can
be used to ignore views.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_ignore-views">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_ignore-views">
<code class="option">
--ignore-views=
<em class="replaceable">
<code>
boolean
</code>
</em>
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for ignore-views">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--ignore-views
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
Boolean
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
FALSE
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045312560400">
</a>
<a class="indexterm" name="idm46045312558912">
</a>
<p>
Skips table views in the dump file.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_init-command">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_init-command">
<code class="option">
--init-command=
<em class="replaceable">
<code>
str
</code>
</em>
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for init-command">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--init-command=str
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
String
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045312546944">
</a>
<a class="indexterm" name="idm46045312545456">
</a>
<p>
Single SQL statement to execute after connecting to the
MySQL server. The definition resets existing statements
defined by it or
<a class="link" href="mysqldump.html#option_mysqldump_init-command-add">
<code class="option">
init-command-add
</code>
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_init-command-add">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_init-command-add">
<code class="option">
--init-command-add=
<em class="replaceable">
<code>
str
</code>
</em>
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for init-command-add">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--init-command-add=str
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
String
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045312532384">
</a>
<a class="indexterm" name="idm46045312530896">
</a>
<p>
Add an additional SQL statement to execute after connecting
or reconnecting to the MySQL server. It's usable without
<a class="link" href="mysqldump.html#option_mysqldump_init-command">
<code class="option">
--init-command
</code>
</a>
but has no
effect if used before it because
<a class="link" href="mysqldump.html#option_mysqldump_init-command">
<code class="option">
init-command
</code>
</a>
resets the
list of commands to call.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_no-data">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_no-data">
<code class="option">
--no-data
</code>
</a>
,
<code class="option">
-d
</code>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for no-data">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--no-data
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045312518608">
</a>
<a class="indexterm" name="idm46045312517120">
</a>
<p>
Do not write any table row information (that is, do not dump
table contents). This is useful if you want to dump only the
<a class="link" href="create-table.html" title="15.1.20 CREATE TABLE Statement">
<code class="literal">
CREATE TABLE
</code>
</a>
statement for
the table (for example, to create an empty copy of the table
by loading the dump file).
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_routines">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_routines">
<code class="option">
--routines
</code>
</a>
,
<code class="option">
-R
</code>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for routines">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--routines
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045312505600">
</a>
<a class="indexterm" name="idm46045312504112">
</a>
<p>
Include stored routines (procedures and functions) for the
dumped databases in the output. This option requires the
global
<a class="link" href="privileges-provided.html#priv_select">
<code class="literal">
SELECT
</code>
</a>
privilege.
</p>
<p>
The output generated by using
<code class="option">
--routines
</code>
contains
<a class="link" href="create-procedure.html" title="15.1.17 CREATE PROCEDURE and CREATE FUNCTION Statements">
<code class="literal">
CREATE PROCEDURE
</code>
</a>
and
<a class="link" href="create-function.html" title="15.1.14 CREATE FUNCTION Statement">
<code class="literal">
CREATE FUNCTION
</code>
</a>
statements to
create the routines.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_skip-generated-invisible-primary-key">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_skip-generated-invisible-primary-key">
<code class="option">
--skip-generated-invisible-primary-key
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for skip-generated-invisible-primary-key">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--skip-generated-invisible-primary-key
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
Boolean
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
FALSE
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045312485104">
</a>
<a class="indexterm" name="idm46045312483584">
</a>
<p>
This option causes generated invisible primary keys to be
excluded from the output. For more information, see
<a class="xref" href="create-table-gipks.html" title="15.1.20.11 Generated Invisible Primary Keys">
Section 15.1.20.11, “Generated Invisible Primary Keys”
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_tables">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_tables">
<code class="option">
--tables
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for tables">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--tables
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045312473152">
</a>
<a class="indexterm" name="idm46045312471664">
</a>
<p>
Override the
<a class="link" href="mysqldump.html#option_mysqldump_databases">
<code class="option">
--databases
</code>
</a>
or
<code class="option">
-B
</code>
option.
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
regards all name arguments following the option as table
names.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_triggers">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_triggers">
<code class="option">
--triggers
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for triggers">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--triggers
</code>
</td>
</tr>
<tr>
<th>
Disabled by
</th>
<td>
<code class="literal">
skip-triggers
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045312456832">
</a>
<a class="indexterm" name="idm46045312455344">
</a>
<p>
Include triggers for each dumped table in the output. This
option is enabled by default; disable it with
<code class="option">
--skip-triggers
</code>
.
</p>
<p>
To be able to dump a table's triggers, you must have the
<a class="link" href="privileges-provided.html#priv_trigger">
<code class="literal">
TRIGGER
</code>
</a>
privilege for the
table.
</p>
<p>
Multiple triggers are permitted.
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
dumps triggers in activation
order so that when the dump file is reloaded, triggers are
created in the same activation order. However, if a
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
dump file contains multiple
triggers for a table that have the same trigger event and
action time, an error occurs for attempts to load the dump
file into an older server that does not support multiple
triggers. (For a workaround, see
<a class="ulink" href="/doc/refman/5.7/en/downgrading-to-previous-series.html" target="_top">
Downgrade Notes
</a>
;
you can convert triggers to be compatible with older
servers.)
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_where">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_where">
<code class="option">
--where='
<em class="replaceable">
<code>
where_condition
</code>
</em>
'
</code>
</a>
,
<code class="option">
-w
'
<em class="replaceable">
<code>
where_condition
</code>
</em>
'
</code>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for where">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--where='where_condition'
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045312438000">
</a>
<a class="indexterm" name="idm46045312436512">
</a>
<p>
Dump only rows selected by the given
<code class="literal">
WHERE
</code>
condition. Quotes around the
condition are mandatory if it contains spaces or other
characters that are special to your command interpreter.
</p>
<p>
Examples:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa86878796"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token constant">--where</span>=<span class="token atrule">"user='jimf'"</span>
<span class="token property">-w</span><span class="token atrule">"userid>1"</span>
<span class="token property">-w</span><span class="token atrule">"userid<1"</span></code></pre>
</div>
</li>
</ul>
</div>
<h4>
<a name="mysqldump-performance-options">
</a>
Performance Options
</h4>
<p>
The following options are the most relevant for the performance
particularly of the restore operations. For large data sets,
restore operation (processing the
<code class="literal">
INSERT
</code>
statements in the dump file) is the most time-consuming part.
When it is urgent to restore data quickly, plan and test the
performance of this stage in advance. For restore times measured
in hours, you might prefer an alternative backup and restore
solution, such as
<a class="link" href="mysql-enterprise-backup.html" title="32.1 MySQL Enterprise Backup Overview">
MySQL Enterprise Backup
</a>
for
<code class="literal">
InnoDB
</code>
-only and mixed-use databases.
</p>
<p>
Performance is also affected by the
<a class="link" href="mysqldump.html#mysqldump-transaction-options" title="Transactional Options">
transactional
options
</a>
, primarily for the dump operation.
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a name="option_mysqldump_column-statistics">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_column-statistics">
<code class="option">
--column-statistics
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for column-statistics">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--column-statistics
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
Boolean
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
OFF
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045312412272">
</a>
<a class="indexterm" name="idm46045312410768">
</a>
<p>
Add
<a class="link" href="analyze-table.html" title="15.7.3.1 ANALYZE TABLE Statement">
<code class="literal">
ANALYZE TABLE
</code>
</a>
statements
to the output to generate histogram statistics for dumped
tables when the dump file is reloaded. This option is
disabled by default because histogram generation for large
tables can take a long time.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_disable-keys">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_disable-keys">
<code class="option">
--disable-keys
</code>
</a>
,
<code class="option">
-K
</code>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for disable-keys">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--disable-keys
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045312399184">
</a>
<a class="indexterm" name="idm46045312397696">
</a>
<p>
For each table, surround the
<a class="link" href="insert.html" title="15.2.7 INSERT Statement">
<code class="literal">
INSERT
</code>
</a>
statements with
<code class="literal">
/*!40000 ALTER TABLE
<em class="replaceable">
<code>
tbl_name
</code>
</em>
DISABLE KEYS
*/;
</code>
and
<code class="literal">
/*!40000 ALTER TABLE
<em class="replaceable">
<code>
tbl_name
</code>
</em>
ENABLE KEYS
*/;
</code>
statements. This makes loading the dump file
faster because the indexes are created after all rows are
inserted. This option is effective only for nonunique
indexes of
<code class="literal">
MyISAM
</code>
tables.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_extended-insert">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_extended-insert">
<code class="option">
--extended-insert
</code>
</a>
,
<code class="option">
-e
</code>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for extended-insert">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--extended-insert
</code>
</td>
</tr>
<tr>
<th>
Disabled by
</th>
<td>
<code class="literal">
skip-extended-insert
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045312380624">
</a>
<a class="indexterm" name="idm46045312379136">
</a>
<p>
Write
<a class="link" href="insert.html" title="15.2.7 INSERT Statement">
<code class="literal">
INSERT
</code>
</a>
statements using
multiple-row syntax that includes several
<code class="literal">
VALUES
</code>
lists. This results in a smaller
dump file and speeds up inserts when the file is reloaded.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_insert-ignore">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_insert-ignore">
<code class="option">
--insert-ignore
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for insert-ignore">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--insert-ignore
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045312367408">
</a>
<a class="indexterm" name="idm46045312365920">
</a>
<p>
Write
<a class="link" href="insert.html" title="15.2.7 INSERT Statement">
<code class="literal">
INSERT
IGNORE
</code>
</a>
statements rather than
<a class="link" href="insert.html" title="15.2.7 INSERT Statement">
<code class="literal">
INSERT
</code>
</a>
statements.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_max-allowed-packet">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_max-allowed-packet">
<code class="option">
--max-allowed-packet=
<em class="replaceable">
<code>
value
</code>
</em>
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for max-allowed-packet">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--max-allowed-packet=value
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
Numeric
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
25165824
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045312349008">
</a>
<a class="indexterm" name="idm46045312347504">
</a>
<p>
The maximum size of the buffer for client/server
communication. The default is 24MB, the maximum is 1GB.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
The value of this option is specific to
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
and should not be confused
with the MySQL server's
<a class="link" href="server-system-variables.html#sysvar_max_allowed_packet">
<code class="literal">
max_allowed_packet
</code>
</a>
system
variable; the server value cannot be exceeded by a single
packet from
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
, regardless of
any setting for the
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
option,
even if the latter is larger.
</p>
</div>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_mysqld-long-query-time">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_mysqld-long-query-time">
<code class="option">
--mysqld-long-query-time=
<em class="replaceable">
<code>
value
</code>
</em>
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for mysqld-long-query-time">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--mysqld-long-query-time=value
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
Numeric
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
Server global setting
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045312326704">
</a>
<a class="indexterm" name="idm46045312325200">
</a>
<p>
Set the session value of the
<a class="link" href="server-system-variables.html#sysvar_long_query_time">
<code class="literal">
long_query_time
</code>
</a>
system
variable. Use this option if you want to increase the time
allowed for queries from
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
before
they are logged to the slow query log file.
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
performs a full table scan,
which means its queries can often exceed a global
<a class="link" href="server-system-variables.html#sysvar_long_query_time">
<code class="literal">
long_query_time
</code>
</a>
setting that is useful for regular queries. The default
global setting is 10 seconds.
</p>
<p>
You can use
<a class="link" href="mysqldump.html#option_mysqldump_mysqld-long-query-time">
<code class="option">
--mysqld-long-query-time
</code>
</a>
to specify a session value from 0 (meaning that every query
from
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
is logged to the slow
query log) to 31536000, which is 365 days in seconds. For
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
’s option, you can only
specify whole seconds. When you do not specify this option,
the server’s global setting applies to
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
’s queries.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_net-buffer-length">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_net-buffer-length">
<code class="option">
--net-buffer-length=
<em class="replaceable">
<code>
value
</code>
</em>
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for net-buffer-length">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--net-buffer-length=value
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
Numeric
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
16384
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045312299984">
</a>
<a class="indexterm" name="idm46045312298480">
</a>
<p>
The initial size of the buffer for client/server
communication. When creating multiple-row
<a class="link" href="insert.html" title="15.2.7 INSERT Statement">
<code class="literal">
INSERT
</code>
</a>
statements (as with
the
<a class="link" href="mysqldump.html#option_mysqldump_extended-insert">
<code class="option">
--extended-insert
</code>
</a>
or
<a class="link" href="mysqldump.html#option_mysqldump_opt">
<code class="option">
--opt
</code>
</a>
option),
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
creates rows up to
<a class="link" href="mysqldump.html#option_mysqldump_net-buffer-length">
<code class="option">
--net-buffer-length
</code>
</a>
bytes
long. If you increase this variable, ensure that the MySQL
server
<a class="link" href="server-system-variables.html#sysvar_net_buffer_length">
<code class="literal">
net_buffer_length
</code>
</a>
system variable has a value at least this large.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_network-timeout">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_network-timeout">
<code class="option">
--network-timeout
</code>
</a>
,
<code class="option">
-M
</code>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for network-timeout">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--network-timeout[={0|1}]
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
Boolean
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
TRUE
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045312276848">
</a>
<a class="indexterm" name="idm46045312275360">
</a>
<p>
Enable large tables to be dumped by setting
<a class="link" href="mysqldump.html#option_mysqldump_max-allowed-packet">
<code class="option">
--max-allowed-packet
</code>
</a>
to
its maximum value and network read and write timeouts to a
large value. This option is enabled by default. To disable
it, use
<a class="link" href="mysqldump.html#option_mysqldump_network-timeout">
<code class="option">
--skip-network-timeout
</code>
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_opt">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_opt">
<code class="option">
--opt
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for opt">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--opt
</code>
</td>
</tr>
<tr>
<th>
Disabled by
</th>
<td>
<code class="literal">
skip-opt
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045312261184">
</a>
<a class="indexterm" name="idm46045312259696">
</a>
<p>
This option, enabled by default, is shorthand for the
combination of
<a class="link" href="mysqldump.html#option_mysqldump_add-drop-table">
<code class="option">
--add-drop-table
</code>
</a>
<a class="link" href="mysqldump.html#option_mysqldump_add-locks">
<code class="option">
--add-locks
</code>
</a>
<a class="link" href="mysqldump.html#option_mysqldump_create-options">
<code class="option">
--create-options
</code>
</a>
<a class="link" href="mysqldump.html#option_mysqldump_disable-keys">
<code class="option">
--disable-keys
</code>
</a>
<a class="link" href="mysqldump.html#option_mysqldump_extended-insert">
<code class="option">
--extended-insert
</code>
</a>
<a class="link" href="mysqldump.html#option_mysqldump_lock-tables">
<code class="option">
--lock-tables
</code>
</a>
<a class="link" href="mysqldump.html#option_mysqldump_quick">
<code class="option">
--quick
</code>
</a>
<a class="link" href="mysqldump.html#option_mysqldump_set-charset">
<code class="option">
--set-charset
</code>
</a>
. It gives a
fast dump operation and produces a dump file that can be
reloaded into a MySQL server quickly.
</p>
<p>
Because the
<code class="option">
--opt
</code>
option is enabled by
default, you only specify its converse, the
<a class="link" href="mysqldump.html#option_mysqldump_skip-opt">
<code class="option">
--skip-opt
</code>
</a>
to turn off
several default settings. See the discussion of
<a class="link" href="mysqldump.html#mysqldump-option-groups" title="Option Groups">
<code class="literal">
mysqldump
</code>
option groups
</a>
for information about selectively
enabling or disabling a subset of the options affected by
<code class="option">
--opt
</code>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_quick">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_quick">
<code class="option">
--quick
</code>
</a>
,
<code class="option">
-q
</code>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for quick">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--quick
</code>
</td>
</tr>
<tr>
<th>
Disabled by
</th>
<td>
<code class="literal">
skip-quick
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045312235424">
</a>
<a class="indexterm" name="idm46045312233936">
</a>
<p>
This option is useful for dumping large tables. It forces
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
to retrieve rows for a table
from the server a row at a time rather than retrieving the
entire row set and buffering it in memory before writing it
out.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_skip-opt">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_skip-opt">
<code class="option">
--skip-opt
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for skip-opt">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--skip-opt
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045312222800">
</a>
<a class="indexterm" name="idm46045312221312">
</a>
<p>
See the description for the
<a class="link" href="mysqldump.html#option_mysqldump_opt">
<code class="option">
--opt
</code>
</a>
option.
</p>
</li>
</ul>
</div>
<h4>
<a name="mysqldump-transaction-options">
</a>
Transactional Options
</h4>
<p>
The following options trade off the performance of the dump
operation, against the reliability and consistency of the
exported data.
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a name="option_mysqldump_add-locks">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_add-locks">
<code class="option">
--add-locks
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for add-locks">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--add-locks
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045312207104">
</a>
<a class="indexterm" name="idm46045312205616">
</a>
<p>
Surround each table dump with
<a class="link" href="lock-tables.html" title="15.3.6 LOCK TABLES and UNLOCK TABLES Statements">
<code class="literal">
LOCK
TABLES
</code>
</a>
and
<a class="link" href="lock-tables.html" title="15.3.6 LOCK TABLES and UNLOCK TABLES Statements">
<code class="literal">
UNLOCK
TABLES
</code>
</a>
statements. This results in faster inserts
when the dump file is reloaded. See
<a class="xref" href="insert-optimization.html" title="10.2.5.1 Optimizing INSERT Statements">
Section 10.2.5.1, “Optimizing INSERT Statements”
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_flush-logs">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_flush-logs">
<code class="option">
--flush-logs
</code>
</a>
,
<code class="option">
-F
</code>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for flush-logs">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--flush-logs
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045312191424">
</a>
<a class="indexterm" name="idm46045312189936">
</a>
<p>
Flush the MySQL server log files before starting the dump.
This option requires the
<a class="link" href="privileges-provided.html#priv_reload">
<code class="literal">
RELOAD
</code>
</a>
privilege. If you use
this option in combination with the
<a class="link" href="mysqldump.html#option_mysqldump_all-databases">
<code class="option">
--all-databases
</code>
</a>
option,
the logs are flushed
<span class="emphasis">
<em>
for each database
dumped
</em>
</span>
. The exception is when using
<a class="link" href="mysqldump.html#option_mysqldump_lock-all-tables">
<code class="option">
--lock-all-tables
</code>
</a>
,
<a class="link" href="mysqldump.html#option_mysqldump_source-data">
<code class="option">
--source-data
</code>
</a>
, or
<a class="link" href="mysqldump.html#option_mysqldump_single-transaction">
<code class="option">
--single-transaction
</code>
</a>
. In
these cases, the logs are flushed only once, corresponding
to the moment that all tables are locked by
<a class="link" href="flush.html#flush-tables-with-read-lock">
<code class="literal">
FLUSH TABLES WITH READ LOCK
</code>
</a>
.
If you want your dump and the log flush to happen at exactly
the same moment, you should use
<code class="option">
--flush-logs
</code>
together with
<a class="link" href="mysqldump.html#option_mysqldump_lock-all-tables">
<code class="option">
--lock-all-tables
</code>
</a>
,
<a class="link" href="mysqldump.html#option_mysqldump_source-data">
<code class="option">
--source-data
</code>
</a>
, or
<a class="link" href="mysqldump.html#option_mysqldump_single-transaction">
<code class="option">
--single-transaction
</code>
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_flush-privileges">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_flush-privileges">
<code class="option">
--flush-privileges
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for flush-privileges">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--flush-privileges
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045312169280">
</a>
<a class="indexterm" name="idm46045312167792">
</a>
<p>
Add a
<a class="link" href="flush.html#flush-privileges">
<code class="literal">
FLUSH PRIVILEGES
</code>
</a>
statement to the dump output after dumping the
<code class="literal">
mysql
</code>
database. This option should be
used any time the dump contains the
<code class="literal">
mysql
</code>
database and any other database that depends on the data in
the
<code class="literal">
mysql
</code>
database for proper
restoration.
</p>
<p>
Because the dump file contains a
<a class="link" href="flush.html#flush-privileges">
<code class="literal">
FLUSH
PRIVILEGES
</code>
</a>
statement, reloading the file requires
privileges sufficient to execute that statement.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_lock-all-tables">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_lock-all-tables">
<code class="option">
--lock-all-tables
</code>
</a>
,
<code class="option">
-x
</code>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for lock-all-tables">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--lock-all-tables
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045312152272">
</a>
<a class="indexterm" name="idm46045312150784">
</a>
<p>
Lock all tables across all databases. This is achieved by
acquiring a global read lock for the duration of the whole
dump. This option automatically turns off
<a class="link" href="mysqldump.html#option_mysqldump_single-transaction">
<code class="option">
--single-transaction
</code>
</a>
and
<a class="link" href="mysqldump.html#option_mysqldump_lock-tables">
<code class="option">
--lock-tables
</code>
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_lock-tables">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_lock-tables">
<code class="option">
--lock-tables
</code>
</a>
,
<code class="option">
-l
</code>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for lock-tables">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--lock-tables
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045312138528">
</a>
<a class="indexterm" name="idm46045312137040">
</a>
<p>
For each dumped database, lock all tables to be dumped
before dumping them. The tables are locked with
<code class="literal">
READ LOCAL
</code>
to permit concurrent inserts
in the case of
<code class="literal">
MyISAM
</code>
tables. For
transactional tables such as
<code class="literal">
InnoDB
</code>
,
<a class="link" href="mysqldump.html#option_mysqldump_single-transaction">
<code class="option">
--single-transaction
</code>
</a>
is a
much better option than
<code class="option">
--lock-tables
</code>
because it does not need to lock the tables at all.
</p>
<p>
Because
<code class="option">
--lock-tables
</code>
locks tables for each
database separately, this option does not guarantee that the
tables in the dump file are logically consistent between
databases. Tables in different databases may be dumped in
completely different states.
</p>
<p>
Some options, such as
<a class="link" href="mysqldump.html#option_mysqldump_opt">
<code class="option">
--opt
</code>
</a>
, automatically
enable
<code class="option">
--lock-tables
</code>
. If you want to
override this, use
<code class="option">
--skip-lock-tables
</code>
at
the end of the option list.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_no-autocommit">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_no-autocommit">
<code class="option">
--no-autocommit
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for no-autocommit">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--no-autocommit
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045312120000">
</a>
<a class="indexterm" name="idm46045312118512">
</a>
<p>
Enclose the
<a class="link" href="insert.html" title="15.2.7 INSERT Statement">
<code class="literal">
INSERT
</code>
</a>
statements
for each dumped table within
<code class="literal">
SET autocommit =
0
</code>
and
<a class="link" href="commit.html" title="15.3.1 START TRANSACTION, COMMIT, and ROLLBACK Statements">
<code class="literal">
COMMIT
</code>
</a>
statements.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_order-by-primary">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_order-by-primary">
<code class="option">
--order-by-primary
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for order-by-primary">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--order-by-primary
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045312105504">
</a>
<a class="indexterm" name="idm46045312104016">
</a>
<p>
Dump each table's rows sorted by its primary key, or by its
first unique index, if such an index exists. This is useful
when dumping a
<code class="literal">
MyISAM
</code>
table to be loaded
into an
<code class="literal">
InnoDB
</code>
table, but makes the dump
operation take considerably longer.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_shared-memory-base-name">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_shared-memory-base-name">
<code class="option">
--shared-memory-base-name=
<em class="replaceable">
<code>
name
</code>
</em>
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for shared-memory-base-name">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--shared-memory-base-name=name
</code>
</td>
</tr>
<tr>
<th>
Platform Specific
</th>
<td>
Windows
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045312089264">
</a>
<a class="indexterm" name="idm46045312087760">
</a>
<p>
On Windows, the shared-memory name to use for connections
made using shared memory to a local server. The default
value is
<code class="literal">
MYSQL
</code>
. The shared-memory name is
case-sensitive.
</p>
<p>
This option applies only if the server was started with the
<a class="link" href="server-system-variables.html#sysvar_shared_memory">
<code class="literal">
shared_memory
</code>
</a>
system
variable enabled to support shared-memory connections.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysqldump_single-transaction">
</a>
<a class="link" href="mysqldump.html#option_mysqldump_single-transaction">
<code class="option">
--single-transaction
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for single-transaction">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--single-transaction
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045312075504">
</a>
<a class="indexterm" name="idm46045312074000">
</a>
<p>
This option sets the transaction isolation mode to
<a class="link" href="innodb-transaction-isolation-levels.html#isolevel_repeatable-read">
<code class="literal">
REPEATABLE READ
</code>
</a>
and sends
a
<a class="link" href="commit.html" title="15.3.1 START TRANSACTION, COMMIT, and ROLLBACK Statements">
<code class="literal">
START
TRANSACTION
</code>
</a>
SQL statement to the server before
dumping data. It is useful only with transactional tables
such as
<code class="literal">
InnoDB
</code>
, because then it dumps the
consistent state of the database at the time when
<a class="link" href="commit.html" title="15.3.1 START TRANSACTION, COMMIT, and ROLLBACK Statements">
<code class="literal">
START
TRANSACTION
</code>
</a>
was issued without blocking any
applications.
</p>
<p>
The
<a class="link" href="privileges-provided.html#priv_reload">
<code class="literal">
RELOAD
</code>
</a>
or
<a class="link" href="privileges-provided.html#priv_flush-tables">
<code class="literal">
FLUSH_TABLES
</code>
</a>
privilege is
required with
<a class="link" href="mysqldump.html#option_mysqldump_single-transaction">
<code class="option">
--single-transaction
</code>
</a>
if
both
<a class="link" href="replication-options-gtids.html#sysvar_gtid_mode">
<code class="literal">
gtid_mode=ON
</code>
</a>
and
<a class="link" href="replication-options-gtids.html#sysvar_gtid_purged">
<code class="literal">
gtid_purged=ON|AUTO
</code>
</a>
.
</p>
<p>
When using this option, you should keep in mind that only
<code class="literal">
InnoDB
</code>
tables are dumped in a consistent
state. For example, any
<code class="literal">
MyISAM
</code>
or
<code class="literal">
MEMORY
</code>
tables dumped while using this
option may still change state.
</p>
<p>
While a
<a class="link" href="mysqldump.html#option_mysqldump_single-transaction">
<code class="option">
--single-transaction
</code>
</a>
dump
is in process, to ensure a valid dump file (correct table
contents and binary log coordinates), no other connection
should use the following statements:
<a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
<code class="literal">
ALTER TABLE
</code>
</a>
,
<a class="link" href="create-table.html" title="15.1.20 CREATE TABLE Statement">
<code class="literal">
CREATE TABLE
</code>
</a>
,
<a class="link" href="drop-table.html" title="15.1.32 DROP TABLE Statement">
<code class="literal">
DROP TABLE
</code>
</a>
,
<a class="link" href="rename-table.html" title="15.1.36 RENAME TABLE Statement">
<code class="literal">
RENAME TABLE
</code>
</a>
,
<a class="link" href="truncate-table.html" title="15.1.37 TRUNCATE TABLE Statement">
<code class="literal">
TRUNCATE TABLE
</code>
</a>
. A consistent
read is not isolated from those statements, so use of them
on a table to be dumped can cause the
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
that is performed by
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
to retrieve the table contents
to obtain incorrect contents or fail.
</p>
<p>
The
<code class="option">
--single-transaction
</code>
option and the
<a class="link" href="mysqldump.html#option_mysqldump_lock-tables">
<code class="option">
--lock-tables
</code>
</a>
option are
mutually exclusive because
<a class="link" href="lock-tables.html" title="15.3.6 LOCK TABLES and UNLOCK TABLES Statements">
<code class="literal">
LOCK
TABLES
</code>
</a>
causes any pending transactions to be
committed implicitly.
</p>
<p>
To dump large tables, combine the
<code class="option">
--single-transaction
</code>
option with the
<a class="link" href="mysqldump.html#option_mysqldump_quick">
<code class="option">
--quick
</code>
</a>
option.
</p>
</li>
</ul>
</div>
<h4>
<a name="mysqldump-option-groups">
</a>
Option Groups
</h4>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
The
<a class="link" href="mysqldump.html#option_mysqldump_opt">
<code class="option">
--opt
</code>
</a>
option turns on
several settings that work together to perform a fast dump
operation. All of these settings are on by default, because
<code class="option">
--opt
</code>
is on by default. Thus you rarely if
ever specify
<code class="literal">
--opt
</code>
. Instead, you can turn
these settings off as a group by specifying
<code class="literal">
--skip-opt
</code>
, then optionally re-enable
certain settings by specifying the associated options later
on the command line.
</p>
</li>
<li class="listitem">
<p>
The
<a class="link" href="mysqldump.html#option_mysqldump_compact">
<code class="option">
--compact
</code>
</a>
option turns
off several settings that control whether optional
statements and comments appear in the output. Again, you can
follow this option with other options that re-enable certain
settings, or turn all the settings on by using the
<code class="literal">
--skip-compact
</code>
form.
</p>
</li>
</ul>
</div>
<p>
When you selectively enable or disable the effect of a group
option, order is important because options are processed first
to last. For example,
<a class="link" href="mysqldump.html#option_mysqldump_disable-keys">
<code class="option">
--disable-keys
</code>
</a>
<a class="link" href="mysqldump.html#option_mysqldump_lock-tables">
<code class="option">
--lock-tables
</code>
</a>
<a class="link" href="mysqldump.html#option_mysqldump_skip-opt">
<code class="option">
--skip-opt
</code>
</a>
would not have the
intended effect; it is the same as
<a class="link" href="mysqldump.html#option_mysqldump_skip-opt">
<code class="option">
--skip-opt
</code>
</a>
by itself.
</p>
<h4>
<a name="mysqldump-option-examples">
</a>
Examples
</h4>
<p>
To make a backup of an entire database:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa33251401"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal">mysqldump <em class="replaceable">db_name</em> > <em class="replaceable">backup-file<span class="token punctuation">.</span>sql</em></code></pre>
</div>
<p>
To load the dump file back into the server:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa43436026"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal">mysql <em class="replaceable">db_name</em> < <em class="replaceable">backup-file<span class="token punctuation">.</span>sql</em></code></pre>
</div>
<p>
Another way to reload the dump file:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa22096539"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal">mysql <span class="token property">-e</span> <span class="token atrule">"source <em class="replaceable">/path-to-backup/backup-file.sql</em>"</span> <em class="replaceable">db_name</em></code></pre>
</div>
<p>
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
is also very useful for populating
databases by copying data from one MySQL server to another:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa89089641"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal">mysqldump <span class="token property">--opt</span> <em class="replaceable">db_name</em> | mysql <span class="token constant">--host</span><span class="token attr-value"><span class="token punctuation">=</span><em class="replaceable">remote_host</em></span> <span class="token property">-C</span> <em class="replaceable">db_name</em></code></pre>
</div>
<p>
You can dump several databases with one command:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa86544729"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal">mysqldump <span class="token property">--databases</span> <em class="replaceable">db_name1</em> <span class="token punctuation">[</span><em class="replaceable">db_name2</em> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">]</span> > my_databases<span class="token punctuation">.</span>sql</code></pre>
</div>
<p>
To dump all databases, use the
<a class="link" href="mysqldump.html#option_mysqldump_all-databases">
<code class="option">
--all-databases
</code>
</a>
option:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa40737"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal">mysqldump <span class="token property">--all-databases</span> > all_databases<span class="token punctuation">.</span>sql</code></pre>
</div>
<p>
For
<code class="literal">
InnoDB
</code>
tables,
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
provides a way of making an online
backup:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa54839139"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal">mysqldump <span class="token property">--all-databases</span> <span class="token property">--source-data</span> <span class="token property">--single-transaction</span> > all_databases<span class="token punctuation">.</span>sql</code></pre>
</div>
<p>
This backup acquires a global read lock on all tables (using
<a class="link" href="flush.html#flush-tables-with-read-lock">
<code class="literal">
FLUSH TABLES WITH READ LOCK
</code>
</a>
) at
the beginning of the dump. As soon as this lock has been
acquired, the binary log coordinates are read and the lock is
released. If long updating statements are running when the
<a class="link" href="flush.html" title="15.7.8.3 FLUSH Statement">
<code class="literal">
FLUSH
</code>
</a>
statement is issued, the
MySQL server may get stalled until those statements finish.
After that, the dump becomes lock free and does not disturb
reads and writes on the tables. If the update statements that
the MySQL server receives are short (in terms of execution
time), the initial lock period should not be noticeable, even
with many updates.
</p>
<p>
For point-in-time recovery (also known as
<span class="quote">
“
<span class="quote">
roll-forward,
</span>
”
</span>
when you need to restore an old
backup and replay the changes that happened since that backup),
it is often useful to rotate the binary log (see
<a class="xref" href="binary-log.html" title="7.4.4 The Binary Log">
Section 7.4.4, “The Binary Log”
</a>
) or at least know the binary log
coordinates to which the dump corresponds:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa98455149"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal">mysqldump <span class="token property">--all-databases</span> <span class="token constant">--source-data</span><span class="token attr-value"><span class="token punctuation">=</span>2</span> > all_databases<span class="token punctuation">.</span>sql</code></pre>
</div>
<p>
Or:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa29797200"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal">mysqldump <span class="token property">--all-databases</span> <span class="token property">--flush-logs</span> <span class="token constant">--source-data</span><span class="token attr-value"><span class="token punctuation">=</span>2</span> > all_databases<span class="token punctuation">.</span>sql</code></pre>
</div>
<p>
The
<a class="link" href="mysqldump.html#option_mysqldump_source-data">
<code class="option">
--source-data
</code>
</a>
option can
be used simultaneously with the
<a class="link" href="mysqldump.html#option_mysqldump_single-transaction">
<code class="option">
--single-transaction
</code>
</a>
option,
which provides a convenient way to make an online backup
suitable for use prior to point-in-time recovery if tables are
stored using the
<code class="literal">
InnoDB
</code>
storage engine.
</p>
<p>
For more information on making backups, see
<a class="xref" href="backup-methods.html" title="9.2 Database Backup Methods">
Section 9.2, “Database Backup Methods”
</a>
, and
<a class="xref" href="backup-strategy-example.html" title="9.3 Example Backup and Recovery Strategy">
Section 9.3, “Example Backup and Recovery Strategy”
</a>
.
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
To select the effect of
<a class="link" href="mysqldump.html#option_mysqldump_opt">
<code class="option">
--opt
</code>
</a>
except for some
features, use the
<code class="option">
--skip
</code>
option for each
feature. To disable extended inserts and memory buffering,
use
<a class="link" href="mysqldump.html#option_mysqldump_opt">
<code class="option">
--opt
</code>
</a>
<a class="link" href="mysqldump.html#option_mysqldump_extended-insert">
<code class="option">
--skip-extended-insert
</code>
</a>
<a class="link" href="mysqldump.html#option_mysqldump_quick">
<code class="option">
--skip-quick
</code>
</a>
.
(Actually,
<a class="link" href="mysqldump.html#option_mysqldump_extended-insert">
<code class="option">
--skip-extended-insert
</code>
</a>
<a class="link" href="mysqldump.html#option_mysqldump_quick">
<code class="option">
--skip-quick
</code>
</a>
is sufficient because
<a class="link" href="mysqldump.html#option_mysqldump_opt">
<code class="option">
--opt
</code>
</a>
is on by default.)
</p>
</li>
<li class="listitem">
<p>
To reverse
<a class="link" href="mysqldump.html#option_mysqldump_opt">
<code class="option">
--opt
</code>
</a>
for all
features except disabling of indexes and table locking, use
<a class="link" href="mysqldump.html#option_mysqldump_skip-opt">
<code class="option">
--skip-opt
</code>
</a>
<a class="link" href="mysqldump.html#option_mysqldump_disable-keys">
<code class="option">
--disable-keys
</code>
</a>
<a class="link" href="mysqldump.html#option_mysqldump_lock-tables">
<code class="option">
--lock-tables
</code>
</a>
.
</p>
</li>
</ul>
</div>
<h4>
<a name="mysqldump-restrictions">
</a>
Restrictions
</h4>
<a class="indexterm" name="idm46045311980720">
</a>
<a class="indexterm" name="idm46045311979232">
</a>
<a class="indexterm" name="idm46045311977744">
</a>
<p>
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
does not dump the
<code class="literal">
performance_schema
</code>
or
<code class="literal">
sys
</code>
schema by default. To dump any of these, name them explicitly on
the command line. You can also name them with the
<a class="link" href="mysqldump.html#option_mysqldump_databases">
<code class="option">
--databases
</code>
</a>
option. For
<code class="literal">
performance_schema
</code>
, also use the
<a class="link" href="mysqldump.html#option_mysqldump_lock-tables">
<code class="option">
--skip-lock-tables
</code>
</a>
option.
</p>
<p>
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
does not dump the
<code class="literal">
INFORMATION_SCHEMA
</code>
schema.
</p>
<p>
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
does not dump
<code class="literal">
InnoDB
</code>
<a class="link" href="create-tablespace.html" title="15.1.21 CREATE TABLESPACE Statement">
<code class="literal">
CREATE
TABLESPACE
</code>
</a>
statements.
</p>
<p>
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
does not dump the NDB Cluster
<a class="link" href="mysql-cluster-ndbinfo.html" title="25.6.17 ndbinfo: The NDB Cluster Information Database">
<code class="literal">
ndbinfo
</code>
</a>
information database.
</p>
<p>
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
includes statements to recreate the
<code class="literal">
general_log
</code>
and
<code class="literal">
slow_query_log
</code>
tables for dumps of the
<code class="literal">
mysql
</code>
database. Log table contents are not
dumped.
</p>
<p>
If you encounter problems backing up views due to insufficient
privileges, see
<a class="xref" href="view-restrictions.html" title="27.9 Restrictions on Views">
Section 27.9, “Restrictions on Views”
</a>
for a
workaround.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/innodb-locking-reads.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="innodb-locking-reads">
</a>
17.7.2.4 Locking Reads
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045164140432">
</a>
<p>
If you query data and then insert or update related data within
the same transaction, the regular
<code class="literal">
SELECT
</code>
statement does not give enough protection. Other transactions
can update or delete the same rows you just queried.
<code class="literal">
InnoDB
</code>
supports two types of
<a class="link" href="glossary.html#glos_locking_read" title="locking read">
locking reads
</a>
that
offer extra safety:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT ... FOR
SHARE
</code>
</a>
</p>
<p>
Sets a shared mode lock on any rows that are read. Other
sessions can read the rows, but cannot modify them until
your transaction commits. If any of these rows were changed
by another transaction that has not yet committed, your
query waits until that transaction ends and then uses the
latest values.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
<code class="literal">
SELECT ... FOR SHARE
</code>
is a replacement
for
<code class="literal">
SELECT ... LOCK IN SHARE MODE
</code>
, but
<code class="literal">
LOCK IN SHARE MODE
</code>
remains available
for backward compatibility. The statements are equivalent.
However,
<code class="literal">
FOR SHARE
</code>
supports
<code class="literal">
OF
<em class="replaceable">
<code>
table_name
</code>
</em>
</code>
,
<code class="literal">
NOWAIT
</code>
, and
<code class="literal">
SKIP
LOCKED
</code>
options. See
<a class="xref" href="innodb-locking-reads.html#innodb-locking-reads-nowait-skip-locked" title="Locking Read Concurrency with NOWAIT and SKIP LOCKED">
Locking Read Concurrency with NOWAIT and SKIP LOCKED
</a>
.
</p>
</div>
<p>
<code class="literal">
SELECT ... FOR SHARE
</code>
requires the
<a class="link" href="privileges-provided.html#priv_select">
<code class="literal">
SELECT
</code>
</a>
privilege.
</p>
<p>
<code class="literal">
SELECT ... FOR SHARE
</code>
statements do not
acquire read locks on MySQL grant tables. For more
information, see
<a class="xref" href="grant-tables.html#grant-tables-concurrency" title="Grant Table Concurrency">
Grant Table Concurrency
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT ... FOR
UPDATE
</code>
</a>
</p>
<p>
For index records the search encounters, locks the rows and
any associated index entries, the same as if you issued an
<code class="literal">
UPDATE
</code>
statement for those rows. Other
transactions are blocked from updating those rows, from
doing
<code class="literal">
SELECT ... FOR SHARE
</code>
, or from
reading the data in certain transaction isolation levels.
Consistent reads ignore any locks set on the records that
exist in the read view. (Old versions of a record cannot be
locked; they are reconstructed by applying
<a class="link" href="glossary.html#glos_undo_log" title="undo log">
undo logs
</a>
on an
in-memory copy of the record.)
</p>
<p>
<code class="literal">
SELECT ... FOR UPDATE
</code>
requires the
<a class="link" href="privileges-provided.html#priv_select">
<code class="literal">
SELECT
</code>
</a>
privilege and at least
one of the
<a class="link" href="privileges-provided.html#priv_delete">
<code class="literal">
DELETE
</code>
</a>
,
<a class="link" href="privileges-provided.html#priv_lock-tables">
<code class="literal">
LOCK TABLES
</code>
</a>
, or
<a class="link" href="privileges-provided.html#priv_update">
<code class="literal">
UPDATE
</code>
</a>
privileges.
</p>
</li>
</ul>
</div>
<p>
These clauses are primarily useful when dealing with
tree-structured or graph-structured data, either in a single
table or split across multiple tables. You traverse edges or
tree branches from one place to another, while reserving the
right to come back and change any of these
<span class="quote">
“
<span class="quote">
pointer
</span>
”
</span>
values.
</p>
<p>
All locks set by
<code class="literal">
FOR SHARE
</code>
and
<code class="literal">
FOR
UPDATE
</code>
queries are released when the transaction is
committed or rolled back.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
Locking reads are only possible when autocommit is disabled
(either by beginning transaction with
<a class="link" href="commit.html" title="15.3.1 START TRANSACTION, COMMIT, and ROLLBACK Statements">
<code class="literal">
START
TRANSACTION
</code>
</a>
or by setting
<a class="link" href="server-system-variables.html#sysvar_autocommit">
<code class="literal">
autocommit
</code>
</a>
to 0.
</p>
</div>
<p>
A locking read clause in an outer statement does not lock the
rows of a table in a nested subquery unless a locking read
clause is also specified in the subquery. For example, the
following statement does not lock rows in table
<code class="literal">
t2
</code>
.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa56871349"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t1 <span class="token keyword">WHERE</span> c1 <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token keyword">SELECT</span> c1 <span class="token keyword">FROM</span> t2<span class="token punctuation">)</span> <span class="token keyword">FOR</span> <span class="token keyword">UPDATE</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
To lock rows in table
<code class="literal">
t2
</code>
, add a locking read
clause to the subquery:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa13957535"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t1 <span class="token keyword">WHERE</span> c1 <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token keyword">SELECT</span> c1 <span class="token keyword">FROM</span> t2 <span class="token keyword">FOR</span> <span class="token keyword">UPDATE</span><span class="token punctuation">)</span> <span class="token keyword">FOR</span> <span class="token keyword">UPDATE</span><span class="token punctuation">;</span></code></pre>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="innodb-locking-reads-examples">
</a>
Locking Read Examples
</h5>
</div>
</div>
</div>
<p>
Suppose that you want to insert a new row into a table
<code class="literal">
child
</code>
, and make sure that the child row has
a parent row in table
<code class="literal">
parent
</code>
. Your
application code can ensure referential integrity throughout
this sequence of operations.
</p>
<p>
First, use a consistent read to query the table
<code class="literal">
PARENT
</code>
and verify that the parent row
exists. Can you safely insert the child row to table
<code class="literal">
CHILD
</code>
? No, because some other session could
delete the parent row in the moment between your
<code class="literal">
SELECT
</code>
and your
<code class="literal">
INSERT
</code>
,
without you being aware of it.
</p>
<p>
To avoid this potential issue, perform the
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
using
<code class="literal">
FOR
SHARE
</code>
:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa43269645"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> parent <span class="token keyword">WHERE</span> <span class="token keyword">NAME</span> <span class="token operator">=</span> <span class="token string">'Jones'</span> <span class="token keyword">FOR</span> <span class="token keyword">SHARE</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
After the
<code class="literal">
FOR SHARE
</code>
query returns the
parent
<code class="literal">
'Jones'
</code>
, you can safely add the
child record to the
<code class="literal">
CHILD
</code>
table and commit
the transaction. Any transaction that tries to acquire an
exclusive lock in the applicable row in the
<code class="literal">
PARENT
</code>
table waits until you are finished,
that is, until the data in all tables is in a consistent
state.
</p>
<p>
For another example, consider an integer counter field in a
table
<code class="literal">
CHILD_CODES
</code>
, used to assign a unique
identifier to each child added to table
<code class="literal">
CHILD
</code>
. Do not use either consistent read or
a shared mode read to read the present value of the counter,
because two users of the database could see the same value for
the counter, and a duplicate-key error occurs if two
transactions attempt to add rows with the same identifier to
the
<code class="literal">
CHILD
</code>
table.
</p>
<p>
Here,
<code class="literal">
FOR SHARE
</code>
is not a good solution
because if two users read the counter at the same time, at
least one of them ends up in deadlock when it attempts to
update the counter.
</p>
<p>
To implement reading and incrementing the counter, first
perform a locking read of the counter using
<code class="literal">
FOR
UPDATE
</code>
, and then increment the counter. For example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa89834019"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> counter_field <span class="token keyword">FROM</span> child_codes <span class="token keyword">FOR</span> <span class="token keyword">UPDATE</span><span class="token punctuation">;</span>
<span class="token keyword">UPDATE</span> child_codes <span class="token keyword">SET</span> counter_field <span class="token operator">=</span> counter_field <span class="token operator">+</span> <span class="token number">1</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
A
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT ... FOR
UPDATE
</code>
</a>
reads the latest available data, setting
exclusive locks on each row it reads. Thus, it sets the same
locks a searched SQL
<a class="link" href="update.html" title="15.2.17 UPDATE Statement">
<code class="literal">
UPDATE
</code>
</a>
would set on the rows.
</p>
<p>
The preceding description is merely an example of how
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT ... FOR
UPDATE
</code>
</a>
works. In MySQL, the specific task of
generating a unique identifier actually can be accomplished
using only a single access to the table:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa14213368"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">UPDATE</span> child_codes <span class="token keyword">SET</span> counter_field <span class="token operator">=</span> <span class="token function">LAST_INSERT_ID</span><span class="token punctuation">(</span>counter_field <span class="token operator">+</span> <span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">SELECT</span> <span class="token function">LAST_INSERT_ID</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
The
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
statement merely
retrieves the identifier information (specific to the current
connection). It does not access any table.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="innodb-locking-reads-nowait-skip-locked">
</a>
Locking Read Concurrency with NOWAIT and SKIP LOCKED
</h5>
</div>
</div>
</div>
<a class="indexterm" name="idm46045164069792">
</a>
<a class="indexterm" name="idm46045164068720">
</a>
<a class="indexterm" name="idm46045164067232">
</a>
<p>
If a row is locked by a transaction, a
<code class="literal">
SELECT ... FOR
UPDATE
</code>
or
<code class="literal">
SELECT ... FOR SHARE
</code>
transaction that requests the same locked row must wait until
the blocking transaction releases the row lock. This behavior
prevents transactions from updating or deleting rows that are
queried for updates by other transactions. However, waiting
for a row lock to be released is not necessary if you want the
query to return immediately when a requested row is locked, or
if excluding locked rows from the result set is acceptable.
</p>
<p>
To avoid waiting for other transactions to release row locks,
<code class="literal">
NOWAIT
</code>
and
<code class="literal">
SKIP LOCKED
</code>
options may be used with
<code class="literal">
SELECT ... FOR
UPDATE
</code>
or
<code class="literal">
SELECT ... FOR SHARE
</code>
locking read statements.
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
NOWAIT
</code>
</p>
<p>
A locking read that uses
<code class="literal">
NOWAIT
</code>
never
waits to acquire a row lock. The query executes
immediately, failing with an error if a requested row is
locked.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SKIP LOCKED
</code>
</p>
<p>
A locking read that uses
<code class="literal">
SKIP LOCKED
</code>
never waits to acquire a row lock. The query executes
immediately, removing locked rows from the result set.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
Queries that skip locked rows return an inconsistent
view of the data.
<code class="literal">
SKIP LOCKED
</code>
is
therefore not suitable for general transactional work.
However, it may be used to avoid lock contention when
multiple sessions access the same queue-like table.
</p>
</div>
</li>
</ul>
</div>
<p>
<code class="literal">
NOWAIT
</code>
and
<code class="literal">
SKIP LOCKED
</code>
only apply to row-level locks.
</p>
<p>
Statements that use
<code class="literal">
NOWAIT
</code>
or
<code class="literal">
SKIP
LOCKED
</code>
are unsafe for statement based replication.
</p>
<p>
The following example demonstrates
<code class="literal">
NOWAIT
</code>
and
<code class="literal">
SKIP LOCKED
</code>
. Session 1 starts a
transaction that takes a row lock on a single record. Session
2 attempts a locking read on the same record using the
<code class="literal">
NOWAIT
</code>
option. Because the requested row is
locked by Session 1, the locking read returns immediately with
an error. In Session 3, the locking read with
<code class="literal">
SKIP
LOCKED
</code>
returns the requested rows except for the row
that is locked by Session 1.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa98052982"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token comment" spellcheck="true"># Session 1:</span>
<span class="token prompt">mysql></span> <span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> t <span class="token punctuation">(</span>i <span class="token datatype">INT</span><span class="token punctuation">,</span> <span class="token keyword">PRIMARY</span> <span class="token keyword">KEY</span> <span class="token punctuation">(</span>i<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token keyword">ENGINE</span> <span class="token operator">=</span> InnoDB<span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">INSERT</span> <span class="token keyword">INTO</span> t <span class="token punctuation">(</span>i<span class="token punctuation">)</span> <span class="token keyword">VALUES</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">,</span><span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">,</span><span class="token punctuation">(</span><span class="token number">3</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">START</span> <span class="token keyword">TRANSACTION</span><span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t <span class="token keyword">WHERE</span> i <span class="token operator">=</span> <span class="token number">2</span> <span class="token keyword">FOR</span> <span class="token keyword">UPDATE</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> i <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 2 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token comment" spellcheck="true"># Session 2:</span>
<span class="token prompt">mysql></span> <span class="token keyword">START</span> <span class="token keyword">TRANSACTION</span><span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t <span class="token keyword">WHERE</span> i <span class="token operator">=</span> <span class="token number">2</span> <span class="token keyword">FOR</span> <span class="token keyword">UPDATE</span> <span class="token keyword">NOWAIT</span><span class="token punctuation">;</span>
<span class="token output">ERROR 3572 (HY000)<span class="token punctuation">:</span> Do not wait for lock.
# Session 3<span class="token punctuation">:</span>
</span>
<span class="token prompt">mysql></span> <span class="token keyword">START</span> <span class="token keyword">TRANSACTION</span><span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t <span class="token keyword">FOR</span> <span class="token keyword">UPDATE</span> <span class="token keyword">SKIP</span> <span class="token keyword">LOCKED</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> i <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 1 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 3 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/federated-create-server.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="federated-create-server">
</a>
18.8.2.2 Creating a FEDERATED Table Using CREATE SERVER
</h4>
</div>
</div>
</div>
<p>
If you are creating a number of
<code class="literal">
FEDERATED
</code>
tables on the same server, or if you want to simplify the
process of creating
<code class="literal">
FEDERATED
</code>
tables, you can
use the
<a class="link" href="create-server.html" title="15.1.18 CREATE SERVER Statement">
<code class="literal">
CREATE SERVER
</code>
</a>
statement
to define the server connection parameters, just as you would
with the
<code class="literal">
CONNECTION
</code>
string.
</p>
<p>
The format of the
<a class="link" href="create-server.html" title="15.1.18 CREATE SERVER Statement">
<code class="literal">
CREATE SERVER
</code>
</a>
statement is:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa34086101"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">CREATE</span> <span class="token keyword">SERVER</span>
<em class="replaceable">server_name</em>
<span class="token keyword">FOREIGN</span> <span class="token keyword">DATA</span> <span class="token keyword">WRAPPER</span> <em class="replaceable">wrapper_name</em>
<span class="token keyword">OPTIONS</span> <span class="token punctuation">(</span><span class="token keyword"><em class="replaceable">option</em></span> <span class="token punctuation">[</span><span class="token punctuation">,</span> <span class="token keyword"><em class="replaceable">option</em></span><span class="token punctuation">]</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">)</span></code></pre>
</div>
<p>
The
<em class="replaceable">
<code>
server_name
</code>
</em>
is used in the
connection string when creating a new
<code class="literal">
FEDERATED
</code>
table.
</p>
<p>
For example, to create a server connection identical to the
<code class="literal">
CONNECTION
</code>
string:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa64174702"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">CONNECTION</span><span class="token operator">=</span><span class="token string">'mysql://fed_user@remote_host:9306/federated/test_table'</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
You would use the following statement:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa28990826"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">CREATE</span> <span class="token keyword">SERVER</span> fedlink
<span class="token keyword">FOREIGN</span> <span class="token keyword">DATA</span> <span class="token keyword">WRAPPER</span> mysql
<span class="token keyword">OPTIONS</span> <span class="token punctuation">(</span><span class="token keyword">USER</span> <span class="token string">'fed_user'</span><span class="token punctuation">,</span> <span class="token keyword">HOST</span> <span class="token string">'remote_host'</span><span class="token punctuation">,</span> <span class="token keyword">PORT</span> <span class="token number">9306</span><span class="token punctuation">,</span> <span class="token keyword">DATABASE</span> <span class="token string">'federated'</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
To create a
<code class="literal">
FEDERATED
</code>
table that uses this
connection, you still use the
<code class="literal">
CONNECTION
</code>
keyword, but specify the name you used in the
<a class="link" href="create-server.html" title="15.1.18 CREATE SERVER Statement">
<code class="literal">
CREATE SERVER
</code>
</a>
statement.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa62045270"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> test_table <span class="token punctuation">(</span>
id <span class="token datatype">INT</span><span class="token punctuation">(</span><span class="token number">20</span><span class="token punctuation">)</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span> <span class="token keyword">AUTO_INCREMENT</span><span class="token punctuation">,</span>
<span class="token keyword">name</span> <span class="token datatype">VARCHAR</span><span class="token punctuation">(</span><span class="token number">32</span><span class="token punctuation">)</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span> <span class="token keyword">DEFAULT</span> <span class="token string">''</span><span class="token punctuation">,</span>
other <span class="token datatype">INT</span><span class="token punctuation">(</span><span class="token number">20</span><span class="token punctuation">)</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span> <span class="token keyword">DEFAULT</span> <span class="token string">'0'</span><span class="token punctuation">,</span>
<span class="token keyword">PRIMARY</span> <span class="token keyword">KEY</span> <span class="token punctuation">(</span>id<span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token keyword">INDEX</span> <span class="token keyword">name</span> <span class="token punctuation">(</span><span class="token keyword">name</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token keyword">INDEX</span> other_key <span class="token punctuation">(</span>other<span class="token punctuation">)</span>
<span class="token punctuation">)</span>
<span class="token keyword">ENGINE</span><span class="token operator">=</span>FEDERATED
<span class="token keyword">DEFAULT</span> <span class="token keyword">CHARSET</span><span class="token operator">=</span>utf8mb4
<span class="token keyword">CONNECTION</span><span class="token operator">=</span><span class="token string">'fedlink/test_table'</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
The connection name in this example contains the name of the
connection (
<code class="literal">
fedlink
</code>
) and the name of the
table (
<code class="literal">
test_table
</code>
) to link to, separated by a
slash. If you specify only the connection name without a table
name, the table name of the local table is used instead.
</p>
<p>
For more information on
<a class="link" href="create-server.html" title="15.1.18 CREATE SERVER Statement">
<code class="literal">
CREATE
SERVER
</code>
</a>
, see
<a class="xref" href="create-server.html" title="15.1.18 CREATE SERVER Statement">
Section 15.1.18, “CREATE SERVER Statement”
</a>
.
</p>
<p>
The
<a class="link" href="create-server.html" title="15.1.18 CREATE SERVER Statement">
<code class="literal">
CREATE SERVER
</code>
</a>
statement
accepts the same arguments as the
<code class="literal">
CONNECTION
</code>
string. The
<a class="link" href="create-server.html" title="15.1.18 CREATE SERVER Statement">
<code class="literal">
CREATE SERVER
</code>
</a>
statement updates the rows in the
<code class="literal">
mysql.servers
</code>
table. See the following table
for information on the correspondence between parameters in a
connection string, options in the
<a class="link" href="create-server.html" title="15.1.18 CREATE SERVER Statement">
<code class="literal">
CREATE
SERVER
</code>
</a>
statement, and the columns in the
<code class="literal">
mysql.servers
</code>
table. For reference, the
format of the
<code class="literal">
CONNECTION
</code>
string is as
follows:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-none"><div class="docs-select-all right" id="sa15090453"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-none"><em class="replaceable">scheme</em>://<em class="replaceable">user_name</em>[:<em class="replaceable">password</em>]@<em class="replaceable">host_name</em>[:<em class="replaceable">port_num</em>]/<em class="replaceable">db_name</em>/<em class="replaceable">tbl_name</em></code></pre>
</div>
<div class="informaltable">
<table summary="The correspondence between parameters in a connection string, options in the CREATE SERVER statement, and the columns in the mysql.servers table.">
<colgroup>
<col style="width: 25%"/>
<col style="width: 25%"/>
<col style="width: 25%"/>
<col style="width: 25%"/>
</colgroup>
<thead>
<tr>
<th scope="col">
Description
</th>
<th scope="col">
<code class="literal">
CONNECTION
</code>
string
</th>
<th scope="col">
<a class="link" href="create-server.html" title="15.1.18 CREATE SERVER Statement">
<code class="literal">
CREATE SERVER
</code>
</a>
option
</th>
<th scope="col">
<code class="literal">
mysql.servers
</code>
column
</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">
Connection scheme
</th>
<td>
<em class="replaceable">
<code>
scheme
</code>
</em>
</td>
<td>
<code class="literal">
wrapper_name
</code>
</td>
<td>
<code class="literal">
Wrapper
</code>
</td>
</tr>
<tr>
<th scope="row">
Remote user
</th>
<td>
<em class="replaceable">
<code>
user_name
</code>
</em>
</td>
<td>
<code class="literal">
USER
</code>
</td>
<td>
<code class="literal">
Username
</code>
</td>
</tr>
<tr>
<th scope="row">
Remote password
</th>
<td>
<em class="replaceable">
<code>
password
</code>
</em>
</td>
<td>
<code class="literal">
PASSWORD
</code>
</td>
<td>
<code class="literal">
Password
</code>
</td>
</tr>
<tr>
<th scope="row">
Remote host
</th>
<td>
<em class="replaceable">
<code>
host_name
</code>
</em>
</td>
<td>
<code class="literal">
HOST
</code>
</td>
<td>
<code class="literal">
Host
</code>
</td>
</tr>
<tr>
<th scope="row">
Remote port
</th>
<td>
<em class="replaceable">
<code>
port_num
</code>
</em>
</td>
<td>
<code class="literal">
PORT
</code>
</td>
<td>
<code class="literal">
Port
</code>
</td>
</tr>
<tr>
<th scope="row">
Remote database
</th>
<td>
<em class="replaceable">
<code>
db_name
</code>
</em>
</td>
<td>
<code class="literal">
DATABASE
</code>
</td>
<td>
<code class="literal">
Db
</code>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/grant.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="grant">
</a>
15.7.1.6 GRANT Statement
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045173992352">
</a>
<a class="indexterm" name="idm46045173991280">
</a>
<a class="indexterm" name="idm46045173990192">
</a>
<a class="indexterm" name="idm46045173988704">
</a>
<a class="indexterm" name="idm46045173987632">
</a>
<a class="indexterm" name="idm46045173986144">
</a>
<a class="indexterm" name="idm46045173984656">
</a>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa60414600"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">GRANT</span>
<em class="replaceable">priv_type</em> <span class="token punctuation">[</span><span class="token punctuation">(</span><em class="replaceable">column_list</em><span class="token punctuation">)</span><span class="token punctuation">]</span>
<span class="token punctuation">[</span><span class="token punctuation">,</span> <em class="replaceable">priv_type</em> <span class="token punctuation">[</span><span class="token punctuation">(</span><em class="replaceable">column_list</em><span class="token punctuation">)</span><span class="token punctuation">]</span><span class="token punctuation">]</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
<span class="token keyword">ON</span> <span class="token punctuation">[</span><em class="replaceable">object_type</em><span class="token punctuation">]</span> <em class="replaceable">priv_level</em>
<span class="token keyword">TO</span> <em class="replaceable">user_or_role</em> <span class="token punctuation">[</span><span class="token punctuation">,</span> <em class="replaceable">user_or_role</em><span class="token punctuation">]</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
<span class="token punctuation">[</span><span class="token keyword">WITH</span> <span class="token keyword">GRANT</span> <span class="token keyword">OPTION</span><span class="token punctuation">]</span>
<span class="token punctuation">[</span><span class="token keyword">AS</span> <span class="token keyword"><em class="replaceable">user</em></span>
<span class="token punctuation">[</span><span class="token keyword">WITH</span> <span class="token keyword">ROLE</span>
<span class="token keyword">DEFAULT</span>
<span class="token operator">|</span> <span class="token keyword">NONE</span>
<span class="token operator">|</span> <span class="token keyword">ALL</span>
<span class="token operator">|</span> <span class="token keyword">ALL</span> <span class="token keyword">EXCEPT</span> <span class="token keyword"><em class="replaceable">role</em></span> <span class="token punctuation">[</span><span class="token punctuation">,</span> <span class="token keyword"><em class="replaceable">role</em></span> <span class="token punctuation">]</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
<span class="token operator">|</span> <span class="token keyword"><em class="replaceable">role</em></span> <span class="token punctuation">[</span><span class="token punctuation">,</span> <span class="token keyword"><em class="replaceable">role</em></span> <span class="token punctuation">]</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
<span class="token punctuation">]</span>
<span class="token punctuation">]</span>
}
<span class="token keyword">GRANT</span> <span class="token keyword">PROXY</span> <span class="token keyword">ON</span> <em class="replaceable">user_or_role</em>
<span class="token keyword">TO</span> <em class="replaceable">user_or_role</em> <span class="token punctuation">[</span><span class="token punctuation">,</span> <em class="replaceable">user_or_role</em><span class="token punctuation">]</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
<span class="token punctuation">[</span><span class="token keyword">WITH</span> <span class="token keyword">GRANT</span> <span class="token keyword">OPTION</span><span class="token punctuation">]</span>
<span class="token keyword">GRANT</span> <span class="token keyword"><em class="replaceable">role</em></span> <span class="token punctuation">[</span><span class="token punctuation">,</span> <span class="token keyword"><em class="replaceable">role</em></span><span class="token punctuation">]</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
<span class="token keyword">TO</span> <em class="replaceable">user_or_role</em> <span class="token punctuation">[</span><span class="token punctuation">,</span> <em class="replaceable">user_or_role</em><span class="token punctuation">]</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
<span class="token punctuation">[</span><span class="token keyword">WITH</span> <span class="token keyword">ADMIN</span> <span class="token keyword">OPTION</span><span class="token punctuation">]</span>
<em class="replaceable">object_type</em>: {
<span class="token keyword">TABLE</span>
<span class="token operator">|</span> <span class="token keyword">FUNCTION</span>
<span class="token operator">|</span> <span class="token keyword">PROCEDURE</span>
}
<em class="replaceable">priv_level</em>: {
<span class="token operator">*</span>
<span class="token operator">|</span> <span class="token operator">*</span><span class="token punctuation">.</span><span class="token operator">*</span>
<span class="token operator">|</span> <em class="replaceable">db_name</em><span class="token punctuation">.</span><span class="token operator">*</span>
<span class="token operator">|</span> <em class="replaceable">db_name<span class="token punctuation">.</span>tbl_name</em>
<span class="token operator">|</span> <em class="replaceable">tbl_name</em>
<span class="token operator">|</span> <em class="replaceable">db_name</em><span class="token punctuation">.</span><em class="replaceable">routine_name</em>
}
<em class="replaceable">user_or_role</em>: {
<span class="token function"><em class="replaceable">user</em></span> <span class="token punctuation">(</span>see Section <span class="token number">8.2</span><span class="token punctuation">.</span><span class="token number">4</span><span class="token punctuation">,</span> “Specifying <span class="token keyword">Account</span> <span class="token keyword">Names</span>”<span class="token punctuation">)</span>
<span class="token operator">|</span> <span class="token keyword"><em class="replaceable">role</em></span> <span class="token punctuation">(</span>see Section <span class="token number">8.2</span><span class="token punctuation">.</span><span class="token number">5</span><span class="token punctuation">,</span> “Specifying <span class="token keyword">Role</span> <span class="token keyword">Names</span>”<span class="token punctuation">)</span>
}</code></pre>
</div>
<p>
The
<a class="link" href="grant.html" title="15.7.1.6 GRANT Statement">
<code class="literal">
GRANT
</code>
</a>
statement assigns
privileges and roles to MySQL user accounts and roles. There are
several aspects to the
<a class="link" href="grant.html" title="15.7.1.6 GRANT Statement">
<code class="literal">
GRANT
</code>
</a>
statement, described under the following topics:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="xref" href="grant.html#grant-overview" title="GRANT General Overview">
GRANT General Overview
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="grant.html#grant-quoting" title="Object Quoting Guidelines">
Object Quoting Guidelines
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="grant.html#grant-accounts" title="Account Names">
Account Names
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="grant.html#grant-privileges" title="Privileges Supported by MySQL">
Privileges Supported by MySQL
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="grant.html#grant-global-privileges" title="Global Privileges">
Global Privileges
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="grant.html#grant-database-privileges" title="Database Privileges">
Database Privileges
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="grant.html#grant-table-privileges" title="Table Privileges">
Table Privileges
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="grant.html#grant-column-privileges" title="Column Privileges">
Column Privileges
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="grant.html#grant-routine-privileges" title="Stored Routine Privileges">
Stored Routine Privileges
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="grant.html#grant-proxy-privileges" title="Proxy User Privileges">
Proxy User Privileges
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="grant.html#grant-roles" title="Granting Roles">
Granting Roles
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="grant.html#grant-as" title="The AS Clause and Privilege Restrictions">
The
<code class="literal">
AS
</code>
Clause and Privilege Restrictions
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="grant.html#grant-other-characteristics" title="Other Account Characteristics">
Other Account Characteristics
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="grant.html#grant-mysql-vs-standard-sql" title="MySQL and Standard SQL Versions of GRANT">
MySQL and Standard SQL Versions of GRANT
</a>
</p>
</li>
</ul>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="grant-overview">
</a>
GRANT General Overview
</h5>
</div>
</div>
</div>
<p>
The
<a class="link" href="grant.html" title="15.7.1.6 GRANT Statement">
<code class="literal">
GRANT
</code>
</a>
statement enables
system administrators to grant privileges and roles, which can
be granted to user accounts and roles. These syntax
restrictions apply:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="link" href="grant.html" title="15.7.1.6 GRANT Statement">
<code class="literal">
GRANT
</code>
</a>
cannot mix granting
both privileges and roles in the same statement. A given
<a class="link" href="grant.html" title="15.7.1.6 GRANT Statement">
<code class="literal">
GRANT
</code>
</a>
statement must grant
either privileges or roles.
</p>
</li>
<li class="listitem">
<p>
The
<code class="literal">
ON
</code>
clause distinguishes whether the
statement grants privileges or roles:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
With
<code class="literal">
ON
</code>
, the statement grants
privileges.
</p>
</li>
<li class="listitem">
<p>
Without
<code class="literal">
ON
</code>
, the statement grants
roles.
</p>
</li>
<li class="listitem">
<p>
It is permitted to assign both privileges and roles to
an account, but you must use separate
<a class="link" href="grant.html" title="15.7.1.6 GRANT Statement">
<code class="literal">
GRANT
</code>
</a>
statements, each
with syntax appropriate to what is to be granted.
</p>
</li>
</ul>
</div>
</li>
</ul>
</div>
<p>
For more information about roles, see
<a class="xref" href="roles.html" title="8.2.10 Using Roles">
Section 8.2.10, “Using Roles”
</a>
.
</p>
<p>
To grant a privilege with
<a class="link" href="grant.html" title="15.7.1.6 GRANT Statement">
<code class="literal">
GRANT
</code>
</a>
, you must have the
<a class="link" href="privileges-provided.html#priv_grant-option">
<code class="literal">
GRANT OPTION
</code>
</a>
privilege, and you
must have the privileges that you are granting.
(Alternatively, if you have the
<a class="link" href="privileges-provided.html#priv_update">
<code class="literal">
UPDATE
</code>
</a>
privilege for the grant
tables in the
<code class="literal">
mysql
</code>
system schema, you can
grant any account any privilege.) When the
<a class="link" href="server-system-variables.html#sysvar_read_only">
<code class="literal">
read_only
</code>
</a>
system variable is
enabled,
<a class="link" href="grant.html" title="15.7.1.6 GRANT Statement">
<code class="literal">
GRANT
</code>
</a>
additionally
requires the
<a class="link" href="privileges-provided.html#priv_connection-admin">
<code class="literal">
CONNECTION_ADMIN
</code>
</a>
privilege (or the deprecated
<a class="link" href="privileges-provided.html#priv_super">
<code class="literal">
SUPER
</code>
</a>
privilege).
</p>
<p>
<a class="link" href="grant.html" title="15.7.1.6 GRANT Statement">
<code class="literal">
GRANT
</code>
</a>
either succeeds for all
named users and roles or rolls back and has no effect if any
error occurs. The statement is written to the binary log only
if it succeeds for all named users and roles.
</p>
<p>
The
<a class="link" href="revoke.html" title="15.7.1.8 REVOKE Statement">
<code class="literal">
REVOKE
</code>
</a>
statement is related
to
<a class="link" href="grant.html" title="15.7.1.6 GRANT Statement">
<code class="literal">
GRANT
</code>
</a>
and enables
administrators to remove account privileges. See
<a class="xref" href="revoke.html" title="15.7.1.8 REVOKE Statement">
Section 15.7.1.8, “REVOKE Statement”
</a>
.
</p>
<p>
Each account name uses the format described in
<a class="xref" href="account-names.html" title="8.2.4 Specifying Account Names">
Section 8.2.4, “Specifying Account Names”
</a>
. Each role name uses the
format described in
<a class="xref" href="role-names.html" title="8.2.5 Specifying Role Names">
Section 8.2.5, “Specifying Role Names”
</a>
. For example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa50881731"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">GRANT</span> <span class="token keyword">ALL</span> <span class="token keyword">ON</span> db1<span class="token punctuation">.</span><span class="token operator">*</span> <span class="token keyword">TO</span> <span class="token string">'jeffrey'</span>@<span class="token string">'localhost'</span><span class="token punctuation">;</span>
<span class="token keyword">GRANT</span> <span class="token string">'role1'</span><span class="token punctuation">,</span> <span class="token string">'role2'</span> <span class="token keyword">TO</span> <span class="token string">'user1'</span>@<span class="token string">'localhost'</span><span class="token punctuation">,</span> <span class="token string">'user2'</span>@<span class="token string">'localhost'</span><span class="token punctuation">;</span>
<span class="token keyword">GRANT</span> <span class="token keyword">SELECT</span> <span class="token keyword">ON</span> world<span class="token punctuation">.</span><span class="token operator">*</span> <span class="token keyword">TO</span> <span class="token string">'role3'</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
The host name part of the account or role name, if omitted,
defaults to
<code class="literal">
'%'
</code>
.
</p>
<p>
Normally, a database administrator first uses
<a class="link" href="create-user.html" title="15.7.1.3 CREATE USER Statement">
<code class="literal">
CREATE USER
</code>
</a>
to create an
account and define its nonprivilege characteristics such as
its password, whether it uses secure connections, and limits
on access to server resources, then uses
<a class="link" href="grant.html" title="15.7.1.6 GRANT Statement">
<code class="literal">
GRANT
</code>
</a>
to define its privileges.
<a class="link" href="alter-user.html" title="15.7.1.1 ALTER USER Statement">
<code class="literal">
ALTER USER
</code>
</a>
may be used to
change the nonprivilege characteristics of existing accounts.
For example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa40766853"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">CREATE</span> <span class="token keyword">USER</span> <span class="token string">'jeffrey'</span>@<span class="token string">'localhost'</span> <span class="token keyword">IDENTIFIED</span> <span class="token keyword">BY</span> <span class="token string">'<em class="replaceable">password</em>'</span><span class="token punctuation">;</span>
<span class="token keyword">GRANT</span> <span class="token keyword">ALL</span> <span class="token keyword">ON</span> db1<span class="token punctuation">.</span><span class="token operator">*</span> <span class="token keyword">TO</span> <span class="token string">'jeffrey'</span>@<span class="token string">'localhost'</span><span class="token punctuation">;</span>
<span class="token keyword">GRANT</span> <span class="token keyword">SELECT</span> <span class="token keyword">ON</span> db2<span class="token punctuation">.</span>invoice <span class="token keyword">TO</span> <span class="token string">'jeffrey'</span>@<span class="token string">'localhost'</span><span class="token punctuation">;</span>
<span class="token keyword">ALTER</span> <span class="token keyword">USER</span> <span class="token string">'jeffrey'</span>@<span class="token string">'localhost'</span> <span class="token keyword">WITH</span> <span class="token keyword">MAX_QUERIES_PER_HOUR</span> <span class="token number">90</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
From the
<a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
<span class="command">
<strong>
mysql
</strong>
</span>
</a>
program,
<a class="link" href="grant.html" title="15.7.1.6 GRANT Statement">
<code class="literal">
GRANT
</code>
</a>
responds with
<code class="literal">
Query OK, 0 rows affected
</code>
when executed
successfully. To determine what privileges result from the
operation, use
<a class="link" href="show-grants.html" title="15.7.7.22 SHOW GRANTS Statement">
<code class="literal">
SHOW GRANTS
</code>
</a>
. See
<a class="xref" href="show-grants.html" title="15.7.7.22 SHOW GRANTS Statement">
Section 15.7.7.22, “SHOW GRANTS Statement”
</a>
.
</p>
<div class="important" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Important
</div>
<p>
Under some circumstances,
<a class="link" href="grant.html" title="15.7.1.6 GRANT Statement">
<code class="literal">
GRANT
</code>
</a>
may be recorded in
server logs or on the client side in a history file such as
<code class="filename">
~/.mysql_history
</code>
, which means that
cleartext passwords may be read by anyone having read access
to that information. For information about the conditions
under which this occurs for the server logs and how to
control it, see
<a class="xref" href="password-logging.html" title="8.1.2.3 Passwords and Logging">
Section 8.1.2.3, “Passwords and Logging”
</a>
. For
similar information about client-side logging, see
<a class="xref" href="mysql-logging.html" title="6.5.1.3 mysql Client Logging">
Section 6.5.1.3, “mysql Client Logging”
</a>
.
</p>
</div>
<p>
<a class="link" href="grant.html" title="15.7.1.6 GRANT Statement">
<code class="literal">
GRANT
</code>
</a>
supports host names up to
255 characters long. User names can be up to 32 characters.
Database, table, column, and routine names can be up to 64
characters.
</p>
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Warning
</div>
<p>
<span class="emphasis">
<em>
Do not attempt to change the permissible length
for user names by altering the
<code class="literal">
mysql.user
</code>
system table. Doing so results in unpredictable behavior
which may even make it impossible for users to log in to the
MySQL server
</em>
</span>
. Never alter the structure of tables
in the
<code class="literal">
mysql
</code>
system schema in any manner
except by means of the procedure described in
<a class="xref" href="upgrading.html" title="Chapter 3 Upgrading MySQL">
Chapter 3,
<i>
Upgrading MySQL
</i>
</a>
.
</p>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="grant-quoting">
</a>
Object Quoting Guidelines
</h5>
</div>
</div>
</div>
<a class="indexterm" name="idm46045173887968">
</a>
<p>
Several objects within
<a class="link" href="grant.html" title="15.7.1.6 GRANT Statement">
<code class="literal">
GRANT
</code>
</a>
statements are subject to quoting, although quoting is
optional in many cases: Account, role, database, table,
column, and routine names. For example, if a
<em class="replaceable">
<code>
user_name
</code>
</em>
or
<em class="replaceable">
<code>
host_name
</code>
</em>
value in an account name
is legal as an unquoted identifier, you need not quote it.
However, quotation marks are necessary to specify a
<em class="replaceable">
<code>
user_name
</code>
</em>
string containing special
characters (such as
<code class="literal">
-
</code>
), or a
<em class="replaceable">
<code>
host_name
</code>
</em>
string containing special
characters or wildcard characters such as
<code class="literal">
%
</code>
(for example,
<code class="literal">
'test-user'@'%.com'
</code>
). Quote
the user name and host name separately.
</p>
<p>
To specify quoted values:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Quote database, table, column, and routine names as
identifiers.
</p>
</li>
<li class="listitem">
<p>
Quote user names and host names as identifiers or as
strings.
</p>
</li>
<li class="listitem">
<p>
Quote passwords as strings.
</p>
</li>
</ul>
</div>
<p>
For string-quoting and identifier-quoting guidelines, see
<a class="xref" href="string-literals.html" title="11.1.1 String Literals">
Section 11.1.1, “String Literals”
</a>
, and
<a class="xref" href="identifiers.html" title="11.2 Schema Object Names">
Section 11.2, “Schema Object Names”
</a>
.
</p>
<div class="important" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Important
</div>
<p>
The use of the wildcard characters
<code class="literal">
%
</code>
and
<code class="literal">
_
</code>
as described in the next few paragraphs
is deprecated, and thus subject to removal in a future
version of MySQL.
</p>
</div>
<p>
The
<code class="literal">
_
</code>
and
<code class="literal">
%
</code>
wildcards
are permitted when specifying database names in
<a class="link" href="grant.html" title="15.7.1.6 GRANT Statement">
<code class="literal">
GRANT
</code>
</a>
statements that grant
privileges at the database level (
<code class="literal">
GRANT ... ON
<em class="replaceable">
<code>
db_name
</code>
</em>
.*
</code>
). This means,
for example, that to use a
<code class="literal">
_
</code>
character as
part of a database name, specify it using the
<code class="literal">
\
</code>
escape character as
<code class="literal">
\_
</code>
in the
<a class="link" href="grant.html" title="15.7.1.6 GRANT Statement">
<code class="literal">
GRANT
</code>
</a>
statement, to
prevent the user from being able to access additional
databases matching the wildcard pattern (for example,
<code class="literal">
GRANT ... ON `foo\_bar`.* TO ...
</code>
).
</p>
<p>
Issuing multiple
<code class="literal">
GRANT
</code>
statements
containing wildcards may not have the expected effect on DML
statements; when resolving grants involving wildcards, MySQL
takes only the first matching grant into consideration. In
other words, if a user has two database-level grants using
wildcards that match the same database, the grant which was
created first is applied. Consider the database
<code class="literal">
db
</code>
and table
<code class="literal">
t
</code>
created
using the statements shown here:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa51146250"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">CREATE</span> <span class="token keyword">DATABASE</span> db<span class="token punctuation">;</span>
<span class="token output">Query OK, 1 row affected (0.01 sec)</span>
<span class="token prompt">mysql></span> <span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> db<span class="token punctuation">.</span>t <span class="token punctuation">(</span>c <span class="token datatype">INT</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected (0.01 sec)</span>
<span class="token prompt">mysql></span> <span class="token keyword">INSERT</span> <span class="token keyword">INTO</span> db<span class="token punctuation">.</span>t <span class="token keyword">VALUES</span> <span class="token keyword">ROW</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 1 row affected (0.00 sec)</span></code></pre>
</div>
<p>
Next (assuming that the current account is the MySQL
<code class="literal">
root
</code>
account or another account having the
necessary privileges), we create a user
<code class="literal">
u
</code>
then issue two
<code class="literal">
GRANT
</code>
statements containing
wildcards, like this:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa11958706"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">CREATE</span> <span class="token keyword">USER</span> u<span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected (0.01 sec)</span>
<span class="token prompt">mysql></span> <span class="token keyword">GRANT</span> <span class="token keyword">SELECT</span> <span class="token keyword">ON</span> <span class="token punctuation">`</span>d_<span class="token punctuation">`</span><span class="token punctuation">.</span><span class="token operator">*</span> <span class="token keyword">TO</span> u<span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected (0.01 sec)</span>
<span class="token prompt">mysql></span> <span class="token keyword">GRANT</span> <span class="token keyword">INSERT</span> <span class="token keyword">ON</span> <span class="token punctuation">`</span>d<span class="token operator">%</span><span class="token punctuation">`</span><span class="token punctuation">.</span><span class="token operator">*</span> <span class="token keyword">TO</span> u<span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected (0.00 sec)</span>
<span class="token prompt">mysql></span> <span class="token keyword">EXIT</span></code></pre>
</div>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa75848072"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal">Bye</code></pre>
</div>
<p>
If we end the session and then log in again with the
<a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
<span class="command">
<strong>
mysql
</strong>
</span>
</a>
client, this time as
<span class="command">
<strong>
u
</strong>
</span>
, we see that this account has only the
privilege provided by the first matching grant, but not the
second:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa52823381"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$> </span><span class="token command">mysql</span> <span class="token property">-uu</span> <span class="token property">-hlocalhost</span></code></pre>
</div>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa6900208"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql">Welcome <span class="token keyword">to</span> the MySQL monitor<span class="token punctuation">.</span> Commands <span class="token keyword">end</span> <span class="token keyword">with</span> <span class="token punctuation">;</span> <span class="token operator">or</span> \g<span class="token punctuation">.</span>
Your MySQL <span class="token keyword">connection</span> id <span class="token operator">is</span> <span class="token number">10</span>
<span class="token keyword">Server</span> version: <span class="token number">8.4</span><span class="token punctuation">.</span><span class="token number">4</span><span class="token operator">-</span>tr <span class="token keyword">Source</span> distribution
Copyright <span class="token punctuation">(</span>c<span class="token punctuation">)</span> <span class="token number">2000</span><span class="token punctuation">,</span> <span class="token number">2023</span><span class="token punctuation">,</span> Oracle <span class="token operator">and</span><span class="token operator">/</span><span class="token operator">or</span> its affiliates<span class="token punctuation">.</span>
Oracle <span class="token operator">is</span> a registered trademark <span class="token keyword">of</span> Oracle Corporation <span class="token operator">and</span><span class="token operator">/</span><span class="token operator">or</span> its
affiliates<span class="token punctuation">.</span> Other <span class="token keyword">names</span> may be trademarks <span class="token keyword">of</span> their respective
owners<span class="token punctuation">.</span>
<span class="token keyword">Type</span> <span class="token string">'help;'</span> <span class="token operator">or</span> <span class="token string">'\h'</span> <span class="token keyword">for</span> <span class="token keyword">help</span><span class="token punctuation">.</span> <span class="token keyword">Type</span> <span class="token string">'\c'</span> <span class="token keyword">to</span> clear the <span class="token keyword">current</span> input
statement<span class="token punctuation">.</span>
<span class="token prompt">mysql></span> <span class="token keyword">TABLE</span> db<span class="token punctuation">.</span>t<span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> c <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 1 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">1 row in set (0.00 sec)</span>
<span class="token prompt">mysql></span> <span class="token keyword">INSERT</span> <span class="token keyword">INTO</span> db<span class="token punctuation">.</span>t <span class="token keyword">VALUES</span> <span class="token keyword">ROW</span><span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output">ERROR 1142 (42000)<span class="token punctuation">:</span> INSERT command denied to user 'u'@'localhost' for table 't'</span></code></pre>
</div>
<p>
In privilege assignments, MySQL interprets occurrences of
unescaped
<code class="literal">
_
</code>
and
<code class="literal">
%
</code>
SQL
wildcard characters in database names as literal characters
under these circumstances:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
When a database name is not used to grant privileges at
the database level, but as a qualifier for granting
privileges to some other object such as a table or routine
(for example,
<code class="literal">
GRANT ... ON
<em class="replaceable">
<code>
db_name
</code>
</em>
.
<em class="replaceable">
<code>
tbl_name
</code>
</em>
</code>
).
</p>
</li>
<li class="listitem">
<p>
Enabling
<a class="link" href="server-system-variables.html#sysvar_partial_revokes">
<code class="literal">
partial_revokes
</code>
</a>
causes MySQL to interpret unescaped
<code class="literal">
_
</code>
and
<code class="literal">
%
</code>
wildcard characters in database
names as literal characters, just as if they had been
escaped as
<code class="literal">
\_
</code>
and
<code class="literal">
\%
</code>
. Because this changes how MySQL
interprets privileges, it may be advisable to avoid
unescaped wildcard characters in privilege assignments for
installations where
<a class="link" href="server-system-variables.html#sysvar_partial_revokes">
<code class="literal">
partial_revokes
</code>
</a>
may be
enabled. For more information, see
<a class="xref" href="partial-revokes.html" title="8.2.12 Privilege Restriction Using Partial Revokes">
Section 8.2.12, “Privilege Restriction Using Partial Revokes”
</a>
.
</p>
</li>
</ul>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="grant-accounts">
</a>
Account Names
</h5>
</div>
</div>
</div>
<p>
A
<em class="replaceable">
<code>
user
</code>
</em>
value in a
<a class="link" href="grant.html" title="15.7.1.6 GRANT Statement">
<code class="literal">
GRANT
</code>
</a>
statement indicates a
MySQL account to which the statement applies. To accommodate
granting rights to users from arbitrary hosts, MySQL supports
specifying the
<em class="replaceable">
<code>
user
</code>
</em>
value in the
form
<code class="literal">
'
<em class="replaceable">
<code>
user_name
</code>
</em>
'@'
<em class="replaceable">
<code>
host_name
</code>
</em>
'
</code>
.
</p>
<p>
You can specify wildcards in the host name. For example,
<code class="literal">
'
<em class="replaceable">
<code>
user_name
</code>
</em>
'@'%.example.com'
</code>
applies to
<em class="replaceable">
<code>
user_name
</code>
</em>
for any host
in the
<code class="literal">
example.com
</code>
domain, and
<code class="literal">
'
<em class="replaceable">
<code>
user_name
</code>
</em>
'@'198.51.100.%'
</code>
applies to
<em class="replaceable">
<code>
user_name
</code>
</em>
for any host
in the
<code class="literal">
198.51.100
</code>
class C subnet.
</p>
<p>
The simple form
<code class="literal">
'
<em class="replaceable">
<code>
user_name
</code>
</em>
'
</code>
is a
synonym for
<code class="literal">
'
<em class="replaceable">
<code>
user_name
</code>
</em>
'@'%'
</code>
.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
MySQL automatically assigns all privileges granted to
<code class="literal">
'
<em class="replaceable">
<code>
username
</code>
</em>
'@'%'
</code>
to the
<code class="literal">
'
<em class="replaceable">
<code>
username
</code>
</em>
'@'localhost'
</code>
account as well. This behavior is deprecated, and is subject
to removal in a future version of MySQL.
</p>
</div>
<p>
<span class="emphasis">
<em>
MySQL does not support wildcards in user
names
</em>
</span>
. To refer to an anonymous user, specify an
account with an empty user name with the
<a class="link" href="grant.html" title="15.7.1.6 GRANT Statement">
<code class="literal">
GRANT
</code>
</a>
statement:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa32967029"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">GRANT</span> <span class="token keyword">ALL</span> <span class="token keyword">ON</span> test<span class="token punctuation">.</span><span class="token operator">*</span> <span class="token keyword">TO</span> <span class="token string">''</span>@<span class="token string">'localhost'</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
In this case, any user who connects from the local host with
the correct password for the anonymous user is permitted
access, with the privileges associated with the anonymous-user
account.
</p>
<p>
For additional information about user name and host name
values in account names, see
<a class="xref" href="account-names.html" title="8.2.4 Specifying Account Names">
Section 8.2.4, “Specifying Account Names”
</a>
.
</p>
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Warning
</div>
<p>
If you permit local anonymous users to connect to the MySQL
server, you should also grant privileges to all local users
as
<code class="literal">
'
<em class="replaceable">
<code>
user_name
</code>
</em>
'@'localhost'
</code>
.
Otherwise, the anonymous user account for
<code class="literal">
localhost
</code>
in the
<code class="literal">
mysql.user
</code>
system table is used when
named users try to log in to the MySQL server from the local
machine. For details, see
<a class="xref" href="connection-access.html" title="8.2.6 Access Control, Stage 1: Connection Verification">
Section 8.2.6, “Access Control, Stage 1: Connection Verification”
</a>
.
</p>
<p>
To determine whether this issue applies to you, execute the
following query, which lists any anonymous users:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa35770037"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> <span class="token keyword">Host</span><span class="token punctuation">,</span> <span class="token keyword">User</span> <span class="token keyword">FROM</span> mysql<span class="token punctuation">.</span><span class="token keyword">user</span> <span class="token keyword">WHERE</span> <span class="token keyword">User</span><span class="token operator">=</span><span class="token string">''</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
To avoid the problem just described, delete the local
anonymous user account using this statement:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa22742286"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">DROP</span> <span class="token keyword">USER</span> <span class="token string">''</span>@<span class="token string">'localhost'</span><span class="token punctuation">;</span></code></pre>
</div>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="grant-privileges">
</a>
Privileges Supported by MySQL
</h5>
</div>
</div>
</div>
<p>
The following tables summarize the permissible static and
dynamic
<em class="replaceable">
<code>
priv_type
</code>
</em>
privilege types
that can be specified for the
<a class="link" href="grant.html" title="15.7.1.6 GRANT Statement">
<code class="literal">
GRANT
</code>
</a>
and
<a class="link" href="revoke.html" title="15.7.1.8 REVOKE Statement">
<code class="literal">
REVOKE
</code>
</a>
statements, and the
levels at which each privilege can be granted. For additional
information about each privilege, see
<a class="xref" href="privileges-provided.html" title="8.2.2 Privileges Provided by MySQL">
Section 8.2.2, “Privileges Provided by MySQL”
</a>
. For information about
the differences between static and dynamic privileges, see
<a class="xref" href="privileges-provided.html#static-dynamic-privileges" title="Static Versus Dynamic Privileges">
Static Versus Dynamic Privileges
</a>
.
</p>
<div class="table">
<a name="idm46045173794304">
</a>
<p class="title">
<b>
Table 15.11 Permissible Static Privileges for GRANT and REVOKE
</b>
</p>
<div class="table-contents">
<table>
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<thead>
<tr>
<th>
Privilege
</th>
<th>
Meaning and Grantable Levels
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_all">
<code class="literal">
ALL [PRIVILEGES]
</code>
</a>
</td>
<td>
Grant all privileges at specified access level except
<a class="link" href="privileges-provided.html#priv_grant-option">
<code class="literal">
GRANT OPTION
</code>
</a>
and
<a class="link" href="privileges-provided.html#priv_proxy">
<code class="literal">
PROXY
</code>
</a>
.
</td>
</tr>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_alter">
<code class="literal">
ALTER
</code>
</a>
</td>
<td>
Enable use of
<a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
<code class="literal">
ALTER TABLE
</code>
</a>
. Levels:
Global, database, table.
</td>
</tr>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_alter-routine">
<code class="literal">
ALTER ROUTINE
</code>
</a>
</td>
<td>
Enable stored routines to be altered or dropped. Levels: Global,
database, routine.
</td>
</tr>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_create">
<code class="literal">
CREATE
</code>
</a>
</td>
<td>
Enable database and table creation. Levels: Global, database, table.
</td>
</tr>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_create-role">
<code class="literal">
CREATE ROLE
</code>
</a>
</td>
<td>
Enable role creation. Level: Global.
</td>
</tr>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_create-routine">
<code class="literal">
CREATE ROUTINE
</code>
</a>
</td>
<td>
Enable stored routine creation. Levels: Global, database.
</td>
</tr>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_create-tablespace">
<code class="literal">
CREATE TABLESPACE
</code>
</a>
</td>
<td>
Enable tablespaces and log file groups to be created, altered, or
dropped. Level: Global.
</td>
</tr>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_create-temporary-tables">
<code class="literal">
CREATE TEMPORARY TABLES
</code>
</a>
</td>
<td>
Enable use of
<a class="link" href="create-table.html" title="15.1.20 CREATE TABLE Statement">
<code class="literal">
CREATE
TEMPORARY TABLE
</code>
</a>
. Levels: Global, database.
</td>
</tr>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_create-user">
<code class="literal">
CREATE USER
</code>
</a>
</td>
<td>
Enable use of
<a class="link" href="create-user.html" title="15.7.1.3 CREATE USER Statement">
<code class="literal">
CREATE USER
</code>
</a>
,
<a class="link" href="drop-user.html" title="15.7.1.5 DROP USER Statement">
<code class="literal">
DROP USER
</code>
</a>
,
<a class="link" href="rename-user.html" title="15.7.1.7 RENAME USER Statement">
<code class="literal">
RENAME USER
</code>
</a>
, and
<a class="link" href="revoke.html" title="15.7.1.8 REVOKE Statement">
<code class="literal">
REVOKE ALL
PRIVILEGES
</code>
</a>
. Level: Global.
</td>
</tr>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_create-view">
<code class="literal">
CREATE VIEW
</code>
</a>
</td>
<td>
Enable views to be created or altered. Levels: Global, database, table.
</td>
</tr>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_delete">
<code class="literal">
DELETE
</code>
</a>
</td>
<td>
Enable use of
<a class="link" href="delete.html" title="15.2.2 DELETE Statement">
<code class="literal">
DELETE
</code>
</a>
. Level: Global,
database, table.
</td>
</tr>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_drop">
<code class="literal">
DROP
</code>
</a>
</td>
<td>
Enable databases, tables, and views to be dropped. Levels: Global,
database, table.
</td>
</tr>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_drop-role">
<code class="literal">
DROP ROLE
</code>
</a>
</td>
<td>
Enable roles to be dropped. Level: Global.
</td>
</tr>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_event">
<code class="literal">
EVENT
</code>
</a>
</td>
<td>
Enable use of events for the Event Scheduler. Levels: Global, database.
</td>
</tr>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_execute">
<code class="literal">
EXECUTE
</code>
</a>
</td>
<td>
Enable the user to execute stored routines. Levels: Global, database,
routine.
</td>
</tr>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_file">
<code class="literal">
FILE
</code>
</a>
</td>
<td>
Enable the user to cause the server to read or write files. Level:
Global.
</td>
</tr>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_flush-privileges">
<code class="literal">
FLUSH_PRIVILEGES
</code>
</a>
</td>
<td>
Enable the user to issue
<a class="link" href="flush.html" title="15.7.8.3 FLUSH Statement">
<code class="literal">
FLUSH
PRIVILEGES
</code>
</a>
statements. Level: Global.
</td>
</tr>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_grant-option">
<code class="literal">
GRANT OPTION
</code>
</a>
</td>
<td>
Enable privileges to be granted to or removed from other accounts.
Levels: Global, database, table, routine, proxy.
</td>
</tr>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_index">
<code class="literal">
INDEX
</code>
</a>
</td>
<td>
Enable indexes to be created or dropped. Levels: Global, database,
table.
</td>
</tr>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_insert">
<code class="literal">
INSERT
</code>
</a>
</td>
<td>
Enable use of
<a class="link" href="insert.html" title="15.2.7 INSERT Statement">
<code class="literal">
INSERT
</code>
</a>
. Levels: Global,
database, table, column.
</td>
</tr>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_lock-tables">
<code class="literal">
LOCK TABLES
</code>
</a>
</td>
<td>
Enable use of
<a class="link" href="lock-tables.html" title="15.3.6 LOCK TABLES and UNLOCK TABLES Statements">
<code class="literal">
LOCK TABLES
</code>
</a>
on tables for
which you have the
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
privilege. Levels: Global, database.
</td>
</tr>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_optimize-local-table">
<code class="literal">
OPTIMIZE_LOCAL_TABLE
</code>
</a>
</td>
<td>
Enable use of
<a class="link" href="optimize-table.html" title="15.7.3.4 OPTIMIZE TABLE Statement">
<code class="literal">
OPTIMIZE
LOCAL TABLE
</code>
</a>
or
<code class="literal">
OPTIMIZE
NO_WRITE_TO_BINLOG TABLE
</code>
. Levels: Global,
database, table.
</td>
</tr>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_process">
<code class="literal">
PROCESS
</code>
</a>
</td>
<td>
Enable the user to see all processes with
<a class="link" href="show-processlist.html" title="15.7.7.31 SHOW PROCESSLIST Statement">
<code class="literal">
SHOW
PROCESSLIST
</code>
</a>
. Level: Global.
</td>
</tr>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_proxy">
<code class="literal">
PROXY
</code>
</a>
</td>
<td>
Enable user proxying. Level: From user to user.
</td>
</tr>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_references">
<code class="literal">
REFERENCES
</code>
</a>
</td>
<td>
Enable foreign key creation. Levels: Global, database, table, column.
</td>
</tr>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_reload">
<code class="literal">
RELOAD
</code>
</a>
</td>
<td>
Enable use of
<a class="link" href="flush.html" title="15.7.8.3 FLUSH Statement">
<code class="literal">
FLUSH
</code>
</a>
operations. Level:
Global.
</td>
</tr>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_replication-client">
<code class="literal">
REPLICATION CLIENT
</code>
</a>
</td>
<td>
Enable the user to ask where source or replica servers are. Level:
Global.
</td>
</tr>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_replication-slave">
<code class="literal">
REPLICATION SLAVE
</code>
</a>
</td>
<td>
Enable replicas to read binary log events from the source. Level:
Global.
</td>
</tr>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_select">
<code class="literal">
SELECT
</code>
</a>
</td>
<td>
Enable use of
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
. Levels: Global,
database, table, column.
</td>
</tr>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_show-databases">
<code class="literal">
SHOW DATABASES
</code>
</a>
</td>
<td>
Enable
<a class="link" href="show-databases.html" title="15.7.7.15 SHOW DATABASES Statement">
<code class="literal">
SHOW DATABASES
</code>
</a>
to show all
databases. Level: Global.
</td>
</tr>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_show-view">
<code class="literal">
SHOW VIEW
</code>
</a>
</td>
<td>
Enable use of
<a class="link" href="show-create-view.html" title="15.7.7.14 SHOW CREATE VIEW Statement">
<code class="literal">
SHOW CREATE VIEW
</code>
</a>
. Levels:
Global, database, table.
</td>
</tr>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_shutdown">
<code class="literal">
SHUTDOWN
</code>
</a>
</td>
<td>
Enable use of
<a class="link" href="mysqladmin.html" title="6.5.2 mysqladmin — A MySQL Server Administration Program">
<span class="command">
<strong>
mysqladmin shutdown
</strong>
</span>
</a>
. Level: Global.
</td>
</tr>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_super">
<code class="literal">
SUPER
</code>
</a>
</td>
<td>
Enable use of other administrative operations such as
<a class="link" href="change-replication-source-to.html" title="15.4.2.2 CHANGE REPLICATION SOURCE TO Statement">
<code class="literal">
CHANGE REPLICATION SOURCE
TO
</code>
</a>
,
<a class="link" href="kill.html" title="15.7.8.4 KILL Statement">
<code class="literal">
KILL
</code>
</a>
,
<a class="link" href="purge-binary-logs.html" title="15.4.1.1 PURGE BINARY LOGS Statement">
<code class="literal">
PURGE BINARY LOGS
</code>
</a>
,
<a class="link" href="set-variable.html" title="15.7.6.1 SET Syntax for Variable Assignment">
<code class="literal">
SET
GLOBAL
</code>
</a>
, and
<a class="link" href="mysqladmin.html" title="6.5.2 mysqladmin — A MySQL Server Administration Program">
<span class="command">
<strong>
mysqladmin
debug
</strong>
</span>
</a>
command. Level: Global.
</td>
</tr>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_trigger">
<code class="literal">
TRIGGER
</code>
</a>
</td>
<td>
Enable trigger operations. Levels: Global, database, table.
</td>
</tr>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_update">
<code class="literal">
UPDATE
</code>
</a>
</td>
<td>
Enable use of
<a class="link" href="update.html" title="15.2.17 UPDATE Statement">
<code class="literal">
UPDATE
</code>
</a>
. Levels: Global,
database, table, column.
</td>
</tr>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_usage">
<code class="literal">
USAGE
</code>
</a>
</td>
<td>
Synonym for
<span class="quote">
“
<span class="quote">
no privileges
</span>
”
</span>
</td>
</tr>
</tbody>
</table>
</div>
<div class="table-contents">
<table cellpadding="0" cellspacing="0" style="position: fixed; top: 0px; display: none; left: 401px; width: 739px;">
<thead>
<tr>
<th style="width: 221.391px;">
Privilege
</th>
<th style="width: 516.609px;">
Meaning and Grantable Levels
</th>
</tr>
</thead>
</table>
</div>
</div>
<br class="table-break"/>
<div class="table">
<a name="idm46045173642080">
</a>
<p class="title">
<b>
Table 15.12 Permissible Dynamic Privileges for GRANT and REVOKE
</b>
</p>
<div class="table-contents">
<table>
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<thead>
<tr>
<th>
Privilege
</th>
<th>
Meaning and Grantable Levels
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_application-password-admin">
<code class="literal">
APPLICATION_PASSWORD_ADMIN
</code>
</a>
</td>
<td>
Enable dual password administration. Level: Global.
</td>
</tr>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_audit-abort-exempt">
<code class="literal">
AUDIT_ABORT_EXEMPT
</code>
</a>
</td>
<td>
Allow queries blocked by audit log filter. Level: Global.
</td>
</tr>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_audit-admin">
<code class="literal">
AUDIT_ADMIN
</code>
</a>
</td>
<td>
Enable audit log configuration. Level: Global.
</td>
</tr>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_authentication-policy-admin">
<code class="literal">
AUTHENTICATION_POLICY_ADMIN
</code>
</a>
</td>
<td>
Enable authentication policy administration. Level: Global.
</td>
</tr>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_backup-admin">
<code class="literal">
BACKUP_ADMIN
</code>
</a>
</td>
<td>
Enable backup administration. Level: Global.
</td>
</tr>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_binlog-admin">
<code class="literal">
BINLOG_ADMIN
</code>
</a>
</td>
<td>
Enable binary log control. Level: Global.
</td>
</tr>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_binlog-encryption-admin">
<code class="literal">
BINLOG_ENCRYPTION_ADMIN
</code>
</a>
</td>
<td>
Enable activation and deactivation of binary log encryption. Level:
Global.
</td>
</tr>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_clone-admin">
<code class="literal">
CLONE_ADMIN
</code>
</a>
</td>
<td>
Enable clone administration. Level: Global.
</td>
</tr>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_connection-admin">
<code class="literal">
CONNECTION_ADMIN
</code>
</a>
</td>
<td>
Enable connection limit/restriction control. Level: Global.
</td>
</tr>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_encryption-key-admin">
<code class="literal">
ENCRYPTION_KEY_ADMIN
</code>
</a>
</td>
<td>
Enable
<code class="literal">
InnoDB
</code>
key rotation. Level: Global.
</td>
</tr>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_firewall-admin">
<code class="literal">
FIREWALL_ADMIN
</code>
</a>
</td>
<td>
Enable firewall rule administration, any user. Level: Global.
</td>
</tr>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_firewall-exempt">
<code class="literal">
FIREWALL_EXEMPT
</code>
</a>
</td>
<td>
Exempt user from firewall restrictions. Level: Global.
</td>
</tr>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_firewall-user">
<code class="literal">
FIREWALL_USER
</code>
</a>
</td>
<td>
Enable firewall rule administration, self. Level: Global.
</td>
</tr>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_flush-optimizer-costs">
<code class="literal">
FLUSH_OPTIMIZER_COSTS
</code>
</a>
</td>
<td>
Enable optimizer cost reloading. Level: Global.
</td>
</tr>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_flush-status">
<code class="literal">
FLUSH_STATUS
</code>
</a>
</td>
<td>
Enable status indicator flushing. Level: Global.
</td>
</tr>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_flush-tables">
<code class="literal">
FLUSH_TABLES
</code>
</a>
</td>
<td>
Enable table flushing. Level: Global.
</td>
</tr>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_flush-user-resources">
<code class="literal">
FLUSH_USER_RESOURCES
</code>
</a>
</td>
<td>
Enable user-resource flushing. Level: Global.
</td>
</tr>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_group-replication-admin">
<code class="literal">
GROUP_REPLICATION_ADMIN
</code>
</a>
</td>
<td>
Enable Group Replication control. Level: Global.
</td>
</tr>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_innodb-redo-log-archive">
<code class="literal">
INNODB_REDO_LOG_ARCHIVE
</code>
</a>
</td>
<td>
Enable redo log archiving administration. Level: Global.
</td>
</tr>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_innodb-redo-log-enable">
<code class="literal">
INNODB_REDO_LOG_ENABLE
</code>
</a>
</td>
<td>
Enable or disable redo logging. Level: Global.
</td>
</tr>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_ndb-stored-user">
<code class="literal">
NDB_STORED_USER
</code>
</a>
</td>
<td>
Enable sharing of user or role between SQL nodes (NDB Cluster). Level:
Global.
</td>
</tr>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_passwordless-user-admin">
<code class="literal">
PASSWORDLESS_USER_ADMIN
</code>
</a>
</td>
<td>
Enable passwordless user account administration. Level: Global.
</td>
</tr>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_persist-ro-variables-admin">
<code class="literal">
PERSIST_RO_VARIABLES_ADMIN
</code>
</a>
</td>
<td>
Enable persisting read-only system variables. Level: Global.
</td>
</tr>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_replication-applier">
<code class="literal">
REPLICATION_APPLIER
</code>
</a>
</td>
<td>
Act as the
<code class="literal">
PRIVILEGE_CHECKS_USER
</code>
for a replication
channel. Level: Global.
</td>
</tr>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_replication-slave-admin">
<code class="literal">
REPLICATION_SLAVE_ADMIN
</code>
</a>
</td>
<td>
Enable regular replication control. Level: Global.
</td>
</tr>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_resource-group-admin">
<code class="literal">
RESOURCE_GROUP_ADMIN
</code>
</a>
</td>
<td>
Enable resource group administration. Level: Global.
</td>
</tr>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_resource-group-user">
<code class="literal">
RESOURCE_GROUP_USER
</code>
</a>
</td>
<td>
Enable resource group administration. Level: Global.
</td>
</tr>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_role-admin">
<code class="literal">
ROLE_ADMIN
</code>
</a>
</td>
<td>
Enable roles to be granted or revoked, use of
<code class="literal">
WITH ADMIN
OPTION
</code>
. Level: Global.
</td>
</tr>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_session-variables-admin">
<code class="literal">
SESSION_VARIABLES_ADMIN
</code>
</a>
</td>
<td>
Enable setting restricted session system variables. Level: Global.
</td>
</tr>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_show-routine">
<code class="literal">
SHOW_ROUTINE
</code>
</a>
</td>
<td>
Enable access to stored routine definitions. Level: Global.
</td>
</tr>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_skip-query-rewrite">
<code class="literal">
SKIP_QUERY_REWRITE
</code>
</a>
</td>
<td>
Do not rewrite queries executed by this user. Level: Global.
</td>
</tr>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_system-user">
<code class="literal">
SYSTEM_USER
</code>
</a>
</td>
<td>
Designate account as system account. Level: Global.
</td>
</tr>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_system-variables-admin">
<code class="literal">
SYSTEM_VARIABLES_ADMIN
</code>
</a>
</td>
<td>
Enable modifying or persisting global system variables. Level: Global.
</td>
</tr>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_table-encryption-admin">
<code class="literal">
TABLE_ENCRYPTION_ADMIN
</code>
</a>
</td>
<td>
Enable overriding default encryption settings. Level: Global.
</td>
</tr>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_telemetry-log-admin">
<code class="literal">
TELEMETRY_LOG_ADMIN
</code>
</a>
</td>
<td>
Enable telemetry log configuration for HeatWave on AWS. Level: Global.
</td>
</tr>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_tp-connection-admin">
<code class="literal">
TP_CONNECTION_ADMIN
</code>
</a>
</td>
<td>
Enable thread pool connection administration. Level: Global.
</td>
</tr>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_version-token-admin">
<code class="literal">
VERSION_TOKEN_ADMIN
</code>
</a>
</td>
<td>
Enable use of Version Tokens functions. Level: Global.
</td>
</tr>
<tr>
<td>
<a class="link" href="privileges-provided.html#priv_xa-recover-admin">
<code class="literal">
XA_RECOVER_ADMIN
</code>
</a>
</td>
<td>
Enable
<a class="link" href="xa-statements.html" title="15.3.8.1 XA Transaction SQL Statements">
<code class="literal">
XA
RECOVER
</code>
</a>
execution. Level: Global.
</td>
</tr>
</tbody>
</table>
</div>
<div class="table-contents">
<table cellpadding="0" cellspacing="0" style="position: fixed; top: 0px; display: none; left: 401px; width: 739px;">
<thead>
<tr>
<th style="width: 226.391px;">
Privilege
</th>
<th style="width: 511.609px;">
Meaning and Grantable Levels
</th>
</tr>
</thead>
</table>
</div>
</div>
<br class="table-break"/>
<p>
A trigger is associated with a table. To create or drop a
trigger, you must have the
<a class="link" href="privileges-provided.html#priv_trigger">
<code class="literal">
TRIGGER
</code>
</a>
privilege for the
table, not the trigger.
</p>
<p>
In
<a class="link" href="grant.html" title="15.7.1.6 GRANT Statement">
<code class="literal">
GRANT
</code>
</a>
statements, the
<a class="link" href="privileges-provided.html#priv_all">
<code class="literal">
ALL
[PRIVILEGES]
</code>
</a>
or
<a class="link" href="privileges-provided.html#priv_proxy">
<code class="literal">
PROXY
</code>
</a>
privilege must be named by itself and cannot be specified
along with other privileges.
<a class="link" href="privileges-provided.html#priv_all">
<code class="literal">
ALL
[PRIVILEGES]
</code>
</a>
stands for all privileges available for
the level at which privileges are to be granted except for the
<a class="link" href="privileges-provided.html#priv_grant-option">
<code class="literal">
GRANT OPTION
</code>
</a>
and
<a class="link" href="privileges-provided.html#priv_proxy">
<code class="literal">
PROXY
</code>
</a>
privileges.
</p>
<p>
MySQL account information is stored in the tables of the
<code class="literal">
mysql
</code>
system schema. For additional
details, consult
<a class="xref" href="access-control.html" title="8.2 Access Control and Account Management">
Section 8.2, “Access Control and Account Management”
</a>
, which
discusses the
<code class="literal">
mysql
</code>
system schema and the
access control system extensively.
</p>
<a class="indexterm" name="idm46045173501168">
</a>
<p>
If the grant tables hold privilege rows that contain
mixed-case database or table names and the
<a class="link" href="server-system-variables.html#sysvar_lower_case_table_names">
<code class="literal">
lower_case_table_names
</code>
</a>
system
variable is set to a nonzero value,
<a class="link" href="revoke.html" title="15.7.1.8 REVOKE Statement">
<code class="literal">
REVOKE
</code>
</a>
cannot be used to revoke
these privileges. It is necessary in such cases to manipulate
the grant tables directly.
(
<a class="link" href="grant.html" title="15.7.1.6 GRANT Statement">
<code class="literal">
GRANT
</code>
</a>
does not create such
rows when
<a class="link" href="server-system-variables.html#sysvar_lower_case_table_names">
<code class="literal">
lower_case_table_names
</code>
</a>
is
set, but such rows might have been created prior to setting
that variable. The
<a class="link" href="server-system-variables.html#sysvar_lower_case_table_names">
<code class="literal">
lower_case_table_names
</code>
</a>
setting can only be configured at server startup.)
</p>
<p>
Privileges can be granted at several levels, depending on the
syntax used for the
<code class="literal">
ON
</code>
clause. For
<a class="link" href="revoke.html" title="15.7.1.8 REVOKE Statement">
<code class="literal">
REVOKE
</code>
</a>
, the same
<code class="literal">
ON
</code>
syntax specifies which privileges to
remove.
</p>
<p>
For the global, database, table, and routine levels,
<a class="link" href="grant.html" title="15.7.1.6 GRANT Statement">
<code class="literal">
GRANT ALL
</code>
</a>
assigns only the privileges that exist at the level you are
granting. For example,
<code class="literal">
GRANT ALL ON
<em class="replaceable">
<code>
db_name
</code>
</em>
.*
</code>
is a
database-level statement, so it does not grant any global-only
privileges such as
<a class="link" href="privileges-provided.html#priv_file">
<code class="literal">
FILE
</code>
</a>
.
Granting
<a class="link" href="privileges-provided.html#priv_all">
<code class="literal">
ALL
</code>
</a>
does not assign
the
<a class="link" href="privileges-provided.html#priv_grant-option">
<code class="literal">
GRANT OPTION
</code>
</a>
or
<a class="link" href="privileges-provided.html#priv_proxy">
<code class="literal">
PROXY
</code>
</a>
privilege.
</p>
<p>
The
<em class="replaceable">
<code>
object_type
</code>
</em>
clause, if present,
should be specified as
<code class="literal">
TABLE
</code>
,
<code class="literal">
FUNCTION
</code>
, or
<code class="literal">
PROCEDURE
</code>
when the following object is a table, a stored function, or a
stored procedure.
</p>
<p>
The privileges that a user holds for a database, table,
column, or routine are formed additively as the logical
<a class="link" href="logical-operators.html#operator_or">
<code class="literal">
OR
</code>
</a>
of the account privileges at
each of the privilege levels, including the global level. It
is not possible to deny a privilege granted at a higher level
by absence of that privilege at a lower level. For example,
this statement grants the
<a class="link" href="privileges-provided.html#priv_select">
<code class="literal">
SELECT
</code>
</a>
and
<a class="link" href="privileges-provided.html#priv_insert">
<code class="literal">
INSERT
</code>
</a>
privileges globally:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa48308398"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">GRANT</span> <span class="token keyword">SELECT</span><span class="token punctuation">,</span> <span class="token keyword">INSERT</span> <span class="token keyword">ON</span> <span class="token operator">*</span><span class="token punctuation">.</span><span class="token operator">*</span> <span class="token keyword">TO</span> u1<span class="token punctuation">;</span></code></pre>
</div>
<p>
The globally granted privileges apply to all databases,
tables, and columns, even though not granted at any of those
lower levels.
</p>
<p>
It is possible to deny explicitly a privilege granted at the
global level by revoking it for particular databases, if the
<a class="link" href="server-system-variables.html#sysvar_partial_revokes">
<code class="literal">
partial_revokes
</code>
</a>
system
variable is enabled:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa9989540"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">GRANT</span> <span class="token keyword">SELECT</span><span class="token punctuation">,</span> <span class="token keyword">INSERT</span><span class="token punctuation">,</span> <span class="token keyword">UPDATE</span> <span class="token keyword">ON</span> <span class="token operator">*</span><span class="token punctuation">.</span><span class="token operator">*</span> <span class="token keyword">TO</span> u1<span class="token punctuation">;</span>
<span class="token keyword">REVOKE</span> <span class="token keyword">INSERT</span><span class="token punctuation">,</span> <span class="token keyword">UPDATE</span> <span class="token keyword">ON</span> db1<span class="token punctuation">.</span><span class="token operator">*</span> <span class="token keyword">FROM</span> u1<span class="token punctuation">;</span></code></pre>
</div>
<p>
The result of the preceding statements is that
<a class="link" href="privileges-provided.html#priv_select">
<code class="literal">
SELECT
</code>
</a>
applies globally to all
tables, whereas
<a class="link" href="privileges-provided.html#priv_insert">
<code class="literal">
INSERT
</code>
</a>
and
<a class="link" href="privileges-provided.html#priv_update">
<code class="literal">
UPDATE
</code>
</a>
apply globally except to
tables in
<code class="literal">
db1
</code>
. Account access to
<code class="literal">
db1
</code>
is read only.
</p>
<p>
Details of the privilege-checking procedure are presented in
<a class="xref" href="request-access.html" title="8.2.7 Access Control, Stage 2: Request Verification">
Section 8.2.7, “Access Control, Stage 2: Request Verification”
</a>
.
</p>
<p>
If you are using table, column, or routine privileges for even
one user, the server examines table, column, and routine
privileges for all users and this slows down MySQL a bit.
Similarly, if you limit the number of queries, updates, or
connections for any users, the server must monitor these
values.
</p>
<p>
MySQL enables you to grant privileges on databases or tables
that do not exist. For tables, the privileges to be granted
must include the
<a class="link" href="privileges-provided.html#priv_create">
<code class="literal">
CREATE
</code>
</a>
privilege.
<span class="emphasis">
<em>
This behavior is by design
</em>
</span>
,
and is intended to enable the database administrator to
prepare user accounts and privileges for databases or tables
that are to be created at a later time.
</p>
<div class="important" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Important
</div>
<p>
<span class="emphasis">
<em>
MySQL does not automatically revoke any privileges
when you drop a database or table
</em>
</span>
. However, if
you drop a routine, any routine-level privileges granted for
that routine are revoked.
</p>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="grant-global-privileges">
</a>
Global Privileges
</h5>
</div>
</div>
</div>
<p>
Global privileges are administrative or apply to all databases
on a given server. To assign global privileges, use
<code class="literal">
ON *.*
</code>
syntax:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa82919249"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">GRANT</span> <span class="token keyword">ALL</span> <span class="token keyword">ON</span> <span class="token operator">*</span><span class="token punctuation">.</span><span class="token operator">*</span> <span class="token keyword">TO</span> <span class="token string">'someuser'</span>@<span class="token string">'somehost'</span><span class="token punctuation">;</span>
<span class="token keyword">GRANT</span> <span class="token keyword">SELECT</span><span class="token punctuation">,</span> <span class="token keyword">INSERT</span> <span class="token keyword">ON</span> <span class="token operator">*</span><span class="token punctuation">.</span><span class="token operator">*</span> <span class="token keyword">TO</span> <span class="token string">'someuser'</span>@<span class="token string">'somehost'</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
The
<a class="link" href="privileges-provided.html#priv_create-tablespace">
<code class="literal">
CREATE TABLESPACE
</code>
</a>
,
<a class="link" href="privileges-provided.html#priv_create-user">
<code class="literal">
CREATE USER
</code>
</a>
,
<a class="link" href="privileges-provided.html#priv_file">
<code class="literal">
FILE
</code>
</a>
,
<a class="link" href="privileges-provided.html#priv_process">
<code class="literal">
PROCESS
</code>
</a>
,
<a class="link" href="privileges-provided.html#priv_reload">
<code class="literal">
RELOAD
</code>
</a>
,
<a class="link" href="privileges-provided.html#priv_replication-client">
<code class="literal">
REPLICATION CLIENT
</code>
</a>
,
<a class="link" href="privileges-provided.html#priv_replication-slave">
<code class="literal">
REPLICATION SLAVE
</code>
</a>
,
<a class="link" href="privileges-provided.html#priv_show-databases">
<code class="literal">
SHOW DATABASES
</code>
</a>
,
<a class="link" href="privileges-provided.html#priv_shutdown">
<code class="literal">
SHUTDOWN
</code>
</a>
, and
<a class="link" href="privileges-provided.html#priv_super">
<code class="literal">
SUPER
</code>
</a>
static privileges are
administrative and can only be granted globally.
</p>
<p>
Dynamic privileges are all global and can only be granted
globally.
</p>
<p>
Other privileges can be granted globally or at more specific
levels.
</p>
<p>
The effect of
<a class="link" href="privileges-provided.html#priv_grant-option">
<code class="literal">
GRANT OPTION
</code>
</a>
granted at the global level differs for static and dynamic
privileges:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="link" href="privileges-provided.html#priv_grant-option">
<code class="literal">
GRANT OPTION
</code>
</a>
granted for
any static global privilege applies to all static global
privileges.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="privileges-provided.html#priv_grant-option">
<code class="literal">
GRANT OPTION
</code>
</a>
granted for
any dynamic privilege applies only to that dynamic
privilege.
</p>
</li>
</ul>
</div>
<p>
<code class="literal">
GRANT ALL
</code>
at the global level grants all
static global privileges and all currently registered dynamic
privileges. A dynamic privilege registered subsequent to
execution of the
<code class="literal">
GRANT
</code>
statement is not
granted retroactively to any account.
</p>
<p>
MySQL stores global privileges in the
<code class="literal">
mysql.user
</code>
system table.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="grant-database-privileges">
</a>
Database Privileges
</h5>
</div>
</div>
</div>
<p>
Database privileges apply to all objects in a given database.
To assign database-level privileges, use
<code class="literal">
ON
<em class="replaceable">
<code>
db_name
</code>
</em>
.*
</code>
syntax:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa19140375"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">GRANT</span> <span class="token keyword">ALL</span> <span class="token keyword">ON</span> mydb<span class="token punctuation">.</span><span class="token operator">*</span> <span class="token keyword">TO</span> <span class="token string">'someuser'</span>@<span class="token string">'somehost'</span><span class="token punctuation">;</span>
<span class="token keyword">GRANT</span> <span class="token keyword">SELECT</span><span class="token punctuation">,</span> <span class="token keyword">INSERT</span> <span class="token keyword">ON</span> mydb<span class="token punctuation">.</span><span class="token operator">*</span> <span class="token keyword">TO</span> <span class="token string">'someuser'</span>@<span class="token string">'somehost'</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
If you use
<code class="literal">
ON *
</code>
syntax (rather than
<code class="literal">
ON *.*
</code>
), privileges are assigned at the
database level for the default database. An error occurs if
there is no default database.
</p>
<p>
The
<a class="link" href="privileges-provided.html#priv_create">
<code class="literal">
CREATE
</code>
</a>
,
<a class="link" href="privileges-provided.html#priv_drop">
<code class="literal">
DROP
</code>
</a>
,
<a class="link" href="privileges-provided.html#priv_event">
<code class="literal">
EVENT
</code>
</a>
,
<a class="link" href="privileges-provided.html#priv_grant-option">
<code class="literal">
GRANT OPTION
</code>
</a>
,
<a class="link" href="privileges-provided.html#priv_lock-tables">
<code class="literal">
LOCK TABLES
</code>
</a>
, and
<a class="link" href="privileges-provided.html#priv_references">
<code class="literal">
REFERENCES
</code>
</a>
privileges can be
specified at the database level. Table or routine privileges
also can be specified at the database level, in which case
they apply to all tables or routines in the database.
</p>
<p>
MySQL stores database privileges in the
<code class="literal">
mysql.db
</code>
system table.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="grant-table-privileges">
</a>
Table Privileges
</h5>
</div>
</div>
</div>
<p>
Table privileges apply to all columns in a given table. To
assign table-level privileges, use
<code class="literal">
ON
<em class="replaceable">
<code>
db_name.tbl_name
</code>
</em>
</code>
syntax:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa16420744"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">GRANT</span> <span class="token keyword">ALL</span> <span class="token keyword">ON</span> mydb<span class="token punctuation">.</span>mytbl <span class="token keyword">TO</span> <span class="token string">'someuser'</span>@<span class="token string">'somehost'</span><span class="token punctuation">;</span>
<span class="token keyword">GRANT</span> <span class="token keyword">SELECT</span><span class="token punctuation">,</span> <span class="token keyword">INSERT</span> <span class="token keyword">ON</span> mydb<span class="token punctuation">.</span>mytbl <span class="token keyword">TO</span> <span class="token string">'someuser'</span>@<span class="token string">'somehost'</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
If you specify
<em class="replaceable">
<code>
tbl_name
</code>
</em>
rather than
<em class="replaceable">
<code>
db_name.tbl_name
</code>
</em>
, the statement
applies to
<em class="replaceable">
<code>
tbl_name
</code>
</em>
in the default
database. An error occurs if there is no default database.
</p>
<p>
The permissible
<em class="replaceable">
<code>
priv_type
</code>
</em>
values at
the table level are
<a class="link" href="privileges-provided.html#priv_alter">
<code class="literal">
ALTER
</code>
</a>
,
<a class="link" href="privileges-provided.html#priv_create-view">
<code class="literal">
CREATE VIEW
</code>
</a>
,
<a class="link" href="privileges-provided.html#priv_create">
<code class="literal">
CREATE
</code>
</a>
,
<a class="link" href="privileges-provided.html#priv_delete">
<code class="literal">
DELETE
</code>
</a>
,
<a class="link" href="privileges-provided.html#priv_drop">
<code class="literal">
DROP
</code>
</a>
,
<a class="link" href="privileges-provided.html#priv_grant-option">
<code class="literal">
GRANT OPTION
</code>
</a>
,
<a class="link" href="privileges-provided.html#priv_index">
<code class="literal">
INDEX
</code>
</a>
,
<a class="link" href="privileges-provided.html#priv_insert">
<code class="literal">
INSERT
</code>
</a>
,
<a class="link" href="privileges-provided.html#priv_references">
<code class="literal">
REFERENCES
</code>
</a>
,
<a class="link" href="privileges-provided.html#priv_select">
<code class="literal">
SELECT
</code>
</a>
,
<a class="link" href="privileges-provided.html#priv_show-view">
<code class="literal">
SHOW VIEW
</code>
</a>
,
<a class="link" href="privileges-provided.html#priv_trigger">
<code class="literal">
TRIGGER
</code>
</a>
, and
<a class="link" href="privileges-provided.html#priv_update">
<code class="literal">
UPDATE
</code>
</a>
.
</p>
<p>
Table-level privileges apply to base tables and views. They do
not apply to tables created with
<a class="link" href="create-temporary-table.html" title="15.1.20.2 CREATE TEMPORARY TABLE Statement">
<code class="literal">
CREATE
TEMPORARY TABLE
</code>
</a>
, even if the table names match. For
information about
<code class="literal">
TEMPORARY
</code>
table
privileges, see
<a class="xref" href="create-temporary-table.html" title="15.1.20.2 CREATE TEMPORARY TABLE Statement">
Section 15.1.20.2, “CREATE TEMPORARY TABLE Statement”
</a>
.
</p>
<a class="indexterm" name="idm46045173390208">
</a>
<a class="indexterm" name="idm46045173388720">
</a>
<p>
MySQL stores table privileges in the
<code class="literal">
mysql.tables_priv
</code>
system table.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="grant-column-privileges">
</a>
Column Privileges
</h5>
</div>
</div>
</div>
<p>
Column privileges apply to single columns in a given table.
Each privilege to be granted at the column level must be
followed by the column or columns, enclosed within
parentheses.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa39804227"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">GRANT</span> <span class="token keyword">SELECT</span> <span class="token punctuation">(</span>col1<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token function">INSERT</span> <span class="token punctuation">(</span>col1<span class="token punctuation">,</span> col2<span class="token punctuation">)</span> <span class="token keyword">ON</span> mydb<span class="token punctuation">.</span>mytbl <span class="token keyword">TO</span> <span class="token string">'someuser'</span>@<span class="token string">'somehost'</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
The permissible
<em class="replaceable">
<code>
priv_type
</code>
</em>
values
for a column (that is, when you use a
<em class="replaceable">
<code>
column_list
</code>
</em>
clause) are
<a class="link" href="privileges-provided.html#priv_insert">
<code class="literal">
INSERT
</code>
</a>
,
<a class="link" href="privileges-provided.html#priv_references">
<code class="literal">
REFERENCES
</code>
</a>
,
<a class="link" href="privileges-provided.html#priv_select">
<code class="literal">
SELECT
</code>
</a>
, and
<a class="link" href="privileges-provided.html#priv_update">
<code class="literal">
UPDATE
</code>
</a>
.
</p>
<p>
MySQL stores column privileges in the
<code class="literal">
mysql.columns_priv
</code>
system table.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="grant-routine-privileges">
</a>
Stored Routine Privileges
</h5>
</div>
</div>
</div>
<p>
The
<a class="link" href="privileges-provided.html#priv_alter-routine">
<code class="literal">
ALTER ROUTINE
</code>
</a>
,
<a class="link" href="privileges-provided.html#priv_create-routine">
<code class="literal">
CREATE ROUTINE
</code>
</a>
,
<a class="link" href="privileges-provided.html#priv_execute">
<code class="literal">
EXECUTE
</code>
</a>
, and
<a class="link" href="privileges-provided.html#priv_grant-option">
<code class="literal">
GRANT OPTION
</code>
</a>
privileges apply
to stored routines (procedures and functions). They can be
granted at the global and database levels. Except for
<a class="link" href="privileges-provided.html#priv_create-routine">
<code class="literal">
CREATE ROUTINE
</code>
</a>
, these
privileges can be granted at the routine level for individual
routines.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa42214503"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">GRANT</span> <span class="token keyword">CREATE</span> <span class="token keyword">ROUTINE</span> <span class="token keyword">ON</span> mydb<span class="token punctuation">.</span><span class="token operator">*</span> <span class="token keyword">TO</span> <span class="token string">'someuser'</span>@<span class="token string">'somehost'</span><span class="token punctuation">;</span>
<span class="token keyword">GRANT</span> <span class="token keyword">EXECUTE</span> <span class="token keyword">ON</span> <span class="token keyword">PROCEDURE</span> mydb<span class="token punctuation">.</span>myproc <span class="token keyword">TO</span> <span class="token string">'someuser'</span>@<span class="token string">'somehost'</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
The permissible
<em class="replaceable">
<code>
priv_type
</code>
</em>
values at
the routine level are
<a class="link" href="privileges-provided.html#priv_alter-routine">
<code class="literal">
ALTER
ROUTINE
</code>
</a>
,
<a class="link" href="privileges-provided.html#priv_execute">
<code class="literal">
EXECUTE
</code>
</a>
, and
<a class="link" href="privileges-provided.html#priv_grant-option">
<code class="literal">
GRANT OPTION
</code>
</a>
.
<a class="link" href="privileges-provided.html#priv_create-routine">
<code class="literal">
CREATE ROUTINE
</code>
</a>
is not a
routine-level privilege because you must have the privilege at
the global or database level to create a routine in the first
place.
</p>
<p>
MySQL stores routine-level privileges in the
<code class="literal">
mysql.procs_priv
</code>
system table.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="grant-proxy-privileges">
</a>
Proxy User Privileges
</h5>
</div>
</div>
</div>
<p>
The
<a class="link" href="privileges-provided.html#priv_proxy">
<code class="literal">
PROXY
</code>
</a>
privilege enables one
user to be a proxy for another. The proxy user impersonates or
takes the identity of the proxied user; that is, it assumes
the privileges of the proxied user.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa69395086"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">GRANT</span> <span class="token keyword">PROXY</span> <span class="token keyword">ON</span> <span class="token string">'localuser'</span>@<span class="token string">'localhost'</span> <span class="token keyword">TO</span> <span class="token string">'externaluser'</span>@<span class="token string">'somehost'</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
When
<a class="link" href="privileges-provided.html#priv_proxy">
<code class="literal">
PROXY
</code>
</a>
is granted, it must
be the only privilege named in the
<a class="link" href="grant.html" title="15.7.1.6 GRANT Statement">
<code class="literal">
GRANT
</code>
</a>
statement, and the only
permitted
<code class="literal">
WITH
</code>
option is
<code class="literal">
WITH
GRANT OPTION
</code>
.
</p>
<p>
Proxying requires that the proxy user authenticate through a
plugin that returns the name of the proxied user to the server
when the proxy user connects, and that the proxy user have the
<code class="literal">
PROXY
</code>
privilege for the proxied user. For
details and examples, see
<a class="xref" href="proxy-users.html" title="8.2.19 Proxy Users">
Section 8.2.19, “Proxy Users”
</a>
.
</p>
<p>
MySQL stores proxy privileges in the
<code class="literal">
mysql.proxies_priv
</code>
system table.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="grant-roles">
</a>
Granting Roles
</h5>
</div>
</div>
</div>
<p>
<code class="literal">
GRANT
</code>
syntax without an
<code class="literal">
ON
</code>
clause grants roles rather than
individual privileges. A role is a named collection of
privileges; see
<a class="xref" href="roles.html" title="8.2.10 Using Roles">
Section 8.2.10, “Using Roles”
</a>
. For example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa92253735"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">GRANT</span> <span class="token string">'role1'</span><span class="token punctuation">,</span> <span class="token string">'role2'</span> <span class="token keyword">TO</span> <span class="token string">'user1'</span>@<span class="token string">'localhost'</span><span class="token punctuation">,</span> <span class="token string">'user2'</span>@<span class="token string">'localhost'</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
Each role to be granted must exist, as well as each user
account or role to which it is to be granted. Roles cannot be
granted to anonymous users.
</p>
<p>
Granting a role does not automatically cause the role to be
active. For information about role activation and
inactivation, see
<a class="xref" href="roles.html#roles-activating" title="Activating Roles">
Activating Roles
</a>
.
</p>
<p>
These privileges are required to grant roles:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
If you have the
<a class="link" href="privileges-provided.html#priv_role-admin">
<code class="literal">
ROLE_ADMIN
</code>
</a>
privilege (or the deprecated
<a class="link" href="privileges-provided.html#priv_super">
<code class="literal">
SUPER
</code>
</a>
privilege), you can
grant or revoke any role to users or roles.
</p>
</li>
<li class="listitem">
<p>
If you were granted a role with a
<a class="link" href="grant.html" title="15.7.1.6 GRANT Statement">
<code class="literal">
GRANT
</code>
</a>
statement that
includes the
<code class="literal">
WITH ADMIN OPTION
</code>
clause,
you become able to grant that role to other users or
roles, or revoke it from other users or roles, as long as
the role is active at such time as you subsequently grant
or revoke it. This includes the ability to use
<code class="literal">
WITH ADMIN OPTION
</code>
itself.
</p>
</li>
<li class="listitem">
<p>
To grant a role that has the
<a class="link" href="privileges-provided.html#priv_system-user">
<code class="literal">
SYSTEM_USER
</code>
</a>
privilege, you
must have the
<a class="link" href="privileges-provided.html#priv_system-user">
<code class="literal">
SYSTEM_USER
</code>
</a>
privilege.
</p>
</li>
</ul>
</div>
<p>
It is possible to create circular references with
<a class="link" href="grant.html" title="15.7.1.6 GRANT Statement">
<code class="literal">
GRANT
</code>
</a>
. For example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa63968337"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">CREATE</span> <span class="token keyword">USER</span> <span class="token string">'u1'</span><span class="token punctuation">,</span> <span class="token string">'u2'</span><span class="token punctuation">;</span>
<span class="token keyword">CREATE</span> <span class="token keyword">ROLE</span> <span class="token string">'r1'</span><span class="token punctuation">,</span> <span class="token string">'r2'</span><span class="token punctuation">;</span>
<span class="token keyword">GRANT</span> <span class="token string">'u1'</span> <span class="token keyword">TO</span> <span class="token string">'u1'</span><span class="token punctuation">;</span> <span class="token comment" spellcheck="true">-- simple loop: u1 => u1</span>
<span class="token keyword">GRANT</span> <span class="token string">'r1'</span> <span class="token keyword">TO</span> <span class="token string">'r1'</span><span class="token punctuation">;</span> <span class="token comment" spellcheck="true">-- simple loop: r1 => r1</span>
<span class="token keyword">GRANT</span> <span class="token string">'r2'</span> <span class="token keyword">TO</span> <span class="token string">'u2'</span><span class="token punctuation">;</span>
<span class="token keyword">GRANT</span> <span class="token string">'u2'</span> <span class="token keyword">TO</span> <span class="token string">'r2'</span><span class="token punctuation">;</span> <span class="token comment" spellcheck="true">-- mixed user/role loop: u2 => r2 => u2</span></code></pre>
</div>
<p>
Circular grant references are permitted but add no new
privileges or roles to the grantee because a user or role
already has its privileges and roles.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="grant-as">
</a>
The
<code class="literal">
AS
</code>
Clause and Privilege Restrictions
</h5>
</div>
</div>
</div>
<a class="indexterm" name="idm46045173324400">
</a>
<a class="indexterm" name="idm46045173322912">
</a>
<p>
<a class="link" href="grant.html" title="15.7.1.6 GRANT Statement">
<code class="literal">
GRANT
</code>
</a>
can specify additional
information about the privilege context to use for statement
execution by using an
<code class="literal">
AS
<em class="replaceable">
<code>
user
</code>
</em>
[WITH ROLE]
</code>
clause.
This syntax is visible at the SQL level, although its primary
purpose is to enable uniform replication across all nodes of
grantor privilege restrictions imposed by partial revokes, by
causing those restrictions to appear in the binary log. For
information about partial revokes, see
<a class="xref" href="partial-revokes.html" title="8.2.12 Privilege Restriction Using Partial Revokes">
Section 8.2.12, “Privilege Restriction Using Partial Revokes”
</a>
.
</p>
<p>
When the
<code class="literal">
AS
<em class="replaceable">
<code>
user
</code>
</em>
</code>
clause is specified, statement execution takes into account
any privilege restrictions associated with the named user,
including all roles specified by
<code class="literal">
WITH ROLE
</code>
,
if present. The result is that the privileges actually granted
by the statement may be reduced relative to those specified.
</p>
<p>
These conditions apply to the
<code class="literal">
AS
<em class="replaceable">
<code>
user
</code>
</em>
</code>
clause:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
AS
</code>
has an effect only when the named
<em class="replaceable">
<code>
user
</code>
</em>
has privilege restrictions
(which implies that the
<a class="link" href="server-system-variables.html#sysvar_partial_revokes">
<code class="literal">
partial_revokes
</code>
</a>
system
variable is enabled).
</p>
</li>
<li class="listitem">
<p>
If
<code class="literal">
WITH ROLE
</code>
is given, all roles named
must be granted to the named
<em class="replaceable">
<code>
user
</code>
</em>
.
</p>
</li>
<li class="listitem">
<p>
The named
<em class="replaceable">
<code>
user
</code>
</em>
should be a
MySQL account specified as
<code class="literal">
'
<em class="replaceable">
<code>
user_name
</code>
</em>
'@'
<em class="replaceable">
<code>
host_name
</code>
</em>
'
</code>
,
<a class="link" href="information-functions.html#function_current-user">
<code class="literal">
CURRENT_USER
</code>
</a>
, or
<a class="link" href="information-functions.html#function_current-user">
<code class="literal">
CURRENT_USER()
</code>
</a>
. The current
user may be named together with
<code class="literal">
WITH
ROLE
</code>
for the case that the executing user wants
<a class="link" href="grant.html" title="15.7.1.6 GRANT Statement">
<code class="literal">
GRANT
</code>
</a>
to execute with a set
of roles applied that may differ from the roles active
within the current session.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
AS
</code>
cannot be used to gain privileges
not possessed by the user who executes the
<a class="link" href="grant.html" title="15.7.1.6 GRANT Statement">
<code class="literal">
GRANT
</code>
</a>
statement. The
executing user must have at least the privileges to be
granted, but the
<code class="literal">
AS
</code>
clause can only
restrict the privileges granted, not escalate them.
</p>
</li>
<li class="listitem">
<p>
With respect to the privileges to be granted,
<code class="literal">
AS
</code>
cannot specify a user/role
combination that has more privileges (fewer restrictions)
than the user who executes the
<a class="link" href="grant.html" title="15.7.1.6 GRANT Statement">
<code class="literal">
GRANT
</code>
</a>
statement. The
<code class="literal">
AS
</code>
user/role combination is permitted
to have more privileges than the executing user, but only
if the statement does not grant those additional
privileges.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
AS
</code>
is supported only for granting
global privileges (
<code class="literal">
ON *.*
</code>
).
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
AS
</code>
is not supported for
<a class="link" href="privileges-provided.html#priv_proxy">
<code class="literal">
PROXY
</code>
</a>
grants.
</p>
</li>
</ul>
</div>
<p>
The following example illustrates the effect of the
<code class="literal">
AS
</code>
clause. Create a user
<code class="literal">
u1
</code>
that has some global privileges, as well
as restrictions on those privileges:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa75268111"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">CREATE</span> <span class="token keyword">USER</span> u1<span class="token punctuation">;</span>
<span class="token keyword">GRANT</span> <span class="token keyword">SELECT</span><span class="token punctuation">,</span> <span class="token keyword">INSERT</span><span class="token punctuation">,</span> <span class="token keyword">UPDATE</span><span class="token punctuation">,</span> <span class="token keyword">DELETE</span> <span class="token keyword">ON</span> <span class="token operator">*</span><span class="token punctuation">.</span><span class="token operator">*</span> <span class="token keyword">TO</span> u1<span class="token punctuation">;</span>
<span class="token keyword">REVOKE</span> <span class="token keyword">INSERT</span><span class="token punctuation">,</span> <span class="token keyword">UPDATE</span> <span class="token keyword">ON</span> schema1<span class="token punctuation">.</span><span class="token operator">*</span> <span class="token keyword">FROM</span> u1<span class="token punctuation">;</span>
<span class="token keyword">REVOKE</span> <span class="token keyword">SELECT</span> <span class="token keyword">ON</span> schema2<span class="token punctuation">.</span><span class="token operator">*</span> <span class="token keyword">FROM</span> u1<span class="token punctuation">;</span></code></pre>
</div>
<p>
Also create a role
<code class="literal">
r1
</code>
that lifts some of
the privilege restrictions and grant the role to
<code class="literal">
u1
</code>
:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa60383714"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">CREATE</span> <span class="token keyword">ROLE</span> r1<span class="token punctuation">;</span>
<span class="token keyword">GRANT</span> <span class="token keyword">INSERT</span> <span class="token keyword">ON</span> schema1<span class="token punctuation">.</span><span class="token operator">*</span> <span class="token keyword">TO</span> r1<span class="token punctuation">;</span>
<span class="token keyword">GRANT</span> <span class="token keyword">SELECT</span> <span class="token keyword">ON</span> schema2<span class="token punctuation">.</span><span class="token operator">*</span> <span class="token keyword">TO</span> r1<span class="token punctuation">;</span>
<span class="token keyword">GRANT</span> r1 <span class="token keyword">TO</span> u1<span class="token punctuation">;</span></code></pre>
</div>
<p>
Now, using an account that has no privilege restrictions of
its own, grant to multiple users the same set of global
privileges, but each with different restrictions imposed by
the
<code class="literal">
AS
</code>
clause, and check which privileges
are actually granted.
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
The
<a class="link" href="grant.html" title="15.7.1.6 GRANT Statement">
<code class="literal">
GRANT
</code>
</a>
statement here
has no
<code class="literal">
AS
</code>
clause, so the privileges
granted are exactly those specified:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa64961744"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">CREATE</span> <span class="token keyword">USER</span> u2<span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">GRANT</span> <span class="token keyword">SELECT</span><span class="token punctuation">,</span> <span class="token keyword">INSERT</span><span class="token punctuation">,</span> <span class="token keyword">UPDATE</span> <span class="token keyword">ON</span> <span class="token operator">*</span><span class="token punctuation">.</span><span class="token operator">*</span> <span class="token keyword">TO</span> u2<span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">SHOW</span> <span class="token keyword">GRANTS</span> <span class="token keyword">FOR</span> u2<span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> Grants for u2@% <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> GRANT SELECT, INSERT, UPDATE ON *.* TO `u2`@`%` <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
</li>
<li class="listitem">
<p>
The
<a class="link" href="grant.html" title="15.7.1.6 GRANT Statement">
<code class="literal">
GRANT
</code>
</a>
statement here
has an
<code class="literal">
AS
</code>
clause, so the privileges
granted are those specified but with the restrictions from
<code class="literal">
u1
</code>
applied:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa70930381"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">CREATE</span> <span class="token keyword">USER</span> u3<span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">GRANT</span> <span class="token keyword">SELECT</span><span class="token punctuation">,</span> <span class="token keyword">INSERT</span><span class="token punctuation">,</span> <span class="token keyword">UPDATE</span> <span class="token keyword">ON</span> <span class="token operator">*</span><span class="token punctuation">.</span><span class="token operator">*</span> <span class="token keyword">TO</span> u3 <span class="token keyword">AS</span> u1<span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">SHOW</span> <span class="token keyword">GRANTS</span> <span class="token keyword">FOR</span> u3<span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> Grants for u3@% <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> GRANT SELECT, INSERT, UPDATE ON *.* TO `u3`@`%` <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> REVOKE INSERT, UPDATE ON `schema1`.* FROM `u3`@`%` <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> REVOKE SELECT ON `schema2`.* FROM `u3`@`%` <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
<p>
As mentioned previously, the
<code class="literal">
AS
</code>
clause
can only add privilege restrictions; it cannot escalate
privileges. Thus, although
<code class="literal">
u1
</code>
has the
<a class="link" href="privileges-provided.html#priv_delete">
<code class="literal">
DELETE
</code>
</a>
privilege, that is
not included in the privileges granted because the
statement does not specify granting
<a class="link" href="privileges-provided.html#priv_delete">
<code class="literal">
DELETE
</code>
</a>
.
</p>
</li>
<li class="listitem">
<p>
The
<code class="literal">
AS
</code>
clause for the
<a class="link" href="grant.html" title="15.7.1.6 GRANT Statement">
<code class="literal">
GRANT
</code>
</a>
statement here makes
the role
<code class="literal">
r1
</code>
active for
<code class="literal">
u1
</code>
. That role lifts some of the
restrictions on
<code class="literal">
u1
</code>
. Consequently, the
privileges granted have some restrictions, but not so many
as for the previous
<a class="link" href="grant.html" title="15.7.1.6 GRANT Statement">
<code class="literal">
GRANT
</code>
</a>
statement:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa51770087"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">CREATE</span> <span class="token keyword">USER</span> u4<span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">GRANT</span> <span class="token keyword">SELECT</span><span class="token punctuation">,</span> <span class="token keyword">INSERT</span><span class="token punctuation">,</span> <span class="token keyword">UPDATE</span> <span class="token keyword">ON</span> <span class="token operator">*</span><span class="token punctuation">.</span><span class="token operator">*</span> <span class="token keyword">TO</span> u4 <span class="token keyword">AS</span> u1 <span class="token keyword">WITH</span> <span class="token keyword">ROLE</span> r1<span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">SHOW</span> <span class="token keyword">GRANTS</span> <span class="token keyword">FOR</span> u4<span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> Grants for u4@% <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> GRANT SELECT, INSERT, UPDATE ON *.* TO `u4`@`%` <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> REVOKE UPDATE ON `schema1`.* FROM `u4`@`%` <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
</li>
</ul>
</div>
<p>
If a
<a class="link" href="grant.html" title="15.7.1.6 GRANT Statement">
<code class="literal">
GRANT
</code>
</a>
statement includes
an
<code class="literal">
AS
<em class="replaceable">
<code>
user
</code>
</em>
</code>
clause, privilege restrictions on the user who executes the
statement are ignored (rather than applied as they would be in
the absence of an
<code class="literal">
AS
</code>
clause).
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="grant-other-characteristics">
</a>
Other Account Characteristics
</h5>
</div>
</div>
</div>
<p>
The optional
<code class="literal">
WITH
</code>
clause is used to enable
a user to grant privileges to other users. The
<code class="literal">
WITH
GRANT OPTION
</code>
clause gives the user the ability to
give to other users any privileges the user has at the
specified privilege level.
</p>
<p>
To grant the
<a class="link" href="privileges-provided.html#priv_grant-option">
<code class="literal">
GRANT OPTION
</code>
</a>
privilege to an account without otherwise changing its
privileges, do this:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa93834064"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">GRANT</span> <span class="token keyword">USAGE</span> <span class="token keyword">ON</span> <span class="token operator">*</span><span class="token punctuation">.</span><span class="token operator">*</span> <span class="token keyword">TO</span> <span class="token string">'someuser'</span>@<span class="token string">'somehost'</span> <span class="token keyword">WITH</span> <span class="token keyword">GRANT</span> <span class="token keyword">OPTION</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
Be careful to whom you give the
<a class="link" href="privileges-provided.html#priv_grant-option">
<code class="literal">
GRANT
OPTION
</code>
</a>
privilege because two users with different
privileges may be able to combine privileges!
</p>
<p>
You cannot grant another user a privilege which you yourself
do not have; the
<a class="link" href="privileges-provided.html#priv_grant-option">
<code class="literal">
GRANT OPTION
</code>
</a>
privilege enables you to assign only those privileges which
you yourself possess.
</p>
<p>
Be aware that when you grant a user the
<a class="link" href="privileges-provided.html#priv_grant-option">
<code class="literal">
GRANT OPTION
</code>
</a>
privilege at a
particular privilege level, any privileges the user possesses
(or may be given in the future) at that level can also be
granted by that user to other users. Suppose that you grant a
user the
<a class="link" href="privileges-provided.html#priv_insert">
<code class="literal">
INSERT
</code>
</a>
privilege on a
database. If you then grant the
<a class="link" href="privileges-provided.html#priv_select">
<code class="literal">
SELECT
</code>
</a>
privilege on the
database and specify
<code class="literal">
WITH GRANT OPTION
</code>
,
that user can give to other users not only the
<a class="link" href="privileges-provided.html#priv_select">
<code class="literal">
SELECT
</code>
</a>
privilege, but also
<a class="link" href="privileges-provided.html#priv_insert">
<code class="literal">
INSERT
</code>
</a>
. If you then grant the
<a class="link" href="privileges-provided.html#priv_update">
<code class="literal">
UPDATE
</code>
</a>
privilege to the user on
the database, the user can grant
<a class="link" href="privileges-provided.html#priv_insert">
<code class="literal">
INSERT
</code>
</a>
,
<a class="link" href="privileges-provided.html#priv_select">
<code class="literal">
SELECT
</code>
</a>
, and
<a class="link" href="privileges-provided.html#priv_update">
<code class="literal">
UPDATE
</code>
</a>
.
</p>
<p>
For a nonadministrative user, you should not grant the
<a class="link" href="privileges-provided.html#priv_alter">
<code class="literal">
ALTER
</code>
</a>
privilege globally or for
the
<code class="literal">
mysql
</code>
system schema. If you do that,
the user can try to subvert the privilege system by renaming
tables!
</p>
<p>
For additional information about security risks associated
with particular privileges, see
<a class="xref" href="privileges-provided.html" title="8.2.2 Privileges Provided by MySQL">
Section 8.2.2, “Privileges Provided by MySQL”
</a>
.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="grant-mysql-vs-standard-sql">
</a>
MySQL and Standard SQL Versions of GRANT
</h5>
</div>
</div>
</div>
<a class="indexterm" name="idm46045173222000">
</a>
<p>
The biggest differences between the MySQL and standard SQL
versions of
<a class="link" href="grant.html" title="15.7.1.6 GRANT Statement">
<code class="literal">
GRANT
</code>
</a>
are:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
MySQL associates privileges with the combination of a host
name and user name and not with only a user name.
</p>
</li>
<li class="listitem">
<p>
Standard SQL does not have global or database-level
privileges, nor does it support all the privilege types
that MySQL supports.
</p>
</li>
<li class="listitem">
<p>
MySQL does not support the standard SQL
<code class="literal">
UNDER
</code>
privilege.
</p>
</li>
<li class="listitem">
<p>
Standard SQL privileges are structured in a hierarchical
manner. If you remove a user, all privileges the user has
been granted are revoked. This is also true in MySQL if
you use
<a class="link" href="drop-user.html" title="15.7.1.5 DROP USER Statement">
<code class="literal">
DROP USER
</code>
</a>
. See
<a class="xref" href="drop-user.html" title="15.7.1.5 DROP USER Statement">
Section 15.7.1.5, “DROP USER Statement”
</a>
.
</p>
</li>
<li class="listitem">
<p>
In standard SQL, when you drop a table, all privileges for
the table are revoked. In standard SQL, when you revoke a
privilege, all privileges that were granted based on that
privilege are also revoked. In MySQL, privileges can be
dropped with
<a class="link" href="drop-user.html" title="15.7.1.5 DROP USER Statement">
<code class="literal">
DROP USER
</code>
</a>
or
<a class="link" href="revoke.html" title="15.7.1.8 REVOKE Statement">
<code class="literal">
REVOKE
</code>
</a>
statements.
</p>
</li>
<li class="listitem">
<p>
In MySQL, it is possible to have the
<a class="link" href="privileges-provided.html#priv_insert">
<code class="literal">
INSERT
</code>
</a>
privilege for only
some of the columns in a table. In this case, you can
still execute
<a class="link" href="insert.html" title="15.2.7 INSERT Statement">
<code class="literal">
INSERT
</code>
</a>
statements on the table, provided that you insert values
only for those columns for which you have the
<a class="link" href="privileges-provided.html#priv_insert">
<code class="literal">
INSERT
</code>
</a>
privilege. The
omitted columns are set to their implicit default values
if strict SQL mode is not enabled. In strict mode, the
statement is rejected if any of the omitted columns have
no default value. (Standard SQL requires you to have the
<a class="link" href="privileges-provided.html#priv_insert">
<code class="literal">
INSERT
</code>
</a>
privilege on all
columns.) For information about strict SQL mode and
implicit default values, see
<a class="xref" href="sql-mode.html" title="7.1.11 Server SQL Modes">
Section 7.1.11, “Server SQL Modes”
</a>
,
and
<a class="xref" href="data-type-defaults.html" title="13.6 Data Type Default Values">
Section 13.6, “Data Type Default Values”
</a>
.
</p>
</li>
</ul>
</div>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/numeric-functions.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h2 class="title">
<a name="numeric-functions">
</a>
14.6 Numeric Functions and Operators
</h2>
</div>
</div>
</div>
<div class="toc">
<dl class="toc">
<dt>
<span class="section">
<a href="arithmetic-functions.html">
14.6.1 Arithmetic Operators
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="mathematical-functions.html">
14.6.2 Mathematical Functions
</a>
</span>
</dt>
</dl>
</div>
<div class="table">
<a name="idm46045206575392">
</a>
<p class="title">
<b>
Table 14.8 Numeric Functions and Operators
</b>
</p>
<div class="table-contents">
<table frame="box" rules="all" summary="A reference that lists numeric functions and operators.">
<colgroup>
<col style="width: 28%"/>
<col style="width: 71%"/>
</colgroup>
<thead>
<tr>
<th>
Name
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<a class="link" href="arithmetic-functions.html#operator_mod">
<code class="literal">
%
</code>
,
<code class="literal">
MOD
</code>
</a>
</td>
<td>
Modulo operator
</td>
</tr>
<tr>
<td>
<a class="link" href="arithmetic-functions.html#operator_times">
<code class="literal">
*
</code>
</a>
</td>
<td>
Multiplication operator
</td>
</tr>
<tr>
<td>
<a class="link" href="arithmetic-functions.html#operator_plus">
<code class="literal">
+
</code>
</a>
</td>
<td>
Addition operator
</td>
</tr>
<tr>
<td>
<a class="link" href="arithmetic-functions.html#operator_minus">
<code class="literal">
-
</code>
</a>
</td>
<td>
Minus operator
</td>
</tr>
<tr>
<td>
<a class="link" href="arithmetic-functions.html#operator_unary-minus">
<code class="literal">
-
</code>
</a>
</td>
<td>
Change the sign of the argument
</td>
</tr>
<tr>
<td>
<a class="link" href="arithmetic-functions.html#operator_divide">
<code class="literal">
/
</code>
</a>
</td>
<td>
Division operator
</td>
</tr>
<tr>
<td>
<a class="link" href="mathematical-functions.html#function_abs">
<code class="literal">
ABS()
</code>
</a>
</td>
<td>
Return the absolute value
</td>
</tr>
<tr>
<td>
<a class="link" href="mathematical-functions.html#function_acos">
<code class="literal">
ACOS()
</code>
</a>
</td>
<td>
Return the arc cosine
</td>
</tr>
<tr>
<td>
<a class="link" href="mathematical-functions.html#function_asin">
<code class="literal">
ASIN()
</code>
</a>
</td>
<td>
Return the arc sine
</td>
</tr>
<tr>
<td>
<a class="link" href="mathematical-functions.html#function_atan">
<code class="literal">
ATAN()
</code>
</a>
</td>
<td>
Return the arc tangent
</td>
</tr>
<tr>
<td>
<a class="link" href="mathematical-functions.html#function_atan2">
<code class="literal">
ATAN2()
</code>
,
<code class="literal">
ATAN()
</code>
</a>
</td>
<td>
Return the arc tangent of the two arguments
</td>
</tr>
<tr>
<td>
<a class="link" href="mathematical-functions.html#function_ceil">
<code class="literal">
CEIL()
</code>
</a>
</td>
<td>
Return the smallest integer value not less than the argument
</td>
</tr>
<tr>
<td>
<a class="link" href="mathematical-functions.html#function_ceiling">
<code class="literal">
CEILING()
</code>
</a>
</td>
<td>
Return the smallest integer value not less than the argument
</td>
</tr>
<tr>
<td>
<a class="link" href="mathematical-functions.html#function_conv">
<code class="literal">
CONV()
</code>
</a>
</td>
<td>
Convert numbers between different number bases
</td>
</tr>
<tr>
<td>
<a class="link" href="mathematical-functions.html#function_cos">
<code class="literal">
COS()
</code>
</a>
</td>
<td>
Return the cosine
</td>
</tr>
<tr>
<td>
<a class="link" href="mathematical-functions.html#function_cot">
<code class="literal">
COT()
</code>
</a>
</td>
<td>
Return the cotangent
</td>
</tr>
<tr>
<td>
<a class="link" href="mathematical-functions.html#function_crc32">
<code class="literal">
CRC32()
</code>
</a>
</td>
<td>
Compute a cyclic redundancy check value
</td>
</tr>
<tr>
<td>
<a class="link" href="mathematical-functions.html#function_degrees">
<code class="literal">
DEGREES()
</code>
</a>
</td>
<td>
Convert radians to degrees
</td>
</tr>
<tr>
<td>
<a class="link" href="arithmetic-functions.html#operator_div">
<code class="literal">
DIV
</code>
</a>
</td>
<td>
Integer division
</td>
</tr>
<tr>
<td>
<a class="link" href="mathematical-functions.html#function_exp">
<code class="literal">
EXP()
</code>
</a>
</td>
<td>
Raise to the power of
</td>
</tr>
<tr>
<td>
<a class="link" href="mathematical-functions.html#function_floor">
<code class="literal">
FLOOR()
</code>
</a>
</td>
<td>
Return the largest integer value not greater than the argument
</td>
</tr>
<tr>
<td>
<a class="link" href="mathematical-functions.html#function_ln">
<code class="literal">
LN()
</code>
</a>
</td>
<td>
Return the natural logarithm of the argument
</td>
</tr>
<tr>
<td>
<a class="link" href="mathematical-functions.html#function_log">
<code class="literal">
LOG()
</code>
</a>
</td>
<td>
Return the natural logarithm of the first argument
</td>
</tr>
<tr>
<td>
<a class="link" href="mathematical-functions.html#function_log10">
<code class="literal">
LOG10()
</code>
</a>
</td>
<td>
Return the base-10 logarithm of the argument
</td>
</tr>
<tr>
<td>
<a class="link" href="mathematical-functions.html#function_log2">
<code class="literal">
LOG2()
</code>
</a>
</td>
<td>
Return the base-2 logarithm of the argument
</td>
</tr>
<tr>
<td>
<a class="link" href="mathematical-functions.html#function_mod">
<code class="literal">
MOD()
</code>
</a>
</td>
<td>
Return the remainder
</td>
</tr>
<tr>
<td>
<a class="link" href="mathematical-functions.html#function_pi">
<code class="literal">
PI()
</code>
</a>
</td>
<td>
Return the value of pi
</td>
</tr>
<tr>
<td>
<a class="link" href="mathematical-functions.html#function_pow">
<code class="literal">
POW()
</code>
</a>
</td>
<td>
Return the argument raised to the specified power
</td>
</tr>
<tr>
<td>
<a class="link" href="mathematical-functions.html#function_power">
<code class="literal">
POWER()
</code>
</a>
</td>
<td>
Return the argument raised to the specified power
</td>
</tr>
<tr>
<td>
<a class="link" href="mathematical-functions.html#function_radians">
<code class="literal">
RADIANS()
</code>
</a>
</td>
<td>
Return argument converted to radians
</td>
</tr>
<tr>
<td>
<a class="link" href="mathematical-functions.html#function_rand">
<code class="literal">
RAND()
</code>
</a>
</td>
<td>
Return a random floating-point value
</td>
</tr>
<tr>
<td>
<a class="link" href="mathematical-functions.html#function_round">
<code class="literal">
ROUND()
</code>
</a>
</td>
<td>
Round the argument
</td>
</tr>
<tr>
<td>
<a class="link" href="mathematical-functions.html#function_sign">
<code class="literal">
SIGN()
</code>
</a>
</td>
<td>
Return the sign of the argument
</td>
</tr>
<tr>
<td>
<a class="link" href="mathematical-functions.html#function_sin">
<code class="literal">
SIN()
</code>
</a>
</td>
<td>
Return the sine of the argument
</td>
</tr>
<tr>
<td>
<a class="link" href="mathematical-functions.html#function_sqrt">
<code class="literal">
SQRT()
</code>
</a>
</td>
<td>
Return the square root of the argument
</td>
</tr>
<tr>
<td>
<a class="link" href="mathematical-functions.html#function_tan">
<code class="literal">
TAN()
</code>
</a>
</td>
<td>
Return the tangent of the argument
</td>
</tr>
<tr>
<td>
<a class="link" href="mathematical-functions.html#function_truncate">
<code class="literal">
TRUNCATE()
</code>
</a>
</td>
<td>
Truncate to specified number of decimal places
</td>
</tr>
</tbody>
</table>
</div>
<div class="table-contents">
<table cellpadding="0" cellspacing="0" style="position: fixed; top: 0px; display: none; left: 401px; width: 567px;">
<thead>
<tr>
<th style="width: 159.984px;">
Name
</th>
<th style="width: 405.75px;">
Description
</th>
</tr>
</thead>
</table>
</div>
</div>
<br class="table-break"/>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/partitioning-limitations-functions.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="partitioning-limitations-functions">
</a>
26.6.3 Partitioning Limitations Relating to Functions
</h3>
</div>
</div>
</div>
<p>
This section discusses limitations in MySQL Partitioning
relating specifically to functions used in partitioning
expressions.
</p>
<a class="indexterm" name="idm46045082721744">
</a>
<p>
Only the MySQL functions shown in the following list are allowed
in partitioning expressions:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="link" href="mathematical-functions.html#function_abs">
<code class="literal">
ABS()
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="mathematical-functions.html#function_ceiling">
<code class="literal">
CEILING()
</code>
</a>
(see
<a class="xref" href="partitioning-limitations-functions.html#partitioning-limitations-ceiling-floor" title="CEILING() and FLOOR()">
CEILING() and FLOOR()
</a>
)
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="date-and-time-functions.html#function_datediff">
<code class="literal">
DATEDIFF()
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="date-and-time-functions.html#function_day">
<code class="literal">
DAY()
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="date-and-time-functions.html#function_dayofmonth">
<code class="literal">
DAYOFMONTH()
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="date-and-time-functions.html#function_dayofweek">
<code class="literal">
DAYOFWEEK()
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="date-and-time-functions.html#function_dayofyear">
<code class="literal">
DAYOFYEAR()
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="date-and-time-functions.html#function_extract">
<code class="literal">
EXTRACT()
</code>
</a>
(see
<a class="xref" href="partitioning-limitations-functions.html#partitioning-limitations-extract" title="EXTRACT() function with WEEK specifier">
EXTRACT() function with WEEK specifier
</a>
)
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="mathematical-functions.html#function_floor">
<code class="literal">
FLOOR()
</code>
</a>
(see
<a class="xref" href="partitioning-limitations-functions.html#partitioning-limitations-ceiling-floor" title="CEILING() and FLOOR()">
CEILING() and FLOOR()
</a>
)
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="date-and-time-functions.html#function_hour">
<code class="literal">
HOUR()
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="date-and-time-functions.html#function_microsecond">
<code class="literal">
MICROSECOND()
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="date-and-time-functions.html#function_minute">
<code class="literal">
MINUTE()
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="mathematical-functions.html#function_mod">
<code class="literal">
MOD()
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="date-and-time-functions.html#function_month">
<code class="literal">
MONTH()
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="date-and-time-functions.html#function_quarter">
<code class="literal">
QUARTER()
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="date-and-time-functions.html#function_second">
<code class="literal">
SECOND()
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="date-and-time-functions.html#function_time-to-sec">
<code class="literal">
TIME_TO_SEC()
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="date-and-time-functions.html#function_to-days">
<code class="literal">
TO_DAYS()
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="date-and-time-functions.html#function_to-seconds">
<code class="literal">
TO_SECONDS()
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="date-and-time-functions.html#function_unix-timestamp">
<code class="literal">
UNIX_TIMESTAMP()
</code>
</a>
(with
<a class="link" href="datetime.html" title="13.2.2 The DATE, DATETIME, and TIMESTAMP Types">
<code class="literal">
TIMESTAMP
</code>
</a>
columns)
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="date-and-time-functions.html#function_weekday">
<code class="literal">
WEEKDAY()
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="date-and-time-functions.html#function_year">
<code class="literal">
YEAR()
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="date-and-time-functions.html#function_yearweek">
<code class="literal">
YEARWEEK()
</code>
</a>
</p>
</li>
</ul>
</div>
<p>
In MySQL 8.4, partition pruning is supported for
the
<a class="link" href="date-and-time-functions.html#function_to-days">
<code class="literal">
TO_DAYS()
</code>
</a>
,
<a class="link" href="date-and-time-functions.html#function_to-seconds">
<code class="literal">
TO_SECONDS()
</code>
</a>
,
<a class="link" href="date-and-time-functions.html#function_year">
<code class="literal">
YEAR()
</code>
</a>
, and
<a class="link" href="date-and-time-functions.html#function_unix-timestamp">
<code class="literal">
UNIX_TIMESTAMP()
</code>
</a>
functions. See
<a class="xref" href="partitioning-pruning.html" title="26.4 Partition Pruning">
Section 26.4, “Partition Pruning”
</a>
, for more information.
</p>
<p>
<a name="partitioning-limitations-ceiling-floor">
</a>
<b>
CEILING() and FLOOR().
</b>
Each of these functions returns an integer only if it is
passed an argument of an exact numeric type, such as one of
the
<a class="link" href="integer-types.html" title="13.1.2 Integer Types (Exact Value) - INTEGER, INT, SMALLINT, TINYINT, MEDIUMINT, BIGINT">
<code class="literal">
INT
</code>
</a>
types or
<a class="link" href="fixed-point-types.html" title="13.1.3 Fixed-Point Types (Exact Value) - DECIMAL, NUMERIC">
<code class="literal">
DECIMAL
</code>
</a>
. This means, for
example, that the following
<a class="link" href="create-table.html" title="15.1.20 CREATE TABLE Statement">
<code class="literal">
CREATE
TABLE
</code>
</a>
statement fails with an error, as shown here:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa28732232"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> t <span class="token punctuation">(</span>c <span class="token datatype">FLOAT</span><span class="token punctuation">)</span> <span class="token keyword">PARTITION</span> <span class="token keyword">BY</span> <span class="token keyword">LIST</span><span class="token punctuation">(</span> <span class="token function">FLOOR</span><span class="token punctuation">(</span>c<span class="token punctuation">)</span> <span class="token punctuation">)</span><span class="token punctuation">(</span>
<span class="token prompt"> -></span> <span class="token keyword">PARTITION</span> p0 <span class="token keyword">VALUES</span> <span class="token keyword">IN</span> <span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">,</span><span class="token number">3</span><span class="token punctuation">,</span><span class="token number">5</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token prompt"> -></span> <span class="token keyword">PARTITION</span> p1 <span class="token keyword">VALUES</span> <span class="token keyword">IN</span> <span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">,</span><span class="token number">4</span><span class="token punctuation">,</span><span class="token number">6</span><span class="token punctuation">)</span>
<span class="token prompt"> -></span> <span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output">ERROR 1490 (HY000)<span class="token punctuation">:</span> The PARTITION function returns the wrong type</span></code></pre>
</div>
<p>
<a name="partitioning-limitations-extract">
</a>
<b>
EXTRACT() function with WEEK specifier.
</b>
The value returned by the
<a class="link" href="date-and-time-functions.html#function_extract">
<code class="literal">
EXTRACT()
</code>
</a>
function, when used
as
<a class="link" href="date-and-time-functions.html#function_extract">
<code class="literal">
EXTRACT(WEEK FROM
<em class="replaceable">
<code>
col
</code>
</em>
)
</code>
</a>
, depends on the
value of the
<a class="link" href="server-system-variables.html#sysvar_default_week_format">
<code class="literal">
default_week_format
</code>
</a>
system
variable. For this reason,
<a class="link" href="date-and-time-functions.html#function_extract">
<code class="literal">
EXTRACT()
</code>
</a>
is not permitted as a
partitioning function when it specifies the unit as
<code class="literal">
WEEK
</code>
. (Bug #54483)
</p>
<p>
See
<a class="xref" href="mathematical-functions.html" title="14.6.2 Mathematical Functions">
Section 14.6.2, “Mathematical Functions”
</a>
, for more
information about the return types of these functions, as well
as
<a class="xref" href="numeric-types.html" title="13.1 Numeric Data Types">
Section 13.1, “Numeric Data Types”
</a>
.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/audit-log-file-formats.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="audit-log-file-formats">
</a>
8.4.5.4 Audit Log File Formats
</h4>
</div>
</div>
</div>
<p>
The MySQL server calls the audit log plugin to write an audit
record to its log file whenever an auditable event occurs.
Typically the first audit record written after plugin startup
contains the server description and startup options. Elements
following that one represent events such as client connect and
disconnect events, executed SQL statements, and so forth. Only
top-level statements are logged, not statements within stored
programs such as triggers or stored procedures. Contents of
files referenced by statements such as
<a class="link" href="load-data.html" title="15.2.9 LOAD DATA Statement">
<code class="literal">
LOAD
DATA
</code>
</a>
are not logged.
</p>
<p>
To select the log format that the audit log plugin uses to write
its log file, set the
<a class="link" href="audit-log-reference.html#sysvar_audit_log_format">
<code class="literal">
audit_log_format
</code>
</a>
system
variable at server startup. These formats are available:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
New-style XML format
(
<a class="link" href="audit-log-reference.html#sysvar_audit_log_format">
<code class="literal">
audit_log_format=NEW
</code>
</a>
): An
XML format that has better compatibility with Oracle Audit
Vault than old-style XML format. MySQL 8.4 uses
new-style XML format by default.
</p>
</li>
<li class="listitem">
<p>
Old-style XML format
(
<a class="link" href="audit-log-reference.html#sysvar_audit_log_format">
<code class="literal">
audit_log_format=OLD
</code>
</a>
): The
original audit log format used by default in older MySQL
series.
</p>
</li>
<li class="listitem">
<p>
JSON format
(
<a class="link" href="audit-log-reference.html#sysvar_audit_log_format">
<code class="literal">
audit_log_format=JSON
</code>
</a>
):
Writes the audit log as a JSON array. Only this format
supports the optional query time and size statistics.
</p>
</li>
</ul>
</div>
<p>
By default, audit log file contents are written in new-style XML
format, without compression or encryption.
</p>
<p>
If you change
<a class="link" href="audit-log-reference.html#sysvar_audit_log_format">
<code class="literal">
audit_log_format
</code>
</a>
,
it is recommended that you also change
<a class="link" href="audit-log-reference.html#sysvar_audit_log_file">
<code class="literal">
audit_log_file
</code>
</a>
. For example, if
you set
<a class="link" href="audit-log-reference.html#sysvar_audit_log_format">
<code class="literal">
audit_log_format
</code>
</a>
to
<code class="literal">
JSON
</code>
, set
<a class="link" href="audit-log-reference.html#sysvar_audit_log_file">
<code class="literal">
audit_log_file
</code>
</a>
to
<code class="literal">
audit.json
</code>
. Otherwise, newer log files will
have a different format than older files, but they will all have
the same base name with nothing to indicate when the format
changed.
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="xref" href="audit-log-file-formats.html#audit-log-file-new-style-xml-format" title="New-Style XML Audit Log File Format">
New-Style XML Audit Log File Format
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="audit-log-file-formats.html#audit-log-file-old-style-xml-format" title="Old-Style XML Audit Log File Format">
Old-Style XML Audit Log File Format
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="audit-log-file-formats.html#audit-log-file-json-format" title="JSON Audit Log File Format">
JSON Audit Log File Format
</a>
</p>
</li>
</ul>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="audit-log-file-new-style-xml-format">
</a>
New-Style XML Audit Log File Format
</h5>
</div>
</div>
</div>
<p>
Here is a sample log file in new-style XML format
(
<a class="link" href="audit-log-reference.html#sysvar_audit_log_format">
<code class="literal">
audit_log_format=NEW
</code>
</a>
),
reformatted slightly for readability:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-xml"><div class="docs-select-all right" id="sa70854550"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-xml"><span class="token prolog"><?xml version="1.0" encoding="utf-8"?></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>AUDIT</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>AUDIT_RECORD</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>TIMESTAMP</span><span class="token punctuation">></span></span>2019-10-03T14:06:33 UTC<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>TIMESTAMP</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>RECORD_ID</span><span class="token punctuation">></span></span>1_2019-10-03T14:06:33<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>RECORD_ID</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>NAME</span><span class="token punctuation">></span></span>Audit<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>NAME</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>SERVER_ID</span><span class="token punctuation">></span></span>1<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>SERVER_ID</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>VERSION</span><span class="token punctuation">></span></span>1<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>VERSION</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>STARTUP_OPTIONS</span><span class="token punctuation">></span></span>/usr/local/mysql/bin/mysqld
--socket=/usr/local/mysql/mysql.sock
--port=3306<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>STARTUP_OPTIONS</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>OS_VERSION</span><span class="token punctuation">></span></span>i686-Linux<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>OS_VERSION</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>MYSQL_VERSION</span><span class="token punctuation">></span></span>5.7.21-log<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>MYSQL_VERSION</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>AUDIT_RECORD</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>AUDIT_RECORD</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>TIMESTAMP</span><span class="token punctuation">></span></span>2019-10-03T14:09:38 UTC<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>TIMESTAMP</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>RECORD_ID</span><span class="token punctuation">></span></span>2_2019-10-03T14:06:33<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>RECORD_ID</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>NAME</span><span class="token punctuation">></span></span>Connect<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>NAME</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>CONNECTION_ID</span><span class="token punctuation">></span></span>5<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>CONNECTION_ID</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>STATUS</span><span class="token punctuation">></span></span>0<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>STATUS</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>STATUS_CODE</span><span class="token punctuation">></span></span>0<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>STATUS_CODE</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>USER</span><span class="token punctuation">></span></span>root<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>USER</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>OS_LOGIN</span><span class="token punctuation">/></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>HOST</span><span class="token punctuation">></span></span>localhost<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>HOST</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>IP</span><span class="token punctuation">></span></span>127.0.0.1<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>IP</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>COMMAND_CLASS</span><span class="token punctuation">></span></span>connect<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>COMMAND_CLASS</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>CONNECTION_TYPE</span><span class="token punctuation">></span></span>SSL/TLS<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>CONNECTION_TYPE</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>CONNECTION_ATTRIBUTES</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>ATTRIBUTE</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>NAME</span><span class="token punctuation">></span></span>_pid<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>NAME</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>VALUE</span><span class="token punctuation">></span></span>42794<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>VALUE</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>ATTRIBUTE</span><span class="token punctuation">></span></span>
...
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>ATTRIBUTE</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>NAME</span><span class="token punctuation">></span></span>program_name<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>NAME</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>VALUE</span><span class="token punctuation">></span></span>mysqladmin<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>VALUE</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>ATTRIBUTE</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>CONNECTION_ATTRIBUTES</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>PRIV_USER</span><span class="token punctuation">></span></span>root<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>PRIV_USER</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>PROXY_USER</span><span class="token punctuation">/></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>DB</span><span class="token punctuation">></span></span>test<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>DB</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>AUDIT_RECORD</span><span class="token punctuation">></span></span>
...
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>AUDIT_RECORD</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>TIMESTAMP</span><span class="token punctuation">></span></span>2019-10-03T14:09:38 UTC<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>TIMESTAMP</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>RECORD_ID</span><span class="token punctuation">></span></span>6_2019-10-03T14:06:33<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>RECORD_ID</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>NAME</span><span class="token punctuation">></span></span>Query<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>NAME</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>CONNECTION_ID</span><span class="token punctuation">></span></span>5<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>CONNECTION_ID</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>STATUS</span><span class="token punctuation">></span></span>0<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>STATUS</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>STATUS_CODE</span><span class="token punctuation">></span></span>0<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>STATUS_CODE</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>USER</span><span class="token punctuation">></span></span>root[root] @ localhost [127.0.0.1]<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>USER</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>OS_LOGIN</span><span class="token punctuation">/></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>HOST</span><span class="token punctuation">></span></span>localhost<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>HOST</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>IP</span><span class="token punctuation">></span></span>127.0.0.1<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>IP</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>COMMAND_CLASS</span><span class="token punctuation">></span></span>drop_table<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>COMMAND_CLASS</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>SQLTEXT</span><span class="token punctuation">></span></span>DROP TABLE IF EXISTS t<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>SQLTEXT</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>AUDIT_RECORD</span><span class="token punctuation">></span></span>
...
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>AUDIT_RECORD</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>TIMESTAMP</span><span class="token punctuation">></span></span>2019-10-03T14:09:39 UTC<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>TIMESTAMP</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>RECORD_ID</span><span class="token punctuation">></span></span>8_2019-10-03T14:06:33<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>RECORD_ID</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>NAME</span><span class="token punctuation">></span></span>Quit<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>NAME</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>CONNECTION_ID</span><span class="token punctuation">></span></span>5<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>CONNECTION_ID</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>STATUS</span><span class="token punctuation">></span></span>0<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>STATUS</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>STATUS_CODE</span><span class="token punctuation">></span></span>0<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>STATUS_CODE</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>USER</span><span class="token punctuation">></span></span>root<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>USER</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>OS_LOGIN</span><span class="token punctuation">/></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>HOST</span><span class="token punctuation">></span></span>localhost<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>HOST</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>IP</span><span class="token punctuation">></span></span>127.0.0.1<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>IP</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>COMMAND_CLASS</span><span class="token punctuation">></span></span>connect<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>COMMAND_CLASS</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>CONNECTION_TYPE</span><span class="token punctuation">></span></span>SSL/TLS<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>CONNECTION_TYPE</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>AUDIT_RECORD</span><span class="token punctuation">></span></span>
...
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>AUDIT_RECORD</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>TIMESTAMP</span><span class="token punctuation">></span></span>2019-10-03T14:09:43 UTC<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>TIMESTAMP</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>RECORD_ID</span><span class="token punctuation">></span></span>11_2019-10-03T14:06:33<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>RECORD_ID</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>NAME</span><span class="token punctuation">></span></span>Quit<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>NAME</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>CONNECTION_ID</span><span class="token punctuation">></span></span>6<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>CONNECTION_ID</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>STATUS</span><span class="token punctuation">></span></span>0<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>STATUS</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>STATUS_CODE</span><span class="token punctuation">></span></span>0<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>STATUS_CODE</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>USER</span><span class="token punctuation">></span></span>root<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>USER</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>OS_LOGIN</span><span class="token punctuation">/></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>HOST</span><span class="token punctuation">></span></span>localhost<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>HOST</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>IP</span><span class="token punctuation">></span></span>127.0.0.1<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>IP</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>COMMAND_CLASS</span><span class="token punctuation">></span></span>connect<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>COMMAND_CLASS</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>CONNECTION_TYPE</span><span class="token punctuation">></span></span>SSL/TLS<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>CONNECTION_TYPE</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>AUDIT_RECORD</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>AUDIT_RECORD</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>TIMESTAMP</span><span class="token punctuation">></span></span>2019-10-03T14:09:45 UTC<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>TIMESTAMP</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>RECORD_ID</span><span class="token punctuation">></span></span>12_2019-10-03T14:06:33<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>RECORD_ID</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>NAME</span><span class="token punctuation">></span></span>NoAudit<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>NAME</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>SERVER_ID</span><span class="token punctuation">></span></span>1<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>SERVER_ID</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>AUDIT_RECORD</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>AUDIT</span><span class="token punctuation">></span></span></code></pre>
</div>
<p>
The audit log file is written as XML, using UTF-8 (up to 4
bytes per character). The root element is
<code class="literal">
<AUDIT>
</code>
. The root element contains
<code class="literal">
<AUDIT_RECORD>
</code>
elements, each of
which provides information about an audited event. When the
audit log plugin begins writing a new log file, it writes the
XML declaration and opening
<code class="literal">
<AUDIT>
</code>
root element tag. When the plugin closes a log file, it writes
the closing
<code class="literal">
</AUDIT>
</code>
root element
tag. The closing tag is not present while the file is open.
</p>
<p>
Elements within
<code class="literal">
<AUDIT_RECORD>
</code>
elements have these characteristics:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Some elements appear in every
<code class="literal">
<AUDIT_RECORD>
</code>
element. Others
are optional and may appear depending on the audit record
type.
</p>
</li>
<li class="listitem">
<p>
Order of elements within an
<code class="literal">
<AUDIT_RECORD>
</code>
element is not
guaranteed.
</p>
</li>
<li class="listitem">
<p>
Element values are not fixed length. Long values may be
truncated as indicated in the element descriptions given
later.
</p>
</li>
<li class="listitem">
<p>
The
<code class="literal">
<
</code>
,
<code class="literal">
>
</code>
,
<code class="literal">
"
</code>
, and
<code class="literal">
&
</code>
characters are encoded as
<code class="literal">
&lt;
</code>
,
<code class="literal">
&gt;
</code>
,
<code class="literal">
&quot;
</code>
, and
<code class="literal">
&amp;
</code>
, respectively. NUL bytes
(U+00) are encoded as the
<code class="literal">
?
</code>
character.
</p>
</li>
<li class="listitem">
<p>
Characters not valid as XML characters are encoded using
numeric character references. Valid XML characters are:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-none"><div class="docs-select-all right" id="sa80399156"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-none">#x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]</code></pre>
</div>
</li>
</ul>
</div>
<p>
The following elements are mandatory in every
<code class="literal">
<AUDIT_RECORD>
</code>
element:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
<NAME>
</code>
</p>
<p>
A string representing the type of instruction that
generated the audit event, such as a command that the
server received from a client.
</p>
<p>
Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-xml"><div class="docs-select-all right" id="sa27319363"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-xml"><span class="token tag"><span class="token tag"><span class="token punctuation"><</span>NAME</span><span class="token punctuation">></span></span>Query<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>NAME</span><span class="token punctuation">></span></span></code></pre>
</div>
<p>
Some common
<code class="literal">
<NAME>
</code>
values:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-none"><div class="docs-select-all right" id="sa8533939"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-none">Audit When auditing starts, which may be server startup time
Connect When a client connects, also known as logging in
Query An SQL statement (executed directly)
Prepare Preparation of an SQL statement; usually followed by Execute
Execute Execution of an SQL statement; usually follows Prepare
Shutdown Server shutdown
Quit When a client disconnects
NoAudit Auditing has been turned off</code></pre>
</div>
<p>
The possible values are
<code class="literal">
Audit
</code>
,
<code class="literal">
Binlog Dump
</code>
,
<code class="literal">
Change
user
</code>
,
<code class="literal">
Close stmt
</code>
,
<code class="literal">
Connect Out
</code>
,
<code class="literal">
Connect
</code>
,
<code class="literal">
Create DB
</code>
,
<code class="literal">
Daemon
</code>
,
<code class="literal">
Debug
</code>
,
<code class="literal">
Delayed insert
</code>
,
<code class="literal">
Drop
DB
</code>
,
<code class="literal">
Execute
</code>
,
<code class="literal">
Fetch
</code>
,
<code class="literal">
Field List
</code>
,
<code class="literal">
Init DB
</code>
,
<code class="literal">
Kill
</code>
,
<code class="literal">
Long Data
</code>
,
<code class="literal">
NoAudit
</code>
,
<code class="literal">
Ping
</code>
,
<code class="literal">
Prepare
</code>
,
<code class="literal">
Processlist
</code>
,
<code class="literal">
Query
</code>
,
<code class="literal">
Quit
</code>
,
<code class="literal">
Refresh
</code>
,
<code class="literal">
Register Slave
</code>
,
<code class="literal">
Reset
stmt
</code>
,
<code class="literal">
Set option
</code>
,
<code class="literal">
Shutdown
</code>
,
<code class="literal">
Sleep
</code>
,
<code class="literal">
Statistics
</code>
,
<code class="literal">
Table
Dump
</code>
,
<code class="literal">
TableDelete
</code>
,
<code class="literal">
TableInsert
</code>
,
<code class="literal">
TableRead
</code>
,
<code class="literal">
TableUpdate
</code>
,
<code class="literal">
Time
</code>
.
</p>
<p>
Many of these values correspond to the
<code class="literal">
COM_
<em class="replaceable">
<code>
xxx
</code>
</em>
</code>
command values listed in the
<code class="filename">
my_command.h
</code>
header file. For
example,
<code class="literal">
Create DB
</code>
and
<code class="literal">
Change
user
</code>
correspond to
<code class="literal">
COM_CREATE_DB
</code>
and
<code class="literal">
COM_CHANGE_USER
</code>
, respectively.
</p>
<p>
Events having
<code class="literal">
<NAME>
</code>
values of
<code class="literal">
Table
<em class="replaceable">
<code>
XXX
</code>
</em>
</code>
accompany
<code class="literal">
Query
</code>
events. For example,
the following statement generates one
<code class="literal">
Query
</code>
event, two
<code class="literal">
TableRead
</code>
events, and a
<code class="literal">
TableInsert
</code>
events:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-xml"><div class="docs-select-all right" id="sa82660133"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-xml">INSERT INTO t3 SELECT t1.* FROM t1 JOIN t2;</code></pre>
</div>
<p>
Each
<code class="literal">
Table
<em class="replaceable">
<code>
XXX
</code>
</em>
</code>
event contains
<code class="literal">
<TABLE>
</code>
and
<code class="literal">
<DB>
</code>
elements to identify the
table to which the event refers and the database that
contains the table.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<RECORD_ID>
</code>
</p>
<p>
A unique identifier for the audit record. The value is
composed from a sequence number and timestamp, in the
format
<code class="literal">
<em class="replaceable">
<code>
SEQ_TIMESTAMP
</code>
</em>
</code>
.
When the audit log plugin opens the audit log file, it
initializes the sequence number to the size of the audit
log file, then increments the sequence by 1 for each
record logged. The timestamp is a UTC value in
<code class="literal">
<em class="replaceable">
<code>
YYYY-MM-DD
</code>
</em>
T
<em class="replaceable">
<code>
hh:mm:ss
</code>
</em>
</code>
format indicating the date and time when the audit log
plugin opened the file.
</p>
<p>
Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-xml"><div class="docs-select-all right" id="sa20907879"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-xml"><span class="token tag"><span class="token tag"><span class="token punctuation"><</span>RECORD_ID</span><span class="token punctuation">></span></span>12_2019-10-03T14:06:33<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>RECORD_ID</span><span class="token punctuation">></span></span></code></pre>
</div>
</li>
<li class="listitem">
<p>
<code class="literal">
<TIMESTAMP>
</code>
</p>
<p>
A string representing a UTC value in
<code class="literal">
<em class="replaceable">
<code>
YYYY-MM-DD
</code>
</em>
T
<em class="replaceable">
<code>
hh:mm:ss
</code>
</em>
UTC
</code>
format indicating the date and time when the
audit event was generated. For example, the event
corresponding to execution of an SQL statement received
from a client has a
<code class="literal">
<TIMESTAMP>
</code>
value occurring after the statement finishes, not when it
was received.
</p>
<p>
Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-xml"><div class="docs-select-all right" id="sa70062856"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-xml"><span class="token tag"><span class="token tag"><span class="token punctuation"><</span>TIMESTAMP</span><span class="token punctuation">></span></span>2019-10-03T14:09:45 UTC<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>TIMESTAMP</span><span class="token punctuation">></span></span></code></pre>
</div>
</li>
</ul>
</div>
<p>
The following elements are optional in
<code class="literal">
<AUDIT_RECORD>
</code>
elements. Many of them
occur only with specific
<code class="literal">
<NAME>
</code>
element values.
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
<COMMAND_CLASS>
</code>
</p>
<p>
A string that indicates the type of action performed.
</p>
<p>
Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-xml"><div class="docs-select-all right" id="sa57253255"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-xml"><span class="token tag"><span class="token tag"><span class="token punctuation"><</span>COMMAND_CLASS</span><span class="token punctuation">></span></span>drop_table<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>COMMAND_CLASS</span><span class="token punctuation">></span></span></code></pre>
</div>
<p>
The values correspond to the
<code class="literal">
statement/sql/
<em class="replaceable">
<code>
xxx
</code>
</em>
</code>
command counters. For example,
<em class="replaceable">
<code>
xxx
</code>
</em>
is
<code class="literal">
drop_table
</code>
and
<code class="literal">
select
</code>
for
<a class="link" href="drop-table.html" title="15.1.32 DROP TABLE Statement">
<code class="literal">
DROP
TABLE
</code>
</a>
and
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
statements, respectively. The following statement displays
the possible names:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa32452577"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> <span class="token function">REPLACE</span><span class="token punctuation">(</span>EVENT_NAME<span class="token punctuation">,</span> <span class="token string">'statement/sql/'</span><span class="token punctuation">,</span> <span class="token string">''</span><span class="token punctuation">)</span> <span class="token keyword">AS</span> <span class="token keyword">name</span>
<span class="token keyword">FROM</span> performance_schema<span class="token punctuation">.</span>events_statements_summary_global_by_event_name
<span class="token keyword">WHERE</span> EVENT_NAME <span class="token operator">LIKE</span> <span class="token string">'statement/sql/%'</span>
<span class="token keyword">ORDER</span> <span class="token keyword">BY</span> <span class="token keyword">name</span><span class="token punctuation">;</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
<code class="literal">
<CONNECTION_ATTRIBUTES>
</code>
</p>
<p>
Events with a
<code class="literal">
<COMMAND_CLASS>
</code>
value of
<code class="literal">
connect
</code>
may include a
<code class="literal">
<CONNECTION_ATTRIBUTES>
</code>
element
to display the connection attributes passed by the client
at connect time. (For information about these attributes,
which are also exposed in Performance Schema tables, see
<a class="xref" href="performance-schema-connection-attribute-tables.html" title="29.12.9 Performance Schema Connection Attribute Tables">
Section 29.12.9, “Performance Schema Connection Attribute Tables”
</a>
.)
</p>
<p>
The
<code class="literal">
<CONNECTION_ATTRIBUTES>
</code>
element contains one
<code class="literal">
<ATTRIBUTE>
</code>
element per attribute, each of which contains
<code class="literal">
<NAME>
</code>
and
<code class="literal">
<VALUE>
</code>
elements to indicate the
attribute name and value, respectively.
</p>
<p>
Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-xml"><div class="docs-select-all right" id="sa5745934"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-xml"><span class="token tag"><span class="token tag"><span class="token punctuation"><</span>CONNECTION_ATTRIBUTES</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>ATTRIBUTE</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>NAME</span><span class="token punctuation">></span></span>_pid<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>NAME</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>VALUE</span><span class="token punctuation">></span></span>42794<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>VALUE</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>ATTRIBUTE</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>ATTRIBUTE</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>NAME</span><span class="token punctuation">></span></span>_os<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>NAME</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>VALUE</span><span class="token punctuation">></span></span>macos0.14<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>VALUE</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>ATTRIBUTE</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>ATTRIBUTE</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>NAME</span><span class="token punctuation">></span></span>_platform<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>NAME</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>VALUE</span><span class="token punctuation">></span></span>x86_64<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>VALUE</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>ATTRIBUTE</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>ATTRIBUTE</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>NAME</span><span class="token punctuation">></span></span>_client_version<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>NAME</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>VALUE</span><span class="token punctuation">></span></span>8.4.0<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>VALUE</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>ATTRIBUTE</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>ATTRIBUTE</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>NAME</span><span class="token punctuation">></span></span>_client_name<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>NAME</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>VALUE</span><span class="token punctuation">></span></span>libmysql<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>VALUE</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>ATTRIBUTE</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>ATTRIBUTE</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>NAME</span><span class="token punctuation">></span></span>program_name<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>NAME</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>VALUE</span><span class="token punctuation">></span></span>mysqladmin<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>VALUE</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>ATTRIBUTE</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>CONNECTION_ATTRIBUTES</span><span class="token punctuation">></span></span></code></pre>
</div>
<p>
If no connection attributes are present in the event, none
are logged and no
<code class="literal">
<CONNECTION_ATTRIBUTES>
</code>
element
appears. This can occur if the connection attempt is
unsuccessful, the client passes no attributes, or the
connection occurs internally such as during server startup
or when initiated by a plugin.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<CONNECTION_ID>
</code>
</p>
<p>
An unsigned integer representing the client connection
identifier. This is the same as the value returned by the
<a class="link" href="information-functions.html#function_connection-id">
<code class="literal">
CONNECTION_ID()
</code>
</a>
function
within the session.
</p>
<p>
Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-xml"><div class="docs-select-all right" id="sa46439710"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-xml"><span class="token tag"><span class="token tag"><span class="token punctuation"><</span>CONNECTION_ID</span><span class="token punctuation">></span></span>127<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>CONNECTION_ID</span><span class="token punctuation">></span></span></code></pre>
</div>
</li>
<li class="listitem">
<p>
<code class="literal">
<CONNECTION_TYPE>
</code>
</p>
<p>
The security state of the connection to the server.
Permitted values are
<code class="literal">
TCP/IP
</code>
(TCP/IP
connection established without encryption),
<code class="literal">
SSL/TLS
</code>
(TCP/IP connection established
with encryption),
<code class="literal">
Socket
</code>
(Unix socket
file connection),
<code class="literal">
Named Pipe
</code>
(Windows
named pipe connection), and
<code class="literal">
Shared
Memory
</code>
(Windows shared memory connection).
</p>
<p>
Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-xml"><div class="docs-select-all right" id="sa77407477"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-xml"><span class="token tag"><span class="token tag"><span class="token punctuation"><</span>CONNECTION_TYPE</span><span class="token punctuation">></span></span>SSL/TLS<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>CONNECTION_TYPE</span><span class="token punctuation">></span></span></code></pre>
</div>
</li>
<li class="listitem">
<p>
<code class="literal">
<DB>
</code>
</p>
<p>
A string representing a database name.
</p>
<p>
Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-xml"><div class="docs-select-all right" id="sa28953231"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-xml"><span class="token tag"><span class="token tag"><span class="token punctuation"><</span>DB</span><span class="token punctuation">></span></span>test<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>DB</span><span class="token punctuation">></span></span></code></pre>
</div>
<p>
For connect events, this element indicates the default
database; the element is empty if there is no default
database. For table-access events, the element indicates
the database to which the accessed table belongs.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<HOST>
</code>
</p>
<p>
A string representing the client host name.
</p>
<p>
Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-xml"><div class="docs-select-all right" id="sa34898375"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-xml"><span class="token tag"><span class="token tag"><span class="token punctuation"><</span>HOST</span><span class="token punctuation">></span></span>localhost<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>HOST</span><span class="token punctuation">></span></span></code></pre>
</div>
</li>
<li class="listitem">
<p>
<code class="literal">
<IP>
</code>
</p>
<p>
A string representing the client IP address.
</p>
<p>
Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-xml"><div class="docs-select-all right" id="sa42025000"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-xml"><span class="token tag"><span class="token tag"><span class="token punctuation"><</span>IP</span><span class="token punctuation">></span></span>127.0.0.1<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>IP</span><span class="token punctuation">></span></span></code></pre>
</div>
</li>
<li class="listitem">
<p>
<code class="literal">
<MYSQL_VERSION>
</code>
</p>
<p>
A string representing the MySQL server version. This is
the same as the value of the
<a class="link" href="information-functions.html#function_version">
<code class="literal">
VERSION()
</code>
</a>
function or
<a class="link" href="server-system-variables.html#sysvar_version">
<code class="literal">
version
</code>
</a>
system variable.
</p>
<p>
Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-xml"><div class="docs-select-all right" id="sa19952882"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-xml"><span class="token tag"><span class="token tag"><span class="token punctuation"><</span>MYSQL_VERSION</span><span class="token punctuation">></span></span>5.7.21-log<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>MYSQL_VERSION</span><span class="token punctuation">></span></span></code></pre>
</div>
</li>
<li class="listitem">
<p>
<code class="literal">
<OS_LOGIN>
</code>
</p>
<p>
A string representing the external user name used during
the authentication process, as set by the plugin used to
authenticate the client. With native (built-in) MySQL
authentication, or if the plugin does not set the value,
this element is empty. The value is the same as that of
the
<a class="link" href="server-system-variables.html#sysvar_external_user">
<code class="literal">
external_user
</code>
</a>
system
variable (see
<a class="xref" href="proxy-users.html" title="8.2.19 Proxy Users">
Section 8.2.19, “Proxy Users”
</a>
).
</p>
<p>
Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-xml"><div class="docs-select-all right" id="sa49139120"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-xml"><span class="token tag"><span class="token tag"><span class="token punctuation"><</span>OS_LOGIN</span><span class="token punctuation">></span></span>jeffrey<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>OS_LOGIN</span><span class="token punctuation">></span></span></code></pre>
</div>
</li>
<li class="listitem">
<p>
<code class="literal">
<OS_VERSION>
</code>
</p>
<p>
A string representing the operating system on which the
server was built or is running.
</p>
<p>
Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-xml"><div class="docs-select-all right" id="sa55636284"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-xml"><span class="token tag"><span class="token tag"><span class="token punctuation"><</span>OS_VERSION</span><span class="token punctuation">></span></span>x86_64-Linux<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>OS_VERSION</span><span class="token punctuation">></span></span></code></pre>
</div>
</li>
<li class="listitem">
<p>
<code class="literal">
<PRIV_USER>
</code>
</p>
<p>
A string representing the user that the server
authenticated the client as. This is the user name that
the server uses for privilege checking, and may differ
from the
<code class="literal">
<USER>
</code>
value.
</p>
<p>
Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-xml"><div class="docs-select-all right" id="sa10696923"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-xml"><span class="token tag"><span class="token tag"><span class="token punctuation"><</span>PRIV_USER</span><span class="token punctuation">></span></span>jeffrey<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>PRIV_USER</span><span class="token punctuation">></span></span></code></pre>
</div>
</li>
<li class="listitem">
<p>
<code class="literal">
<PROXY_USER>
</code>
</p>
<p>
A string representing the proxy user (see
<a class="xref" href="proxy-users.html" title="8.2.19 Proxy Users">
Section 8.2.19, “Proxy Users”
</a>
). The value is empty if user
proxying is not in effect.
</p>
<p>
Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-xml"><div class="docs-select-all right" id="sa19591829"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-xml"><span class="token tag"><span class="token tag"><span class="token punctuation"><</span>PROXY_USER</span><span class="token punctuation">></span></span>developer<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>PROXY_USER</span><span class="token punctuation">></span></span></code></pre>
</div>
</li>
<li class="listitem">
<p>
<code class="literal">
<SERVER_ID>
</code>
</p>
<p>
An unsigned integer representing the server ID. This is
the same as the value of the
<a class="link" href="replication-options.html#sysvar_server_id">
<code class="literal">
server_id
</code>
</a>
system
variable.
</p>
<p>
Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-xml"><div class="docs-select-all right" id="sa4224159"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-xml"><span class="token tag"><span class="token tag"><span class="token punctuation"><</span>SERVER_ID</span><span class="token punctuation">></span></span>1<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>SERVER_ID</span><span class="token punctuation">></span></span></code></pre>
</div>
</li>
<li class="listitem">
<p>
<code class="literal">
<SQLTEXT>
</code>
</p>
<p>
A string representing the text of an SQL statement. The
value can be empty. Long values may be truncated. The
string, like the audit log file itself, is written using
UTF-8 (up to 4 bytes per character), so the value may be
the result of conversion. For example, the original
statement might have been received from the client as an
SJIS string.
</p>
<p>
Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-xml"><div class="docs-select-all right" id="sa59606447"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-xml"><span class="token tag"><span class="token tag"><span class="token punctuation"><</span>SQLTEXT</span><span class="token punctuation">></span></span>DELETE FROM t1<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>SQLTEXT</span><span class="token punctuation">></span></span></code></pre>
</div>
</li>
<li class="listitem">
<p>
<code class="literal">
<STARTUP_OPTIONS>
</code>
</p>
<p>
A string representing the options that were given on the
command line or in option files when the MySQL server was
started. The first option is the path to the server
executable.
</p>
<p>
Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-xml"><div class="docs-select-all right" id="sa61756035"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-xml"><span class="token tag"><span class="token tag"><span class="token punctuation"><</span>STARTUP_OPTIONS</span><span class="token punctuation">></span></span>/usr/local/mysql/bin/mysqld
--port=3306 --log_output=FILE<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>STARTUP_OPTIONS</span><span class="token punctuation">></span></span></code></pre>
</div>
</li>
<li class="listitem">
<p>
<code class="literal">
<STATUS>
</code>
</p>
<p>
An unsigned integer representing the command status: 0 for
success, nonzero if an error occurred. This is the same as
the value of the
<a class="ulink" href="/doc/c-api/8.4/en/mysql-errno.html" target="_top">
<code class="literal">
mysql_errno()
</code>
</a>
C API
function. See the description for
<code class="literal">
<STATUS_CODE>
</code>
for information
about how it differs from
<code class="literal">
<STATUS>
</code>
.
</p>
<p>
The audit log does not contain the SQLSTATE value or error
message. To see the associations between error codes,
SQLSTATE values, and messages, see
<a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html" target="_top">
Server Error Message Reference
</a>
.
</p>
<p>
Warnings are not logged.
</p>
<p>
Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-xml"><div class="docs-select-all right" id="sa52964813"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-xml"><span class="token tag"><span class="token tag"><span class="token punctuation"><</span>STATUS</span><span class="token punctuation">></span></span>1051<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>STATUS</span><span class="token punctuation">></span></span></code></pre>
</div>
</li>
<li class="listitem">
<p>
<code class="literal">
<STATUS_CODE>
</code>
</p>
<p>
An unsigned integer representing the command status: 0 for
success, 1 if an error occurred.
</p>
<p>
The
<code class="literal">
STATUS_CODE
</code>
value differs from the
<code class="literal">
STATUS
</code>
value:
<code class="literal">
STATUS_CODE
</code>
is 0 for success and 1 for
error, which is compatible with the EZ_collector consumer
for Audit Vault.
<code class="literal">
STATUS
</code>
is the value of
the
<a class="ulink" href="/doc/c-api/8.4/en/mysql-errno.html" target="_top">
<code class="literal">
mysql_errno()
</code>
</a>
C API
function. This is 0 for success and nonzero for error, and
thus is not necessarily 1 for error.
</p>
<p>
Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-xml"><div class="docs-select-all right" id="sa87985754"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-xml"><span class="token tag"><span class="token tag"><span class="token punctuation"><</span>STATUS_CODE</span><span class="token punctuation">></span></span>0<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>STATUS_CODE</span><span class="token punctuation">></span></span></code></pre>
</div>
</li>
<li class="listitem">
<p>
<code class="literal">
<TABLE>
</code>
</p>
<p>
A string representing a table name.
</p>
<p>
Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-xml"><div class="docs-select-all right" id="sa24388473"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-xml"><span class="token tag"><span class="token tag"><span class="token punctuation"><</span>TABLE</span><span class="token punctuation">></span></span>t3<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>TABLE</span><span class="token punctuation">></span></span></code></pre>
</div>
</li>
<li class="listitem">
<p>
<code class="literal">
<USER>
</code>
</p>
<p>
A string representing the user name sent by the client.
This may differ from the
<code class="literal">
<PRIV_USER>
</code>
value.
</p>
<p>
Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-xml"><div class="docs-select-all right" id="sa77811755"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-xml"><span class="token tag"><span class="token tag"><span class="token punctuation"><</span>USER</span><span class="token punctuation">></span></span>root[root] @ localhost [127.0.0.1]<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>USER</span><span class="token punctuation">></span></span></code></pre>
</div>
</li>
<li class="listitem">
<p>
<code class="literal">
<VERSION>
</code>
</p>
<p>
An unsigned integer representing the version of the audit
log file format.
</p>
<p>
Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-xml"><div class="docs-select-all right" id="sa64856045"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-xml"><span class="token tag"><span class="token tag"><span class="token punctuation"><</span>VERSION</span><span class="token punctuation">></span></span>1<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>VERSION</span><span class="token punctuation">></span></span></code></pre>
</div>
</li>
</ul>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="audit-log-file-old-style-xml-format">
</a>
Old-Style XML Audit Log File Format
</h5>
</div>
</div>
</div>
<p>
Here is a sample log file in old-style XML format
(
<a class="link" href="audit-log-reference.html#sysvar_audit_log_format">
<code class="literal">
audit_log_format=OLD
</code>
</a>
),
reformatted slightly for readability:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-xml"><div class="docs-select-all right" id="sa97326358"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-xml"><span class="token prolog"><?xml version="1.0" encoding="utf-8"?></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>AUDIT</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>AUDIT_RECORD</span>
<span class="token attr-name">TIMESTAMP</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>2019-10-03T14:25:00 UTC<span class="token punctuation">"</span></span>
<span class="token attr-name">RECORD_ID</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>1_2019-10-03T14:25:00<span class="token punctuation">"</span></span>
<span class="token attr-name">NAME</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>Audit<span class="token punctuation">"</span></span>
<span class="token attr-name">SERVER_ID</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>1<span class="token punctuation">"</span></span>
<span class="token attr-name">VERSION</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>1<span class="token punctuation">"</span></span>
<span class="token attr-name">STARTUP_OPTIONS</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>--port<span class="token punctuation">=</span>3306<span class="token punctuation">"</span></span>
<span class="token attr-name">OS_VERSION</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>i686-Linux<span class="token punctuation">"</span></span>
<span class="token attr-name">MYSQL_VERSION</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>5.7.21-log<span class="token punctuation">"</span></span><span class="token punctuation">/></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>AUDIT_RECORD</span>
<span class="token attr-name">TIMESTAMP</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>2019-10-03T14:25:24 UTC<span class="token punctuation">"</span></span>
<span class="token attr-name">RECORD_ID</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>2_2019-10-03T14:25:00<span class="token punctuation">"</span></span>
<span class="token attr-name">NAME</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>Connect<span class="token punctuation">"</span></span>
<span class="token attr-name">CONNECTION_ID</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>4<span class="token punctuation">"</span></span>
<span class="token attr-name">STATUS</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>0<span class="token punctuation">"</span></span>
<span class="token attr-name">STATUS_CODE</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>0<span class="token punctuation">"</span></span>
<span class="token attr-name">USER</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>root<span class="token punctuation">"</span></span>
<span class="token attr-name">OS_LOGIN</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span><span class="token punctuation">"</span></span>
<span class="token attr-name">HOST</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>localhost<span class="token punctuation">"</span></span>
<span class="token attr-name">IP</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>127.0.0.1<span class="token punctuation">"</span></span>
<span class="token attr-name">COMMAND_CLASS</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>connect<span class="token punctuation">"</span></span>
<span class="token attr-name">CONNECTION_TYPE</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>SSL/TLS<span class="token punctuation">"</span></span>
<span class="token attr-name">PRIV_USER</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>root<span class="token punctuation">"</span></span>
<span class="token attr-name">PROXY_USER</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span><span class="token punctuation">"</span></span>
<span class="token attr-name">DB</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>test<span class="token punctuation">"</span></span><span class="token punctuation">/></span></span>
...
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>AUDIT_RECORD</span>
<span class="token attr-name">TIMESTAMP</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>2019-10-03T14:25:24 UTC<span class="token punctuation">"</span></span>
<span class="token attr-name">RECORD_ID</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>6_2019-10-03T14:25:00<span class="token punctuation">"</span></span>
<span class="token attr-name">NAME</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>Query<span class="token punctuation">"</span></span>
<span class="token attr-name">CONNECTION_ID</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>4<span class="token punctuation">"</span></span>
<span class="token attr-name">STATUS</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>0<span class="token punctuation">"</span></span>
<span class="token attr-name">STATUS_CODE</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>0<span class="token punctuation">"</span></span>
<span class="token attr-name">USER</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>root[root] @ localhost [127.0.0.1]<span class="token punctuation">"</span></span>
<span class="token attr-name">OS_LOGIN</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span><span class="token punctuation">"</span></span>
<span class="token attr-name">HOST</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>localhost<span class="token punctuation">"</span></span>
<span class="token attr-name">IP</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>127.0.0.1<span class="token punctuation">"</span></span>
<span class="token attr-name">COMMAND_CLASS</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>drop_table<span class="token punctuation">"</span></span>
<span class="token attr-name">SQLTEXT</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>DROP TABLE IF EXISTS t<span class="token punctuation">"</span></span><span class="token punctuation">/></span></span>
...
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>AUDIT_RECORD</span>
<span class="token attr-name">TIMESTAMP</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>2019-10-03T14:25:24 UTC<span class="token punctuation">"</span></span>
<span class="token attr-name">RECORD_ID</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>8_2019-10-03T14:25:00<span class="token punctuation">"</span></span>
<span class="token attr-name">NAME</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>Quit<span class="token punctuation">"</span></span>
<span class="token attr-name">CONNECTION_ID</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>4<span class="token punctuation">"</span></span>
<span class="token attr-name">STATUS</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>0<span class="token punctuation">"</span></span>
<span class="token attr-name">STATUS_CODE</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>0<span class="token punctuation">"</span></span>
<span class="token attr-name">USER</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>root<span class="token punctuation">"</span></span>
<span class="token attr-name">OS_LOGIN</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span><span class="token punctuation">"</span></span>
<span class="token attr-name">HOST</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>localhost<span class="token punctuation">"</span></span>
<span class="token attr-name">IP</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>127.0.0.1<span class="token punctuation">"</span></span>
<span class="token attr-name">COMMAND_CLASS</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>connect<span class="token punctuation">"</span></span>
<span class="token attr-name">CONNECTION_TYPE</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>SSL/TLS<span class="token punctuation">"</span></span><span class="token punctuation">/></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>AUDIT_RECORD</span>
<span class="token attr-name">TIMESTAMP</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>2019-10-03T14:25:32 UTC<span class="token punctuation">"</span></span>
<span class="token attr-name">RECORD_ID</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>12_2019-10-03T14:25:00<span class="token punctuation">"</span></span>
<span class="token attr-name">NAME</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>NoAudit<span class="token punctuation">"</span></span>
<span class="token attr-name">SERVER_ID</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>1<span class="token punctuation">"</span></span><span class="token punctuation">/></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>AUDIT</span><span class="token punctuation">></span></span></code></pre>
</div>
<p>
The audit log file is written as XML, using UTF-8 (up to 4
bytes per character). The root element is
<code class="literal">
<AUDIT>
</code>
. The root element contains
<code class="literal">
<AUDIT_RECORD>
</code>
elements, each of
which provides information about an audited event. When the
audit log plugin begins writing a new log file, it writes the
XML declaration and opening
<code class="literal">
<AUDIT>
</code>
root element tag. When the plugin closes a log file, it writes
the closing
<code class="literal">
</AUDIT>
</code>
root element
tag. The closing tag is not present while the file is open.
</p>
<p>
Attributes of
<code class="literal">
<AUDIT_RECORD>
</code>
elements
have these characteristics:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Some attributes appear in every
<code class="literal">
<AUDIT_RECORD>
</code>
element. Others
are optional and may appear depending on the audit record
type.
</p>
</li>
<li class="listitem">
<p>
Order of attributes within an
<code class="literal">
<AUDIT_RECORD>
</code>
element is not
guaranteed.
</p>
</li>
<li class="listitem">
<p>
Attribute values are not fixed length. Long values may be
truncated as indicated in the attribute descriptions given
later.
</p>
</li>
<li class="listitem">
<p>
The
<code class="literal">
<
</code>
,
<code class="literal">
>
</code>
,
<code class="literal">
"
</code>
, and
<code class="literal">
&
</code>
characters are encoded as
<code class="literal">
&lt;
</code>
,
<code class="literal">
&gt;
</code>
,
<code class="literal">
&quot;
</code>
, and
<code class="literal">
&amp;
</code>
, respectively. NUL bytes
(U+00) are encoded as the
<code class="literal">
?
</code>
character.
</p>
</li>
<li class="listitem">
<p>
Characters not valid as XML characters are encoded using
numeric character references. Valid XML characters are:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-none"><div class="docs-select-all right" id="sa68474817"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-none">#x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]</code></pre>
</div>
</li>
</ul>
</div>
<p>
The following attributes are mandatory in every
<code class="literal">
<AUDIT_RECORD>
</code>
element:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
NAME
</code>
</p>
<p>
A string representing the type of instruction that
generated the audit event, such as a command that the
server received from a client.
</p>
<p>
Example:
<code class="literal">
NAME="Query"
</code>
</p>
<p>
Some common
<code class="literal">
NAME
</code>
values:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-none"><div class="docs-select-all right" id="sa3261619"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-none">Audit When auditing starts, which may be server startup time
Connect When a client connects, also known as logging in
Query An SQL statement (executed directly)
Prepare Preparation of an SQL statement; usually followed by Execute
Execute Execution of an SQL statement; usually follows Prepare
Shutdown Server shutdown
Quit When a client disconnects
NoAudit Auditing has been turned off</code></pre>
</div>
<p>
The possible values are
<code class="literal">
Audit
</code>
,
<code class="literal">
Binlog Dump
</code>
,
<code class="literal">
Change
user
</code>
,
<code class="literal">
Close stmt
</code>
,
<code class="literal">
Connect Out
</code>
,
<code class="literal">
Connect
</code>
,
<code class="literal">
Create DB
</code>
,
<code class="literal">
Daemon
</code>
,
<code class="literal">
Debug
</code>
,
<code class="literal">
Delayed insert
</code>
,
<code class="literal">
Drop
DB
</code>
,
<code class="literal">
Execute
</code>
,
<code class="literal">
Fetch
</code>
,
<code class="literal">
Field List
</code>
,
<code class="literal">
Init DB
</code>
,
<code class="literal">
Kill
</code>
,
<code class="literal">
Long Data
</code>
,
<code class="literal">
NoAudit
</code>
,
<code class="literal">
Ping
</code>
,
<code class="literal">
Prepare
</code>
,
<code class="literal">
Processlist
</code>
,
<code class="literal">
Query
</code>
,
<code class="literal">
Quit
</code>
,
<code class="literal">
Refresh
</code>
,
<code class="literal">
Register Slave
</code>
,
<code class="literal">
Reset
stmt
</code>
,
<code class="literal">
Set option
</code>
,
<code class="literal">
Shutdown
</code>
,
<code class="literal">
Sleep
</code>
,
<code class="literal">
Statistics
</code>
,
<code class="literal">
Table
Dump
</code>
,
<code class="literal">
TableDelete
</code>
,
<code class="literal">
TableInsert
</code>
,
<code class="literal">
TableRead
</code>
,
<code class="literal">
TableUpdate
</code>
,
<code class="literal">
Time
</code>
.
</p>
<p>
Many of these values correspond to the
<code class="literal">
COM_
<em class="replaceable">
<code>
xxx
</code>
</em>
</code>
command values listed in the
<code class="filename">
my_command.h
</code>
header file. For
example,
<code class="literal">
"Create DB"
</code>
and
<code class="literal">
"Change user"
</code>
correspond to
<code class="literal">
COM_CREATE_DB
</code>
and
<code class="literal">
COM_CHANGE_USER
</code>
, respectively.
</p>
<p>
Events having
<code class="literal">
NAME
</code>
values of
<code class="literal">
Table
<em class="replaceable">
<code>
XXX
</code>
</em>
</code>
accompany
<code class="literal">
Query
</code>
events. For example,
the following statement generates one
<code class="literal">
Query
</code>
event, two
<code class="literal">
TableRead
</code>
events, and a
<code class="literal">
TableInsert
</code>
events:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-xml"><div class="docs-select-all right" id="sa92660872"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-xml">INSERT INTO t3 SELECT t1.* FROM t1 JOIN t2;</code></pre>
</div>
<p>
Each
<code class="literal">
Table
<em class="replaceable">
<code>
XXX
</code>
</em>
</code>
event has
<code class="literal">
TABLE
</code>
and
<code class="literal">
DB
</code>
attributes to identify the table to
which the event refers and the database that contains the
table.
</p>
<p>
<code class="literal">
Connect
</code>
events for old-style XML audit
log format do not include connection attributes.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
RECORD_ID
</code>
</p>
<p>
A unique identifier for the audit record. The value is
composed from a sequence number and timestamp, in the
format
<code class="literal">
<em class="replaceable">
<code>
SEQ_TIMESTAMP
</code>
</em>
</code>
.
When the audit log plugin opens the audit log file, it
initializes the sequence number to the size of the audit
log file, then increments the sequence by 1 for each
record logged. The timestamp is a UTC value in
<code class="literal">
<em class="replaceable">
<code>
YYYY-MM-DD
</code>
</em>
T
<em class="replaceable">
<code>
hh:mm:ss
</code>
</em>
</code>
format indicating the date and time when the audit log
plugin opened the file.
</p>
<p>
Example:
<code class="literal">
RECORD_ID="12_2019-10-03T14:25:00"
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
TIMESTAMP
</code>
</p>
<p>
A string representing a UTC value in
<code class="literal">
<em class="replaceable">
<code>
YYYY-MM-DD
</code>
</em>
T
<em class="replaceable">
<code>
hh:mm:ss
</code>
</em>
UTC
</code>
format indicating the date and time when the
audit event was generated. For example, the event
corresponding to execution of an SQL statement received
from a client has a
<code class="literal">
TIMESTAMP
</code>
value
occurring after the statement finishes, not when it was
received.
</p>
<p>
Example:
<code class="literal">
TIMESTAMP="2019-10-03T14:25:32
UTC"
</code>
</p>
</li>
</ul>
</div>
<p>
The following attributes are optional in
<code class="literal">
<AUDIT_RECORD>
</code>
elements. Many of them
occur only for elements with specific values of the
<code class="literal">
NAME
</code>
attribute.
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
COMMAND_CLASS
</code>
</p>
<p>
A string that indicates the type of action performed.
</p>
<p>
Example:
<code class="literal">
COMMAND_CLASS="drop_table"
</code>
</p>
<p>
The values correspond to the
<code class="literal">
statement/sql/
<em class="replaceable">
<code>
xxx
</code>
</em>
</code>
command counters. For example,
<em class="replaceable">
<code>
xxx
</code>
</em>
is
<code class="literal">
drop_table
</code>
and
<code class="literal">
select
</code>
for
<a class="link" href="drop-table.html" title="15.1.32 DROP TABLE Statement">
<code class="literal">
DROP
TABLE
</code>
</a>
and
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
statements, respectively. The following statement displays
the possible names:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa8936131"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> <span class="token function">REPLACE</span><span class="token punctuation">(</span>EVENT_NAME<span class="token punctuation">,</span> <span class="token string">'statement/sql/'</span><span class="token punctuation">,</span> <span class="token string">''</span><span class="token punctuation">)</span> <span class="token keyword">AS</span> <span class="token keyword">name</span>
<span class="token keyword">FROM</span> performance_schema<span class="token punctuation">.</span>events_statements_summary_global_by_event_name
<span class="token keyword">WHERE</span> EVENT_NAME <span class="token operator">LIKE</span> <span class="token string">'statement/sql/%'</span>
<span class="token keyword">ORDER</span> <span class="token keyword">BY</span> <span class="token keyword">name</span><span class="token punctuation">;</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
<code class="literal">
CONNECTION_ID
</code>
</p>
<p>
An unsigned integer representing the client connection
identifier. This is the same as the value returned by the
<a class="link" href="information-functions.html#function_connection-id">
<code class="literal">
CONNECTION_ID()
</code>
</a>
function
within the session.
</p>
<p>
Example:
<code class="literal">
CONNECTION_ID="127"
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
CONNECTION_TYPE
</code>
</p>
<p>
The security state of the connection to the server.
Permitted values are
<code class="literal">
TCP/IP
</code>
(TCP/IP
connection established without encryption),
<code class="literal">
SSL/TLS
</code>
(TCP/IP connection established
with encryption),
<code class="literal">
Socket
</code>
(Unix socket
file connection),
<code class="literal">
Named Pipe
</code>
(Windows
named pipe connection), and
<code class="literal">
Shared
Memory
</code>
(Windows shared memory connection).
</p>
<p>
Example:
<code class="literal">
CONNECTION_TYPE="SSL/TLS"
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
DB
</code>
</p>
<p>
A string representing a database name.
</p>
<p>
Example:
<code class="literal">
DB="test"
</code>
</p>
<p>
For connect events, this attribute indicates the default
database; the attribute is empty if there is no default
database. For table-access events, the attribute indicates
the database to which the accessed table belongs.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
HOST
</code>
</p>
<p>
A string representing the client host name.
</p>
<p>
Example:
<code class="literal">
HOST="localhost"
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
IP
</code>
</p>
<p>
A string representing the client IP address.
</p>
<p>
Example:
<code class="literal">
IP="127.0.0.1"
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MYSQL_VERSION
</code>
</p>
<p>
A string representing the MySQL server version. This is
the same as the value of the
<a class="link" href="information-functions.html#function_version">
<code class="literal">
VERSION()
</code>
</a>
function or
<a class="link" href="server-system-variables.html#sysvar_version">
<code class="literal">
version
</code>
</a>
system variable.
</p>
<p>
Example:
<code class="literal">
MYSQL_VERSION="5.7.21-log"
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
OS_LOGIN
</code>
</p>
<p>
A string representing the external user name used during
the authentication process, as set by the plugin used to
authenticate the client. With native (built-in) MySQL
authentication, or if the plugin does not set the value,
this attribute is empty. The value is the same as that of
the
<a class="link" href="server-system-variables.html#sysvar_external_user">
<code class="literal">
external_user
</code>
</a>
system
variable (see
<a class="xref" href="proxy-users.html" title="8.2.19 Proxy Users">
Section 8.2.19, “Proxy Users”
</a>
).
</p>
<p>
Example:
<code class="literal">
OS_LOGIN="jeffrey"
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
OS_VERSION
</code>
</p>
<p>
A string representing the operating system on which the
server was built or is running.
</p>
<p>
Example:
<code class="literal">
OS_VERSION="x86_64-Linux"
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
PRIV_USER
</code>
</p>
<p>
A string representing the user that the server
authenticated the client as. This is the user name that
the server uses for privilege checking, and it may differ
from the
<code class="literal">
USER
</code>
value.
</p>
<p>
Example:
<code class="literal">
PRIV_USER="jeffrey"
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
PROXY_USER
</code>
</p>
<p>
A string representing the proxy user (see
<a class="xref" href="proxy-users.html" title="8.2.19 Proxy Users">
Section 8.2.19, “Proxy Users”
</a>
). The value is empty if user
proxying is not in effect.
</p>
<p>
Example:
<code class="literal">
PROXY_USER="developer"
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SERVER_ID
</code>
</p>
<p>
An unsigned integer representing the server ID. This is
the same as the value of the
<a class="link" href="replication-options.html#sysvar_server_id">
<code class="literal">
server_id
</code>
</a>
system
variable.
</p>
<p>
Example:
<code class="literal">
SERVER_ID="1"
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SQLTEXT
</code>
</p>
<p>
A string representing the text of an SQL statement. The
value can be empty. Long values may be truncated. The
string, like the audit log file itself, is written using
UTF-8 (up to 4 bytes per character), so the value may be
the result of conversion. For example, the original
statement might have been received from the client as an
SJIS string.
</p>
<p>
Example:
<code class="literal">
SQLTEXT="DELETE FROM t1"
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
STARTUP_OPTIONS
</code>
</p>
<p>
A string representing the options that were given on the
command line or in option files when the MySQL server was
started.
</p>
<p>
Example:
<code class="literal">
STARTUP_OPTIONS="--port=3306
--log_output=FILE"
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
STATUS
</code>
</p>
<p>
An unsigned integer representing the command status: 0 for
success, nonzero if an error occurred. This is the same as
the value of the
<a class="ulink" href="/doc/c-api/8.4/en/mysql-errno.html" target="_top">
<code class="literal">
mysql_errno()
</code>
</a>
C API
function. See the description for
<code class="literal">
STATUS_CODE
</code>
for information about how
it differs from
<code class="literal">
STATUS
</code>
.
</p>
<p>
The audit log does not contain the SQLSTATE value or error
message. To see the associations between error codes,
SQLSTATE values, and messages, see
<a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html" target="_top">
Server Error Message Reference
</a>
.
</p>
<p>
Warnings are not logged.
</p>
<p>
Example:
<code class="literal">
STATUS="1051"
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
STATUS_CODE
</code>
</p>
<p>
An unsigned integer representing the command status: 0 for
success, 1 if an error occurred.
</p>
<p>
The
<code class="literal">
STATUS_CODE
</code>
value differs from the
<code class="literal">
STATUS
</code>
value:
<code class="literal">
STATUS_CODE
</code>
is 0 for success and 1 for
error, which is compatible with the EZ_collector consumer
for Audit Vault.
<code class="literal">
STATUS
</code>
is the value of
the
<a class="ulink" href="/doc/c-api/8.4/en/mysql-errno.html" target="_top">
<code class="literal">
mysql_errno()
</code>
</a>
C API
function. This is 0 for success and nonzero for error, and
thus is not necessarily 1 for error.
</p>
<p>
Example:
<code class="literal">
STATUS_CODE="0"
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
TABLE
</code>
</p>
<p>
A string representing a table name.
</p>
<p>
Example:
<code class="literal">
TABLE="t3"
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
USER
</code>
</p>
<p>
A string representing the user name sent by the client.
This may differ from the
<code class="literal">
PRIV_USER
</code>
value.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
VERSION
</code>
</p>
<p>
An unsigned integer representing the version of the audit
log file format.
</p>
<p>
Example:
<code class="literal">
VERSION="1"
</code>
</p>
</li>
</ul>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="audit-log-file-json-format">
</a>
JSON Audit Log File Format
</h5>
</div>
</div>
</div>
<p>
For JSON-format audit logging
(
<a class="link" href="audit-log-reference.html#sysvar_audit_log_format">
<code class="literal">
audit_log_format=JSON
</code>
</a>
), the
log file contents form a
<a class="link" href="json.html" title="13.5 The JSON Data Type">
<code class="literal">
JSON
</code>
</a>
array with each array element representing an audited event as
a
<a class="link" href="json.html" title="13.5 The JSON Data Type">
<code class="literal">
JSON
</code>
</a>
hash of key-value pairs.
Examples of complete event records appear later in this
section. The following is an excerpt of partial events:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-json"><div class="docs-select-all right" id="sa58159893"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token punctuation">[</span>
<span class="token punctuation">{</span>
<span class="token property">"timestamp"</span><span class="token operator">:</span> <span class="token string">"2019-10-03 13:50:01"</span><span class="token punctuation">,</span>
<span class="token property">"id"</span><span class="token operator">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
<span class="token property">"class"</span><span class="token operator">:</span> <span class="token string">"audit"</span><span class="token punctuation">,</span>
<span class="token property">"event"</span><span class="token operator">:</span> <span class="token string">"startup"</span><span class="token punctuation">,</span>
...
<span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token punctuation">{</span>
<span class="token property">"timestamp"</span><span class="token operator">:</span> <span class="token string">"2019-10-03 15:02:32"</span><span class="token punctuation">,</span>
<span class="token property">"id"</span><span class="token operator">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
<span class="token property">"class"</span><span class="token operator">:</span> <span class="token string">"connection"</span><span class="token punctuation">,</span>
<span class="token property">"event"</span><span class="token operator">:</span> <span class="token string">"connect"</span><span class="token punctuation">,</span>
...
<span class="token punctuation">}</span><span class="token punctuation">,</span>
...
<span class="token punctuation">{</span>
<span class="token property">"timestamp"</span><span class="token operator">:</span> <span class="token string">"2019-10-03 17:37:26"</span><span class="token punctuation">,</span>
<span class="token property">"id"</span><span class="token operator">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
<span class="token property">"class"</span><span class="token operator">:</span> <span class="token string">"table_access"</span><span class="token punctuation">,</span>
<span class="token property">"event"</span><span class="token operator">:</span> <span class="token string">"insert"</span><span class="token punctuation">,</span>
...
<span class="token punctuation">}</span>
...
<span class="token punctuation">]</span></code></pre>
</div>
<p>
The audit log file is written using UTF-8 (up to 4 bytes per
character). When the audit log plugin begins writing a new log
file, it writes the opening
<code class="literal">
[
</code>
array marker.
When the plugin closes a log file, it writes the closing
<code class="literal">
]
</code>
array marker. The closing marker is not
present while the file is open.
</p>
<p>
Items within audit records have these characteristics:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Some items appear in every audit record. Others are
optional and may appear depending on the audit record
type.
</p>
</li>
<li class="listitem">
<p>
Order of items within an audit record is not guaranteed.
</p>
</li>
<li class="listitem">
<p>
Item values are not fixed length. Long values may be
truncated as indicated in the item descriptions given
later.
</p>
</li>
<li class="listitem">
<p>
The
<code class="literal">
"
</code>
and
<code class="literal">
\
</code>
characters are encoded as
<code class="literal">
\"
</code>
and
<code class="literal">
\\
</code>
, respectively.
</p>
</li>
</ul>
</div>
<p>
JSON format is the only audit log file format that supports
the optional query time and size statistics. This data is
available in the slow query log for qualifying queries, and in
the context of the audit log it similarly helps to detect
outliers for activity analysis.
</p>
<p>
To add the query statistics to the log file, you must set them
up as a filter using the
<a class="link" href="audit-log-reference.html#function_audit-log-filter-set-filter">
<code class="literal">
audit_log_filter_set_filter()
</code>
</a>
audit log function as the service element of the JSON
filtering syntax. For instructions to do this, see
<a class="xref" href="audit-log-logging-configuration.html#audit-log-query-statistics" title="Adding Query Statistics for Outlier Detection">
Adding Query Statistics for Outlier Detection
</a>
. For the
<code class="literal">
bytes_sent
</code>
and
<code class="literal">
bytes_received
</code>
fields to be populated, the
system variable
<a class="link" href="server-system-variables.html#sysvar_log_slow_extra">
<code class="literal">
log_slow_extra
</code>
</a>
must be set to
ON.
</p>
<p>
The following examples show the JSON object formats for
different event types (as indicated by the
<code class="literal">
class
</code>
and
<code class="literal">
event
</code>
items),
reformatted slightly for readability:
</p>
<p>
Auditing startup event:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-json"><div class="docs-select-all right" id="sa6282170"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token punctuation">{</span> <span class="token property">"timestamp"</span><span class="token operator">:</span> <span class="token string">"2019-10-03 14:21:56"</span><span class="token punctuation">,</span>
<span class="token property">"id"</span><span class="token operator">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
<span class="token property">"class"</span><span class="token operator">:</span> <span class="token string">"audit"</span><span class="token punctuation">,</span>
<span class="token property">"event"</span><span class="token operator">:</span> <span class="token string">"startup"</span><span class="token punctuation">,</span>
<span class="token property">"connection_id"</span><span class="token operator">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
<span class="token property">"startup_data"</span><span class="token operator">:</span> <span class="token punctuation">{</span> <span class="token property">"server_id"</span><span class="token operator">:</span> <span class="token number">1</span><span class="token punctuation">,</span>
<span class="token property">"os_version"</span><span class="token operator">:</span> <span class="token string">"i686-Linux"</span><span class="token punctuation">,</span>
<span class="token property">"mysql_version"</span><span class="token operator">:</span> <span class="token string">"5.7.21-log"</span><span class="token punctuation">,</span>
<span class="token property">"args"</span><span class="token operator">:</span> <span class="token punctuation">[</span><span class="token string">"/usr/local/mysql/bin/mysqld"</span><span class="token punctuation">,</span>
<span class="token string">"--loose-audit-log-format=JSON"</span><span class="token punctuation">,</span>
<span class="token string">"--log-error=log.err"</span><span class="token punctuation">,</span>
<span class="token string">"--pid-file=mysqld.pid"</span><span class="token punctuation">,</span>
<span class="token string">"--port=3306"</span> <span class="token punctuation">]</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span></code></pre>
</div>
<p>
When the audit log plugin starts as a result of server startup
(as opposed to being enabled at runtime),
<code class="literal">
connection_id
</code>
is set to 0, and
<code class="literal">
account
</code>
and
<code class="literal">
login
</code>
are
not present.
</p>
<p>
Auditing shutdown event:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-json"><div class="docs-select-all right" id="sa5675394"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token punctuation">{</span> <span class="token property">"timestamp"</span><span class="token operator">:</span> <span class="token string">"2019-10-03 14:28:20"</span><span class="token punctuation">,</span>
<span class="token property">"id"</span><span class="token operator">:</span> <span class="token number">3</span><span class="token punctuation">,</span>
<span class="token property">"class"</span><span class="token operator">:</span> <span class="token string">"audit"</span><span class="token punctuation">,</span>
<span class="token property">"event"</span><span class="token operator">:</span> <span class="token string">"shutdown"</span><span class="token punctuation">,</span>
<span class="token property">"connection_id"</span><span class="token operator">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
<span class="token property">"shutdown_data"</span><span class="token operator">:</span> <span class="token punctuation">{</span> <span class="token property">"server_id"</span><span class="token operator">:</span> <span class="token number">1</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span></code></pre>
</div>
<p>
When the audit log plugin is uninstalled as a result of server
shutdown (as opposed to being disabled at runtime),
<code class="literal">
connection_id
</code>
is set to 0, and
<code class="literal">
account
</code>
and
<code class="literal">
login
</code>
are
not present.
</p>
<p>
Connect or change-user event:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-json"><div class="docs-select-all right" id="sa92291713"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token punctuation">{</span> <span class="token property">"timestamp"</span><span class="token operator">:</span> <span class="token string">"2019-10-03 14:23:18"</span><span class="token punctuation">,</span>
<span class="token property">"id"</span><span class="token operator">:</span> <span class="token number">1</span><span class="token punctuation">,</span>
<span class="token property">"class"</span><span class="token operator">:</span> <span class="token string">"connection"</span><span class="token punctuation">,</span>
<span class="token property">"event"</span><span class="token operator">:</span> <span class="token string">"connect"</span><span class="token punctuation">,</span>
<span class="token property">"connection_id"</span><span class="token operator">:</span> <span class="token number">5</span><span class="token punctuation">,</span>
<span class="token property">"account"</span><span class="token operator">:</span> <span class="token punctuation">{</span> <span class="token property">"user"</span><span class="token operator">:</span> <span class="token string">"root"</span><span class="token punctuation">,</span> <span class="token property">"host"</span><span class="token operator">:</span> <span class="token string">"localhost"</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token property">"login"</span><span class="token operator">:</span> <span class="token punctuation">{</span> <span class="token property">"user"</span><span class="token operator">:</span> <span class="token string">"root"</span><span class="token punctuation">,</span> <span class="token property">"os"</span><span class="token operator">:</span> <span class="token string">""</span><span class="token punctuation">,</span> <span class="token property">"ip"</span><span class="token operator">:</span> "<span class="token operator">:</span><span class="token operator">:</span><span class="token number">1</span>"<span class="token punctuation">,</span> <span class="token property">"proxy"</span><span class="token operator">:</span> <span class="token string">""</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token property">"connection_data"</span><span class="token operator">:</span> <span class="token punctuation">{</span> <span class="token property">"connection_type"</span><span class="token operator">:</span> <span class="token string">"ssl"</span><span class="token punctuation">,</span>
<span class="token property">"status"</span><span class="token operator">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
<span class="token property">"db"</span><span class="token operator">:</span> <span class="token string">"test"</span><span class="token punctuation">,</span>
<span class="token property">"connection_attributes"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"_pid"</span><span class="token operator">:</span> <span class="token string">"43236"</span><span class="token punctuation">,</span>
...
<span class="token property">"program_name"</span><span class="token operator">:</span> <span class="token string">"mysqladmin"</span>
<span class="token punctuation">}</span> <span class="token punctuation">}</span>
<span class="token punctuation">}</span></code></pre>
</div>
<p>
Disconnect event:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-json"><div class="docs-select-all right" id="sa94048835"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token punctuation">{</span> <span class="token property">"timestamp"</span><span class="token operator">:</span> <span class="token string">"2019-10-03 14:24:45"</span><span class="token punctuation">,</span>
<span class="token property">"id"</span><span class="token operator">:</span> <span class="token number">3</span><span class="token punctuation">,</span>
<span class="token property">"class"</span><span class="token operator">:</span> <span class="token string">"connection"</span><span class="token punctuation">,</span>
<span class="token property">"event"</span><span class="token operator">:</span> <span class="token string">"disconnect"</span><span class="token punctuation">,</span>
<span class="token property">"connection_id"</span><span class="token operator">:</span> <span class="token number">5</span><span class="token punctuation">,</span>
<span class="token property">"account"</span><span class="token operator">:</span> <span class="token punctuation">{</span> <span class="token property">"user"</span><span class="token operator">:</span> <span class="token string">"root"</span><span class="token punctuation">,</span> <span class="token property">"host"</span><span class="token operator">:</span> <span class="token string">"localhost"</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token property">"login"</span><span class="token operator">:</span> <span class="token punctuation">{</span> <span class="token property">"user"</span><span class="token operator">:</span> <span class="token string">"root"</span><span class="token punctuation">,</span> <span class="token property">"os"</span><span class="token operator">:</span> <span class="token string">""</span><span class="token punctuation">,</span> <span class="token property">"ip"</span><span class="token operator">:</span> "<span class="token operator">:</span><span class="token operator">:</span><span class="token number">1</span>"<span class="token punctuation">,</span> <span class="token property">"proxy"</span><span class="token operator">:</span> <span class="token string">""</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token property">"connection_data"</span><span class="token operator">:</span> <span class="token punctuation">{</span> <span class="token property">"connection_type"</span><span class="token operator">:</span> <span class="token string">"ssl"</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span></code></pre>
</div>
<p>
Query event:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-json"><div class="docs-select-all right" id="sa1369824"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token punctuation">{</span> <span class="token property">"timestamp"</span><span class="token operator">:</span> <span class="token string">"2019-10-03 14:23:35"</span><span class="token punctuation">,</span>
<span class="token property">"id"</span><span class="token operator">:</span> <span class="token number">2</span><span class="token punctuation">,</span>
<span class="token property">"class"</span><span class="token operator">:</span> <span class="token string">"general"</span><span class="token punctuation">,</span>
<span class="token property">"event"</span><span class="token operator">:</span> <span class="token string">"status"</span><span class="token punctuation">,</span>
<span class="token property">"connection_id"</span><span class="token operator">:</span> <span class="token number">5</span><span class="token punctuation">,</span>
<span class="token property">"account"</span><span class="token operator">:</span> <span class="token punctuation">{</span> <span class="token property">"user"</span><span class="token operator">:</span> <span class="token string">"root"</span><span class="token punctuation">,</span> <span class="token property">"host"</span><span class="token operator">:</span> <span class="token string">"localhost"</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token property">"login"</span><span class="token operator">:</span> <span class="token punctuation">{</span> <span class="token property">"user"</span><span class="token operator">:</span> <span class="token string">"root"</span><span class="token punctuation">,</span> <span class="token property">"os"</span><span class="token operator">:</span> <span class="token string">""</span><span class="token punctuation">,</span> <span class="token property">"ip"</span><span class="token operator">:</span> "<span class="token operator">:</span><span class="token operator">:</span><span class="token number">1</span>"<span class="token punctuation">,</span> <span class="token property">"proxy"</span><span class="token operator">:</span> <span class="token string">""</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token property">"general_data"</span><span class="token operator">:</span> <span class="token punctuation">{</span> <span class="token property">"command"</span><span class="token operator">:</span> <span class="token string">"Query"</span><span class="token punctuation">,</span>
<span class="token property">"sql_command"</span><span class="token operator">:</span> <span class="token string">"show_variables"</span><span class="token punctuation">,</span>
<span class="token property">"query"</span><span class="token operator">:</span> <span class="token string">"SHOW VARIABLES"</span><span class="token punctuation">,</span>
<span class="token property">"status"</span><span class="token operator">:</span> <span class="token number">0</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span></code></pre>
</div>
<p>
Query event with optional query statistics for outlier
detection:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-json"><div class="docs-select-all right" id="sa96330512"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token punctuation">{</span> <span class="token property">"timestamp"</span><span class="token operator">:</span> <span class="token string">"2022-01-28 13:09:30"</span><span class="token punctuation">,</span>
<span class="token property">"id"</span><span class="token operator">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
<span class="token property">"class"</span><span class="token operator">:</span> <span class="token string">"general"</span><span class="token punctuation">,</span>
<span class="token property">"event"</span><span class="token operator">:</span> <span class="token string">"status"</span><span class="token punctuation">,</span>
<span class="token property">"connection_id"</span><span class="token operator">:</span> <span class="token number">46</span><span class="token punctuation">,</span>
<span class="token property">"account"</span><span class="token operator">:</span> <span class="token punctuation">{</span> <span class="token property">"user"</span><span class="token operator">:</span> <span class="token string">"user"</span><span class="token punctuation">,</span> <span class="token property">"host"</span><span class="token operator">:</span> <span class="token string">"localhost"</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token property">"login"</span><span class="token operator">:</span> <span class="token punctuation">{</span> <span class="token property">"user"</span><span class="token operator">:</span> "user<span class="token property">", “os"</span><span class="token operator">:</span> "<span class="token property">", “ip"</span><span class="token operator">:</span> "<span class="token number">127.0</span>.<span class="token number">0.1</span><span class="token property">", “proxy"</span><span class="token operator">:</span> <span class="token string">""</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token property">"general_data"</span><span class="token operator">:</span> <span class="token punctuation">{</span> <span class="token property">"command"</span><span class="token operator">:</span> <span class="token string">"Query"</span><span class="token punctuation">,</span>
<span class="token property">"sql_command"</span><span class="token operator">:</span> <span class="token string">"insert"</span><span class="token punctuation">,</span>
<span class="token property">"query"</span><span class="token operator">:</span> <span class="token string">"INSERT INTO audit_table VALUES(4)"</span><span class="token punctuation">,</span>
<span class="token property">"status"</span><span class="token operator">:</span> <span class="token number">1146</span> <span class="token punctuation">}</span>
<span class="token property">"query_statistics"</span><span class="token operator">:</span> <span class="token punctuation">{</span> <span class="token property">"query_time"</span><span class="token operator">:</span> <span class="token number">0.116250</span><span class="token punctuation">,</span>
<span class="token property">"bytes_sent"</span><span class="token operator">:</span> <span class="token number">18384</span><span class="token punctuation">,</span>
<span class="token property">"bytes_received"</span><span class="token operator">:</span> <span class="token number">78858</span><span class="token punctuation">,</span>
<span class="token property">"rows_sent"</span><span class="token operator">:</span> <span class="token number">3</span><span class="token punctuation">,</span>
<span class="token property">"rows_examined"</span><span class="token operator">:</span> <span class="token number">20878</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span></code></pre>
</div>
<p>
Table access event (read, delete, insert, update):
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-json"><div class="docs-select-all right" id="sa63533740"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token punctuation">{</span> <span class="token property">"timestamp"</span><span class="token operator">:</span> <span class="token string">"2019-10-03 14:23:41"</span><span class="token punctuation">,</span>
<span class="token property">"id"</span><span class="token operator">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
<span class="token property">"class"</span><span class="token operator">:</span> <span class="token string">"table_access"</span><span class="token punctuation">,</span>
<span class="token property">"event"</span><span class="token operator">:</span> <span class="token string">"insert"</span><span class="token punctuation">,</span>
<span class="token property">"connection_id"</span><span class="token operator">:</span> <span class="token number">5</span><span class="token punctuation">,</span>
<span class="token property">"account"</span><span class="token operator">:</span> <span class="token punctuation">{</span> <span class="token property">"user"</span><span class="token operator">:</span> <span class="token string">"root"</span><span class="token punctuation">,</span> <span class="token property">"host"</span><span class="token operator">:</span> <span class="token string">"localhost"</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token property">"login"</span><span class="token operator">:</span> <span class="token punctuation">{</span> <span class="token property">"user"</span><span class="token operator">:</span> <span class="token string">"root"</span><span class="token punctuation">,</span> <span class="token property">"os"</span><span class="token operator">:</span> <span class="token string">""</span><span class="token punctuation">,</span> <span class="token property">"ip"</span><span class="token operator">:</span> <span class="token string">"127.0.0.1"</span><span class="token punctuation">,</span> <span class="token property">"proxy"</span><span class="token operator">:</span> <span class="token string">""</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token property">"table_access_data"</span><span class="token operator">:</span> <span class="token punctuation">{</span> <span class="token property">"db"</span><span class="token operator">:</span> <span class="token string">"test"</span><span class="token punctuation">,</span>
<span class="token property">"table"</span><span class="token operator">:</span> <span class="token string">"t1"</span><span class="token punctuation">,</span>
<span class="token property">"query"</span><span class="token operator">:</span> <span class="token string">"INSERT INTO t1 (i) VALUES(1),(2),(3)"</span><span class="token punctuation">,</span>
<span class="token property">"sql_command"</span><span class="token operator">:</span> <span class="token string">"insert"</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span></code></pre>
</div>
<p>
The items in the following list appear at the top level of
JSON-format audit records: Each item value is either a scalar
or a
<a class="link" href="json.html" title="13.5 The JSON Data Type">
<code class="literal">
JSON
</code>
</a>
hash. For items that
have a hash value, the description lists only the item names
within that hash. For more complete descriptions of
second-level hash items, see later in this section.
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
account
</code>
</p>
<p>
The MySQL account associated with the event. The value is
a hash containing these items equivalent to the value of
the
<a class="link" href="information-functions.html#function_current-user">
<code class="literal">
CURRENT_USER()
</code>
</a>
function
within the section:
<code class="literal">
user
</code>
,
<code class="literal">
host
</code>
.
</p>
<p>
Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-json"><div class="docs-select-all right" id="sa19262033"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token property">"account"</span><span class="token operator">:</span> <span class="token punctuation">{</span> <span class="token property">"user"</span><span class="token operator">:</span> <span class="token string">"root"</span><span class="token punctuation">,</span> <span class="token property">"host"</span><span class="token operator">:</span> <span class="token string">"localhost"</span> <span class="token punctuation">}</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
<code class="literal">
class
</code>
</p>
<p>
A string representing the event class. The class defines
the type of event, when taken together with the
<code class="literal">
event
</code>
item that specifies the event
subclass.
</p>
<p>
Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-json"><div class="docs-select-all right" id="sa98101895"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token property">"class"</span><span class="token operator">:</span> <span class="token string">"connection"</span></code></pre>
</div>
<p>
The following table shows the permitted combinations of
<code class="literal">
class
</code>
and
<code class="literal">
event
</code>
values.
</p>
<div class="table">
<a name="audit-log-class-event-combinations">
</a>
<p class="title">
<b>
Table 8.33 Audit Log Class and Event Combinations
</b>
</p>
<div class="table-contents">
<table summary="Permitted combinations of audit log class and event values.">
<colgroup>
<col style="width: 30%"/>
<col style="width: 40%"/>
</colgroup>
<thead>
<tr>
<th>
Class Value
</th>
<th>
Permitted Event Values
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<code class="literal">
audit
</code>
</td>
<td>
<code class="literal">
startup
</code>
,
<code class="literal">
shutdown
</code>
</td>
</tr>
<tr>
<td>
<code class="literal">
connection
</code>
</td>
<td>
<code class="literal">
connect
</code>
,
<code class="literal">
change_user
</code>
,
<code class="literal">
disconnect
</code>
</td>
</tr>
<tr>
<td>
<code class="literal">
general
</code>
</td>
<td>
<code class="literal">
status
</code>
</td>
</tr>
<tr>
<td>
<code class="literal">
table_access_data
</code>
</td>
<td>
<code class="literal">
read
</code>
,
<code class="literal">
delete
</code>
,
<code class="literal">
insert
</code>
,
<code class="literal">
update
</code>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<br class="table-break"/>
</li>
<li class="listitem">
<p>
<code class="literal">
connection_data
</code>
</p>
<p>
Information about a client connection. The value is a hash
containing these items:
<code class="literal">
connection_type
</code>
,
<code class="literal">
status
</code>
,
<code class="literal">
db
</code>
, and
possibly
<code class="literal">
connection_attributes
</code>
. This
item occurs only for audit records with a
<code class="literal">
class
</code>
value of
<code class="literal">
connection
</code>
.
</p>
<p>
Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-json"><div class="docs-select-all right" id="sa17302286"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token property">"connection_data"</span><span class="token operator">:</span> <span class="token punctuation">{</span> <span class="token property">"connection_type"</span><span class="token operator">:</span> <span class="token string">"ssl"</span><span class="token punctuation">,</span>
<span class="token property">"status"</span><span class="token operator">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
<span class="token property">"db"</span><span class="token operator">:</span> <span class="token string">"test"</span> <span class="token punctuation">}</span></code></pre>
</div>
<p>
Events with a
<code class="literal">
class
</code>
value of
<code class="literal">
connection
</code>
and
<code class="literal">
event
</code>
value of
<code class="literal">
connect
</code>
may include a
<code class="literal">
connection_attributes
</code>
item to display
the connection attributes passed by the client at connect
time. (For information about these attributes, which are
also exposed in Performance Schema tables, see
<a class="xref" href="performance-schema-connection-attribute-tables.html" title="29.12.9 Performance Schema Connection Attribute Tables">
Section 29.12.9, “Performance Schema Connection Attribute Tables”
</a>
.)
</p>
<p>
The
<code class="literal">
connection_attributes
</code>
value is a
hash that represents each attribute by its name and value.
</p>
<p>
Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-json"><div class="docs-select-all right" id="sa99840536"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token property">"connection_attributes"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"_pid"</span><span class="token operator">:</span> <span class="token string">"43236"</span><span class="token punctuation">,</span>
<span class="token property">"_os"</span><span class="token operator">:</span> <span class="token string">"macos0.14"</span><span class="token punctuation">,</span>
<span class="token property">"_platform"</span><span class="token operator">:</span> <span class="token string">"x86_64"</span><span class="token punctuation">,</span>
<span class="token property">"_client_version"</span><span class="token operator">:</span> <span class="token string">"8.4.0"</span><span class="token punctuation">,</span>
<span class="token property">"_client_name"</span><span class="token operator">:</span> <span class="token string">"libmysql"</span><span class="token punctuation">,</span>
<span class="token property">"program_name"</span><span class="token operator">:</span> <span class="token string">"mysqladmin"</span>
<span class="token punctuation">}</span></code></pre>
</div>
<p>
If no connection attributes are present in the event, none
are logged and no
<code class="literal">
connection_attributes
</code>
item appears. This can occur if the connection attempt is
unsuccessful, the client passes no attributes, or the
connection occurs internally such as during server startup
or when initiated by a plugin.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
connection_id
</code>
</p>
<p>
An unsigned integer representing the client connection
identifier. This is the same as the value returned by the
<a class="link" href="information-functions.html#function_connection-id">
<code class="literal">
CONNECTION_ID()
</code>
</a>
function
within the session.
</p>
<p>
Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-json"><div class="docs-select-all right" id="sa55774610"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token property">"connection_id"</span><span class="token operator">:</span> <span class="token number">5</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
<code class="literal">
event
</code>
</p>
<p>
A string representing the subclass of the event class. The
subclass defines the type of event, when taken together
with the
<code class="literal">
class
</code>
item that specifies the
event class. For more information, see the
<code class="literal">
class
</code>
item description.
</p>
<p>
Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-json"><div class="docs-select-all right" id="sa57962596"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token property">"event"</span><span class="token operator">:</span> <span class="token string">"connect"</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
<code class="literal">
general_data
</code>
</p>
<p>
Information about an executed statement or command. The
value is a hash containing these items:
<code class="literal">
command
</code>
,
<code class="literal">
sql_command
</code>
,
<code class="literal">
query
</code>
,
<code class="literal">
status
</code>
. This item occurs only for audit
records with a
<code class="literal">
class
</code>
value of
<code class="literal">
general
</code>
.
</p>
<p>
Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-json"><div class="docs-select-all right" id="sa37767202"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token property">"general_data"</span><span class="token operator">:</span> <span class="token punctuation">{</span> <span class="token property">"command"</span><span class="token operator">:</span> <span class="token string">"Query"</span><span class="token punctuation">,</span>
<span class="token property">"sql_command"</span><span class="token operator">:</span> <span class="token string">"show_variables"</span><span class="token punctuation">,</span>
<span class="token property">"query"</span><span class="token operator">:</span> <span class="token string">"SHOW VARIABLES"</span><span class="token punctuation">,</span>
<span class="token property">"status"</span><span class="token operator">:</span> <span class="token number">0</span> <span class="token punctuation">}</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
<code class="literal">
id
</code>
</p>
<p>
An unsigned integer representing an event ID.
</p>
<p>
Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-json"><div class="docs-select-all right" id="sa18692206"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token property">"id"</span><span class="token operator">:</span> <span class="token number">2</span></code></pre>
</div>
<p>
For audit records that have the same
<code class="literal">
timestamp
</code>
value, their
<code class="literal">
id
</code>
values distinguish them and form a
sequence. Within the audit log,
<code class="literal">
timestamp
</code>
/
<code class="literal">
id
</code>
pairs
are unique. These pairs are bookmarks that identify event
locations within the log.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
login
</code>
</p>
<p>
Information indicating how a client connected to the
server. The value is a hash containing these items:
<code class="literal">
user
</code>
,
<code class="literal">
os
</code>
,
<code class="literal">
ip
</code>
,
<code class="literal">
proxy
</code>
.
</p>
<p>
Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-json"><div class="docs-select-all right" id="sa64432156"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token property">"login"</span><span class="token operator">:</span> <span class="token punctuation">{</span> <span class="token property">"user"</span><span class="token operator">:</span> <span class="token string">"root"</span><span class="token punctuation">,</span> <span class="token property">"os"</span><span class="token operator">:</span> <span class="token string">""</span><span class="token punctuation">,</span> <span class="token property">"ip"</span><span class="token operator">:</span> "<span class="token operator">:</span><span class="token operator">:</span><span class="token number">1</span>"<span class="token punctuation">,</span> <span class="token property">"proxy"</span><span class="token operator">:</span> <span class="token string">""</span> <span class="token punctuation">}</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
<code class="literal">
query_statistics
</code>
</p>
<p>
Optional query statistics for outlier detection. The value
is a hash containing these items:
<code class="literal">
query_time
</code>
,
<code class="literal">
rows_sent
</code>
,
<code class="literal">
rows_examined
</code>
,
<code class="literal">
bytes_received
</code>
,
<code class="literal">
bytes_sent
</code>
. For instructions to set up
the query statistics, see
<a class="xref" href="audit-log-logging-configuration.html#audit-log-query-statistics" title="Adding Query Statistics for Outlier Detection">
Adding Query Statistics for Outlier Detection
</a>
.
</p>
<p>
Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-json"><div class="docs-select-all right" id="sa7514794"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token property">"query_statistics"</span><span class="token operator">:</span> <span class="token punctuation">{</span> <span class="token property">"query_time"</span><span class="token operator">:</span> <span class="token number">0.116250</span><span class="token punctuation">,</span>
<span class="token property">"bytes_sent"</span><span class="token operator">:</span> <span class="token number">18384</span><span class="token punctuation">,</span>
<span class="token property">"bytes_received"</span><span class="token operator">:</span> <span class="token number">78858</span><span class="token punctuation">,</span>
<span class="token property">"rows_sent"</span><span class="token operator">:</span> <span class="token number">3</span><span class="token punctuation">,</span>
<span class="token property">"rows_examined"</span><span class="token operator">:</span> <span class="token number">20878</span> <span class="token punctuation">}</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
<code class="literal">
shutdown_data
</code>
</p>
<p>
Information pertaining to audit log plugin termination.
The value is a hash containing these items:
<code class="literal">
server_id
</code>
This item occurs only for
audit records with
<code class="literal">
class
</code>
and
<code class="literal">
event
</code>
values of
<code class="literal">
audit
</code>
and
<code class="literal">
shutdown
</code>
,
respectively.
</p>
<p>
Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-json"><div class="docs-select-all right" id="sa6367835"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token property">"shutdown_data"</span><span class="token operator">:</span> <span class="token punctuation">{</span> <span class="token property">"server_id"</span><span class="token operator">:</span> <span class="token number">1</span> <span class="token punctuation">}</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
<code class="literal">
startup_data
</code>
</p>
<p>
Information pertaining to audit log plugin initialization.
The value is a hash containing these items:
<code class="literal">
server_id
</code>
,
<code class="literal">
os_version
</code>
,
<code class="literal">
mysql_version
</code>
,
<code class="literal">
args
</code>
.
This item occurs only for audit records with
<code class="literal">
class
</code>
and
<code class="literal">
event
</code>
values of
<code class="literal">
audit
</code>
and
<code class="literal">
startup
</code>
, respectively.
</p>
<p>
Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-json"><div class="docs-select-all right" id="sa37414091"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token property">"startup_data"</span><span class="token operator">:</span> <span class="token punctuation">{</span> <span class="token property">"server_id"</span><span class="token operator">:</span> <span class="token number">1</span><span class="token punctuation">,</span>
<span class="token property">"os_version"</span><span class="token operator">:</span> <span class="token string">"i686-Linux"</span><span class="token punctuation">,</span>
<span class="token property">"mysql_version"</span><span class="token operator">:</span> <span class="token string">"5.7.21-log"</span><span class="token punctuation">,</span>
<span class="token property">"args"</span><span class="token operator">:</span> <span class="token punctuation">[</span><span class="token string">"/usr/local/mysql/bin/mysqld"</span><span class="token punctuation">,</span>
<span class="token string">"--loose-audit-log-format=JSON"</span><span class="token punctuation">,</span>
<span class="token string">"--log-error=log.err"</span><span class="token punctuation">,</span>
<span class="token string">"--pid-file=mysqld.pid"</span><span class="token punctuation">,</span>
<span class="token string">"--port=3306"</span> <span class="token punctuation">]</span> <span class="token punctuation">}</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
<code class="literal">
table_access_data
</code>
</p>
<p>
Information about an access to a table. The value is a
hash containing these items:
<code class="literal">
db
</code>
,
<code class="literal">
table
</code>
,
<code class="literal">
query
</code>
,
<code class="literal">
sql_command
</code>
, This item occurs only for
audit records with a
<code class="literal">
class
</code>
value of
<code class="literal">
table_access
</code>
.
</p>
<p>
Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-json"><div class="docs-select-all right" id="sa46667829"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token property">"table_access_data"</span><span class="token operator">:</span> <span class="token punctuation">{</span> <span class="token property">"db"</span><span class="token operator">:</span> <span class="token string">"test"</span><span class="token punctuation">,</span>
<span class="token property">"table"</span><span class="token operator">:</span> <span class="token string">"t1"</span><span class="token punctuation">,</span>
<span class="token property">"query"</span><span class="token operator">:</span> <span class="token string">"INSERT INTO t1 (i) VALUES(1),(2),(3)"</span><span class="token punctuation">,</span>
<span class="token property">"sql_command"</span><span class="token operator">:</span> <span class="token string">"insert"</span> <span class="token punctuation">}</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
<code class="literal">
time
</code>
</p>
<p>
This field is similar to that in the
<code class="literal">
timestamp
</code>
field, but the value is an
integer and represents the UNIX timestamp value indicating
the date and time when the audit event was generated.
</p>
<p>
Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-json"><div class="docs-select-all right" id="sa5495074"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token property">"time"</span> <span class="token operator">:</span> <span class="token number">1618498687</span></code></pre>
</div>
<p>
The
<code class="literal">
time
</code>
field occurs in JSON-format
log files only if the
<a class="link" href="audit-log-reference.html#sysvar_audit_log_format_unix_timestamp">
<code class="literal">
audit_log_format_unix_timestamp
</code>
</a>
system variable is enabled.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
timestamp
</code>
</p>
<p>
A string representing a UTC value in
<em class="replaceable">
<code>
YYYY-MM-DD hh:mm:ss
</code>
</em>
format
indicating the date and time when the audit event was
generated. For example, the event corresponding to
execution of an SQL statement received from a client has a
<code class="literal">
timestamp
</code>
value occurring after the
statement finishes, not when it was received.
</p>
<p>
Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-json"><div class="docs-select-all right" id="sa1155895"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token property">"timestamp"</span><span class="token operator">:</span> <span class="token string">"2019-10-03 13:50:01"</span></code></pre>
</div>
<p>
For audit records that have the same
<code class="literal">
timestamp
</code>
value, their
<code class="literal">
id
</code>
values distinguish them and form a
sequence. Within the audit log,
<code class="literal">
timestamp
</code>
/
<code class="literal">
id
</code>
pairs
are unique. These pairs are bookmarks that identify event
locations within the log.
</p>
</li>
</ul>
</div>
<p>
These items appear within hash values associated with
top-level items of JSON-format audit records:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
args
</code>
</p>
<p>
An array of options that were given on the command line or
in option files when the MySQL server was started. The
first option is the path to the server executable.
</p>
<p>
Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-json"><div class="docs-select-all right" id="sa30220596"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token property">"args"</span><span class="token operator">:</span> <span class="token punctuation">[</span><span class="token string">"/usr/local/mysql/bin/mysqld"</span><span class="token punctuation">,</span>
<span class="token string">"--loose-audit-log-format=JSON"</span><span class="token punctuation">,</span>
<span class="token string">"--log-error=log.err"</span><span class="token punctuation">,</span>
<span class="token string">"--pid-file=mysqld.pid"</span><span class="token punctuation">,</span>
<span class="token string">"--port=3306"</span> <span class="token punctuation">]</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
<code class="literal">
bytes_received
</code>
</p>
<p>
The number of bytes received from the client. This item is
part of the optional query statistics. For this field to
be populated, the system variable
<a class="link" href="server-system-variables.html#sysvar_log_slow_extra">
<code class="literal">
log_slow_extra
</code>
</a>
must be
set to
<code class="literal">
ON
</code>
.
</p>
<p>
Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-json"><div class="docs-select-all right" id="sa3855363"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token property">"bytes_received"</span><span class="token operator">:</span> <span class="token number">78858</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
<code class="literal">
bytes_sent
</code>
</p>
<p>
The number of bytes sent to the client. This item is part
of the optional query statistics. For this field to be
populated, the system variable
<a class="link" href="server-system-variables.html#sysvar_log_slow_extra">
<code class="literal">
log_slow_extra
</code>
</a>
must be
set to
<code class="literal">
ON
</code>
.
</p>
<p>
Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-json"><div class="docs-select-all right" id="sa19064110"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token property">"bytes_sent"</span><span class="token operator">:</span> <span class="token number">18384</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
<code class="literal">
command
</code>
</p>
<p>
A string representing the type of instruction that
generated the audit event, such as a command that the
server received from a client.
</p>
<p>
Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-json"><div class="docs-select-all right" id="sa8053937"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token property">"command"</span><span class="token operator">:</span> <span class="token string">"Query"</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
<code class="literal">
connection_type
</code>
</p>
<p>
The security state of the connection to the server.
Permitted values are
<code class="literal">
tcp/ip
</code>
(TCP/IP
connection established without encryption),
<code class="literal">
ssl
</code>
(TCP/IP connection established with
encryption),
<code class="literal">
socket
</code>
(Unix socket file
connection),
<code class="literal">
named_pipe
</code>
(Windows named
pipe connection), and
<code class="literal">
shared_memory
</code>
(Windows shared memory connection).
</p>
<p>
Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-json"><div class="docs-select-all right" id="sa16590549"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token property">"connection_type"</span><span class="token operator">:</span> <span class="token string">"tcp/tcp"</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
<code class="literal">
db
</code>
</p>
<p>
A string representing a database name. For
<code class="literal">
connection_data
</code>
, it is the default
database. For
<code class="literal">
table_access_data
</code>
, it is
the table database.
</p>
<p>
Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-json"><div class="docs-select-all right" id="sa90648817"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token property">"db"</span><span class="token operator">:</span> <span class="token string">"test"</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
<code class="literal">
host
</code>
</p>
<p>
A string representing the client host name.
</p>
<p>
Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-json"><div class="docs-select-all right" id="sa16939747"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token property">"host"</span><span class="token operator">:</span> <span class="token string">"localhost"</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
<code class="literal">
ip
</code>
</p>
<p>
A string representing the client IP address.
</p>
<p>
Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-json"><div class="docs-select-all right" id="sa27928144"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token property">"ip"</span><span class="token operator">:</span> "<span class="token operator">:</span><span class="token operator">:</span><span class="token number">1</span>"</code></pre>
</div>
</li>
<li class="listitem">
<p>
<code class="literal">
mysql_version
</code>
</p>
<p>
A string representing the MySQL server version. This is
the same as the value of the
<a class="link" href="information-functions.html#function_version">
<code class="literal">
VERSION()
</code>
</a>
function or
<a class="link" href="server-system-variables.html#sysvar_version">
<code class="literal">
version
</code>
</a>
system variable.
</p>
<p>
Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-json"><div class="docs-select-all right" id="sa27522602"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token property">"mysql_version"</span><span class="token operator">:</span> <span class="token string">"5.7.21-log"</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
<code class="literal">
os
</code>
</p>
<p>
A string representing the external user name used during
the authentication process, as set by the plugin used to
authenticate the client. With native (built-in) MySQL
authentication, or if the plugin does not set the value,
this attribute is empty. The value is the same as that of
the
<a class="link" href="server-system-variables.html#sysvar_external_user">
<code class="literal">
external_user
</code>
</a>
system
variable. See
<a class="xref" href="proxy-users.html" title="8.2.19 Proxy Users">
Section 8.2.19, “Proxy Users”
</a>
.
</p>
<p>
Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-json"><div class="docs-select-all right" id="sa73771891"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token property">"os"</span><span class="token operator">:</span> <span class="token string">"jeffrey"</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
<code class="literal">
os_version
</code>
</p>
<p>
A string representing the operating system on which the
server was built or is running.
</p>
<p>
Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-json"><div class="docs-select-all right" id="sa47634394"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token property">"os_version"</span><span class="token operator">:</span> <span class="token string">"i686-Linux"</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
<code class="literal">
proxy
</code>
</p>
<p>
A string representing the proxy user (see
<a class="xref" href="proxy-users.html" title="8.2.19 Proxy Users">
Section 8.2.19, “Proxy Users”
</a>
). The value is empty if user
proxying is not in effect.
</p>
<p>
Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-json"><div class="docs-select-all right" id="sa36688323"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token property">"proxy"</span><span class="token operator">:</span> <span class="token string">"developer"</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
<code class="literal">
query
</code>
</p>
<p>
A string representing the text of an SQL statement. The
value can be empty. Long values may be truncated. The
string, like the audit log file itself, is written using
UTF-8 (up to 4 bytes per character), so the value may be
the result of conversion. For example, the original
statement might have been received from the client as an
SJIS string.
</p>
<p>
Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-json"><div class="docs-select-all right" id="sa34939748"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token property">"query"</span><span class="token operator">:</span> <span class="token string">"DELETE FROM t1"</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
<code class="literal">
query_time
</code>
</p>
<p>
The query execution time in microseconds (if the
<code class="literal">
longlong
</code>
data type is selected) or
seconds (if the
<code class="literal">
double
</code>
data type is
selected). This item is part of the optional query
statistics.
</p>
<p>
Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-json"><div class="docs-select-all right" id="sa79299162"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token property">"query_time"</span><span class="token operator">:</span> <span class="token number">0.116250</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
<code class="literal">
rows_examined
</code>
</p>
<p>
The number of rows accessed during the query. This item is
part of the optional query statistics.
</p>
<p>
Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-json"><div class="docs-select-all right" id="sa90228444"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token property">"rows_examined"</span><span class="token operator">:</span> <span class="token number">20878</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
<code class="literal">
rows_sent
</code>
</p>
<p>
The number of rows sent to the client as a result. This
item is part of the optional query statistics.
</p>
<p>
Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-json"><div class="docs-select-all right" id="sa35196704"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token property">"rows_sent"</span><span class="token operator">:</span> <span class="token number">3</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
<code class="literal">
server_id
</code>
</p>
<p>
An unsigned integer representing the server ID. This is
the same as the value of the
<a class="link" href="replication-options.html#sysvar_server_id">
<code class="literal">
server_id
</code>
</a>
system
variable.
</p>
<p>
Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-json"><div class="docs-select-all right" id="sa16314371"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token property">"server_id"</span><span class="token operator">:</span> <span class="token number">1</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
<code class="literal">
sql_command
</code>
</p>
<p>
A string that indicates the SQL statement type.
</p>
<p>
Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-json"><div class="docs-select-all right" id="sa57257067"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token property">"sql_command"</span><span class="token operator">:</span> <span class="token string">"insert"</span></code></pre>
</div>
<p>
The values correspond to the
<code class="literal">
statement/sql/
<em class="replaceable">
<code>
xxx
</code>
</em>
</code>
command counters. For example,
<em class="replaceable">
<code>
xxx
</code>
</em>
is
<code class="literal">
drop_table
</code>
and
<code class="literal">
select
</code>
for
<a class="link" href="drop-table.html" title="15.1.32 DROP TABLE Statement">
<code class="literal">
DROP
TABLE
</code>
</a>
and
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
statements, respectively. The following statement displays
the possible names:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa3473720"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> <span class="token function">REPLACE</span><span class="token punctuation">(</span>EVENT_NAME<span class="token punctuation">,</span> <span class="token string">'statement/sql/'</span><span class="token punctuation">,</span> <span class="token string">''</span><span class="token punctuation">)</span> <span class="token keyword">AS</span> <span class="token keyword">name</span>
<span class="token keyword">FROM</span> performance_schema<span class="token punctuation">.</span>events_statements_summary_global_by_event_name
<span class="token keyword">WHERE</span> EVENT_NAME <span class="token operator">LIKE</span> <span class="token string">'statement/sql/%'</span>
<span class="token keyword">ORDER</span> <span class="token keyword">BY</span> <span class="token keyword">name</span><span class="token punctuation">;</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
<code class="literal">
status
</code>
</p>
<p>
An unsigned integer representing the command status: 0 for
success, nonzero if an error occurred. This is the same as
the value of the
<a class="ulink" href="/doc/c-api/8.4/en/mysql-errno.html" target="_top">
<code class="literal">
mysql_errno()
</code>
</a>
C API
function.
</p>
<p>
The audit log does not contain the SQLSTATE value or error
message. To see the associations between error codes,
SQLSTATE values, and messages, see
<a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html" target="_top">
Server Error Message Reference
</a>
.
</p>
<p>
Warnings are not logged.
</p>
<p>
Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-json"><div class="docs-select-all right" id="sa72052958"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token property">"status"</span><span class="token operator">:</span> <span class="token number">1051</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
<code class="literal">
table
</code>
</p>
<p>
A string representing a table name.
</p>
<p>
Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-json"><div class="docs-select-all right" id="sa32285773"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token property">"table"</span><span class="token operator">:</span> <span class="token string">"t1"</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
<code class="literal">
user
</code>
</p>
<p>
A string representing a user name. The meaning differs
depending on the item within which
<code class="literal">
user
</code>
occurs:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
Within
<code class="literal">
account
</code>
items,
<code class="literal">
user
</code>
is a string representing the
user that the server authenticated the client as. This
is the user name that the server uses for privilege
checking.
</p>
</li>
<li class="listitem">
<p>
Within
<code class="literal">
login
</code>
items,
<code class="literal">
user
</code>
is a string representing the
user name sent by the client.
</p>
</li>
</ul>
</div>
<p>
Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-json"><div class="docs-select-all right" id="sa36425564"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token property">"user"</span><span class="token operator">:</span> <span class="token string">"root"</span></code></pre>
</div>
</li>
</ul>
</div>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/encrypted-connections.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h2 class="title">
<a name="encrypted-connections">
</a>
8.3 Using Encrypted Connections
</h2>
</div>
</div>
</div>
<div class="toc">
<dl class="toc">
<dt>
<span class="section">
<a href="using-encrypted-connections.html">
8.3.1 Configuring MySQL to Use Encrypted Connections
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="encrypted-connection-protocols-ciphers.html">
8.3.2 Encrypted Connection TLS Protocols and Ciphers
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="creating-ssl-rsa-files.html">
8.3.3 Creating SSL and RSA Certificates and Keys
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="windows-and-ssh.html">
8.3.4 Connecting to MySQL Remotely from Windows with SSH
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="reusing-ssl-sessions.html">
8.3.5 Reusing SSL Sessions
</a>
</span>
</dt>
</dl>
</div>
<a class="indexterm" name="idm46045247211600">
</a>
<a class="indexterm" name="idm46045247210560">
</a>
<a class="indexterm" name="idm46045247209488">
</a>
<a class="indexterm" name="idm46045247208448">
</a>
<a class="indexterm" name="idm46045247207408">
</a>
<a class="indexterm" name="idm46045247206336">
</a>
<p>
With an unencrypted connection between the MySQL client and the
server, someone with access to the network could watch all your
traffic and inspect the data being sent or received between client
and server.
</p>
<a class="indexterm" name="idm46045247204256">
</a>
<p>
When you must move information over a network in a secure fashion,
an unencrypted connection is unacceptable. To make any kind of data
unreadable, use encryption. Encryption algorithms must include
security elements to resist many kinds of known attacks such as
changing the order of encrypted messages or replaying data twice.
</p>
<p>
MySQL supports encrypted connections between clients and the server
using the TLS (Transport Layer Security) protocol. TLS is sometimes
referred to as SSL (Secure Sockets Layer) but MySQL does not
actually use the SSL protocol for encrypted connections because its
encryption is weak (see
<a class="xref" href="encrypted-connection-protocols-ciphers.html" title="8.3.2 Encrypted Connection TLS Protocols and Ciphers">
Section 8.3.2, “Encrypted Connection TLS Protocols and Ciphers”
</a>
).
</p>
<p>
TLS uses encryption algorithms to ensure that data received over a
public network can be trusted. It has mechanisms to detect data
change, loss, or replay. TLS also incorporates algorithms that
provide identity verification using the X.509 standard.
</p>
<a class="indexterm" name="idm46045247200288">
</a>
<p>
X.509 makes it possible to identify someone on the Internet. In
basic terms, there should be some entity called a
<span class="quote">
“
<span class="quote">
Certificate
Authority
</span>
”
</span>
(or CA) that assigns electronic certificates to
anyone who needs them. Certificates rely on asymmetric encryption
algorithms that have two encryption keys (a public key and a secret
key). A certificate owner can present the certificate to another
party as proof of identity. A certificate consists of its owner's
public key. Any data encrypted using this public key can be
decrypted only using the corresponding secret key, which is held by
the owner of the certificate.
</p>
<p>
Support for encrypted connections in MySQL is provided using
OpenSSL. For information about the encryption protocols and ciphers
that OpenSSL supports, see
<a class="xref" href="encrypted-connection-protocols-ciphers.html" title="8.3.2 Encrypted Connection TLS Protocols and Ciphers">
Section 8.3.2, “Encrypted Connection TLS Protocols and Ciphers”
</a>
.
</p>
<p>
By default, MySQL instances link to an available installed OpenSSL
library at runtime for support of encrypted connections and other
encryption-related operations. You may compile MySQL from source and
use the
<a class="link" href="source-configuration-options.html#option_cmake_with_ssl">
<code class="option">
WITH_SSL
</code>
</a>
<span class="command">
<strong>
CMake
</strong>
</span>
option to specify the path to a particular
installed OpenSSL version or an alternative OpenSSL system package.
In that case, MySQL selects that version. For instructions to do
this, see
<a class="xref" href="source-ssl-library-configuration.html" title="2.8.6 Configuring SSL Library Support">
Section 2.8.6, “Configuring SSL Library Support”
</a>
.
</p>
<p>
You can check what version of the OpenSSL library is in use at
runtime using the
<a class="link" href="server-status-variables.html#statvar_Tls_library_version">
<code class="literal">
Tls_library_version
</code>
</a>
system status
variable.
</p>
<p>
If you compile MySQL with one version of OpenSSL and want to change
to a different version without recompiling, you may do this by
editing the dynamic library loader path
(
<code class="literal">
LD_LIBRARY_PATH
</code>
on Unix systems or
<code class="literal">
PATH
</code>
on Windows systems). Remove the path to the
compiled version of OpenSSL, and add the path to the replacement
version, placing it before any other OpenSSL libraries on the path.
At startup, when MySQL cannot find the version of OpenSSL specified
with
<a class="link" href="source-configuration-options.html#option_cmake_with_ssl">
<code class="option">
WITH_SSL
</code>
</a>
on the path, it uses the
first version specified on the path instead.
</p>
<p>
By default, MySQL programs attempt to connect using encryption if
the server supports encrypted connections, falling back to an
unencrypted connection if an encrypted connection cannot be
established. For information about options that affect use of
encrypted connections, see
<a class="xref" href="using-encrypted-connections.html" title="8.3.1 Configuring MySQL to Use Encrypted Connections">
Section 8.3.1, “Configuring MySQL to Use Encrypted Connections”
</a>
and
<a class="xref" href="connection-options.html#encrypted-connection-options" title="Command Options for Encrypted Connections">
Command Options for Encrypted Connections
</a>
.
</p>
<p>
MySQL performs encryption on a per-connection basis, and use of
encryption for a given user can be optional or mandatory. This
enables you to choose an encrypted or unencrypted connection
according to the requirements of individual applications. For
information on how to require users to use encrypted connections,
see the discussion of the
<code class="literal">
REQUIRE
</code>
clause of the
<a class="link" href="create-user.html" title="15.7.1.3 CREATE USER Statement">
<code class="literal">
CREATE USER
</code>
</a>
statement in
<a class="xref" href="create-user.html" title="15.7.1.3 CREATE USER Statement">
Section 15.7.1.3, “CREATE USER Statement”
</a>
. See also the description of the
<a class="link" href="server-system-variables.html#sysvar_require_secure_transport">
<code class="literal">
require_secure_transport
</code>
</a>
system
variable at
<a class="xref" href="server-system-variables.html" title="7.1.8 Server System Variables">
Section 7.1.8, “Server System Variables”
</a>
</p>
<p>
Encrypted connections can be used between source and replica
servers. See
<a class="xref" href="replication-encrypted-connections.html" title="19.3.1 Setting Up Replication to Use Encrypted Connections">
Section 19.3.1, “Setting Up Replication to Use Encrypted Connections”
</a>
.
</p>
<p>
For information about using encrypted connections from the MySQL C
API, see
<a class="ulink" href="/doc/c-api/8.4/en/c-api-encrypted-connections.html" target="_top">
Support for Encrypted Connections
</a>
.
</p>
<p>
It is also possible to connect using encryption from within an SSH
connection to the MySQL server host. For an example, see
<a class="xref" href="windows-and-ssh.html" title="8.3.4 Connecting to MySQL Remotely from Windows with SSH">
Section 8.3.4, “Connecting to MySQL Remotely from Windows with SSH”
</a>
.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/symbolic-links-to-databases.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="symbolic-links-to-databases">
</a>
10.12.2.1 Using Symbolic Links for Databases on Unix
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045222476128">
</a>
<a class="indexterm" name="idm46045222474640">
</a>
<p>
On Unix, symlink a database using this procedure:
</p>
<div class="orderedlist">
<ol class="orderedlist" type="1">
<li class="listitem">
<p>
Create the database using
<a class="link" href="create-database.html" title="15.1.12 CREATE DATABASE Statement">
<code class="literal">
CREATE
DATABASE
</code>
</a>
:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa57836518"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">CREATE</span> <span class="token keyword">DATABASE</span> mydb1<span class="token punctuation">;</span></code></pre>
</div>
<p>
Using
<a class="link" href="create-database.html" title="15.1.12 CREATE DATABASE Statement">
<code class="literal">
CREATE DATABASE
</code>
</a>
creates the database in the MySQL data directory and
permits the server to update the data dictionary with
information about the database directory.
</p>
</li>
<li class="listitem">
<p>
Stop the server to ensure that no activity occurs in the
new database while it is being moved.
</p>
</li>
<li class="listitem">
<p>
Move the database directory to some disk where you have
free space. For example, use
<span class="command">
<strong>
tar
</strong>
</span>
or
<span class="command">
<strong>
mv
</strong>
</span>
. If you use a method that copies
rather than moves the database directory, remove the
original database directory after copying it.
</p>
</li>
<li class="listitem">
<p>
Create a soft link in the data directory to the moved
database directory:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa51139218"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$> </span><span class="token command">ln</span> <span class="token property">-s</span> <em class="replaceable">/path/to/mydb1</em> <em class="replaceable">/path/to/datadir</em></code></pre>
</div>
<p>
The command creates a symlink named
<code class="filename">
mydb1
</code>
in the data directory.
</p>
</li>
<li class="listitem">
<p>
Restart the server.
</p>
</li>
</ol>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/keywords.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h2 class="title">
<a name="keywords">
</a>
11.3 Keywords and Reserved Words
</h2>
</div>
</div>
</div>
<a class="indexterm" name="idm46045219567040">
</a>
<a class="indexterm" name="idm46045219566000">
</a>
<p>
Keywords are words that have significance in SQL. Certain
keywords, such as
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
,
<a class="link" href="delete.html" title="15.2.2 DELETE Statement">
<code class="literal">
DELETE
</code>
</a>
, or
<a class="link" href="integer-types.html" title="13.1.2 Integer Types (Exact Value) - INTEGER, INT, SMALLINT, TINYINT, MEDIUMINT, BIGINT">
<code class="literal">
BIGINT
</code>
</a>
, are reserved and require
special treatment for use as identifiers such as table and column
names. This may also be true for the names of built-in functions.
</p>
<p>
Nonreserved keywords are permitted as identifiers without quoting.
Reserved words are permitted as identifiers if you quote them as
described in
<a class="xref" href="identifiers.html" title="11.2 Schema Object Names">
Section 11.2, “Schema Object Names”
</a>
:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa98612608"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> <span class="token keyword">interval</span> <span class="token punctuation">(</span><span class="token keyword">begin</span> <span class="token datatype">INT</span><span class="token punctuation">,</span> <span class="token keyword">end</span> <span class="token datatype">INT</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output">ERROR 1064 (42000)<span class="token punctuation">:</span> You have an error in your SQL syntax ...
near 'interval (begin INT, end INT)'</span></code></pre>
</div>
<p>
<code class="literal">
BEGIN
</code>
and
<code class="literal">
END
</code>
are keywords
but not reserved, so their use as identifiers does not require
quoting.
<code class="literal">
INTERVAL
</code>
is a reserved keyword and
must be quoted to be used as an identifier:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa32393341"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> <span class="token punctuation">`</span><span class="token keyword">interval</span><span class="token punctuation">`</span> <span class="token punctuation">(</span><span class="token keyword">begin</span> <span class="token datatype">INT</span><span class="token punctuation">,</span> <span class="token keyword">end</span> <span class="token datatype">INT</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected (0.01 sec)</span></code></pre>
</div>
<p>
Exception: A word that follows a period in a qualified name must
be an identifier, so it need not be quoted even if it is reserved:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa34244847"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> mydb<span class="token punctuation">.</span><span class="token keyword">interval</span> <span class="token punctuation">(</span><span class="token keyword">begin</span> <span class="token datatype">INT</span><span class="token punctuation">,</span> <span class="token keyword">end</span> <span class="token datatype">INT</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected (0.01 sec)</span></code></pre>
</div>
<p>
Names of built-in functions are permitted as identifiers but may
require care to be used as such. For example,
<code class="literal">
COUNT
</code>
is acceptable as a column name. However,
by default, no whitespace is permitted in function invocations
between the function name and the following
<code class="literal">
(
</code>
character. This requirement enables the parser to distinguish
whether the name is used in a function call or in nonfunction
context. For further details on recognition of function names, see
<a class="xref" href="function-resolution.html" title="11.2.5 Function Name Parsing and Resolution">
Section 11.2.5, “Function Name Parsing and Resolution”
</a>
.
</p>
<p>
The
<code class="literal">
INFORMATION_SCHEMA.KEYWORDS
</code>
table lists the
words considered keywords by MySQL and indicates whether they are
reserved. See
<a class="xref" href="information-schema-keywords-table.html" title="28.3.17 The INFORMATION_SCHEMA KEYWORDS Table">
Section 28.3.17, “The INFORMATION_SCHEMA KEYWORDS Table”
</a>
.
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="xref" href="keywords.html#keywords-in-current-series" title="MySQL 8.4 Keywords and Reserved Words">
MySQL 8.4 Keywords and Reserved Words
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="keywords.html#keywords-new-in-current-series" title="MySQL 8.4 New Keywords and Reserved Words">
MySQL 8.4 New Keywords and Reserved Words
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="keywords.html#keywords-removed-in-current-series" title="MySQL 8.4 Removed Keywords and Reserved Words">
MySQL 8.4 Removed Keywords and Reserved Words
</a>
</p>
</li>
</ul>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h3 class="title">
<a name="keywords-in-current-series">
</a>
MySQL 8.4 Keywords and Reserved Words
</h3>
</div>
</div>
</div>
<p>
The following list shows the keywords and reserved words in
MySQL 8.4, along with changes to individual words
from version to version. Reserved keywords are marked with (R).
In addition,
<code class="literal">
_FILENAME
</code>
is reserved.
</p>
<p>
At some point, you might upgrade to a higher version, so it is a
good idea to have a look at future reserved words, too. You can
find these in the manuals that cover higher versions of MySQL.
Most of the reserved words in the list are forbidden by standard
SQL as column or table names (for example,
<code class="literal">
GROUP
</code>
). A few are reserved because MySQL
needs them and uses a
<span class="command">
<strong>
yacc
</strong>
</span>
parser.
</p>
<p>
<a name="keywords-8-4-detailed-top">
</a>
<a class="link" href="keywords.html#keywords-8-4-detailed-A">
A
</a>
|
<a class="link" href="keywords.html#keywords-8-4-detailed-B">
B
</a>
|
<a class="link" href="keywords.html#keywords-8-4-detailed-C">
C
</a>
|
<a class="link" href="keywords.html#keywords-8-4-detailed-D">
D
</a>
|
<a class="link" href="keywords.html#keywords-8-4-detailed-E">
E
</a>
|
<a class="link" href="keywords.html#keywords-8-4-detailed-F">
F
</a>
|
<a class="link" href="keywords.html#keywords-8-4-detailed-G">
G
</a>
|
<a class="link" href="keywords.html#keywords-8-4-detailed-H">
H
</a>
|
<a class="link" href="keywords.html#keywords-8-4-detailed-I">
I
</a>
|
<a class="link" href="keywords.html#keywords-8-4-detailed-J">
J
</a>
|
<a class="link" href="keywords.html#keywords-8-4-detailed-K">
K
</a>
|
<a class="link" href="keywords.html#keywords-8-4-detailed-L">
L
</a>
|
<a class="link" href="keywords.html#keywords-8-4-detailed-M">
M
</a>
|
<a class="link" href="keywords.html#keywords-8-4-detailed-N">
N
</a>
|
<a class="link" href="keywords.html#keywords-8-4-detailed-O">
O
</a>
|
<a class="link" href="keywords.html#keywords-8-4-detailed-P">
P
</a>
|
<a class="link" href="keywords.html#keywords-8-4-detailed-Q">
Q
</a>
|
<a class="link" href="keywords.html#keywords-8-4-detailed-R">
R
</a>
|
<a class="link" href="keywords.html#keywords-8-4-detailed-S">
S
</a>
|
<a class="link" href="keywords.html#keywords-8-4-detailed-T">
T
</a>
|
<a class="link" href="keywords.html#keywords-8-4-detailed-U">
U
</a>
|
<a class="link" href="keywords.html#keywords-8-4-detailed-V">
V
</a>
|
<a class="link" href="keywords.html#keywords-8-4-detailed-W">
W
</a>
|
<a class="link" href="keywords.html#keywords-8-4-detailed-X">
X
</a>
|
<a class="link" href="keywords.html#keywords-8-4-detailed-Y">
Y
</a>
|
<a class="link" href="keywords.html#keywords-8-4-detailed-Z">
Z
</a>
</p>
<p>
<a name="keywords-8-4-detailed-A">
</a>
A
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
ACCESSIBLE
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ACCOUNT
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ACTION
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ACTIVE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ADD
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ADMIN
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
AFTER
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
AGAINST
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
AGGREGATE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ALGORITHM
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ALL
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ALTER
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ALWAYS
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ANALYZE
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
AND
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ANY
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ARRAY
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
AS
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ASC
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ASCII
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ASENSITIVE
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
AT
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ATTRIBUTE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
AUTHENTICATION
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
AUTO
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
AUTOEXTEND_SIZE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
AUTO_INCREMENT
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
AVG
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
AVG_ROW_LENGTH
</code>
</p>
</li>
</ul>
</div>
<p>
<a name="keywords-8-4-detailed-B">
</a>
B
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
BACKUP
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
BEFORE
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
BEGIN
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
BERNOULLI
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
BETWEEN
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
BIGINT
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
BINARY
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
BINLOG
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
BIT
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
BLOB
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
BLOCK
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
BOOL
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
BOOLEAN
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
BOTH
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
BTREE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
BUCKETS
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
BULK
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
BY
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
BYTE
</code>
</p>
</li>
</ul>
</div>
<p>
<a name="keywords-8-4-detailed-C">
</a>
C
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
CACHE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
CALL
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
CASCADE
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
CASCADED
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
CASE
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
CATALOG_NAME
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
CHAIN
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
CHALLENGE_RESPONSE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
CHANGE
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
CHANGED
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
CHANNEL
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
CHAR
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
CHARACTER
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
CHARSET
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
CHECK
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
CHECKSUM
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
CIPHER
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
CLASS_ORIGIN
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
CLIENT
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
CLONE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
CLOSE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
COALESCE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
CODE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
COLLATE
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
COLLATION
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
COLUMN
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
COLUMNS
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
COLUMN_FORMAT
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
COLUMN_NAME
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
COMMENT
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
COMMIT
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
COMMITTED
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
COMPACT
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
COMPLETION
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
COMPONENT
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
COMPRESSED
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
COMPRESSION
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
CONCURRENT
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
CONDITION
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
CONNECTION
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
CONSISTENT
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
CONSTRAINT
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
CONSTRAINT_CATALOG
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
CONSTRAINT_NAME
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
CONSTRAINT_SCHEMA
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
CONTAINS
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
CONTEXT
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
CONTINUE
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
CONVERT
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
CPU
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
CREATE
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
CROSS
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
CUBE
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
CUME_DIST
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
CURRENT
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
CURRENT_DATE
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
CURRENT_TIME
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
CURRENT_TIMESTAMP
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
CURRENT_USER
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
CURSOR
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
CURSOR_NAME
</code>
</p>
</li>
</ul>
</div>
<p>
<a name="keywords-8-4-detailed-D">
</a>
D
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
DATA
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
DATABASE
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
DATABASES
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
DATAFILE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
DATE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
DATETIME
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
DAY
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
DAY_HOUR
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
DAY_MICROSECOND
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
DAY_MINUTE
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
DAY_SECOND
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
DEALLOCATE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
DEC
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
DECIMAL
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
DECLARE
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
DEFAULT
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
DEFAULT_AUTH
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
DEFINER
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
DEFINITION
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
DELAYED
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
DELAY_KEY_WRITE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
DELETE
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
DENSE_RANK
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
DESC
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
DESCRIBE
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
DESCRIPTION
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
DETERMINISTIC
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
DIAGNOSTICS
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
DIRECTORY
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
DISABLE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
DISCARD
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
DISK
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
DISTINCT
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
DISTINCTROW
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
DIV
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
DO
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
DOUBLE
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
DROP
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
DUAL
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
DUMPFILE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
DUPLICATE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
DYNAMIC
</code>
</p>
</li>
</ul>
</div>
<p>
<a name="keywords-8-4-detailed-E">
</a>
E
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
EACH
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ELSE
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ELSEIF
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
EMPTY
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ENABLE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ENCLOSED
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ENCRYPTION
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
END
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ENDS
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ENFORCED
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ENGINE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ENGINES
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ENGINE_ATTRIBUTE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ENUM
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ERROR
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ERRORS
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ESCAPE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ESCAPED
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
EVENT
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
EVENTS
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
EVERY
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
EXCEPT
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
EXCHANGE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
EXCLUDE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
EXECUTE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
EXISTS
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
EXIT
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
EXPANSION
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
EXPIRE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
EXPLAIN
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
EXPORT
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
EXTENDED
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
EXTENT_SIZE
</code>
</p>
</li>
</ul>
</div>
<p>
<a name="keywords-8-4-detailed-F">
</a>
F
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
FACTOR
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
FAILED_LOGIN_ATTEMPTS
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
FALSE
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
FAST
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
FAULTS
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
FETCH
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
FIELDS
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
FILE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
FILE_BLOCK_SIZE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
FILTER
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
FINISH
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
FIRST
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
FIRST_VALUE
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
FIXED
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
FLOAT
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
FLOAT4
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
FLOAT8
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
FLUSH
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
FOLLOWING
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
FOLLOWS
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
FOR
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
FORCE
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
FOREIGN
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
FORMAT
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
FOUND
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
FROM
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
FULL
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
FULLTEXT
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
FUNCTION
</code>
(R)
</p>
</li>
</ul>
</div>
<p>
<a name="keywords-8-4-detailed-G">
</a>
G
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
GENERAL
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
GENERATE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
GENERATED
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
GEOMCOLLECTION
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
GEOMETRY
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
GEOMETRYCOLLECTION
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
GET
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
GET_FORMAT
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
GET_SOURCE_PUBLIC_KEY
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
GLOBAL
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
GRANT
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
GRANTS
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
GROUP
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
GROUPING
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
GROUPS
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
GROUP_REPLICATION
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
GTIDS
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
GTID_ONLY
</code>
</p>
</li>
</ul>
</div>
<p>
<a name="keywords-8-4-detailed-H">
</a>
H
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
HANDLER
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
HASH
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
HAVING
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
HELP
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
HIGH_PRIORITY
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
HISTOGRAM
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
HISTORY
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
HOST
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
HOSTS
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
HOUR
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
HOUR_MICROSECOND
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
HOUR_MINUTE
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
HOUR_SECOND
</code>
(R)
</p>
</li>
</ul>
</div>
<p>
<a name="keywords-8-4-detailed-I">
</a>
I
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
IDENTIFIED
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
IF
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
IGNORE
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
IGNORE_SERVER_IDS
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
IMPORT
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
IN
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
INACTIVE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
INDEX
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
INDEXES
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
INFILE
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
INITIAL
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
INITIAL_SIZE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
INITIATE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
INNER
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
INOUT
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
INSENSITIVE
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
INSERT
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
INSERT_METHOD
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
INSTALL
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
INSTANCE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
INT
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
INT1
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
INT2
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
INT3
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
INT4
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
INT8
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
INTEGER
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
INTERSECT
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
INTERVAL
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
INTO
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
INVISIBLE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
INVOKER
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
IO
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
IO_AFTER_GTIDS
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
IO_BEFORE_GTIDS
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
IO_THREAD
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
IPC
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
IS
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ISOLATION
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ISSUER
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ITERATE
</code>
(R)
</p>
</li>
</ul>
</div>
<p>
<a name="keywords-8-4-detailed-J">
</a>
J
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
JOIN
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
JSON
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
JSON_TABLE
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
JSON_VALUE
</code>
</p>
</li>
</ul>
</div>
<p>
<a name="keywords-8-4-detailed-K">
</a>
K
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
KEY
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
KEYRING
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
KEYS
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
KEY_BLOCK_SIZE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
KILL
</code>
(R)
</p>
</li>
</ul>
</div>
<p>
<a name="keywords-8-4-detailed-L">
</a>
L
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
LAG
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
LANGUAGE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
LAST
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
LAST_VALUE
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
LATERAL
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
LEAD
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
LEADING
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
LEAVE
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
LEAVES
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
LEFT
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
LESS
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
LEVEL
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
LIKE
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
LIMIT
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
LINEAR
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
LINES
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
LINESTRING
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
LIST
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
LOAD
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
LOCAL
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
LOCALTIME
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
LOCALTIMESTAMP
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
LOCK
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
LOCKED
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
LOCKS
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
LOG
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
LOGFILE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
LOGS
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
LONG
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
LONGBLOB
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
LONGTEXT
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
LOOP
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
LOW_PRIORITY
</code>
(R)
</p>
</li>
</ul>
</div>
<p>
<a name="keywords-8-4-detailed-M">
</a>
M
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
MANUAL
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MASTER
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MATCH
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MAXVALUE
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MAX_CONNECTIONS_PER_HOUR
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MAX_QUERIES_PER_HOUR
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MAX_ROWS
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MAX_SIZE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MAX_UPDATES_PER_HOUR
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MAX_USER_CONNECTIONS
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MEDIUM
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MEDIUMBLOB
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MEDIUMINT
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MEDIUMTEXT
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MEMBER
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MEMORY
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MERGE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MESSAGE_TEXT
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MICROSECOND
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MIDDLEINT
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MIGRATE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MINUTE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MINUTE_MICROSECOND
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MINUTE_SECOND
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MIN_ROWS
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MOD
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MODE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MODIFIES
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MODIFY
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MONTH
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MULTILINESTRING
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MULTIPOINT
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MULTIPOLYGON
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MUTEX
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MYSQL_ERRNO
</code>
</p>
</li>
</ul>
</div>
<p>
<a name="keywords-8-4-detailed-N">
</a>
N
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
NAME
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
NAMES
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
NATIONAL
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
NATURAL
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
NCHAR
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
NDB
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
NDBCLUSTER
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
NESTED
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
NETWORK_NAMESPACE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
NEVER
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
NEW
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
NEXT
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
NO
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
NODEGROUP
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
NONE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
NOT
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
NOWAIT
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
NO_WAIT
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
NO_WRITE_TO_BINLOG
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
NTH_VALUE
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
NTILE
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
NULL
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
NULLS
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
NUMBER
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
NUMERIC
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
NVARCHAR
</code>
</p>
</li>
</ul>
</div>
<p>
<a name="keywords-8-4-detailed-O">
</a>
O
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
OF
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
OFF
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
OFFSET
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
OJ
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
OLD
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ON
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ONE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ONLY
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
OPEN
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
OPTIMIZE
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
OPTIMIZER_COSTS
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
OPTION
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
OPTIONAL
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
OPTIONALLY
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
OPTIONS
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
OR
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ORDER
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ORDINALITY
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ORGANIZATION
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
OTHERS
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
OUT
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
OUTER
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
OUTFILE
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
OVER
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
OWNER
</code>
</p>
</li>
</ul>
</div>
<p>
<a name="keywords-8-4-detailed-P">
</a>
P
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
PACK_KEYS
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
PAGE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
PARALLEL
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
PARSER
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
PARSE_TREE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
PARTIAL
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
PARTITION
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
PARTITIONING
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
PARTITIONS
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
PASSWORD
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
PASSWORD_LOCK_TIME
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
PATH
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
PERCENT_RANK
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
PERSIST
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
PERSIST_ONLY
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
PHASE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
PLUGIN
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
PLUGINS
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
PLUGIN_DIR
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
POINT
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
POLYGON
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
PORT
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
PRECEDES
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
PRECEDING
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
PRECISION
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
PREPARE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
PRESERVE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
PREV
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
PRIMARY
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
PRIVILEGES
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
PRIVILEGE_CHECKS_USER
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
PROCEDURE
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
PROCESS
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
PROCESSLIST
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
PROFILE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
PROFILES
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
PROXY
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
PURGE
</code>
(R)
</p>
</li>
</ul>
</div>
<p>
<a name="keywords-8-4-detailed-Q">
</a>
Q
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
QUALIFY
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
QUARTER
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
QUERY
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
QUICK
</code>
</p>
</li>
</ul>
</div>
<p>
<a name="keywords-8-4-detailed-R">
</a>
R
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
RANDOM
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
RANGE
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
RANK
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
READ
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
READS
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
READ_ONLY
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
READ_WRITE
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
REAL
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
REBUILD
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
RECOVER
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
RECURSIVE
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
REDO_BUFFER_SIZE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
REDUNDANT
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
REFERENCE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
REFERENCES
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
REGEXP
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
REGISTRATION
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
RELAY
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
RELAYLOG
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
RELAY_LOG_FILE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
RELAY_LOG_POS
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
RELAY_THREAD
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
RELEASE
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
RELOAD
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
REMOVE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
RENAME
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
REORGANIZE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
REPAIR
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
REPEAT
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
REPEATABLE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
REPLACE
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
REPLICA
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
REPLICAS
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
REPLICATE_DO_DB
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
REPLICATE_DO_TABLE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
REPLICATE_IGNORE_DB
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
REPLICATE_IGNORE_TABLE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
REPLICATE_REWRITE_DB
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
REPLICATE_WILD_DO_TABLE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
REPLICATE_WILD_IGNORE_TABLE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
REPLICATION
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
REQUIRE
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
REQUIRE_ROW_FORMAT
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
RESET
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
RESIGNAL
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
RESOURCE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
RESPECT
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
RESTART
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
RESTORE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
RESTRICT
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
RESUME
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
RETAIN
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
RETURN
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
RETURNED_SQLSTATE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
RETURNING
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
RETURNS
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
REUSE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
REVERSE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
REVOKE
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
RIGHT
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
RLIKE
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ROLE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ROLLBACK
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ROLLUP
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ROTATE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ROUTINE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ROW
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ROWS
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ROW_COUNT
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ROW_FORMAT
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ROW_NUMBER
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
RTREE
</code>
</p>
</li>
</ul>
</div>
<p>
<a name="keywords-8-4-detailed-S">
</a>
S
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
S3
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SAVEPOINT
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SCHEDULE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SCHEMA
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SCHEMAS
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SCHEMA_NAME
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SECOND
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SECONDARY
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SECONDARY_ENGINE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SECONDARY_ENGINE_ATTRIBUTE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SECONDARY_LOAD
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SECONDARY_UNLOAD
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SECOND_MICROSECOND
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SECURITY
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SELECT
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SENSITIVE
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SEPARATOR
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SERIAL
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SERIALIZABLE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SERVER
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SESSION
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SET
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SHARE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SHOW
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SHUTDOWN
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SIGNAL
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SIGNED
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SIMPLE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SKIP
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SLAVE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SLOW
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SMALLINT
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SNAPSHOT
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SOCKET
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SOME
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SONAME
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SOUNDS
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SOURCE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SOURCE_AUTO_POSITION
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SOURCE_BIND
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SOURCE_COMPRESSION_ALGORITHMS
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SOURCE_CONNECT_RETRY
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SOURCE_DELAY
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SOURCE_HEARTBEAT_PERIOD
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SOURCE_HOST
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SOURCE_LOG_FILE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SOURCE_LOG_POS
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SOURCE_PASSWORD
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SOURCE_PORT
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SOURCE_PUBLIC_KEY_PATH
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SOURCE_RETRY_COUNT
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SOURCE_SSL
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SOURCE_SSL_CA
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SOURCE_SSL_CAPATH
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SOURCE_SSL_CERT
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SOURCE_SSL_CIPHER
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SOURCE_SSL_CRL
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SOURCE_SSL_CRLPATH
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SOURCE_SSL_KEY
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SOURCE_SSL_VERIFY_SERVER_CERT
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SOURCE_TLS_CIPHERSUITES
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SOURCE_TLS_VERSION
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SOURCE_USER
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SOURCE_ZSTD_COMPRESSION_LEVEL
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SPATIAL
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SPECIFIC
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SQL
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SQLEXCEPTION
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SQLSTATE
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SQLWARNING
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SQL_AFTER_GTIDS
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SQL_AFTER_MTS_GAPS
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SQL_BEFORE_GTIDS
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SQL_BIG_RESULT
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SQL_BUFFER_RESULT
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SQL_CALC_FOUND_ROWS
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SQL_NO_CACHE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SQL_SMALL_RESULT
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SQL_THREAD
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SQL_TSI_DAY
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SQL_TSI_HOUR
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SQL_TSI_MINUTE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SQL_TSI_MONTH
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SQL_TSI_QUARTER
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SQL_TSI_SECOND
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SQL_TSI_WEEK
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SQL_TSI_YEAR
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SRID
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SSL
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
STACKED
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
START
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
STARTING
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
STARTS
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
STATS_AUTO_RECALC
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
STATS_PERSISTENT
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
STATS_SAMPLE_PAGES
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
STATUS
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
STOP
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
STORAGE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
STORED
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
STRAIGHT_JOIN
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
STREAM
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
STRING
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SUBCLASS_ORIGIN
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SUBJECT
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SUBPARTITION
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SUBPARTITIONS
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SUPER
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SUSPEND
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SWAPS
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SWITCHES
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SYSTEM
</code>
(R)
</p>
</li>
</ul>
</div>
<p>
<a name="keywords-8-4-detailed-T">
</a>
T
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
TABLE
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
TABLES
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
TABLESAMPLE
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
TABLESPACE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
TABLE_CHECKSUM
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
TABLE_NAME
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
TEMPORARY
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
TEMPTABLE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
TERMINATED
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
TEXT
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
THAN
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
THEN
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
THREAD_PRIORITY
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
TIES
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
TIME
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
TIMESTAMP
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
TIMESTAMPADD
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
TIMESTAMPDIFF
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
TINYBLOB
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
TINYINT
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
TINYTEXT
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
TLS
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
TO
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
TRAILING
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
TRANSACTION
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
TRIGGER
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
TRIGGERS
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
TRUE
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
TRUNCATE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
TYPE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
TYPES
</code>
</p>
</li>
</ul>
</div>
<p>
<a name="keywords-8-4-detailed-U">
</a>
U
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
UNBOUNDED
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
UNCOMMITTED
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
UNDEFINED
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
UNDO
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
UNDOFILE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
UNDO_BUFFER_SIZE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
UNICODE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
UNINSTALL
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
UNION
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
UNIQUE
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
UNKNOWN
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
UNLOCK
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
UNREGISTER
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
UNSIGNED
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
UNTIL
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
UPDATE
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
UPGRADE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
URL
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
USAGE
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
USE
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
USER
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
USER_RESOURCES
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
USE_FRM
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
USING
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
UTC_DATE
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
UTC_TIME
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
UTC_TIMESTAMP
</code>
(R)
</p>
</li>
</ul>
</div>
<p>
<a name="keywords-8-4-detailed-V">
</a>
V
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
VALIDATION
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
VALUE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
VALUES
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
VARBINARY
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
VARCHAR
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
VARCHARACTER
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
VARIABLES
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
VARYING
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
VCPU
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
VIEW
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
VIRTUAL
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
VISIBLE
</code>
</p>
</li>
</ul>
</div>
<p>
<a name="keywords-8-4-detailed-W">
</a>
W
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
WAIT
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
WARNINGS
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
WEEK
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
WEIGHT_STRING
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
WHEN
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
WHERE
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
WHILE
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
WINDOW
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
WITH
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
WITHOUT
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
WORK
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
WRAPPER
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
WRITE
</code>
(R)
</p>
</li>
</ul>
</div>
<p>
<a name="keywords-8-4-detailed-X">
</a>
X
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
X509
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
XA
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
XID
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
XML
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
XOR
</code>
(R)
</p>
</li>
</ul>
</div>
<p>
<a name="keywords-8-4-detailed-Y">
</a>
Y
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
YEAR
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
YEAR_MONTH
</code>
(R)
</p>
</li>
</ul>
</div>
<p>
<a name="keywords-8-4-detailed-Z">
</a>
Z
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
ZEROFILL
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ZONE
</code>
</p>
</li>
</ul>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h3 class="title">
<a name="keywords-new-in-current-series">
</a>
MySQL 8.4 New Keywords and Reserved Words
</h3>
</div>
</div>
</div>
<p>
The following list shows the keywords and reserved words that
are added in MySQL 8.4, compared to MySQL 8.0.
Reserved keywords are marked with (R).
</p>
<p>
<a name="keywords-new-8-4-top">
</a>
<a class="link" href="keywords.html#keywords-new-8-4-A">
A
</a>
|
<a class="link" href="keywords.html#keywords-new-8-4-B">
B
</a>
|
<a class="link" href="keywords.html#keywords-new-8-4-G">
G
</a>
|
<a class="link" href="keywords.html#keywords-new-8-4-L">
L
</a>
|
<a class="link" href="keywords.html#keywords-new-8-4-M">
M
</a>
|
<a class="link" href="keywords.html#keywords-new-8-4-P">
P
</a>
|
<a class="link" href="keywords.html#keywords-new-8-4-Q">
Q
</a>
|
<a class="link" href="keywords.html#keywords-new-8-4-S">
S
</a>
|
<a class="link" href="keywords.html#keywords-new-8-4-T">
T
</a>
</p>
<p>
<a name="keywords-new-8-4-A">
</a>
A
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
AUTO
</code>
</p>
</li>
</ul>
</div>
<p>
<a name="keywords-new-8-4-B">
</a>
B
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
BERNOULLI
</code>
</p>
</li>
</ul>
</div>
<p>
<a name="keywords-new-8-4-G">
</a>
G
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
GTIDS
</code>
</p>
</li>
</ul>
</div>
<p>
<a name="keywords-new-8-4-L">
</a>
L
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
LOG
</code>
</p>
</li>
</ul>
</div>
<p>
<a name="keywords-new-8-4-M">
</a>
M
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
MANUAL
</code>
(R)
</p>
</li>
</ul>
</div>
<p>
<a name="keywords-new-8-4-P">
</a>
P
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
PARALLEL
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
PARSE_TREE
</code>
</p>
</li>
</ul>
</div>
<p>
<a name="keywords-new-8-4-Q">
</a>
Q
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
QUALIFY
</code>
(R)
</p>
</li>
</ul>
</div>
<p>
<a name="keywords-new-8-4-S">
</a>
S
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
S3
</code>
</p>
</li>
</ul>
</div>
<p>
<a name="keywords-new-8-4-T">
</a>
T
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
TABLESAMPLE
</code>
(R)
</p>
</li>
</ul>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h3 class="title">
<a name="keywords-removed-in-current-series">
</a>
MySQL 8.4 Removed Keywords and Reserved Words
</h3>
</div>
</div>
</div>
<p>
The following list shows the keywords and reserved words that
are removed in MySQL 8.4, compared to MySQL 8.0.
Reserved keywords are marked with (R).
</p>
<p>
<a name="keywords-removed-8-4-top">
</a>
<a class="link" href="keywords.html#keywords-removed-8-4-G">
G
</a>
|
<a class="link" href="keywords.html#keywords-removed-8-4-M">
M
</a>
</p>
<p>
<a name="keywords-removed-8-4-G">
</a>
G
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
GET_MASTER_PUBLIC_KEY
</code>
</p>
</li>
</ul>
</div>
<p>
<a name="keywords-removed-8-4-M">
</a>
M
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
MASTER_AUTO_POSITION
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MASTER_BIND
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MASTER_COMPRESSION_ALGORITHMS
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MASTER_CONNECT_RETRY
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MASTER_DELAY
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MASTER_HEARTBEAT_PERIOD
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MASTER_HOST
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MASTER_LOG_FILE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MASTER_LOG_POS
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MASTER_PASSWORD
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MASTER_PORT
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MASTER_PUBLIC_KEY_PATH
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MASTER_RETRY_COUNT
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MASTER_SSL
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MASTER_SSL_CA
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MASTER_SSL_CAPATH
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MASTER_SSL_CERT
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MASTER_SSL_CIPHER
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MASTER_SSL_CRL
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MASTER_SSL_CRLPATH
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MASTER_SSL_KEY
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MASTER_SSL_VERIFY_SERVER_CERT
</code>
(R)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MASTER_TLS_CIPHERSUITES
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MASTER_TLS_VERSION
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MASTER_USER
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MASTER_ZSTD_COMPRESSION_LEVEL
</code>
</p>
</li>
</ul>
</div>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/webauthn-pluggable-authentication.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="webauthn-pluggable-authentication">
</a>
8.4.1.11 WebAuthn Pluggable Authentication
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045244070640">
</a>
<a class="indexterm" name="idm46045244069536">
</a>
<a class="indexterm" name="idm46045244068048">
</a>
<a class="indexterm" name="idm46045244066944">
</a>
<a class="indexterm" name="idm46045244065440">
</a>
<a class="indexterm" name="idm46045244063952">
</a>
<a class="indexterm" name="idm46045244062464">
</a>
<a class="indexterm" name="idm46045244061376">
</a>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
WebAuthn authentication is an extension included in MySQL Enterprise Edition, a
commercial product. To learn more about commercial products,
see
<a class="ulink" href="https://www.mysql.com/products/" target="_blank">
https://www.mysql.com/products/
</a>
.
</p>
</div>
<p>
MySQL Enterprise Edition supports an authentication method that enables users to
authenticate to MySQL Server using WebAuthn authentication.
</p>
<p>
WebAuthn stands for Web Authentication, which is a web standard
published by the World Wide Web Consortium (W3C) and web
application APIs that add FIDO-based authentication to supported
browsers and platforms.
</p>
<p>
WebAuthn pluggable authentication replaces FIDO pluggable
authentication, which is deprecated. WebAuthn pluggable
authentication supports both FIDO and FIDO2 devices.
</p>
<p>
WebAuthn pluggable authentication provides these capabilities:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
WebAuthn enables authentication to MySQL Server using
devices such as smart cards, security keys, and biometric
readers.
</p>
</li>
<li class="listitem">
<p>
Because authentication can occur other than by providing a
password, WebAuthn enables passwordless authentication.
</p>
</li>
<li class="listitem">
<p>
On the other hand, device authentication is often used in
conjunction with password authentication, so WebAuthn
authentication can be used to good effect for MySQL accounts
that use multifactor authentication; see
<a class="xref" href="multifactor-authentication.html" title="8.2.18 Multifactor Authentication">
Section 8.2.18, “Multifactor Authentication”
</a>
.
</p>
</li>
</ul>
</div>
<p>
The following table shows the plugin and library file names. The
file name suffix might differ on your system. Common suffixes
are
<code class="filename">
.so
</code>
for Unix and Unix-like systems, and
<code class="filename">
.dll
</code>
for Windows. The file must be located
in the directory named by the
<a class="link" href="server-system-variables.html#sysvar_plugin_dir">
<code class="literal">
plugin_dir
</code>
</a>
system variable. For
installation information, see
<a class="xref" href="webauthn-pluggable-authentication.html#webauthn-pluggable-authentication-installation" title="Installing WebAuthn Pluggable Authentication">
Installing WebAuthn Pluggable Authentication
</a>
.
</p>
<div class="table">
<a name="idm46045244047568">
</a>
<p class="title">
<b>
Table 8.26 Plugin and Library Names for WebAuthn Authentication
</b>
</p>
<div class="table-contents">
<table summary="Names for the plugins and library file used for WebAuthn authentication.">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<thead>
<tr>
<th>
Plugin or File
</th>
<th>
Plugin or File Name
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
Server-side plugin
</td>
<td>
<code class="literal">
authentication_webauthn
</code>
</td>
</tr>
<tr>
<td>
Client-side plugin
</td>
<td>
<code class="literal">
authentication_webauthn_client
</code>
</td>
</tr>
<tr>
<td>
Library file
</td>
<td>
<code class="filename">
authentication_webauthn.so
</code>
,
<code class="filename">
authentication_webauthn_client.so
</code>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<br class="table-break"/>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
A
<code class="literal">
libfido2
</code>
library must be available on
systems where either the server-side or client-side WebAuthn
authentication plugin is used.
</p>
</div>
<p>
The server-side WebAuthn authentication plugin is included only
in MySQL Enterprise Edition. It is not included in MySQL community distributions.
The client-side plugin is included in all distributions,
including community distributions, which enables clients from
any distribution to connect to a server that has the server-side
plugin loaded.
</p>
<p>
The following sections provide installation and usage
information specific to WebAuthn pluggable authentication:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="xref" href="webauthn-pluggable-authentication.html#webauthn-pluggable-authentication-installation" title="Installing WebAuthn Pluggable Authentication">
Installing WebAuthn Pluggable Authentication
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="webauthn-pluggable-authentication.html#webauthn-pluggable-authentication-usage" title="Using WebAuthn Authentication">
Using WebAuthn Authentication
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="webauthn-pluggable-authentication.html#webauthn-pluggable-authentication-passwordless" title="WebAuthn Passwordless Authentication">
WebAuthn Passwordless Authentication
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="webauthn-pluggable-authentication.html#webauthn-pluggable-authentication-unregistration" title="Device Unregistration for WebAuthn">
Device Unregistration for WebAuthn
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="webauthn-pluggable-authentication.html#webauthn-pluggable-authentication-process" title="How WebAuthn Authentication of MySQL Users Works">
How WebAuthn Authentication of MySQL Users Works
</a>
</p>
</li>
</ul>
</div>
<p>
For general information about pluggable authentication in MySQL,
see
<a class="xref" href="pluggable-authentication.html" title="8.2.17 Pluggable Authentication">
Section 8.2.17, “Pluggable Authentication”
</a>
.
</p>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="webauthn-pluggable-authentication-installation">
</a>
Installing WebAuthn Pluggable Authentication
</h5>
</div>
</div>
</div>
<p>
This section describes how to install the server-side WebAuthn
authentication plugin. For general information about
installing plugins, see
<a class="xref" href="plugin-loading.html" title="7.6.1 Installing and Uninstalling Plugins">
Section 7.6.1, “Installing and Uninstalling Plugins”
</a>
.
</p>
<p>
To be usable by the server, the plugin library file must be
located in the MySQL plugin directory (the directory named by
the
<a class="link" href="server-system-variables.html#sysvar_plugin_dir">
<code class="literal">
plugin_dir
</code>
</a>
system
variable). If necessary, configure the plugin directory
location by setting the value of
<a class="link" href="server-system-variables.html#sysvar_plugin_dir">
<code class="literal">
plugin_dir
</code>
</a>
at server startup.
</p>
<p>
The server-side plugin library file base name is
<code class="literal">
authentication_webauthn
</code>
. The file name
suffix differs per platform (for example,
<code class="filename">
.so
</code>
for Unix and Unix-like systems,
<code class="filename">
.dll
</code>
for Windows).
</p>
<p>
Before installing the server-side plugin, define a unique name
for the relying party ID (used for device registration and
authentication), which is the MySQL server. Start the server
using the
<code class="literal">
--loose-authentication-webauthn-rp-id=
<em class="replaceable">
<code>
value
</code>
</em>
</code>
option. The example here specifies the value
<code class="literal">
mysql.com
</code>
as the relying party ID. Replace
this value with one that satisfies your requirements.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa97699547"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$> </span><span class="token command">mysqld</span> <span class="token punctuation">[</span><em class="replaceable">options</em><span class="token punctuation">]</span> <span class="token constant">--loose-authentication-webauthn-rp-id</span><span class="token attr-value"><span class="token punctuation">=</span>mysql.com</span></code></pre>
</div>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
For replication, use the same
<a class="link" href="pluggable-authentication-system-variables.html#sysvar_authentication_webauthn_rp_id">
<code class="literal">
authentication_webauthn_rp_id
</code>
</a>
value on all nodes if a user is expected to connect to
multiple servers.
</p>
</div>
<p>
To define the relying party and load the plugin at server
startup, use the
<a class="link" href="server-options.html#option_mysqld_plugin-load-add">
<code class="option">
--plugin-load-add
</code>
</a>
option to
name the library file that contains it, adjusting the .so
suffix for your platform as necessary. With this
plugin-loading method, the option must be given each time the
server starts.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa44507495"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$> </span><span class="token command">mysqld</span> <span class="token punctuation">[</span><em class="replaceable">options</em><span class="token punctuation">]</span>
<span class="token constant">--loose-authentication-webauthn-rp-id</span><span class="token attr-value"><span class="token punctuation">=</span>mysql.com</span>
<span class="token constant">--plugin-load-add</span><span class="token attr-value"><span class="token punctuation">=</span>authentication_webauthn.so</span></code></pre>
</div>
<p>
To define the relying party and load the plugin, put lines
such as this in your
<code class="filename">
my.cnf
</code>
file,
adjusting the
<code class="filename">
.so
</code>
suffix for your
platform as necessary:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-ini"><div class="docs-select-all right" id="sa45661962"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-ini"><span class="token selector">[mysqld]</span>
<span class="token constant">plugin-load-add</span><span class="token attr-value"><span class="token punctuation">=</span>authentication_webauthn.so</span>
<span class="token constant">authentication_webauthn_rp_id</span><span class="token attr-value"><span class="token punctuation">=</span>mysql.com</span></code></pre>
</div>
<p>
After modifying
<code class="filename">
my.cnf
</code>
, restart the
server to cause the new setting to take effect.
</p>
<p>
Alternatively, to load the plugin at runtime, use this
statement, adjusting the
<code class="filename">
.so
</code>
suffix for
your platform as necessary:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa89807855"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">INSTALL</span> <span class="token keyword">PLUGIN</span> authentication_webauthn
<span class="token keyword">SONAME</span> <span class="token string">'authentication_webauthn.so'</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
<a class="link" href="install-plugin.html" title="15.7.4.4 INSTALL PLUGIN Statement">
<code class="literal">
INSTALL PLUGIN
</code>
</a>
loads the plugin
immediately, and also registers it in the
<code class="literal">
mysql.plugins
</code>
system table to cause the
server to load it for each subsequent normal startup without
the need for
<a class="link" href="server-options.html#option_mysqld_plugin-load-add">
<code class="option">
--plugin-load-add
</code>
</a>
.
</p>
<p>
To verify plugin installation, examine the Information Schema
<a class="link" href="information-schema-plugins-table.html" title="28.3.22 The INFORMATION_SCHEMA PLUGINS Table">
<code class="literal">
PLUGINS
</code>
</a>
table or use the
<a class="link" href="show-plugins.html" title="15.7.7.27 SHOW PLUGINS Statement">
<code class="literal">
SHOW PLUGINS
</code>
</a>
statement (see
<a class="xref" href="obtaining-plugin-information.html" title="7.6.2 Obtaining Server Plugin Information">
Section 7.6.2, “Obtaining Server Plugin Information”
</a>
). For example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa98903244"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> PLUGIN_NAME<span class="token punctuation">,</span> PLUGIN_STATUS
<span class="token keyword">FROM</span> INFORMATION_SCHEMA<span class="token punctuation">.</span><span class="token keyword">PLUGINS</span>
<span class="token keyword">WHERE</span> PLUGIN_NAME <span class="token operator">=</span> <span class="token string">'authentication_webauthn'</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> PLUGIN_NAME <span class="token punctuation">|</span> PLUGIN_STATUS <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> authentication_webauthn <span class="token punctuation">|</span> ACTIVE <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
<p>
If a plugin fails to initialize, check the server error log
for diagnostic messages.
</p>
<p>
To associate MySQL accounts with the WebAuthn authentication
plugin, see
<a class="xref" href="webauthn-pluggable-authentication.html#webauthn-pluggable-authentication-usage" title="Using WebAuthn Authentication">
Using WebAuthn Authentication
</a>
.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="webauthn-pluggable-authentication-usage">
</a>
Using WebAuthn Authentication
</h5>
</div>
</div>
</div>
<p>
WebAuthn authentication typically is used in the context of
multifactor authentication (see
<a class="xref" href="multifactor-authentication.html" title="8.2.18 Multifactor Authentication">
Section 8.2.18, “Multifactor Authentication”
</a>
). This section
shows how to incorporate WebAuthn device-based authentication
into a multifactor account, using the
<code class="literal">
authentication_webauthn
</code>
plugin.
</p>
<p>
It is assumed in the following discussion that the server is
running with the server-side WebAuthn authentication plugin
enabled, as described in
<a class="xref" href="webauthn-pluggable-authentication.html#webauthn-pluggable-authentication-installation" title="Installing WebAuthn Pluggable Authentication">
Installing WebAuthn Pluggable Authentication
</a>
,
and that the client-side WebAuthn plugin is available in the
plugin directory on the client host.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
On Windows, WebAuthn authentication only functions if the
client process runs as a user with administrator privileges.
It might also be necessary to add the location of your
FIDO/FIDO2 device to the client host'
<code class="literal">
PATH
</code>
environment variable.
</p>
</div>
<p>
It is also assumed that WebAuthn authentication is used in
conjunction with non-WebAuthn authentication (which implies a
2FA or 3FA account). WebAuthn can also be used by itself to
create 1FA accounts that authenticate in a passwordless
manner. In this case, the setup process differs somewhat. For
instructions, see
<a class="xref" href="webauthn-pluggable-authentication.html#webauthn-pluggable-authentication-passwordless" title="WebAuthn Passwordless Authentication">
WebAuthn Passwordless Authentication
</a>
.
</p>
<p>
An account that is configured to use the
<code class="literal">
authentication_webauthn
</code>
plugin is
associated with a Fast Identity Online (FIDO/FIDO2) device.
Because of this, a one-time device registration step is
required before WebAuthn authentication can occur. The device
registration process has these characteristics:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Any FIDO/FIDO2 device associated with an account must be
registered before the account can be used.
</p>
</li>
<li class="listitem">
<p>
Registration requires that a FIDO/FIDO2 device be
available on the client host, or registration fails.
</p>
</li>
<li class="listitem">
<p>
The user is expected to perform the appropriate FIDO/FIDO2
device action when prompted during registration (for
example, touching the device or performing a biometric
scan).
</p>
</li>
<li class="listitem">
<p>
To perform device registration, the client user must
invoke the
<a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
<span class="command">
<strong>
mysql
</strong>
</span>
</a>
client program and
specify the
<a class="link" href="mysql-command-options.html#option_mysql_register-factor">
<code class="option">
--register-factor
</code>
</a>
option to
specify the factor or factors for which a device is being
registered. For example, if the account is set to use
WebAuthn as the second authentication factor, the user
invokes
<a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
<span class="command">
<strong>
mysql
</strong>
</span>
</a>
with the
<a class="link" href="mysql-command-options.html#option_mysql_register-factor">
<code class="option">
--register-factor=2
</code>
</a>
option.
</p>
</li>
<li class="listitem">
<p>
If the user account is configured with the
<code class="literal">
authentication_webauthn
</code>
plugin set as
the second or third factor, authentication for all
preceding factors must succeed before the registration
step can proceed.
</p>
</li>
<li class="listitem">
<p>
The server knows from the information in the user account
whether the FIDO/FIDO2 device requires registration or has
already been registered. When the client program connects,
the server places the client session in sandbox mode if
the device must be registered, so that registration must
occur before anything else can be done. Sandbox mode used
for FIDO/FIDO2 device registration is similar to that used
for handling of expired passwords. See
<a class="xref" href="expired-password-handling.html" title="8.2.16 Server Handling of Expired Passwords">
Section 8.2.16, “Server Handling of Expired Passwords”
</a>
.
</p>
</li>
<li class="listitem">
<p>
In sandbox mode, no statements other than
<a class="link" href="alter-user.html" title="15.7.1.1 ALTER USER Statement">
<code class="literal">
ALTER USER
</code>
</a>
are permitted.
Registration is performed using forms of this statement.
When invoked with the
<a class="link" href="mysql-command-options.html#option_mysql_register-factor">
<code class="option">
--register-factor
</code>
</a>
option,
the
<a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
<span class="command">
<strong>
mysql
</strong>
</span>
</a>
client generates the
<a class="link" href="alter-user.html" title="15.7.1.1 ALTER USER Statement">
<code class="literal">
ALTER USER
</code>
</a>
statements
required to perform registration. After registration has
been accomplished, the server switches the session out of
sandbox mode, and the client can proceed normally. For
information about the generated
<a class="link" href="alter-user.html" title="15.7.1.1 ALTER USER Statement">
<code class="literal">
ALTER
USER
</code>
</a>
statements, refer to the
<a class="link" href="mysql-command-options.html#option_mysql_register-factor">
<code class="option">
--register-factor
</code>
</a>
description.
</p>
</li>
<li class="listitem">
<p>
When device registration has been performed for the
account, the server updates the
<code class="literal">
mysql.user
</code>
system table row for that
account to update the device registration status and to
store the public key and credential ID. (The server does
not retain the credential ID following FIDO2 device
registration.)
</p>
</li>
<li class="listitem">
<p>
The registration step can be performed only by the user
named by the account. If one user attempts to perform
registration for another user, an error occurs.
</p>
</li>
<li class="listitem">
<p>
The user should use the same FIDO/FIDO2 device during
registration and authentication. If, after registering a
FIDO/FIDO2 device on the client host, the device is reset
or a different device is inserted, authentication fails.
In this case, the device associated with the account must
be unregistered and registration must be done again.
</p>
</li>
</ul>
</div>
<p>
Suppose that you want an account to authenticate first using
the
<code class="literal">
caching_sha2_password
</code>
plugin, then
using the
<code class="literal">
authentication_webauthn
</code>
plugin.
Create a multifactor account using a statement like this:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa10606600"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">CREATE</span> <span class="token keyword">USER</span> <span class="token string">'u2'</span>@<span class="token string">'localhost'</span>
<span class="token keyword">IDENTIFIED</span> <span class="token keyword">WITH</span> caching_sha2_password
<span class="token keyword">BY</span> <span class="token string">'<em class="replaceable">sha2_password</em>'</span>
<span class="token operator">AND</span> <span class="token keyword">IDENTIFIED</span> <span class="token keyword">WITH</span> authentication_webauthn<span class="token punctuation">;</span></code></pre>
</div>
<p>
To connect, supply the factor 1 password to satisfy
authentication for that factor, and to initiate registration
of the FIDO/FIDO2 device, set the
<a class="link" href="mysql-command-options.html#option_mysql_register-factor">
<code class="option">
--register-factor
</code>
</a>
to factor 2.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa54241711"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$> </span><span class="token command">mysql</span> <span class="token constant">--user</span><span class="token attr-value"><span class="token punctuation">=</span>u2</span> <span class="token property">--password1</span> <span class="token constant">--register-factor</span><span class="token attr-value"><span class="token punctuation">=</span>2</span>
Enter password<span class="token punctuation">:</span> <span class="token punctuation"></span><em class="replaceable"><span class="token punctuation">(</span>enter factor 1 password<span class="token punctuation">)</span></em><span class="token punctuation"></span>
Please insert FIDO device and follow the instruction<span class="token punctuation">.</span> Depending on the device<span class="token punctuation">,</span>
you may have to perform gesture action multiple times<span class="token punctuation">.</span>
1<span class="token punctuation">.</span> Perform gesture action <span class="token punctuation">(</span>Skip this step if you are prompted to enter device PIN<span class="token punctuation">)</span><span class="token punctuation">.</span>
2<span class="token punctuation">.</span> Enter PIN for token device<span class="token punctuation">:</span>
3<span class="token punctuation">.</span> Perform gesture action for registration to complete<span class="token punctuation">.</span>
Welcome to the MySQL monitor<span class="token punctuation">.</span> Commands end with <span class="token punctuation">;</span> or \g<span class="token punctuation">.</span>
Your MySQL connection id is 8</code></pre>
</div>
<p>
After the factor 1 password is accepted, the client session
enters sandbox mode so that device registration can be
performed for factor 2. During registration, you are prompted
to perform the appropriate FIDO/FIDO2 device action, such as
touching the device or performing a biometric scan.
</p>
<p>
Optionally, you can invoke the
<a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
<span class="command">
<strong>
mysql
</strong>
</span>
</a>
client
program and specify the
<a class="link" href="mysql-command-options.html#option_mysql_plugin-authentication-webauthn-client-preserve-privacy">
<code class="option">
--plugin-authentication-webauthn-client-preserve-privacy
</code>
</a>
option. If the FIDO2 device contains multiple discoverable
credentials (resident keys) for a given replying party (RP)
ID, this option permits choosing a key to be used for
assertion. By default, the option is set to
<code class="literal">
FALSE
</code>
, indicating that assertions are to be
created using all resident keys for a given RP ID. When
specified with this option,
<a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
<span class="command">
<strong>
mysql
</strong>
</span>
</a>
prompts
the you for a device PIN and lists all of the available
credentials for given RP ID. Select one key and then perform
the remaining online instructions to complete the
authentication. The example here assumes that
<code class="literal">
mysql.com
</code>
is a valid RP ID:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa43534959"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$> </span><span class="token command">mysql</span> <span class="token constant">--user</span><span class="token attr-value"><span class="token punctuation">=</span>u2</span> <span class="token property">--password1</span> <span class="token constant">--register-factor</span><span class="token attr-value"><span class="token punctuation">=</span>2</span>
<span class="token property">--plugin-authentication-webauthn-client-preserve-privacy</span>
Enter password<span class="token punctuation">:</span> <span class="token punctuation"></span><em class="replaceable"><span class="token punctuation">(</span>enter factor 1 password<span class="token punctuation">)</span></em><span class="token punctuation"></span>
Enter PIN for token device<span class="token punctuation">:</span>
Found following credentials for RP ID<span class="token punctuation">:</span> mysql<span class="token punctuation">.</span>com
<span class="token punctuation">[</span>1<span class="token punctuation">]</span>`u2`@`127<span class="token punctuation">.</span>0<span class="token punctuation">.</span>0<span class="token punctuation">.</span>1`
<span class="token punctuation">[</span>2<span class="token punctuation">]</span>`u2`@`%`
Please select one<span class="token punctuation">(</span>1<span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>N<span class="token punctuation">)</span><span class="token punctuation">:</span>
1
Please insert FIDO device and perform gesture action for authentication to complete<span class="token punctuation">.</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> CURRENT_USER() <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> [email protected] <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
<p>
The
<a class="link" href="mysql-command-options.html#option_mysql_plugin-authentication-webauthn-client-preserve-privacy">
<code class="option">
--plugin-authentication-webauthn-client-preserve-privacy
</code>
</a>
option has no effect on FIDO devices that do not support the
resident-key feature.
</p>
<p>
When the registration process is complete, the connection to
the server is permitted.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
The connection to the server is permitted following
registration regardless of additional authentication factors
in the account's authentication chain. For example, if
the account in the preceding example was defined with a
third authentication factor (using non-WebAuthn
authentication), the connection would be permitted after a
successful registration without authenticating the third
factor. However, subsequent connections would require
authenticating all three factors.
</p>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="webauthn-pluggable-authentication-passwordless">
</a>
WebAuthn Passwordless Authentication
</h5>
</div>
</div>
</div>
<p>
This section describes how WebAuthn can be used by itself to
create 1FA accounts that authenticate in a passwordless
manner. In this context,
<span class="quote">
“
<span class="quote">
passwordless
</span>
”
</span>
means
that authentication occurs but uses a method other than a
password, such as a security key or biometric scan. It does
not refer to an account that uses a password-based
authentication plugin for which the password is empty. That
kind of
<span class="quote">
“
<span class="quote">
passwordless
</span>
”
</span>
is completely insecure and
is not recommended.
</p>
<p>
The following prerequisites apply when using the
<code class="literal">
authentication_webauthn
</code>
plugin to achieve
passwordless authentication:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
The user that creates a passwordless-authentication
account requires the
<a class="link" href="privileges-provided.html#priv_passwordless-user-admin">
<code class="literal">
PASSWORDLESS_USER_ADMIN
</code>
</a>
privilege in addition to the
<a class="link" href="privileges-provided.html#priv_create-user">
<code class="literal">
CREATE
USER
</code>
</a>
privilege.
</p>
</li>
<li class="listitem">
<p>
The first element of the
<a class="link" href="server-system-variables.html#sysvar_authentication_policy">
<code class="literal">
authentication_policy
</code>
</a>
value must be an asterisk (
<code class="literal">
*
</code>
) and not a
plugin name. For example, the default
<a class="link" href="server-system-variables.html#sysvar_authentication_policy">
<code class="literal">
authentication_policy
</code>
</a>
value supports enabling passwordless authentication
because the first element is an asterisk:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-ini"><div class="docs-select-all right" id="sa8355260"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-ini"><span class="token constant">authentication_policy</span><span class="token attr-value"><span class="token punctuation">=</span>'*,,'</span></code></pre>
</div>
<p>
For information about configuring the
<a class="link" href="server-system-variables.html#sysvar_authentication_policy">
<code class="literal">
authentication_policy
</code>
</a>
value, see
<a class="xref" href="multifactor-authentication.html#multifactor-authentication-policy" title="Configuring the Multifactor Authentication Policy">
Configuring the Multifactor Authentication Policy
</a>
.
</p>
</li>
</ul>
</div>
<p>
To use
<code class="literal">
authentication_webauthn
</code>
as a
passwordless authentication method, the account must be
created with
<code class="literal">
authentication_webauthn
</code>
as the
first factor authentication method. The
<code class="literal">
INITIAL
AUTHENTICATION IDENTIFIED BY
</code>
clause must also be
specified for the first factor (it is not supported with 2nd
or 3rd factors). This clause specifies whether a randomly
generated or user-specified password will be used for
FIDO/FIDO2 device registration. After device registration, the
server deletes the password and modifies the account to make
<code class="literal">
authentication_webauthn
</code>
the sole
authentication method (the 1FA method).
</p>
<p>
The required
<a class="link" href="create-user.html" title="15.7.1.3 CREATE USER Statement">
<code class="literal">
CREATE USER
</code>
</a>
syntax
is as follows:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa2152259"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">CREATE</span> <span class="token keyword">USER</span> <span class="token keyword"><em class="replaceable">user</em></span>
<span class="token keyword">IDENTIFIED</span> <span class="token keyword">WITH</span> authentication_webauthn
INITIAL AUTHENTICATION <span class="token keyword">IDENTIFIED</span> <span class="token keyword">BY</span> {<span class="token keyword">RANDOM</span> <span class="token keyword">PASSWORD</span> <span class="token operator">|</span> <span class="token string">'<em class="replaceable">auth_string</em>'</span>}<span class="token punctuation">;</span></code></pre>
</div>
<p>
The following example uses the
<code class="literal">
RANDOM
PASSWORD
</code>
syntax:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa70030828"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">CREATE</span> <span class="token keyword">USER</span> <span class="token string">'u1'</span>@<span class="token string">'localhost'</span>
<span class="token keyword">IDENTIFIED</span> <span class="token keyword">WITH</span> authentication_webauthn
INITIAL AUTHENTICATION <span class="token keyword">IDENTIFIED</span> <span class="token keyword">BY</span> <span class="token keyword">RANDOM</span> <span class="token keyword">PASSWORD</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> user <span class="token punctuation">|</span> host <span class="token punctuation">|</span> generated password <span class="token punctuation">|</span> auth_factor <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> u1 <span class="token punctuation">|</span> localhost <span class="token punctuation">|</span> 9XHK]M{l2rnD;VXyHzeF <span class="token punctuation">|</span> 1 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
<p>
To perform registration, the user must authenticate to the
server with the password associated with the
<code class="literal">
INITIAL
AUTHENTICATION IDENTIFIED BY
</code>
clause, either the
randomly generated password, or the
<code class="literal">
'
<em class="replaceable">
<code>
auth_string
</code>
</em>
'
</code>
value. If the account was created as just shown, the user
executes this command and pastes in the preceding randomly
generated password (
<code class="literal">
9XHK]M{l2rnD;VXyHzeF
</code>
)
at the prompt:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa58683290"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$> </span><span class="token command">mysql</span> <span class="token constant">--user</span><span class="token attr-value"><span class="token punctuation">=</span>u1</span> <span class="token property">--password</span> <span class="token constant">--register-factor</span><span class="token attr-value"><span class="token punctuation">=</span>2</span>
Enter password<span class="token punctuation">:</span>
Please insert FIDO device and follow the instruction<span class="token punctuation">.</span> Depending on the device<span class="token punctuation">,</span>
you may have to perform gesture action multiple times<span class="token punctuation">.</span>
1<span class="token punctuation">.</span> Perform gesture action <span class="token punctuation">(</span>Skip this step if you are prompted to enter device PIN<span class="token punctuation">)</span><span class="token punctuation">.</span>
2<span class="token punctuation">.</span> Enter PIN for token device<span class="token punctuation">:</span>
3<span class="token punctuation">.</span> Perform gesture action for registration to complete<span class="token punctuation">.</span>
Welcome to the MySQL monitor<span class="token punctuation">.</span> Commands end with <span class="token punctuation">;</span> or \g<span class="token punctuation">.</span>
Your MySQL connection id is 10</code></pre>
</div>
<p>
Alternatively, use the
<a class="link" href="mysql-command-options.html#option_mysql_plugin-authentication-webauthn-client-preserve-privacy">
<code class="option">
--plugin-authentication-webauthn-client-preserve-privacy
</code>
</a>
option to select a discoverable credential for authentication.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa97840356"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$> </span><span class="token command">mysql</span> <span class="token constant">--user</span><span class="token attr-value"><span class="token punctuation">=</span>u1</span> <span class="token property">--password</span> <span class="token constant">--register-factor</span><span class="token attr-value"><span class="token punctuation">=</span>2</span>
<span class="token property">--plugin-authentication-webauthn-client-preserve-privacy</span>
Enter password<span class="token punctuation">:</span>
Enter PIN for token device<span class="token punctuation">:</span>
Found following credentials for RP ID<span class="token punctuation">:</span> mysql<span class="token punctuation">.</span>com
<span class="token punctuation">[</span>1<span class="token punctuation">]</span>`u1`@`127<span class="token punctuation">.</span>0<span class="token punctuation">.</span>0<span class="token punctuation">.</span>1`
<span class="token punctuation">[</span>2<span class="token punctuation">]</span>`u1`@`%`
Please select one<span class="token punctuation">(</span>1<span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>N<span class="token punctuation">)</span><span class="token punctuation">:</span>
1
Please insert FIDO device and perform gesture action for authentication to complete<span class="token punctuation">.</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> CURRENT_USER() <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> [email protected] <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
<p>
The option
<a class="link" href="mysql-command-options.html#option_mysql_register-factor">
<code class="option">
--register-factor=2
</code>
</a>
is used because the
<code class="literal">
INITIAL AUTHENTICATION IDENTIFIED
BY
</code>
clause is currently acting as the first factor
authentication method. The user must therefore provide the
temporary password by using the second factor. On a successful
registration, the server removes the temporary password and
revises the account entry in the
<code class="literal">
mysql.user
</code>
system table to list
<code class="literal">
authentication_webauthn
</code>
as the sole (1FA)
authentication method.
</p>
<p>
When creating a passwordless-authentication account, it is
important to include the
<code class="literal">
INITIAL AUTHENTICATION
IDENTIFIED BY
</code>
clause in the
<a class="link" href="create-user.html" title="15.7.1.3 CREATE USER Statement">
<code class="literal">
CREATE USER
</code>
</a>
statement. The
server accepts a statement without the clause, but the
resulting account is unusable because there is no way to
connect to the server to register the device. Suppose that you
execute a statement like this:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa63711153"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">CREATE</span> <span class="token keyword">USER</span> <span class="token string">'u2'</span>@<span class="token string">'localhost'</span>
<span class="token keyword">IDENTIFIED</span> <span class="token keyword">WITH</span> authentication_webauthn<span class="token punctuation">;</span></code></pre>
</div>
<p>
Subsequent attempts to use the account to connect fail like
this:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa93138608"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$> </span><span class="token command">mysql</span> <span class="token constant">--user</span><span class="token attr-value"><span class="token punctuation">=</span>u2</span> <span class="token property">--skip-password</span>
mysql<span class="token punctuation">:</span> <span class="token punctuation">[</span>Warning<span class="token punctuation">]</span> Using a password on the command line can be insecure<span class="token punctuation">.</span>
No FIDO device on client host<span class="token punctuation">.</span>
<span class="token output">ERROR 1 (HY000)<span class="token punctuation">:</span> Unknown MySQL error</span></code></pre>
</div>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
Passwordless authentication is achieved using the Universal
2nd Factor (U2F) protocol, which does not support additional
security measures such as setting a PIN on the device to be
registered. It is therefore the responsibility of the device
holder to ensure the device is handled in a secure manner.
</p>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="webauthn-pluggable-authentication-unregistration">
</a>
Device Unregistration for WebAuthn
</h5>
</div>
</div>
</div>
<p>
It is possible to unregister FIDO/FIDO2 devices associated
with a MySQL account. This might be desirable or necessary
under multiple circumstances:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
A FIDO/FIDO2 device is to be replaced with a different
device. The previous device must be unregistered and the
new device registered.
</p>
<p>
In this case, the account owner or any user who has the
<a class="link" href="privileges-provided.html#priv_create-user">
<code class="literal">
CREATE USER
</code>
</a>
privilege can
unregister the device. The account owner can register the
new device.
</p>
</li>
<li class="listitem">
<p>
A FIDO/FIDO2 device is reset or lost. Authentication
attempts will fail until the current device is
unregistered and a new registration is performed.
</p>
<p>
In this case, the account owner, being unable to
authenticate, cannot unregister the current device and
must contact the DBA (or any user who has the
<a class="link" href="privileges-provided.html#priv_create-user">
<code class="literal">
CREATE USER
</code>
</a>
privilege) to
do so. Then the account owner can reregister the reset
device or register a new device.
</p>
</li>
</ul>
</div>
<p>
Unregistering a FIDO/FIDO2 device can be done by the account
owner or by any user who has the
<a class="link" href="create-user.html" title="15.7.1.3 CREATE USER Statement">
<code class="literal">
CREATE
USER
</code>
</a>
privilege. Use this syntax:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa73837816"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">ALTER</span> <span class="token keyword">USER</span> <span class="token keyword"><em class="replaceable">user</em></span> {<span class="token number">2</span> <span class="token operator">|</span> <span class="token number">3</span>} FACTOR UNREGISTER<span class="token punctuation">;</span></code></pre>
</div>
<p>
To re-register a device or perform a new registration, refer
to the instructions in
<a class="xref" href="webauthn-pluggable-authentication.html#webauthn-pluggable-authentication-usage" title="Using WebAuthn Authentication">
Using WebAuthn Authentication
</a>
.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="webauthn-pluggable-authentication-process">
</a>
How WebAuthn Authentication of MySQL Users Works
</h5>
</div>
</div>
</div>
<p>
This section provides an overview of how MySQL and WebAuthn
work together to authenticate MySQL users. For examples
showing how to set up MySQL accounts to use the WebAuthn
authentication plugins, see
<a class="xref" href="webauthn-pluggable-authentication.html#webauthn-pluggable-authentication-usage" title="Using WebAuthn Authentication">
Using WebAuthn Authentication
</a>
.
</p>
<p>
An account that uses WebAuthn authentication must perform an
initial device registration step before it can connect to the
server. After the device has been registered, authentication
can proceed. WebAuthn device registration process is as
follows:
</p>
<div class="orderedlist">
<ol class="orderedlist" type="1">
<li class="listitem">
<p>
The server sends a random challenge, user ID, and relying
party ID (which uniquely identifies a server) to the
client in JSON format. The relying party ID is defined by
the
<a class="link" href="pluggable-authentication-system-variables.html#sysvar_authentication_webauthn_rp_id">
<code class="literal">
authentication_webauthn_rp_id
</code>
</a>
system variable. The default value is
<code class="literal">
mysql.com
</code>
.
</p>
</li>
<li class="listitem">
<p>
The client receives that information and sends it to the
client-side WebAuthn authentication plugin, which in turn
provides it to the FIDO/FIDO2 device. Client also sends
1-byte capability, with RESIDENT_KEYS bit set to
<code class="literal">
ON
</code>
(if it is FIDO2 device) or
<code class="literal">
OFF
</code>
.
</p>
</li>
<li class="listitem">
<p>
After the user has performed the appropriate device action
(for example, touching the device or performing a
biometric scan) the FIDO/FIDO2 device generates a
public/private key pair, a key handle, an X.509
certificate, and a signature, which is returned to the
server.
</p>
</li>
<li class="listitem">
<p>
The server-side WebAuthn authentication plugin verifies
the signature. With successful verification, the server
stores the credential ID (for FIDO devices only) and
public key in the
<code class="literal">
mysql.user
</code>
system
table.
</p>
</li>
</ol>
</div>
<p>
After registration has been performed successfully, WebAuthn
authentication follows this process:
</p>
<div class="orderedlist">
<ol class="orderedlist" type="1">
<li class="listitem">
<p>
The server sends a random challenge, user ID, relying
party ID and credentials to the client. The challenge is
converted to URL-safe Base64 format.
</p>
</li>
<li class="listitem">
<p>
The client sends the same information to the device. The
client queries the device to check if it supports
Client-to-Authenticator Protocols (CTAP2) protocol. CTAP2
support indicates that the device is FIDO2-protocol aware.
</p>
</li>
<li class="listitem">
<p>
The FIDO/FIDO2 device prompts the user to perform the
appropriate device action, based on the selection made
during registration.
</p>
<p>
If the device is FIDO2-protocol aware, the device signs
with all private keys available in the device for a given
RP ID. Optionally, it may prompt user to pick one from the
list as well. If the device is not FIDO2 capable, it
fetches the right private key.
</p>
</li>
<li class="listitem">
<p>
This action unlocks the private key and the challenge is
signed.
</p>
</li>
<li class="listitem">
<p>
This signed challenge is returned to the server.
</p>
</li>
<li class="listitem">
<p>
The server-side WebAuthn authentication plugin verifies
the signature with the public key and responds to indicate
authentication success or failure.
</p>
</li>
</ol>
</div>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/using-encrypted-connections.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="using-encrypted-connections">
</a>
8.3.1 Configuring MySQL to Use Encrypted Connections
</h3>
</div>
</div>
</div>
<a class="indexterm" name="idm46045247175632">
</a>
<a class="indexterm" name="idm46045247174592">
</a>
<a class="indexterm" name="idm46045247173120">
</a>
<p>
Several configuration parameters are available to indicate whether
to use encrypted connections, and to specify the appropriate
certificate and key files. This section provides general guidance
about configuring the server and clients for encrypted
connections:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="xref" href="using-encrypted-connections.html#using-encrypted-connections-server-side-startup-configuration" title="Server-Side Startup Configuration for Encrypted Connections">
Server-Side Startup Configuration for Encrypted Connections
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="using-encrypted-connections.html#using-encrypted-connections-server-side-runtime-configuration" title="Server-Side Runtime Configuration and Monitoring for Encrypted Connections">
Server-Side Runtime Configuration and Monitoring for Encrypted
Connections
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="using-encrypted-connections.html#using-encrypted-connections-client-side-configuration" title="Client-Side Configuration for Encrypted Connections">
Client-Side Configuration for Encrypted Connections
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="using-encrypted-connections.html#enforce-certificate-validation" title="Configuring Certificate Validation Enforcement">
Configuring Certificate Validation Enforcement
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="using-encrypted-connections.html#mandatory-encrypted-connections" title="Configuring Encrypted Connections as Mandatory">
Configuring Encrypted Connections as Mandatory
</a>
</p>
</li>
</ul>
</div>
<p>
Encrypted connections also can be used in other contexts, as
discussed in these additional sections:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Between source and replica replication servers. See
<a class="xref" href="replication-encrypted-connections.html" title="19.3.1 Setting Up Replication to Use Encrypted Connections">
Section 19.3.1, “Setting Up Replication to Use Encrypted Connections”
</a>
.
</p>
</li>
<li class="listitem">
<p>
Among Group Replication servers. See
<a class="xref" href="group-replication-secure-socket-layer-support-ssl.html" title="20.6.2 Securing Group Communication Connections with Secure Socket Layer (SSL)">
Section 20.6.2, “Securing Group Communication Connections with Secure Socket Layer (SSL)”
</a>
.
</p>
</li>
<li class="listitem">
<p>
By client programs that are based on the MySQL C API. See
<a class="ulink" href="/doc/c-api/8.4/en/c-api-encrypted-connections.html" target="_top">
Support for Encrypted Connections
</a>
.
</p>
</li>
</ul>
</div>
<p>
Instructions for creating any required certificate and key files
are available in
<a class="xref" href="creating-ssl-rsa-files.html" title="8.3.3 Creating SSL and RSA Certificates and Keys">
Section 8.3.3, “Creating SSL and RSA Certificates and Keys”
</a>
.
</p>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h4 class="title">
<a name="using-encrypted-connections-server-side-startup-configuration">
</a>
Server-Side Startup Configuration for Encrypted Connections
</h4>
</div>
</div>
</div>
<p>
To require that clients connect using encrypted connections,
enable the
<a class="link" href="server-system-variables.html#sysvar_require_secure_transport">
<code class="literal">
require_secure_transport
</code>
</a>
system
variable. See
<a class="xref" href="using-encrypted-connections.html#mandatory-encrypted-connections" title="Configuring Encrypted Connections as Mandatory">
Configuring Encrypted Connections as Mandatory
</a>
.
</p>
<p>
These system variables on the server side specify the
certificate and key files the server uses when permitting
clients to establish encrypted connections:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="link" href="server-system-variables.html#sysvar_ssl_ca">
<code class="literal">
ssl_ca
</code>
</a>
: The path name of
the Certificate Authority (CA) certificate file.
(
<a class="link" href="server-system-variables.html#sysvar_ssl_capath">
<code class="literal">
ssl_capath
</code>
</a>
is similar but
specifies the path name of a directory of CA certificate
files.)
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="server-system-variables.html#sysvar_ssl_cert">
<code class="literal">
ssl_cert
</code>
</a>
: The path name of
the server public key certificate file. This certificate can
be sent to the client and authenticated against the CA
certificate that it has.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="server-system-variables.html#sysvar_ssl_key">
<code class="literal">
ssl_key
</code>
</a>
: The path name of
the server private key file.
</p>
</li>
</ul>
</div>
<p>
For example, to enable the server for encrypted connections,
start it with these lines in the
<code class="filename">
my.cnf
</code>
file, changing the file names as necessary:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-ini"><div class="docs-select-all right" id="sa82085773"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-ini"><span class="token selector">[mysqld]</span>
<span class="token constant">ssl_ca</span><span class="token attr-value"><span class="token punctuation">=</span>ca.pem</span>
<span class="token constant">ssl_cert</span><span class="token attr-value"><span class="token punctuation">=</span>server-cert.pem</span>
<span class="token constant">ssl_key</span><span class="token attr-value"><span class="token punctuation">=</span>server-key.pem</span></code></pre>
</div>
<p>
To specify in addition that clients are required to use
encrypted connections, enable the
<a class="link" href="server-system-variables.html#sysvar_require_secure_transport">
<code class="literal">
require_secure_transport
</code>
</a>
system
variable:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-ini"><div class="docs-select-all right" id="sa65214602"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-ini"><span class="token selector">[mysqld]</span>
<span class="token constant">ssl_ca</span><span class="token attr-value"><span class="token punctuation">=</span>ca.pem</span>
<span class="token constant">ssl_cert</span><span class="token attr-value"><span class="token punctuation">=</span>server-cert.pem</span>
<span class="token constant">ssl_key</span><span class="token attr-value"><span class="token punctuation">=</span>server-key.pem</span>
<span class="token constant">require_secure_transport</span><span class="token attr-value"><span class="token punctuation">=</span>ON</span></code></pre>
</div>
<p>
Each certificate and key system variable names a file in PEM
format. Should you need to create the required certificate and
key files, see
<a class="xref" href="creating-ssl-rsa-files.html" title="8.3.3 Creating SSL and RSA Certificates and Keys">
Section 8.3.3, “Creating SSL and RSA Certificates and Keys”
</a>
. MySQL
servers compiled using OpenSSL can generate missing certificate
and key files automatically at startup. See
<a class="xref" href="creating-ssl-rsa-files-using-mysql.html" title="8.3.3.1 Creating SSL and RSA Certificates and Keys using MySQL">
Section 8.3.3.1, “Creating SSL and RSA Certificates and Keys using MySQL”
</a>
.
Alternatively, if you have a MySQL source distribution, you can
test your setup using the demonstration certificate and key
files in its
<code class="filename">
mysql-test/std_data
</code>
directory.
</p>
<p>
The server performs certificate and key file autodiscovery. If
no explicit encrypted-connection options are given to configure
encrypted connections, the server attempts to enable
encrypted-connection support automatically at startup:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
If the server discovers valid certificate and key files
named
<code class="filename">
ca.pem
</code>
,
<code class="filename">
server-cert.pem
</code>
, and
<code class="filename">
server-key.pem
</code>
in the data directory,
it enables support for encrypted connections by clients.
(The files need not have been generated automatically; what
matters is that they have those names and are valid.)
</p>
</li>
<li class="listitem">
<p>
If the server does not find valid certificate and key files
in the data directory, it continues executing but without
support for encrypted connections.
</p>
</li>
</ul>
</div>
<p>
If the server automatically enables encrypted connection
support, it writes a note to the error log. If the server
discovers that the CA certificate is self-signed, it writes a
warning to the error log. (The certificate is self-signed if
created automatically by the server.)
</p>
<p>
MySQL also provides these system variables for server-side
encrypted-connection control:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="link" href="server-system-variables.html#sysvar_ssl_cipher">
<code class="literal">
ssl_cipher
</code>
</a>
: The list of
permissible ciphers for connection encryption.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="server-system-variables.html#sysvar_ssl_crl">
<code class="literal">
ssl_crl
</code>
</a>
: The path name of
the file containing certificate revocation lists.
(
<a class="link" href="server-system-variables.html#sysvar_ssl_crlpath">
<code class="literal">
ssl_crlpath
</code>
</a>
is similar but
specifies the path name of a directory of certificate
revocation-list files.)
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="server-system-variables.html#sysvar_tls_version">
<code class="literal">
tls_version
</code>
</a>
,
<a class="link" href="server-system-variables.html#sysvar_tls_ciphersuites">
<code class="literal">
tls_ciphersuites
</code>
</a>
: Which
encryption protocols and ciphersuites the server permits for
encrypted connections; see
<a class="xref" href="encrypted-connection-protocols-ciphers.html" title="8.3.2 Encrypted Connection TLS Protocols and Ciphers">
Section 8.3.2, “Encrypted Connection TLS Protocols and Ciphers”
</a>
.
For example, you can configure
<a class="link" href="server-system-variables.html#sysvar_tls_version">
<code class="literal">
tls_version
</code>
</a>
to prevent
clients from using less-secure protocols.
</p>
</li>
</ul>
</div>
<p>
If the server cannot create a valid TLS context from the system
variables for server-side encrypted-connection control, the
server executes without support for encrypted connections.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h4 class="title">
<a name="using-encrypted-connections-server-side-runtime-configuration">
</a>
Server-Side Runtime Configuration and Monitoring for Encrypted
Connections
</h4>
</div>
</div>
</div>
<p>
The
<code class="literal">
tls_
<em class="replaceable">
<code>
xxx
</code>
</em>
</code>
and
<code class="literal">
ssl_
<em class="replaceable">
<code>
xxx
</code>
</em>
</code>
system
variables are dynamic and can be set at runtime, not just at
startup. If changed with
<a class="link" href="set-variable.html" title="15.7.6.1 SET Syntax for Variable Assignment">
<code class="literal">
SET
GLOBAL
</code>
</a>
, the new values apply only until server
restart. If changed with
<a class="link" href="set-variable.html" title="15.7.6.1 SET Syntax for Variable Assignment">
<code class="literal">
SET
PERSIST
</code>
</a>
, the new values also carry over to subsequent
server restarts. See
<a class="xref" href="set-variable.html" title="15.7.6.1 SET Syntax for Variable Assignment">
Section 15.7.6.1, “SET Syntax for Variable Assignment”
</a>
. However,
runtime changes to these variables do not immediately affect the
TLS context for new connections, as explained later in this
section.
</p>
<p>
Along with the change that enables runtime changes to the TLS
context-related system variables, the server enables runtime
updates to the actual TLS context used for new connections. This
capability may be useful, for example, to avoid restarting a
MySQL server that has been running so long that its SSL
certificate has expired.
</p>
<p>
To create the initial TLS context, the server uses the values
that the context-related system variables have at startup. To
expose the context values, the server also initializes a set of
corresponding status variables. The following table shows the
system variables that define the TLS context and the
corresponding status variables that expose the currently active
context values.
</p>
<div class="table">
<a name="tls-context-variables-table">
</a>
<p class="title">
<b>
Table 8.12 System and Status Variables for Server Main Connection Interface TLS Context
</b>
</p>
<div class="table-contents">
<table summary="The system variables that define the server TLS context and the corresponding status variables that expose active context values.">
<colgroup>
<col style="width: 45%"/>
<col style="width: 55%"/>
</colgroup>
<thead>
<tr>
<th>
System Variable Name
</th>
<th>
Corresponding Status Variable Name
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<a class="link" href="server-system-variables.html#sysvar_ssl_ca">
<code class="literal">
ssl_ca
</code>
</a>
</td>
<td>
<a class="link" href="server-status-variables.html#statvar_Current_tls_ca">
<code class="literal">
Current_tls_ca
</code>
</a>
</td>
</tr>
<tr>
<td>
<a class="link" href="server-system-variables.html#sysvar_ssl_capath">
<code class="literal">
ssl_capath
</code>
</a>
</td>
<td>
<a class="link" href="server-status-variables.html#statvar_Current_tls_capath">
<code class="literal">
Current_tls_capath
</code>
</a>
</td>
</tr>
<tr>
<td>
<a class="link" href="server-system-variables.html#sysvar_ssl_cert">
<code class="literal">
ssl_cert
</code>
</a>
</td>
<td>
<a class="link" href="server-status-variables.html#statvar_Current_tls_cert">
<code class="literal">
Current_tls_cert
</code>
</a>
</td>
</tr>
<tr>
<td>
<a class="link" href="server-system-variables.html#sysvar_ssl_cipher">
<code class="literal">
ssl_cipher
</code>
</a>
</td>
<td>
<a class="link" href="server-status-variables.html#statvar_Current_tls_cipher">
<code class="literal">
Current_tls_cipher
</code>
</a>
</td>
</tr>
<tr>
<td>
<a class="link" href="server-system-variables.html#sysvar_ssl_crl">
<code class="literal">
ssl_crl
</code>
</a>
</td>
<td>
<a class="link" href="server-status-variables.html#statvar_Current_tls_crl">
<code class="literal">
Current_tls_crl
</code>
</a>
</td>
</tr>
<tr>
<td>
<a class="link" href="server-system-variables.html#sysvar_ssl_crlpath">
<code class="literal">
ssl_crlpath
</code>
</a>
</td>
<td>
<a class="link" href="server-status-variables.html#statvar_Current_tls_crlpath">
<code class="literal">
Current_tls_crlpath
</code>
</a>
</td>
</tr>
<tr>
<td>
<a class="link" href="server-system-variables.html#sysvar_ssl_key">
<code class="literal">
ssl_key
</code>
</a>
</td>
<td>
<a class="link" href="server-status-variables.html#statvar_Current_tls_key">
<code class="literal">
Current_tls_key
</code>
</a>
</td>
</tr>
<tr>
<td>
<a class="link" href="server-system-variables.html#sysvar_tls_ciphersuites">
<code class="literal">
tls_ciphersuites
</code>
</a>
</td>
<td>
<a class="link" href="server-status-variables.html#statvar_Current_tls_ciphersuites">
<code class="literal">
Current_tls_ciphersuites
</code>
</a>
</td>
</tr>
<tr>
<td>
<a class="link" href="server-system-variables.html#sysvar_tls_version">
<code class="literal">
tls_version
</code>
</a>
</td>
<td>
<a class="link" href="server-status-variables.html#statvar_Current_tls_version">
<code class="literal">
Current_tls_version
</code>
</a>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<br class="table-break"/>
<p>
Those active TLS context values are also exposed as properties
in the Performance Schema
<a class="link" href="performance-schema-tls-channel-status-table.html" title="29.12.22.9 The tls_channel_status Table">
<code class="literal">
tls_channel_status
</code>
</a>
table, along
with the properties for any other active TLS contexts.
</p>
<p>
To reconfigure the TLS context at runtime, use this procedure:
</p>
<div class="orderedlist">
<ol class="orderedlist" type="1">
<li class="listitem">
<p>
Set each TLS context-related system variable that should be
changed to its new value.
</p>
</li>
<li class="listitem">
<p>
Execute
<a class="link" href="alter-instance.html#alter-instance-reload-tls">
<code class="literal">
ALTER INSTANCE RELOAD
TLS
</code>
</a>
. This statement reconfigures the active TLS
context from the current values of the TLS context-related
system variables. It also sets the context-related status
variables to reflect the new active context values. The
statement requires the
<a class="link" href="privileges-provided.html#priv_connection-admin">
<code class="literal">
CONNECTION_ADMIN
</code>
</a>
privilege.
</p>
</li>
<li class="listitem">
<p>
New connections established after execution of
<a class="link" href="alter-instance.html#alter-instance-reload-tls">
<code class="literal">
ALTER INSTANCE RELOAD TLS
</code>
</a>
use
the new TLS context. Existing connections remain unaffected.
If existing connections should be terminated, use the
<a class="link" href="kill.html" title="15.7.8.4 KILL Statement">
<code class="literal">
KILL
</code>
</a>
statement.
</p>
</li>
</ol>
</div>
<p>
The members of each pair of system and status variables may have
different values temporarily due to the way the reconfiguration
procedure works:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Changes to the system variables prior to
<a class="link" href="alter-instance.html#alter-instance-reload-tls">
<code class="literal">
ALTER INSTANCE RELOAD TLS
</code>
</a>
do
not change the TLS context. At this point, those changes
have no effect on new connections, and corresponding
context-related system and status variables may have
different values. This enables you to make any changes
required to individual system variables, then update the
active TLS context atomically with
<a class="link" href="alter-instance.html#alter-instance-reload-tls">
<code class="literal">
ALTER INSTANCE RELOAD TLS
</code>
</a>
after all system variable changes have been made.
</p>
</li>
<li class="listitem">
<p>
After
<a class="link" href="alter-instance.html#alter-instance-reload-tls">
<code class="literal">
ALTER INSTANCE RELOAD
TLS
</code>
</a>
, corresponding system and status variables
have the same values. This remains true until the next
change to the system variables.
</p>
</li>
</ul>
</div>
<p>
In some cases,
<a class="link" href="alter-instance.html#alter-instance-reload-tls">
<code class="literal">
ALTER INSTANCE RELOAD
TLS
</code>
</a>
by itself may suffice to reconfigure the TLS
context, without changing any system variables. Suppose that the
certificate in the file named by
<a class="link" href="server-system-variables.html#sysvar_ssl_cert">
<code class="literal">
ssl_cert
</code>
</a>
has expired. It is
sufficient to replace the existing file contents with a
nonexpired certificate and execute
<a class="link" href="alter-instance.html#alter-instance-reload-tls">
<code class="literal">
ALTER
INSTANCE RELOAD TLS
</code>
</a>
to cause the new file contents to
be read and used for new connections.
</p>
<p>
The server implements independent connection-encryption
configuration for the administrative connection interface. See
<a class="xref" href="administrative-connection-interface.html#administrative-interface-encrypted-connections" title="Administrative Interface Support for Encrypted Connections">
Administrative Interface Support for Encrypted Connections
</a>
.
In addition,
<a class="link" href="alter-instance.html#alter-instance-reload-tls">
<code class="literal">
ALTER INSTANCE RELOAD
TLS
</code>
</a>
is extended with a
<code class="literal">
FOR CHANNEL
</code>
clause that enables specifying the channel (interface) for which
to reload the TLS context. See
<a class="xref" href="alter-instance.html" title="15.1.5 ALTER INSTANCE Statement">
Section 15.1.5, “ALTER INSTANCE Statement”
</a>
.
There are no status variables to expose the administrative
interface TLS context, but the Performance Schema
<a class="link" href="performance-schema-tls-channel-status-table.html" title="29.12.22.9 The tls_channel_status Table">
<code class="literal">
tls_channel_status
</code>
</a>
table exposes
TLS properties for both the main and administrative interfaces.
See
<a class="xref" href="performance-schema-tls-channel-status-table.html" title="29.12.22.9 The tls_channel_status Table">
Section 29.12.22.9, “The tls_channel_status Table”
</a>
.
</p>
<p>
Updating the main interface TLS context has these effects:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
The update changes the TLS context used for new connections
on the main connection interface.
</p>
</li>
<li class="listitem">
<p>
The update also changes the TLS context used for new
connections on the administrative interface unless some
nondefault TLS parameter value is configured for that
interface.
</p>
</li>
<li class="listitem">
<p>
The update does not affect the TLS context used by other
enabled server plugins or components such as Group
Replication or X Plugin:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
To apply the main interface reconfiguration to Group
Replication's group communication connections, which
take their settings from the server's TLS
context-related system variables, you must execute
<a class="link" href="stop-group-replication.html" title="15.4.3.2 STOP GROUP_REPLICATION Statement">
<code class="literal">
STOP GROUP_REPLICATION
</code>
</a>
followed by
<a class="link" href="start-group-replication.html" title="15.4.3.1 START GROUP_REPLICATION Statement">
<code class="literal">
START
GROUP_REPLICATION
</code>
</a>
to stop and restart Group
Replication.
</p>
</li>
<li class="listitem">
<p>
X Plugin initializes its TLS context at plugin
initialization as described at
<a class="xref" href="x-plugin-encrypted-connections.html" title="22.5.3 Using Encrypted Connections with X Plugin">
Section 22.5.3, “Using Encrypted Connections with X Plugin”
</a>
. This
context does not change thereafter.
</p>
</li>
</ul>
</div>
</li>
</ul>
</div>
<p>
By default, the
<code class="literal">
RELOAD TLS
</code>
action rolls back
with an error and has no effect if the configuration values do
not permit creation of the new TLS context. The previous context
values continue to be used for new connections. If the optional
<code class="literal">
NO ROLLBACK ON ERROR
</code>
clause is given and the
new context cannot be created, rollback does not occur. Instead,
a warning is generated and encryption is disabled for new
connections on the interface to which the statement applies.
</p>
<p>
Options that enable or disable encrypted connections on a
connection interface have an effect only at startup. For
example, the
<a class="link" href="server-system-variables.html#sysvar_tls_version">
<code class="option">
--tls-version
</code>
</a>
and
<a class="link" href="server-system-variables.html#sysvar_admin_tls_version">
<code class="option">
--admin-tls-version
</code>
</a>
options
affect only at startup whether the main and administrative
interfaces support those TLS versions. Such options are ignored
and have no effect on the operation of
<a class="link" href="alter-instance.html#alter-instance-reload-tls">
<code class="literal">
ALTER INSTANCE RELOAD TLS
</code>
</a>
at
runtime. For example, you can set
<a class="link" href="server-system-variables.html#sysvar_tls_version">
<code class="option">
tls_version=''
</code>
</a>
to start the
server with encrypted connections disabled on the main
interface, then reconfigure TLS and execute
<a class="link" href="alter-instance.html#alter-instance-reload-tls">
<code class="literal">
ALTER INSTANCE RELOAD TLS
</code>
</a>
to
enable encrypted connections at runtime.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h4 class="title">
<a name="using-encrypted-connections-client-side-configuration">
</a>
Client-Side Configuration for Encrypted Connections
</h4>
</div>
</div>
</div>
<p>
For a complete list of client options related to establishment
of encrypted connections, see
<a class="xref" href="connection-options.html#encrypted-connection-options" title="Command Options for Encrypted Connections">
Command Options for Encrypted Connections
</a>
.
</p>
<p>
By default, MySQL client programs attempt to establish an
encrypted connection if the server supports encrypted
connections, with further control available through the
<a class="link" href="connection-options.html#option_general_ssl-mode">
<code class="option">
--ssl-mode
</code>
</a>
option:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
In the absence of an
<a class="link" href="connection-options.html#option_general_ssl-mode">
<code class="option">
--ssl-mode
</code>
</a>
option, clients
attempt to connect using encryption, falling back to an
unencrypted connection if an encrypted connection cannot be
established. This is also the behavior with an explicit
<a class="link" href="connection-options.html#option_general_ssl-mode">
<code class="option">
--ssl-mode=PREFERRED
</code>
</a>
option.
</p>
</li>
<li class="listitem">
<p>
With
<a class="link" href="connection-options.html#option_general_ssl-mode">
<code class="option">
--ssl-mode=REQUIRED
</code>
</a>
,
clients require an encrypted connection and fail if one
cannot be established.
</p>
</li>
<li class="listitem">
<p>
With
<a class="link" href="connection-options.html#option_general_ssl-mode">
<code class="option">
--ssl-mode=DISABLED
</code>
</a>
,
clients use an unencrypted connection.
</p>
</li>
<li class="listitem">
<p>
With
<a class="link" href="connection-options.html#option_general_ssl-mode">
<code class="option">
--ssl-mode=VERIFY_CA
</code>
</a>
or
<a class="link" href="connection-options.html#option_general_ssl-mode">
<code class="option">
--ssl-mode=VERIFY_IDENTITY
</code>
</a>
,
clients require an encrypted connection, and also perform
verification against the server CA certificate and (with
<code class="literal">
VERIFY_IDENTITY
</code>
) against the server host
name in its certificate.
</p>
</li>
</ul>
</div>
<div class="important" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Important
</div>
<p>
The default setting,
<a class="link" href="connection-options.html#option_general_ssl-mode">
<code class="option">
--ssl-mode=PREFERRED
</code>
</a>
, produces
an encrypted connection if the other default settings are
unchanged. However, to help prevent sophisticated
man-in-the-middle attacks, it is important for the client to
verify the server’s identity. The settings
<a class="link" href="connection-options.html#option_general_ssl-mode">
<code class="option">
--ssl-mode=VERIFY_CA
</code>
</a>
and
<a class="link" href="connection-options.html#option_general_ssl-mode">
<code class="option">
--ssl-mode=VERIFY_IDENTITY
</code>
</a>
are a better choice than the default setting to help prevent
this type of attack.
<code class="literal">
VERIFY_CA
</code>
makes the
client check that the server’s certificate is valid.
<code class="literal">
VERIFY_IDENTITY
</code>
makes the client check that
the server’s certificate is valid, and also makes the client
check that the host name the client is using matches the
identity in the server’s certificate. To implement one of
these settings, you must first ensure that the CA certificate
for the server is reliably available to all the clients that
use it in your environment, otherwise availability issues will
result. For this reason, they are not the default setting.
</p>
</div>
<p>
Attempts to establish an unencrypted connection fail if the
<a class="link" href="server-system-variables.html#sysvar_require_secure_transport">
<code class="literal">
require_secure_transport
</code>
</a>
system
variable is enabled on the server side to cause the server to
require encrypted connections. See
<a class="xref" href="using-encrypted-connections.html#mandatory-encrypted-connections" title="Configuring Encrypted Connections as Mandatory">
Configuring Encrypted Connections as Mandatory
</a>
.
</p>
<p>
The following options on the client side identify the
certificate and key files clients use when establishing
encrypted connections to the server. They are similar to the
<a class="link" href="server-system-variables.html#sysvar_ssl_ca">
<code class="literal">
ssl_ca
</code>
</a>
,
<a class="link" href="server-system-variables.html#sysvar_ssl_cert">
<code class="literal">
ssl_cert
</code>
</a>
, and
<a class="link" href="server-system-variables.html#sysvar_ssl_key">
<code class="literal">
ssl_key
</code>
</a>
system variables used
on the server side, but
<a class="link" href="connection-options.html#option_general_ssl-cert">
<code class="option">
--ssl-cert
</code>
</a>
and
<a class="link" href="connection-options.html#option_general_ssl-key">
<code class="option">
--ssl-key
</code>
</a>
identify the client
public and private key:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="link" href="connection-options.html#option_general_ssl-ca">
<code class="option">
--ssl-ca
</code>
</a>
: The path name of
the Certificate Authority (CA) certificate file. This
option, if used, must specify the same certificate used by
the server. (
<code class="option">
--ssl-capath
</code>
is similar but
specifies the path name of a directory of CA certificate
files.)
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="connection-options.html#option_general_ssl-cert">
<code class="option">
--ssl-cert
</code>
</a>
: The path name of
the client public key certificate file.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="connection-options.html#option_general_ssl-key">
<code class="option">
--ssl-key
</code>
</a>
: The path name of
the client private key file.
</p>
</li>
</ul>
</div>
<p>
For additional security relative to that provided by the default
encryption, clients can supply a CA certificate matching the one
used by the server and enable host name identity verification.
In this way, the server and client place their trust in the same
CA certificate and the client verifies that the host to which it
connected is the one intended:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
To specify the CA certificate, use
<a class="link" href="connection-options.html#option_general_ssl-ca">
<code class="option">
--ssl-ca
</code>
</a>
(or
<a class="link" href="connection-options.html#option_general_ssl-capath">
<code class="option">
--ssl-capath
</code>
</a>
), and specify
<a class="link" href="connection-options.html#option_general_ssl-mode">
<code class="option">
--ssl-mode=VERIFY_CA
</code>
</a>
.
</p>
</li>
<li class="listitem">
<p>
To enable host name identity verification as well, use
<a class="link" href="connection-options.html#option_general_ssl-mode">
<code class="option">
--ssl-mode=VERIFY_IDENTITY
</code>
</a>
rather than
<a class="link" href="connection-options.html#option_general_ssl-mode">
<code class="option">
--ssl-mode=VERIFY_CA
</code>
</a>
.
</p>
</li>
</ul>
</div>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
Host name identity verification with
<code class="literal">
VERIFY_IDENTITY
</code>
does not work with
self-signed certificates that are created automatically by the
server (see
<a class="xref" href="creating-ssl-rsa-files-using-mysql.html" title="8.3.3.1 Creating SSL and RSA Certificates and Keys using MySQL">
Section 8.3.3.1, “Creating SSL and RSA Certificates and Keys using MySQL”
</a>
). Such
self-signed certificates do not contain the server name as the
Common Name value.
</p>
</div>
<p>
MySQL also provides these options for client-side
encrypted-connection control:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="link" href="connection-options.html#option_general_ssl-cipher">
<code class="option">
--ssl-cipher
</code>
</a>
: The list of
permissible ciphers for connection encryption.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="connection-options.html#option_general_ssl-crl">
<code class="option">
--ssl-crl
</code>
</a>
: The path name of
the file containing certificate revocation lists.
(
<code class="option">
--ssl-crlpath
</code>
is similar but specifies the
path name of a directory of certificate revocation-list
files.)
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="connection-options.html#option_general_tls-version">
<code class="option">
--tls-version
</code>
</a>
,
<a class="link" href="connection-options.html#option_general_tls-ciphersuites">
<code class="option">
--tls-ciphersuites
</code>
</a>
: The
permitted encryption protocols and ciphersuites; see
<a class="xref" href="encrypted-connection-protocols-ciphers.html" title="8.3.2 Encrypted Connection TLS Protocols and Ciphers">
Section 8.3.2, “Encrypted Connection TLS Protocols and Ciphers”
</a>
.
</p>
</li>
</ul>
</div>
<p>
Depending on the encryption requirements of the MySQL account
used by a client, the client may be required to specify certain
options to connect using encryption to the MySQL server.
</p>
<p>
Suppose that you want to connect using an account that has no
special encryption requirements or that was created using a
<a class="link" href="create-user.html" title="15.7.1.3 CREATE USER Statement">
<code class="literal">
CREATE USER
</code>
</a>
statement that
included the
<code class="literal">
REQUIRE SSL
</code>
clause. Assuming
that the server supports encrypted connections, a client can
connect using encryption with no
<a class="link" href="connection-options.html#option_general_ssl-mode">
<code class="option">
--ssl-mode
</code>
</a>
option or with an
explicit
<a class="link" href="connection-options.html#option_general_ssl-mode">
<code class="option">
--ssl-mode=PREFERRED
</code>
</a>
option:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa50975263"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal">mysql</code></pre>
</div>
<p>
Or:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa46147351"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal">mysql <span class="token constant">--ssl-mode</span><span class="token attr-value"><span class="token punctuation">=</span>PREFERRED</span></code></pre>
</div>
<p>
For an account created with a
<code class="literal">
REQUIRE SSL
</code>
clause, the connection attempt fails if an encrypted connection
cannot be established. For an account with no special encryption
requirements, the attempt falls back to an unencrypted
connection if an encrypted connection cannot be established. To
prevent fallback and fail if an encrypted connection cannot be
obtained, connect like this:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa75723591"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal">mysql <span class="token constant">--ssl-mode</span><span class="token attr-value"><span class="token punctuation">=</span>REQUIRED</span></code></pre>
</div>
<p>
If the account has more stringent security requirements, other
options must be specified to establish an encrypted connection:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
For accounts created with a
<code class="literal">
REQUIRE X509
</code>
clause, clients must specify at least
<a class="link" href="connection-options.html#option_general_ssl-cert">
<code class="option">
--ssl-cert
</code>
</a>
and
<a class="link" href="connection-options.html#option_general_ssl-key">
<code class="option">
--ssl-key
</code>
</a>
. In addition,
<a class="link" href="connection-options.html#option_general_ssl-ca">
<code class="option">
--ssl-ca
</code>
</a>
(or
<a class="link" href="connection-options.html#option_general_ssl-capath">
<code class="option">
--ssl-capath
</code>
</a>
) is recommended
so that the public certificate provided by the server can be
verified. For example (enter the command on a single line):
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa35146522"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal">mysql <span class="token constant">--ssl-ca</span><span class="token attr-value"><span class="token punctuation">=</span>ca.pem</span>
<span class="token constant">--ssl-cert</span><span class="token attr-value"><span class="token punctuation">=</span>client-cert.pem</span>
<span class="token constant">--ssl-key</span><span class="token attr-value"><span class="token punctuation">=</span>client-key.pem</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
For accounts created with a
<code class="literal">
REQUIRE
ISSUER
</code>
or
<code class="literal">
REQUIRE SUBJECT
</code>
clause, the encryption requirements are the same as for
<code class="literal">
REQUIRE X509
</code>
, but the certificate must
match the issue or subject, respectively, specified in the
account definition.
</p>
</li>
</ul>
</div>
<p>
For additional information about the
<code class="literal">
REQUIRE
</code>
clause, see
<a class="xref" href="create-user.html" title="15.7.1.3 CREATE USER Statement">
Section 15.7.1.3, “CREATE USER Statement”
</a>
.
</p>
<p>
MySQL servers can generate client certificate and key files that
clients can use to connect to MySQL server instances. See
<a class="xref" href="creating-ssl-rsa-files.html" title="8.3.3 Creating SSL and RSA Certificates and Keys">
Section 8.3.3, “Creating SSL and RSA Certificates and Keys”
</a>
.
</p>
<div class="important" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Important
</div>
<p>
If a client connecting to a MySQL server instance uses an SSL
certificate with the
<code class="literal">
extendedKeyUsage
</code>
extension (an X.509 v3 extension), the extended key usage must
include client authentication (
<code class="literal">
clientAuth
</code>
).
If the SSL certificate is only specified for server
authentication (
<code class="literal">
serverAuth
</code>
) and other
non-client certificate purposes, certificate verification
fails and the client connection to the MySQL server instance
fails. There is no
<code class="literal">
extendedKeyUsage
</code>
extension in SSL certificates generated by MySQL Server (as
described in
<a class="xref" href="creating-ssl-rsa-files-using-mysql.html" title="8.3.3.1 Creating SSL and RSA Certificates and Keys using MySQL">
Section 8.3.3.1, “Creating SSL and RSA Certificates and Keys using MySQL”
</a>
),
and SSL certificates created using the
<span class="command">
<strong>
openssl
</strong>
</span>
command following the instructions
in
<a class="xref" href="creating-ssl-files-using-openssl.html" title="8.3.3.2 Creating SSL Certificates and Keys Using openssl">
Section 8.3.3.2, “Creating SSL Certificates and Keys Using openssl”
</a>
. If you
use your own client certificate created in another way, ensure
any
<code class="literal">
extendedKeyUsage
</code>
extension includes
client authentication.
</p>
</div>
<p>
To prevent use of encryption and override other
<code class="option">
--ssl-
<em class="replaceable">
<code>
xxx
</code>
</em>
</code>
options,
invoke the client program with
<a class="link" href="connection-options.html#option_general_ssl-mode">
<code class="option">
--ssl-mode=DISABLED
</code>
</a>
:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa29124270"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal">mysql <span class="token constant">--ssl-mode</span><span class="token attr-value"><span class="token punctuation">=</span>DISABLED</span></code></pre>
</div>
<p>
To determine whether the current connection with the server uses
encryption, check the session value of the
<a class="link" href="server-status-variables.html#statvar_Ssl_cipher">
<code class="literal">
Ssl_cipher
</code>
</a>
status variable. If
the value is empty, the connection is not encrypted. Otherwise,
the connection is encrypted and the value indicates the
encryption cipher. For example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa55006083"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SHOW</span> <span class="token keyword">SESSION</span> <span class="token keyword">STATUS</span> <span class="token operator">LIKE</span> <span class="token string">'Ssl_cipher'</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> Variable_name <span class="token punctuation">|</span> Value <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> Ssl_cipher <span class="token punctuation">|</span> DHE<span class="token punctuation">-</span>RSA<span class="token punctuation">-</span>AES128<span class="token punctuation">-</span>GCM<span class="token punctuation">-</span>SHA256 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
<p>
For the
<a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
<span class="command">
<strong>
mysql
</strong>
</span>
</a>
client, an alternative is to
use the
<code class="literal">
STATUS
</code>
or
<code class="literal">
\s
</code>
command and check the
<code class="literal">
SSL
</code>
line:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa13798224"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> \s
<span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
<span class="token keyword">SSL</span>: <span class="token operator">Not</span> <span class="token keyword">in</span> <span class="token keyword">use</span>
<span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span></code></pre>
</div>
<p>
Or:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa13118727"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> \s
<span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
<span class="token keyword">SSL</span>: <span class="token keyword">Cipher</span> <span class="token keyword">in</span> <span class="token keyword">use</span> <span class="token operator">is</span> DHE<span class="token operator">-</span>RSA<span class="token operator">-</span>AES128<span class="token operator">-</span>GCM<span class="token operator">-</span>SHA256
<span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span></code></pre>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h4 class="title">
<a name="enforce-certificate-validation">
</a>
Configuring Certificate Validation Enforcement
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045246918224">
</a>
<p>
The
<a class="link" href="server-system-variables.html#sysvar_tls_certificates_enforced_validation">
<code class="option">
--tls-certificates-enforced-validation
</code>
</a>
option enables validation of the server public key certificate
file, Certificate Authority (CA) certificate files, and
certificate revocation-list files at server startup:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa51108319"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal">mysqld <span class="token property">--tls-certificates-enforced-validation</span></code></pre>
</div>
<p>
If set to
<code class="literal">
ON
</code>
, the server stops execution of
the startup in case of invalid certificates. The server informs
DBAs by providing valid debug messages, error messages, or both
depending on the status of the certificates. This capability may
be useful, for example, to avoid restarting a MySQL server that
has been running so long that its SSL certificate has expired.
</p>
<p>
Similarly, when you execute the
<a class="link" href="alter-instance.html#alter-instance-reload-tls">
<code class="literal">
ALTER
INSTANCE RELOAD TLS
</code>
</a>
statement to change the TLS
context at runtime, the new server and CA certificate files are
not used if validation fails. The server continues to use the
old certificates in this case. For more information about
changing the TLS context dynamically, see
<a class="xref" href="using-encrypted-connections.html#using-encrypted-connections-server-side-runtime-configuration" title="Server-Side Runtime Configuration and Monitoring for Encrypted Connections">
Server-Side Runtime Configuration and Monitoring for Encrypted
Connections
</a>
.
</p>
<p>
<span class="strong">
<strong>
Validating CA Certificates
</strong>
</span>
</p>
<p>
For a connection using the server main interface:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
If
<a class="link" href="server-system-variables.html#sysvar_ssl_ca">
<code class="option">
--ssl_ca
</code>
</a>
is specified,
then the server validates the respective CA certificate and
gives the DBA an appropriate warning message.
</p>
</li>
<li class="listitem">
<p>
If
<a class="link" href="server-system-variables.html#sysvar_ssl_capath">
<code class="option">
--ssl_capath
</code>
</a>
is specified,
then the server validates all the CA certificates in the
respective folder and gives the DBA an appropriate warning
message.
</p>
</li>
<li class="listitem">
<p>
If SSL parameters are not specified, by default the server
validates the CA certificate present in the data directory
and gives the DBA an appropriate warning message.
</p>
</li>
</ul>
</div>
<p>
For a connection using the server administrative interface:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
If
<a class="link" href="server-system-variables.html#sysvar_admin_ssl_ca">
<code class="option">
--admin_ssl_ca
</code>
</a>
is
specified, then the server validates the respective CA
certificate and gives the DBA an appropriate warning
message.
</p>
</li>
<li class="listitem">
<p>
If
<a class="link" href="server-system-variables.html#sysvar_admin_ssl_capath">
<code class="option">
--admin_ssl_capath
</code>
</a>
is
specified, then the server validates all of the CA
certificates in the respective folder and gives the DBA an
appropriate warning message.
</p>
</li>
<li class="listitem">
<p>
If administrative SSL parameters are not specified, by
default the server validates the CA certificate present in
the data directory and gives the DBA an appropriate warning
message.
</p>
</li>
</ul>
</div>
<p>
<span class="strong">
<strong>
Validating the Server
Certificate
</strong>
</span>
</p>
<p>
For a connection using the server main interface:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
If
<a class="link" href="server-system-variables.html#sysvar_ssl_cert">
<code class="option">
--ssl_cert
</code>
</a>
is not
specified, then the server validates the server certificate
in default data directory.
</p>
</li>
<li class="listitem">
<p>
If
<a class="link" href="server-system-variables.html#sysvar_ssl_cert">
<code class="option">
--ssl_cert
</code>
</a>
is given, then
the server validates the server certificate, taking into
consideration
<a class="link" href="server-system-variables.html#sysvar_ssl_crl">
<code class="option">
--ssl_crl
</code>
</a>
, if
specified.
</p>
</li>
<li class="listitem">
<p>
If a DBA sets the command-line option to validate
certificates, then the server stops in case of invalid
certificates and an appropriate error message is displayed
to the DBA. Otherwise, the server emits warning messages to
the DBA and the server starts.
</p>
</li>
</ul>
</div>
<p>
For a connection using the server administrative interface:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
If
<a class="link" href="server-system-variables.html#sysvar_admin_ssl_cert">
<code class="option">
--admin_ssl_cert
</code>
</a>
is not
specified, then the server validates the server certificate
in default data directory.
</p>
</li>
<li class="listitem">
<p>
If
<a class="link" href="server-system-variables.html#sysvar_admin_ssl_cert">
<code class="option">
--admin_ssl_cert
</code>
</a>
is given,
then the server validates the server certificate, taking
into consideration
<a class="link" href="server-system-variables.html#sysvar_admin_ssl_crl">
<code class="option">
--admin_ssl_crl
</code>
</a>
, if
specified.
</p>
</li>
<li class="listitem">
<p>
If a DBA sets the command-line option to validate
certificates, then the server stops in case of invalid
certificates and an appropriate error message is displayed
to the DBA. Otherwise, the server emits warning messages to
the DBA and the server starts.
</p>
</li>
</ul>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h4 class="title">
<a name="mandatory-encrypted-connections">
</a>
Configuring Encrypted Connections as Mandatory
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045246881056">
</a>
<p>
For some MySQL deployments it may be not only desirable but
mandatory to use encrypted connections (for example, to satisfy
regulatory requirements). This section discusses configuration
settings that enable you to do this. These levels of control are
available:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
You can configure the server to require that clients connect
using encrypted connections.
</p>
</li>
<li class="listitem">
<p>
You can invoke individual client programs to require an
encrypted connection, even if the server permits but does
not require encryption.
</p>
</li>
<li class="listitem">
<p>
You can configure individual MySQL accounts to be usable
only over encrypted connections.
</p>
</li>
</ul>
</div>
<p>
To require that clients connect using encrypted connections,
enable the
<a class="link" href="server-system-variables.html#sysvar_require_secure_transport">
<code class="literal">
require_secure_transport
</code>
</a>
system
variable. For example, put these lines in the server
<code class="filename">
my.cnf
</code>
file:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-ini"><div class="docs-select-all right" id="sa7441136"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-ini"><span class="token selector">[mysqld]</span>
<span class="token constant">require_secure_transport</span><span class="token attr-value"><span class="token punctuation">=</span>ON</span></code></pre>
</div>
<p>
Alternatively, to set and persist the value at runtime, use this
statement:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa14199433"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SET</span> <span class="token keyword">PERSIST</span> require_secure_transport<span class="token operator">=</span><span class="token keyword">ON</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
<a class="link" href="set-variable.html" title="15.7.6.1 SET Syntax for Variable Assignment">
<code class="literal">
SET
PERSIST
</code>
</a>
sets a value for the running MySQL instance.
It also saves the value, causing it to be used for subsequent
server restarts. See
<a class="xref" href="set-variable.html" title="15.7.6.1 SET Syntax for Variable Assignment">
Section 15.7.6.1, “SET Syntax for Variable Assignment”
</a>
.
</p>
<p>
With
<a class="link" href="server-system-variables.html#sysvar_require_secure_transport">
<code class="literal">
require_secure_transport
</code>
</a>
enabled, client connections to the server are required to use
some form of secure transport, and the server permits only
TCP/IP connections that use SSL, or connections that use a
socket file (on Unix) or shared memory (on Windows). The server
rejects nonsecure connection attempts, which fail with an
<a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html#error_er_secure_transport_required" target="_top">
<code class="literal">
ER_SECURE_TRANSPORT_REQUIRED
</code>
</a>
error.
</p>
<p>
To invoke a client program such that it requires an encrypted
connection whether or not the server requires encryption, use an
<a class="link" href="connection-options.html#option_general_ssl-mode">
<code class="option">
--ssl-mode
</code>
</a>
option value of
<code class="literal">
REQUIRED
</code>
,
<code class="literal">
VERIFY_CA
</code>
, or
<code class="literal">
VERIFY_IDENTITY
</code>
. For example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa72016127"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal">mysql <span class="token constant">--ssl-mode</span><span class="token attr-value"><span class="token punctuation">=</span>REQUIRED</span>
mysqldump <span class="token constant">--ssl-mode</span><span class="token attr-value"><span class="token punctuation">=</span>VERIFY_CA</span>
mysqladmin <span class="token constant">--ssl-mode</span><span class="token attr-value"><span class="token punctuation">=</span>VERIFY_IDENTITY</span></code></pre>
</div>
<p>
To configure a MySQL account to be usable only over encrypted
connections, include a
<code class="literal">
REQUIRE
</code>
clause in the
<a class="link" href="create-user.html" title="15.7.1.3 CREATE USER Statement">
<code class="literal">
CREATE USER
</code>
</a>
statement that
creates the account, specifying in that clause the encryption
characteristics you require. For example, to require an
encrypted connection and the use of a valid X.509 certificate,
use
<code class="literal">
REQUIRE X509
</code>
:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa95121199"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">CREATE</span> <span class="token keyword">USER</span> <span class="token string">'jeffrey'</span>@<span class="token string">'localhost'</span> <span class="token keyword">REQUIRE</span> <span class="token keyword">X509</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
For additional information about the
<code class="literal">
REQUIRE
</code>
clause, see
<a class="xref" href="create-user.html" title="15.7.1.3 CREATE USER Statement">
Section 15.7.1.3, “CREATE USER Statement”
</a>
.
</p>
<p>
To modify existing accounts that have no encryption
requirements, use the
<a class="link" href="alter-user.html" title="15.7.1.1 ALTER USER Statement">
<code class="literal">
ALTER USER
</code>
</a>
statement.
</p>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/keyring-file-component.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="keyring-file-component">
</a>
8.4.4.4 Using the component_keyring_file File-Based Keyring Component
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045240814768">
</a>
<a class="indexterm" name="idm46045240813696">
</a>
<p>
The
<code class="literal">
component_keyring_file
</code>
keyring component
stores keyring data in a file local to the server host.
</p>
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Warning
</div>
<p>
For encryption key management, the
<code class="literal">
component_keyring_file
</code>
and
<code class="literal">
component_keyring_encrypted_file
</code>
components
are not intended as a regulatory compliance solution. Security
standards such as PCI, FIPS, and others require use of key
management systems to secure, manage, and protect encryption
keys in key vaults or hardware security modules (HSMs).
</p>
</div>
<p>
To use
<code class="literal">
component_keyring_file
</code>
for keystore
management, you must:
</p>
<div class="orderedlist">
<ol class="orderedlist" type="1">
<li class="listitem">
<p>
Write a manifest that tells the server to load
<code class="literal">
component_keyring_file
</code>
, as described in
<a class="xref" href="keyring-component-installation.html" title="8.4.4.2 Keyring Component Installation">
Section 8.4.4.2, “Keyring Component Installation”
</a>
.
</p>
</li>
<li class="listitem">
<p>
Write a configuration file for
<code class="literal">
component_keyring_file
</code>
, as described
here.
</p>
</li>
</ol>
</div>
<p>
When it initializes,
<code class="literal">
component_keyring_file
</code>
reads either a global configuration file, or a global
configuration file paired with a local configuration file:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
The component attempts to read its global configuration file
from the directory where the component library file is
installed (that is, the server plugin directory).
</p>
</li>
<li class="listitem">
<p>
If the global configuration file indicates use of a local
configuration file, the component attempts to read its local
configuration file from the data directory.
</p>
</li>
<li class="listitem">
<p>
Although global and local configuration files are located in
different directories, the file name is
<code class="filename">
component_keyring_file.cnf
</code>
in both
locations.
</p>
</li>
<li class="listitem">
<p>
It is an error for no configuration file to exist.
<code class="literal">
component_keyring_file
</code>
cannot initialize
without a valid configuration.
</p>
</li>
</ul>
</div>
<p>
Local configuration files permit setting up multiple server
instances to use
<code class="literal">
component_keyring_file
</code>
, such
that component configuration for each server instance is
specific to a given data directory instance. This enables the
same keyring component to be used with a distinct data file for
each instance.
</p>
<p>
<code class="literal">
component_keyring_file
</code>
configuration files
have these properties:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
A configuration file must be in valid JSON format.
</p>
</li>
<li class="listitem">
<p>
A configuration file permits these configuration items:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
<code class="literal">
"read_local_config"
</code>
: This item is
permitted only in the global configuration file. If the
item is not present, the component uses only the global
configuration file. If the item is present, its value is
<code class="literal">
true
</code>
or
<code class="literal">
false
</code>
,
indicating whether the component should read
configuration information from the local configuration
file.
</p>
<p>
If the
<code class="literal">
"read_local_config"
</code>
item is
present in the global configuration file along with
other items, the component checks the
<code class="literal">
"read_local_config"
</code>
item value first:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: square; ">
<li class="listitem">
<p>
If the value is
<code class="literal">
false
</code>
, the
component processes the other items in the global
configuration file and ignores the local
configuration file.
</p>
</li>
<li class="listitem">
<p>
If the value is
<code class="literal">
true
</code>
, the
component ignores the other items in the global
configuration file and attempts to read the local
configuration file.
</p>
</li>
</ul>
</div>
</li>
<li class="listitem">
<p>
<code class="literal">
"path"
</code>
: The item value is a string
that names the file to use for storing keyring data. The
file should be named using an absolute path, not a
relative path. This item is mandatory in the
configuration. If not specified,
<code class="literal">
component_keyring_file
</code>
initialization
fails.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
"read_only"
</code>
: The item value indicates
whether the keyring data file is read only. The item
value is
<code class="literal">
true
</code>
(read only) or
<code class="literal">
false
</code>
(read/write). This item is
mandatory in the configuration. If not specified,
<code class="literal">
component_keyring_file
</code>
initialization
fails.
</p>
</li>
</ul>
</div>
</li>
<li class="listitem">
<p>
The database administrator has the responsibility for
creating any configuration files to be used, and for
ensuring that their contents are correct. If an error
occurs, server startup fails and the administrator must
correct any issues indicated by diagnostics in the server
error log.
</p>
</li>
</ul>
</div>
<p>
Given the preceding configuration file properties, to configure
<code class="literal">
component_keyring_file
</code>
, create a global
configuration file named
<code class="filename">
component_keyring_file.cnf
</code>
in the directory
where the
<code class="literal">
component_keyring_file
</code>
library file
is installed, and optionally create a local configuration file,
also named
<code class="filename">
component_keyring_file.cnf
</code>
, in
the data directory. The following instructions assume that a
keyring data file named
<code class="filename">
/usr/local/mysql/keyring/component_keyring_file
</code>
is to be used in read/write fashion.
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
To use a global configuration file only, the file contents
look like this:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-json"><div class="docs-select-all right" id="sa14510718"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token punctuation">{</span>
<span class="token property">"path"</span><span class="token operator">:</span> <span class="token string">"/usr/local/mysql/keyring/component_keyring_file"</span><span class="token punctuation">,</span>
<span class="token property">"read_only"</span><span class="token operator">:</span> <span class="token boolean">false</span>
<span class="token punctuation">}</span></code></pre>
</div>
<p>
Create this file in the directory where the
<code class="literal">
component_keyring_file
</code>
library file is
installed.
</p>
<p>
This path must not point to or include the MySQL data
directory.
</p>
</li>
<li class="listitem">
<p>
Alternatively, to use a global and local configuration file
pair, the global file looks like this:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-json"><div class="docs-select-all right" id="sa42250483"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token punctuation">{</span>
<span class="token property">"read_local_config"</span><span class="token operator">:</span> <span class="token boolean">true</span>
<span class="token punctuation">}</span></code></pre>
</div>
<p>
Create this file in the directory where the
<code class="literal">
component_keyring_file
</code>
library file is
installed.
</p>
<p>
The local file looks like this:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-json"><div class="docs-select-all right" id="sa57115530"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-json"><span class="token punctuation">{</span>
<span class="token property">"path"</span><span class="token operator">:</span> <span class="token string">"/usr/local/mysql/keyring/component_keyring_file"</span><span class="token punctuation">,</span>
<span class="token property">"read_only"</span><span class="token operator">:</span> <span class="token boolean">false</span>
<span class="token punctuation">}</span></code></pre>
</div>
<p>
This path must not point to or include the MySQL data
directory.
</p>
</li>
</ul>
</div>
<p>
Keyring operations are transactional:
<code class="literal">
component_keyring_file
</code>
uses a backup file
during write operations to ensure that it can roll back to the
original file if an operation fails. The backup file has the
same name as the data file with a suffix of
<code class="filename">
.backup
</code>
.
</p>
<p>
<code class="literal">
component_keyring_file
</code>
supports the functions
that comprise the standard MySQL Keyring service interface.
Keyring operations performed by those functions are accessible
in SQL statements as described in
<a class="xref" href="keyring-functions-general-purpose.html" title="8.4.4.12 General-Purpose Keyring Key-Management Functions">
Section 8.4.4.12, “General-Purpose Keyring Key-Management Functions”
</a>
.
</p>
<p>
Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa88386371"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> keyring_key_generate<span class="token punctuation">(</span><span class="token string">'MyKey'</span><span class="token punctuation">,</span> <span class="token string">'AES'</span><span class="token punctuation">,</span> <span class="token number">32</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">SELECT</span> keyring_key_remove<span class="token punctuation">(</span><span class="token string">'MyKey'</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
For information about the characteristics of key values
permitted by
<code class="literal">
component_keyring_file
</code>
, see
<a class="xref" href="keyring-key-types.html" title="8.4.4.10 Supported Keyring Key Types and Lengths">
Section 8.4.4.10, “Supported Keyring Key Types and Lengths”
</a>
.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/where-optimization.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="where-optimization">
</a>
10.2.1.1 WHERE Clause Optimization
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045230318512">
</a>
<a class="indexterm" name="idm46045230317472">
</a>
<p>
This section discusses optimizations that can be made for
processing
<code class="literal">
WHERE
</code>
clauses. The examples use
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
statements, but the same
optimizations apply for
<code class="literal">
WHERE
</code>
clauses in
<a class="link" href="delete.html" title="15.2.2 DELETE Statement">
<code class="literal">
DELETE
</code>
</a>
and
<a class="link" href="update.html" title="15.2.17 UPDATE Statement">
<code class="literal">
UPDATE
</code>
</a>
statements.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
Because work on the MySQL optimizer is ongoing, not all of
the optimizations that MySQL performs are documented here.
</p>
</div>
<p>
You might be tempted to rewrite your queries to make
arithmetic operations faster, while sacrificing readability.
Because MySQL does similar optimizations automatically, you
can often avoid this work, and leave the query in a more
understandable and maintainable form. Some of the
optimizations performed by MySQL follow:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Removal of unnecessary parentheses:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa26100429"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"> <span class="token punctuation">(</span><span class="token punctuation">(</span>a <span class="token operator">AND</span> b<span class="token punctuation">)</span> <span class="token operator">AND</span> c <span class="token operator">OR</span> <span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token punctuation">(</span>a <span class="token operator">AND</span> b<span class="token punctuation">)</span> <span class="token operator">AND</span> <span class="token punctuation">(</span>c <span class="token operator">AND</span> d<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
<span class="token prompt">-></span> <span class="token punctuation">(</span>a <span class="token operator">AND</span> b <span class="token operator">AND</span> c<span class="token punctuation">)</span> <span class="token operator">OR</span> <span class="token punctuation">(</span>a <span class="token operator">AND</span> b <span class="token operator">AND</span> c <span class="token operator">AND</span> d<span class="token punctuation">)</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
Constant folding:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa89623698"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"> <span class="token punctuation">(</span>a<span class="token operator"><</span>b <span class="token operator">AND</span> b<span class="token operator">=</span>c<span class="token punctuation">)</span> <span class="token operator">AND</span> a<span class="token operator">=</span><span class="token number">5</span>
<span class="token prompt">-></span> b<span class="token operator">></span><span class="token number">5</span> <span class="token operator">AND</span> b<span class="token operator">=</span>c <span class="token operator">AND</span> a<span class="token operator">=</span><span class="token number">5</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
Constant condition removal:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa66815747"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"> <span class="token punctuation">(</span>b<span class="token operator">>=</span><span class="token number">5</span> <span class="token operator">AND</span> b<span class="token operator">=</span><span class="token number">5</span><span class="token punctuation">)</span> <span class="token operator">OR</span> <span class="token punctuation">(</span>b<span class="token operator">=</span><span class="token number">6</span> <span class="token operator">AND</span> <span class="token number">5</span><span class="token operator">=</span><span class="token number">5</span><span class="token punctuation">)</span> <span class="token operator">OR</span> <span class="token punctuation">(</span>b<span class="token operator">=</span><span class="token number">7</span> <span class="token operator">AND</span> <span class="token number">5</span><span class="token operator">=</span><span class="token number">6</span><span class="token punctuation">)</span>
<span class="token prompt">-></span> b<span class="token operator">=</span><span class="token number">5</span> <span class="token operator">OR</span> b<span class="token operator">=</span><span class="token number">6</span></code></pre>
</div>
<p>
This takes place during preparation rather than during the
optimization phase, which helps in simplification of
joins. See
<a class="xref" href="outer-join-optimization.html" title="10.2.1.9 Outer Join Optimization">
Section 10.2.1.9, “Outer Join Optimization”
</a>
, for
further information and examples.
</p>
</li>
<li class="listitem">
<p>
Constant expressions used by indexes are evaluated only
once.
</p>
</li>
<li class="listitem">
<p>
Comparisons of columns of numeric types with constant
values are checked and folded or removed for invalid or
out-of-rage values:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa37760594"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token comment" spellcheck="true"># CREATE TABLE t (c TINYINT UNSIGNED NOT NULL);</span>
<span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t <span class="token keyword">WHERE</span> c <span class="token operator"><</span> <span class="token number">256</span><span class="token punctuation">;</span>
<span class="token operator">-</span>≫ <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t <span class="token keyword">WHERE</span> <span class="token number">1</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
See
<a class="xref" href="constant-folding-optimization.html" title="10.2.1.14 Constant-Folding Optimization">
Section 10.2.1.14, “Constant-Folding Optimization”
</a>
, for
more information.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="aggregate-functions.html#function_count">
<code class="literal">
COUNT(*)
</code>
</a>
on a single table
without a
<code class="literal">
WHERE
</code>
is retrieved directly
from the table information for
<code class="literal">
MyISAM
</code>
and
<code class="literal">
MEMORY
</code>
tables. This is also done
for any
<code class="literal">
NOT NULL
</code>
expression when used
with only one table.
</p>
</li>
<li class="listitem">
<p>
Early detection of invalid constant expressions. MySQL
quickly detects that some
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
statements are
impossible and returns no rows.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
HAVING
</code>
is merged with
<code class="literal">
WHERE
</code>
if you do not use
<code class="literal">
GROUP
BY
</code>
or aggregate functions
(
<a class="link" href="aggregate-functions.html#function_count">
<code class="literal">
COUNT()
</code>
</a>
,
<a class="link" href="aggregate-functions.html#function_min">
<code class="literal">
MIN()
</code>
</a>
, and so on).
</p>
</li>
<li class="listitem">
<p>
For each table in a join, a simpler
<code class="literal">
WHERE
</code>
is constructed to get a fast
<code class="literal">
WHERE
</code>
evaluation for the table and also
to skip rows as soon as possible.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045230281456">
</a>
<a class="indexterm" name="idm46045230280384">
</a>
All constant tables are read first before any other tables
in the query. A constant table is any of the following:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
An empty table or a table with one row.
</p>
</li>
<li class="listitem">
<p>
A table that is used with a
<code class="literal">
WHERE
</code>
clause on a
<code class="literal">
PRIMARY KEY
</code>
or a
<code class="literal">
UNIQUE
</code>
index, where all index parts
are compared to constant expressions and are defined
as
<code class="literal">
NOT NULL
</code>
.
</p>
</li>
</ul>
</div>
<p>
All of the following tables are used as constant tables:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa55723719"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t <span class="token keyword">WHERE</span> <em class="replaceable">primary_key</em><span class="token operator">=</span><span class="token number">1</span><span class="token punctuation">;</span>
<span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t1<span class="token punctuation">,</span>t2
<span class="token keyword">WHERE</span> t1<span class="token punctuation">.</span><em class="replaceable">primary_key</em><span class="token operator">=</span><span class="token number">1</span> <span class="token operator">AND</span> t2<span class="token punctuation">.</span><em class="replaceable">primary_key</em><span class="token operator">=</span>t1<span class="token punctuation">.</span>id<span class="token punctuation">;</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
The best join combination for joining the tables is found
by trying all possibilities. If all columns in
<code class="literal">
ORDER BY
</code>
and
<code class="literal">
GROUP
BY
</code>
clauses come from the same table, that table
is preferred first when joining.
</p>
</li>
<li class="listitem">
<p>
If there is an
<code class="literal">
ORDER BY
</code>
clause and a
different
<code class="literal">
GROUP BY
</code>
clause, or if the
<code class="literal">
ORDER BY
</code>
or
<code class="literal">
GROUP BY
</code>
contains columns from tables other than the first table in
the join queue, a temporary table is created.
</p>
</li>
<li class="listitem">
<p>
If you use the
<code class="literal">
SQL_SMALL_RESULT
</code>
modifier, MySQL uses an in-memory temporary table.
</p>
</li>
<li class="listitem">
<p>
Each table index is queried, and the best index is used
unless the optimizer believes that it is more efficient to
use a table scan. At one time, a scan was used based on
whether the best index spanned more than 30% of the table,
but a fixed percentage no longer determines the choice
between using an index or a scan. The optimizer now is
more complex and bases its estimate on additional factors
such as table size, number of rows, and I/O block size.
</p>
</li>
<li class="listitem">
<p>
In some cases, MySQL can read rows from the index without
even consulting the data file. If all columns used from
the index are numeric, only the index tree is used to
resolve the query.
</p>
</li>
<li class="listitem">
<p>
Before each row is output, those that do not match the
<code class="literal">
HAVING
</code>
clause are skipped.
</p>
</li>
</ul>
</div>
<p>
Some examples of queries that are very fast:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa31198760"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> <span class="token function">COUNT</span><span class="token punctuation">(</span><span class="token operator">*</span><span class="token punctuation">)</span> <span class="token keyword">FROM</span> <em class="replaceable">tbl_name</em><span class="token punctuation">;</span>
<span class="token keyword">SELECT</span> <span class="token function">MIN</span><span class="token punctuation">(</span><em class="replaceable">key_part1</em><span class="token punctuation">)</span><span class="token punctuation">,</span><span class="token function">MAX</span><span class="token punctuation">(</span><em class="replaceable">key_part1</em><span class="token punctuation">)</span> <span class="token keyword">FROM</span> <em class="replaceable">tbl_name</em><span class="token punctuation">;</span>
<span class="token keyword">SELECT</span> <span class="token function">MAX</span><span class="token punctuation">(</span><em class="replaceable">key_part2</em><span class="token punctuation">)</span> <span class="token keyword">FROM</span> <em class="replaceable">tbl_name</em>
<span class="token keyword">WHERE</span> <em class="replaceable">key_part1</em><span class="token operator">=</span><em class="replaceable">constant</em><span class="token punctuation">;</span>
<span class="token keyword">SELECT</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span> <span class="token keyword">FROM</span> <em class="replaceable">tbl_name</em>
<span class="token keyword">ORDER</span> <span class="token keyword">BY</span> <em class="replaceable">key_part1</em><span class="token punctuation">,</span><em class="replaceable">key_part2</em><span class="token punctuation">,</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span> <span class="token keyword">LIMIT</span> <span class="token number">10</span><span class="token punctuation">;</span>
<span class="token keyword">SELECT</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span> <span class="token keyword">FROM</span> <em class="replaceable">tbl_name</em>
<span class="token keyword">ORDER</span> <span class="token keyword">BY</span> <em class="replaceable">key_part1</em> <span class="token keyword">DESC</span><span class="token punctuation">,</span> <em class="replaceable">key_part2</em> <span class="token keyword">DESC</span><span class="token punctuation">,</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span> <span class="token keyword">LIMIT</span> <span class="token number">10</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
MySQL resolves the following queries using only the index
tree, assuming that the indexed columns are numeric:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa77769662"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> <em class="replaceable">key_part1</em><span class="token punctuation">,</span><em class="replaceable">key_part2</em> <span class="token keyword">FROM</span> <em class="replaceable">tbl_name</em> <span class="token keyword">WHERE</span> <em class="replaceable">key_part1</em><span class="token operator">=</span><em class="replaceable">val</em><span class="token punctuation">;</span>
<span class="token keyword">SELECT</span> <span class="token function">COUNT</span><span class="token punctuation">(</span><span class="token operator">*</span><span class="token punctuation">)</span> <span class="token keyword">FROM</span> <em class="replaceable">tbl_name</em>
<span class="token keyword">WHERE</span> <em class="replaceable">key_part1</em><span class="token operator">=</span><em class="replaceable">val1</em> <span class="token operator">AND</span> <em class="replaceable">key_part2</em><span class="token operator">=</span><em class="replaceable">val2</em><span class="token punctuation">;</span>
<span class="token keyword">SELECT</span> <span class="token function">MAX</span><span class="token punctuation">(</span><em class="replaceable">key_part2</em><span class="token punctuation">)</span> <span class="token keyword">FROM</span> <em class="replaceable">tbl_name</em> <span class="token keyword">GROUP</span> <span class="token keyword">BY</span> <em class="replaceable">key_part1</em><span class="token punctuation">;</span></code></pre>
</div>
<p>
The following queries use indexing to retrieve the rows in
sorted order without a separate sorting pass:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa68570056"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span> <span class="token keyword">FROM</span> <em class="replaceable">tbl_name</em>
<span class="token keyword">ORDER</span> <span class="token keyword">BY</span> <em class="replaceable">key_part1</em><span class="token punctuation">,</span><em class="replaceable">key_part2</em><span class="token punctuation">,</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span> <span class="token punctuation">;</span>
<span class="token keyword">SELECT</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span> <span class="token keyword">FROM</span> <em class="replaceable">tbl_name</em>
<span class="token keyword">ORDER</span> <span class="token keyword">BY</span> <em class="replaceable">key_part1</em> <span class="token keyword">DESC</span><span class="token punctuation">,</span> <em class="replaceable">key_part2</em> <span class="token keyword">DESC</span><span class="token punctuation">,</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span> <span class="token punctuation">;</span></code></pre>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/connector-cpp-info.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h2 class="title">
<a name="connector-cpp-info">
</a>
31.1 MySQL Connector/C++
</h2>
</div>
</div>
</div>
<a class="indexterm" name="idm46045060392544">
</a>
<a class="indexterm" name="idm46045060391504">
</a>
<p>
The MySQL Connector/C++ manual is published in standalone form, not
as part of the MySQL Reference Manual. For information, see these
documents:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Main manual:
<a class="ulink" href="/doc/connector-cpp/9.1/en/" target="_top">
MySQL Connector/C++ 9.1 Developer Guide
</a>
</p>
</li>
<li class="listitem">
<p>
Release notes:
<a class="ulink" href="/doc/relnotes/connector-cpp/en/" target="_top">
MySQL
Connector/C++ Release Notes
</a>
</p>
</li>
</ul>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/use.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="use">
</a>
15.8.4 USE Statement
</h3>
</div>
</div>
</div>
<a class="indexterm" name="idm46045167844592">
</a>
<a class="indexterm" name="idm46045167843552">
</a>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa45164723"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">USE</span> <em class="replaceable">db_name</em></code></pre>
</div>
<p>
The
<a class="link" href="use.html" title="15.8.4 USE Statement">
<code class="literal">
USE
</code>
</a>
statement tells MySQL to
use the named database as the default (current) database for
subsequent statements. This statement requires some privilege for
the database or some object within it.
</p>
<p>
The named database remains the default until the end of the
session or another
<a class="link" href="use.html" title="15.8.4 USE Statement">
<code class="literal">
USE
</code>
</a>
statement is
issued:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa50358340"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">USE</span> db1<span class="token punctuation">;</span>
<span class="token keyword">SELECT</span> <span class="token function">COUNT</span><span class="token punctuation">(</span><span class="token operator">*</span><span class="token punctuation">)</span> <span class="token keyword">FROM</span> mytable<span class="token punctuation">;</span> <span class="token comment" spellcheck="true"># selects from db1.mytable</span>
<span class="token keyword">USE</span> db2<span class="token punctuation">;</span>
<span class="token keyword">SELECT</span> <span class="token function">COUNT</span><span class="token punctuation">(</span><span class="token operator">*</span><span class="token punctuation">)</span> <span class="token keyword">FROM</span> mytable<span class="token punctuation">;</span> <span class="token comment" spellcheck="true"># selects from db2.mytable</span></code></pre>
</div>
<p>
The database name must be specified on a single line. Newlines in
database names are not supported.
</p>
<p>
Making a particular database the default by means of the
<a class="link" href="use.html" title="15.8.4 USE Statement">
<code class="literal">
USE
</code>
</a>
statement does not preclude
accessing tables in other databases. The following example
accesses the
<code class="literal">
author
</code>
table from the
<code class="literal">
db1
</code>
database and the
<code class="literal">
editor
</code>
table from the
<code class="literal">
db2
</code>
database:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa11425340"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">USE</span> db1<span class="token punctuation">;</span>
<span class="token keyword">SELECT</span> author_name<span class="token punctuation">,</span>editor_name <span class="token keyword">FROM</span> author<span class="token punctuation">,</span>db2<span class="token punctuation">.</span>editor
<span class="token keyword">WHERE</span> author<span class="token punctuation">.</span>editor_id <span class="token operator">=</span> db2<span class="token punctuation">.</span>editor<span class="token punctuation">.</span>editor_id<span class="token punctuation">;</span></code></pre>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/mysql-cluster-limitations-database-objects.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="mysql-cluster-limitations-database-objects">
</a>
25.2.7.5 Limits Associated with Database Objects in NDB Cluster
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045123311728">
</a>
<p>
Some database objects such as tables and indexes have different
limitations when using the
<a class="link" href="mysql-cluster.html" title="Chapter 25 MySQL NDB Cluster 8.4">
<code class="literal">
NDBCLUSTER
</code>
</a>
storage engine:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<b>
Number of database objects.
</b>
The maximum number of
<span class="emphasis">
<em>
all
</em>
</span>
<a class="link" href="mysql-cluster.html" title="Chapter 25 MySQL NDB Cluster 8.4">
<code class="literal">
NDB
</code>
</a>
database objects in a
single NDB Cluster—including databases, tables, and
indexes—is limited to 20320.
</p>
</li>
<li class="listitem">
<p>
<b>
Attributes per table.
</b>
The maximum number of attributes (that is, columns and
indexes) that can belong to a given table is 512.
</p>
</li>
<li class="listitem">
<p>
<b>
Attributes per key.
</b>
The maximum number of attributes per key is 32.
</p>
</li>
<li class="listitem">
<p>
<b>
Row size.
</b>
The maximum permitted size of any one row is 30000 bytes.
</p>
<p>
Each
<a class="link" href="blob.html" title="13.3.4 The BLOB and TEXT Types">
<code class="literal">
BLOB
</code>
</a>
or
<a class="link" href="blob.html" title="13.3.4 The BLOB and TEXT Types">
<code class="literal">
TEXT
</code>
</a>
column contributes 256 +
8 = 264 bytes to this total; this includes
<a class="link" href="json.html" title="13.5 The JSON Data Type">
<code class="literal">
JSON
</code>
</a>
columns. See
<a class="xref" href="storage-requirements.html#data-types-storage-reqs-strings" title="String Type Storage Requirements">
String Type Storage Requirements
</a>
, as well
as
<a class="xref" href="storage-requirements.html#data-types-storage-reqs-json" title="JSON Storage Requirements">
JSON Storage Requirements
</a>
, for more
information relating to these types.
</p>
<p>
In addition, the maximum offset for a fixed-width column of
an
<code class="literal">
NDB
</code>
table is 8188 bytes; attempting to
create a table that violates this limitation fails with NDB
error 851
<span class="errortext">
Maximum offset for fixed-size columns
exceeded
</span>
. For memory-based columns, you can work
around this limitation by using a variable-width column type
such as
<a class="link" href="char.html" title="13.3.2 The CHAR and VARCHAR Types">
<code class="literal">
VARCHAR
</code>
</a>
or defining
the column as
<code class="literal">
COLUMN_FORMAT=DYNAMIC
</code>
; this
does not work with columns stored on disk. For disk-based
columns, you may be able to do so by reordering one or more
of the table's disk-based columns such that the
combined width of all but the disk-based column defined last
in the
<a class="link" href="create-table.html" title="15.1.20 CREATE TABLE Statement">
<code class="literal">
CREATE TABLE
</code>
</a>
statement
used to create the table does not exceed 8188 bytes, less
any possible rounding performed for some data types such as
<a class="link" href="char.html" title="13.3.2 The CHAR and VARCHAR Types">
<code class="literal">
CHAR
</code>
</a>
or
<code class="literal">
VARCHAR
</code>
; otherwise it is necessary to use
memory-based storage for one or more of the offending column
or columns instead.
</p>
</li>
<li class="listitem">
<p>
<b>
BIT column storage per table.
</b>
The maximum combined width for all
<a class="link" href="bit-type.html" title="13.1.5 Bit-Value Type - BIT">
<code class="literal">
BIT
</code>
</a>
columns used in a given
<code class="literal">
NDB
</code>
table is 4096.
</p>
</li>
<li class="listitem">
<p>
<b>
FIXED column storage.
</b>
NDB Cluster supports a maximum of 128 TB per fragment of
data in
<code class="literal">
FIXED
</code>
columns.
</p>
</li>
</ul>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/binary-installation.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h2 class="title">
<a name="binary-installation">
</a>
2.2 Installing MySQL on Unix/Linux Using Generic Binaries
</h2>
</div>
</div>
</div>
<a class="indexterm" name="idm46045332649760">
</a>
<a class="indexterm" name="idm46045332648304">
</a>
<p>
Oracle provides a set of binary distributions of MySQL. These
include generic binary distributions in the form of compressed
<span class="command">
<strong>
tar
</strong>
</span>
files (files with a
<code class="filename">
.tar.xz
</code>
extension) for a number of platforms,
and binaries in platform-specific package formats for selected
platforms.
</p>
<p>
This section covers the installation of MySQL from a compressed
<span class="command">
<strong>
tar
</strong>
</span>
file binary distribution on Unix/Linux
platforms. For Linux-generic binary distribution installation
instructions with a focus on MySQL security features, refer to the
<a class="ulink" href="/doc/mysql-secure-deployment-guide/en/" target="_top">
Secure
Deployment Guide
</a>
. For other platform-specific binary package
formats, see the other platform-specific sections in this manual.
For example, for Windows distributions, see
<a class="xref" href="windows-installation.html" title="2.3 Installing MySQL on Microsoft Windows">
Section 2.3, “Installing MySQL on Microsoft Windows”
</a>
. See
<a class="xref" href="getting-mysql.html" title="2.1.3 How to Get MySQL">
Section 2.1.3, “How to Get MySQL”
</a>
on how to obtain MySQL in different
distribution formats.
</p>
<p>
MySQL compressed
<span class="command">
<strong>
tar
</strong>
</span>
file binary distributions
have names of the form
<code class="filename">
mysql-
<em class="replaceable">
<code>
VERSION
</code>
</em>
-
<em class="replaceable">
<code>
OS
</code>
</em>
.tar.xz
</code>
,
where
<code class="literal">
<em class="replaceable">
<code>
VERSION
</code>
</em>
</code>
is a
number (for example,
<code class="literal">
8.4.3
</code>
), and
<em class="replaceable">
<code>
OS
</code>
</em>
indicates the type of operating system
for which the distribution is intended (for example,
<code class="literal">
pc-linux-i686
</code>
or
<code class="literal">
winx64
</code>
).
</p>
<p>
There is also a
<span class="quote">
“
<span class="quote">
minimal install
</span>
”
</span>
version of the MySQL
compressed
<span class="command">
<strong>
tar
</strong>
</span>
file for the Linux generic binary
distribution, which has a name of the form
<code class="filename">
mysql-
<em class="replaceable">
<code>
VERSION
</code>
</em>
-
<em class="replaceable">
<code>
OS
</code>
</em>
-
<em class="replaceable">
<code>
GLIBCVER
</code>
</em>
-
<em class="replaceable">
<code>
ARCH
</code>
</em>
-minimal.tar.xz
</code>
.
The minimal install distribution excludes debug binaries and is
stripped of debug symbols, making it significantly smaller than the
regular binary distribution. If you choose to install the minimal
install distribution, remember to adjust for the difference in file
name format in the instructions that follow.
</p>
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Warnings
</div>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
If you have previously installed MySQL using your operating
system native package management system, such as Yum or APT,
you may experience problems installing using a native binary.
Make sure your previous MySQL installation has been removed
entirely (using your package management system), and that any
additional files, such as old versions of your data files,
have also been removed. You should also check for
configuration files such as
<code class="filename">
/etc/my.cnf
</code>
or the
<code class="filename">
/etc/mysql
</code>
directory and delete
them.
</p>
<p>
For information about replacing third-party packages with
official MySQL packages, see
<a class="xref" href="linux-installation-yum-repo.html#linux-installation-yum-repo-replace-third-party" title="Replacing a Native Third-Party Distribution of MySQL">
Replacing a Native Third-Party Distribution of MySQL
</a>
or
<a class="xref" href="linux-installation-apt-repo.html#repo-qg-apt-replacing" title="Replacing a Native Distribution of MySQL Using the MySQL APT Repository">
Replacing a Native Distribution of MySQL Using the MySQL APT Repository
</a>
.
</p>
</li>
<li class="listitem">
<p>
MySQL has a dependency on the
<code class="literal">
libaio
</code>
library. Data directory initialization and subsequent server
startup steps fail if this library is not installed locally.
If necessary, install it using the appropriate package
manager. For example, on Yum-based systems:
</p>
<a class="indexterm" name="idm46045332622864">
</a>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa4673948"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$> </span><span class="token command"></span><em class="replaceable"><span class="token command">yum</span> search libaio</em> <span class="token comment" spellcheck="true"># search for info</span>
<span class="token prompt">$> </span><span class="token command"></span><em class="replaceable"><span class="token command">yum</span> install libaio</em> <span class="token comment" spellcheck="true"># install library</span></code></pre>
</div>
<p>
Or, on APT-based systems:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa39997883"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$> </span><span class="token command"></span><em class="replaceable"><span class="token command">apt-cache</span> search libaio</em> <span class="token comment" spellcheck="true"># search for info</span>
<span class="token prompt">$> </span><span class="token command"></span><em class="replaceable"><span class="token command">apt-get</span> install libaio1</em> <span class="token comment" spellcheck="true"># install library</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
<span class="bold">
<strong>
Oracle Linux 8 / Red Hat 8
</strong>
</span>
(EL8): These platforms by default do not install the file
<code class="filename">
/lib64/libtinfo.so.5
</code>
, which is required
by the MySQL client
<span class="command">
<strong>
bin/mysql
</strong>
</span>
for packages
<code class="filename">
mysql-VERSION-el7-x86_64.tar.gz
</code>
and
<code class="filename">
mysql-VERSION-linux-glibc2.12-x86_64.tar.xz
</code>
.
To work around this issue, install the
<code class="literal">
ncurses-compat-libs
</code>
package:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa20952623"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$> </span><span class="token command"></span><em class="replaceable"><span class="token command">yum</span> install ncurses-compat-libs</em></code></pre>
</div>
</li>
<li class="listitem">
<p>
If no RPM or
<code class="filename">
.deb
</code>
file specific to your
distribution is provided by Oracle (or by your Linux vendor),
you can try the generic binaries. In some cases, due to
library incompatibilities or other issues, these may not work
with your Linux installation. In such cases, you can try to
compile and install MySQL from source. See
<a class="xref" href="source-installation.html" title="2.8 Installing MySQL from Source">
Section 2.8, “Installing MySQL from Source”
</a>
, for more information
and instructions.
</p>
</li>
</ul>
</div>
</div>
<p>
To install a compressed
<span class="command">
<strong>
tar
</strong>
</span>
file binary
distribution, unpack it at the installation location you choose
(typically
<code class="filename">
/usr/local/mysql
</code>
). This creates the
directories shown in the following table.
</p>
<div class="table">
<a name="binary-installation-layout">
</a>
<p class="title">
<b>
Table 2.3 MySQL Installation Layout for Generic Unix/Linux Binary Package
</b>
</p>
<div class="table-contents">
<table>
<colgroup>
<col style="width: 45%"/>
<col style="width: 55%"/>
</colgroup>
<thead>
<tr>
<th>
Directory
</th>
<th>
Contents of Directory
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<code class="filename">
bin
</code>
</td>
<td>
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
server, client and utility programs
</td>
</tr>
<tr>
<td>
<code class="filename">
docs
</code>
</td>
<td>
MySQL manual in Info format
</td>
</tr>
<tr>
<td>
<code class="filename">
man
</code>
</td>
<td>
Unix manual pages
</td>
</tr>
<tr>
<td>
<code class="filename">
include
</code>
</td>
<td>
Include (header) files
</td>
</tr>
<tr>
<td>
<code class="filename">
lib
</code>
</td>
<td>
Libraries
</td>
</tr>
<tr>
<td>
<code class="filename">
share
</code>
</td>
<td>
Error messages, dictionary, and SQL for database installation
</td>
</tr>
<tr>
<td>
<code class="literal">
support-files
</code>
</td>
<td>
Miscellaneous support files
</td>
</tr>
</tbody>
</table>
</div>
</div>
<br class="table-break"/>
<p>
Debug versions of the
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
binary are available
as
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld-debug
</strong>
</span>
</a>
. To compile your own debug
version of MySQL from a source distribution, use the appropriate
configuration options to enable debugging support. See
<a class="xref" href="source-installation.html" title="2.8 Installing MySQL from Source">
Section 2.8, “Installing MySQL from Source”
</a>
.
</p>
<a class="indexterm" name="idm46045332577344">
</a>
<p>
To install and use a MySQL binary distribution, the command sequence
looks like this:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa95881351"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$> </span><span class="token command">groupadd</span> mysql
<span class="token prompt">$> </span><span class="token command">useradd</span> <span class="token property">-r</span> <span class="token property">-g</span> mysql <span class="token property">-s</span> /bin/false mysql
<span class="token prompt">$> </span><span class="token command">cd</span> /usr/local
<span class="token prompt">$> </span><span class="token command">tar</span> xvf <em class="replaceable">/path/to/mysql-VERSION-OS</em><span class="token punctuation">.</span>tar<span class="token punctuation">.</span>xz
<span class="token prompt">$> </span><span class="token command">ln</span> <span class="token property">-s</span> <em class="replaceable">full-path-to-mysql-VERSION-OS</em> mysql
<span class="token prompt">$> </span><span class="token command">cd</span> mysql
<span class="token prompt">$> </span><span class="token command">mkdir</span> mysql-files
<span class="token prompt">$> </span><span class="token command">chown</span> mysql<span class="token punctuation">:</span>mysql mysql-files
<span class="token prompt">$> </span><span class="token command">chmod</span> 750 mysql-files
<span class="token prompt">$> </span><span class="token command">bin/mysqld</span> <span class="token property">--initialize</span> <span class="token constant">--user</span><span class="token attr-value"><span class="token punctuation">=</span>mysql</span>
<span class="token prompt">$> </span><span class="token command">bin/mysqld_safe</span> <span class="token constant">--user</span><span class="token attr-value"><span class="token punctuation">=</span>mysql</span> &
<span class="token comment" spellcheck="true"># Next command is optional</span>
<span class="token prompt">$> </span><span class="token command">cp</span> support-files/mysql<span class="token punctuation">.</span>server /etc/init<span class="token punctuation">.</span>d/mysql<span class="token punctuation">.</span>server</code></pre>
</div>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
This procedure assumes that you have
<code class="literal">
root
</code>
(administrator) access to your system. Alternatively, you can
prefix each command using the
<span class="command">
<strong>
sudo
</strong>
</span>
(Linux) or
<span class="command">
<strong>
pfexec
</strong>
</span>
(Solaris) command.
</p>
</div>
<p>
The
<code class="filename">
mysql-files
</code>
directory provides a convenient
location to use as the value for the
<code class="literal">
secure_file_priv
</code>
system variable, which limits
import and export operations to a specific directory. See
<a class="xref" href="server-system-variables.html" title="7.1.8 Server System Variables">
Section 7.1.8, “Server System Variables”
</a>
.
</p>
<p>
A more detailed version of the preceding description for installing
a binary distribution follows.
</p>
<h3>
<a name="binary-installation-createsysuser">
</a>
Create a mysql User and Group
</h3>
<p>
If your system does not already have a user and group to use for
running
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
, you may need to create them. The
following commands add the
<code class="literal">
mysql
</code>
group and the
<code class="literal">
mysql
</code>
user. You might want to call the user and
group something else instead of
<code class="literal">
mysql
</code>
. If so,
substitute the appropriate name in the following instructions. The
syntax for
<span class="command">
<strong>
useradd
</strong>
</span>
and
<span class="command">
<strong>
groupadd
</strong>
</span>
may differ slightly on different
versions of Unix/Linux, or they may have different names such as
<span class="command">
<strong>
adduser
</strong>
</span>
and
<span class="command">
<strong>
addgroup
</strong>
</span>
.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa60623269"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$> </span><span class="token command">groupadd</span> mysql
<span class="token prompt">$> </span><span class="token command">useradd</span> <span class="token property">-r</span> <span class="token property">-g</span> mysql <span class="token property">-s</span> /bin/false mysql</code></pre>
</div>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
Because the user is required only for ownership purposes, not
login purposes, the
<span class="command">
<strong>
useradd
</strong>
</span>
command uses the
<code class="option">
-r
</code>
and
<code class="option">
-s /bin/false
</code>
options to
create a user that does not have login permissions to your server
host. Omit these options if your
<span class="command">
<strong>
useradd
</strong>
</span>
does
not support them.
</p>
</div>
<h3>
<a name="binary-installation-unpack">
</a>
Obtain and Unpack the Distribution
</h3>
<p>
Pick the directory under which you want to unpack the distribution
and change location into it. The example here unpacks the
distribution under
<code class="filename">
/usr/local
</code>
. The
instructions, therefore, assume that you have permission to create
files and directories in
<code class="filename">
/usr/local
</code>
. If that
directory is protected, you must perform the installation as
<code class="literal">
root
</code>
.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa93507845"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$> </span><span class="token command">cd</span> /usr/local</code></pre>
</div>
<p>
Obtain a distribution file using the instructions in
<a class="xref" href="getting-mysql.html" title="2.1.3 How to Get MySQL">
Section 2.1.3, “How to Get MySQL”
</a>
. For a given release, binary
distributions for all platforms are built from the same MySQL source
distribution.
</p>
<p>
Unpack the distribution, which creates the installation directory.
<span class="command">
<strong>
tar
</strong>
</span>
can uncompress and unpack the distribution if
it has
<code class="literal">
z
</code>
option support:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa98036952"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$> </span><span class="token command">tar</span> xvf <em class="replaceable">/path/to/mysql-VERSION-OS</em><span class="token punctuation">.</span>tar<span class="token punctuation">.</span>xz</code></pre>
</div>
<p>
The
<span class="command">
<strong>
tar
</strong>
</span>
command creates a directory named
<code class="filename">
mysql-
<em class="replaceable">
<code>
VERSION
</code>
</em>
-
<em class="replaceable">
<code>
OS
</code>
</em>
</code>
.
</p>
<p>
To install MySQL from a compressed
<span class="command">
<strong>
tar
</strong>
</span>
file
binary distribution, your system must have GNU
<code class="literal">
XZ
Utils
</code>
to uncompress the distribution and a reasonable
<span class="command">
<strong>
tar
</strong>
</span>
to unpack it.
</p>
<p>
GNU
<span class="command">
<strong>
tar
</strong>
</span>
is known to work. The standard
<span class="command">
<strong>
tar
</strong>
</span>
provided with some operating systems is not
able to unpack the long file names in the MySQL distribution. You
should download and install GNU
<span class="command">
<strong>
tar
</strong>
</span>
, or if
available, use a preinstalled version of GNU tar. Usually this is
available as
<span class="command">
<strong>
gnutar
</strong>
</span>
,
<span class="command">
<strong>
gtar
</strong>
</span>
, or
as
<span class="command">
<strong>
tar
</strong>
</span>
within a GNU or Free Software directory,
such as
<code class="filename">
/usr/sfw/bin
</code>
or
<code class="filename">
/usr/local/bin
</code>
. GNU
<span class="command">
<strong>
tar
</strong>
</span>
is
available from
<a class="ulink" href="http://www.gnu.org/software/tar/" target="_blank">
http://www.gnu.org/software/tar/
</a>
.
</p>
<p>
If your
<span class="command">
<strong>
tar
</strong>
</span>
does not support the
<code class="literal">
xz
</code>
format then use the
<span class="command">
<strong>
xz
</strong>
</span>
command to unpack the distribution and
<span class="command">
<strong>
tar
</strong>
</span>
to
unpack it. Replace the preceding
<span class="command">
<strong>
tar
</strong>
</span>
command with
the following alternative command to uncompress and extract the
distribution:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa52457161"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$> </span><span class="token command">xz</span> <span class="token property">-dc</span> <em class="replaceable">/path/to/mysql-VERSION-OS</em><span class="token punctuation">.</span>tar<span class="token punctuation">.</span>xz | tar x</code></pre>
</div>
<p>
Next, create a symbolic link to the installation directory created
by
<span class="command">
<strong>
tar
</strong>
</span>
:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa54109550"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$> </span><span class="token command">ln</span> <span class="token property">-s</span> <em class="replaceable">full-path-to-mysql-VERSION-OS</em> mysql</code></pre>
</div>
<p>
</p>
<p>
The
<code class="literal">
ln
</code>
command makes a symbolic link to the
installation directory. This enables you to refer more easily to it
as
<code class="filename">
/usr/local/mysql
</code>
. To avoid having to type
the path name of client programs always when you are working with
MySQL, you can add the
<code class="filename">
/usr/local/mysql/bin
</code>
directory to your
<code class="literal">
PATH
</code>
variable:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa11319209"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$> </span><span class="token command">export</span> PATH<span class="token attr-value"><span class="token punctuation">=</span>$PATH:/usr/local/mysql/bin</span></code></pre>
</div>
<p>
</p>
<h3>
<a name="binary-installation-postinstall">
</a>
Perform Postinstallation Setup
</h3>
<p>
The remainder of the installation process involves setting
distribution ownership and access permissions, initializing the data
directory, starting the MySQL server, and setting up the
configuration file. For instructions, see
<a class="xref" href="postinstallation.html" title="2.9 Postinstallation Setup and Testing">
Section 2.9, “Postinstallation Setup and Testing”
</a>
.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/security.html | <div id="docs-body">
<div class="chapter">
<div class="titlepage">
<div>
<div>
<h1 class="title">
<a name="security">
</a>
Chapter 8 Security
</h1>
</div>
</div>
</div>
<div class="toc">
<p>
<b>
Table of Contents
</b>
</p>
<dl class="toc">
<dt>
<span class="section">
<a href="general-security-issues.html">
8.1 General Security Issues
</a>
</span>
</dt>
<dd>
<dl>
<dt>
<span class="section">
<a href="security-guidelines.html">
8.1.1 Security Guidelines
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="password-security.html">
8.1.2 Keeping Passwords Secure
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="security-against-attack.html">
8.1.3 Making MySQL Secure Against Attackers
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="security-options.html">
8.1.4 Security-Related mysqld Options and Variables
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="changing-mysql-user.html">
8.1.5 How to Run MySQL as a Normal User
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="load-data-local-security.html">
8.1.6 Security Considerations for LOAD DATA LOCAL
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="secure-client-programming.html">
8.1.7 Client Programming Security Guidelines
</a>
</span>
</dt>
</dl>
</dd>
<dt>
<span class="section">
<a href="access-control.html">
8.2 Access Control and Account Management
</a>
</span>
</dt>
<dd>
<dl>
<dt>
<span class="section">
<a href="user-names.html">
8.2.1 Account User Names and Passwords
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="privileges-provided.html">
8.2.2 Privileges Provided by MySQL
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="grant-tables.html">
8.2.3 Grant Tables
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="account-names.html">
8.2.4 Specifying Account Names
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="role-names.html">
8.2.5 Specifying Role Names
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="connection-access.html">
8.2.6 Access Control, Stage 1: Connection Verification
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="request-access.html">
8.2.7 Access Control, Stage 2: Request Verification
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="creating-accounts.html">
8.2.8 Adding Accounts, Assigning Privileges, and Dropping Accounts
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="reserved-accounts.html">
8.2.9 Reserved Accounts
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="roles.html">
8.2.10 Using Roles
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="account-categories.html">
8.2.11 Account Categories
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="partial-revokes.html">
8.2.12 Privilege Restriction Using Partial Revokes
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="privilege-changes.html">
8.2.13 When Privilege Changes Take Effect
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="assigning-passwords.html">
8.2.14 Assigning Account Passwords
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="password-management.html">
8.2.15 Password Management
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="expired-password-handling.html">
8.2.16 Server Handling of Expired Passwords
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="pluggable-authentication.html">
8.2.17 Pluggable Authentication
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="multifactor-authentication.html">
8.2.18 Multifactor Authentication
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="proxy-users.html">
8.2.19 Proxy Users
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="account-locking.html">
8.2.20 Account Locking
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="user-resources.html">
8.2.21 Setting Account Resource Limits
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="problems-connecting.html">
8.2.22 Troubleshooting Problems Connecting to MySQL
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="account-activity-auditing.html">
8.2.23 SQL-Based Account Activity Auditing
</a>
</span>
</dt>
</dl>
</dd>
<dt>
<span class="section">
<a href="encrypted-connections.html">
8.3 Using Encrypted Connections
</a>
</span>
</dt>
<dd>
<dl>
<dt>
<span class="section">
<a href="using-encrypted-connections.html">
8.3.1 Configuring MySQL to Use Encrypted Connections
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="encrypted-connection-protocols-ciphers.html">
8.3.2 Encrypted Connection TLS Protocols and Ciphers
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="creating-ssl-rsa-files.html">
8.3.3 Creating SSL and RSA Certificates and Keys
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="windows-and-ssh.html">
8.3.4 Connecting to MySQL Remotely from Windows with SSH
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="reusing-ssl-sessions.html">
8.3.5 Reusing SSL Sessions
</a>
</span>
</dt>
</dl>
</dd>
<dt>
<span class="section">
<a href="security-plugins.html">
8.4 Security Components and Plugins
</a>
</span>
</dt>
<dd>
<dl>
<dt>
<span class="section">
<a href="authentication-plugins.html">
8.4.1 Authentication Plugins
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="connection-control.html">
8.4.2 The Connection-Control Plugins
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="validate-password.html">
8.4.3 The Password Validation Component
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="keyring.html">
8.4.4 The MySQL Keyring
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="audit-log.html">
8.4.5 MySQL Enterprise Audit
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="audit-api-message-emit.html">
8.4.6 The Audit Message Component
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="firewall.html">
8.4.7 MySQL Enterprise Firewall
</a>
</span>
</dt>
</dl>
</dd>
<dt>
<span class="section">
<a href="data-masking.html">
8.5 MySQL Enterprise Data Masking and De-Identification
</a>
</span>
</dt>
<dd>
<dl>
<dt>
<span class="section">
<a href="data-masking-components-vs-plugin.html">
8.5.1 Data-Masking Components Versus the Data-Masking Plugin
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="data-masking-components.html">
8.5.2 MySQL Enterprise Data Masking and De-Identification Components
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="data-masking-plugin.html">
8.5.3 MySQL Enterprise Data Masking and De-Identification Plugin
</a>
</span>
</dt>
</dl>
</dd>
<dt>
<span class="section">
<a href="enterprise-encryption.html">
8.6 MySQL Enterprise Encryption
</a>
</span>
</dt>
<dd>
<dl>
<dt>
<span class="section">
<a href="enterprise-encryption-installation.html">
8.6.1 MySQL Enterprise Encryption Installation and Upgrading
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="enterprise-encryption-configuring.html">
8.6.2 Configuring MySQL Enterprise Encryption
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="enterprise-encryption-usage.html">
8.6.3 MySQL Enterprise Encryption Usage and Examples
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="enterprise-encryption-function-reference.html">
8.6.4 MySQL Enterprise Encryption Function Reference
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="enterprise-encryption-functions.html">
8.6.5 MySQL Enterprise Encryption Component Function Descriptions
</a>
</span>
</dt>
</dl>
</dd>
<dt>
<span class="section">
<a href="selinux.html">
8.7 SELinux
</a>
</span>
</dt>
<dd>
<dl>
<dt>
<span class="section">
<a href="selinux-checking.html">
8.7.1 Check if SELinux is Enabled
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="selinux-mode.html">
8.7.2 Changing the SELinux Mode
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="selinux-policies.html">
8.7.3 MySQL Server SELinux Policies
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="selinux-file-context.html">
8.7.4 SELinux File Context
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="selinux-context-tcp-port.html">
8.7.5 SELinux TCP Port Context
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="selinux-troubleshooting.html">
8.7.6 Troubleshooting SELinux
</a>
</span>
</dt>
</dl>
</dd>
<dt>
<span class="section">
<a href="fips-mode.html">
8.8 FIPS Support
</a>
</span>
</dt>
</dl>
</div>
<p>
When thinking about security within a MySQL installation, you should
consider a wide range of possible topics and how they affect the
security of your MySQL server and related applications:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
General factors that affect security. These include choosing
good passwords, not granting unnecessary privileges to users,
ensuring application security by preventing SQL injections and
data corruption, and others. See
<a class="xref" href="general-security-issues.html" title="8.1 General Security Issues">
Section 8.1, “General Security Issues”
</a>
.
</p>
</li>
<li class="listitem">
<p>
Security of the installation itself. The data files, log files,
and the all the application files of your installation should be
protected to ensure that they are not readable or writable by
unauthorized parties. For more information, see
<a class="xref" href="postinstallation.html" title="2.9 Postinstallation Setup and Testing">
Section 2.9, “Postinstallation Setup and Testing”
</a>
.
</p>
</li>
<li class="listitem">
<p>
Access control and security within the database system itself,
including the users and databases granted with access to the
databases, views and stored programs in use within the database.
For more information, see
<a class="xref" href="access-control.html" title="8.2 Access Control and Account Management">
Section 8.2, “Access Control and Account Management”
</a>
.
</p>
</li>
<li class="listitem">
<p>
The features offered by security-related plugins. See
<a class="xref" href="security-plugins.html" title="8.4 Security Components and Plugins">
Section 8.4, “Security Components and Plugins”
</a>
.
</p>
</li>
<li class="listitem">
<p>
Network security of MySQL and your system. The security is
related to the grants for individual users, but you may also
wish to restrict MySQL so that it is available only locally on
the MySQL server host, or to a limited set of other hosts.
</p>
</li>
<li class="listitem">
<p>
Ensure that you have adequate and appropriate backups of your
database files, configuration and log files. Also be sure that
you have a recovery solution in place and test that you are able
to successfully recover the information from your backups. See
<a class="xref" href="backup-and-recovery.html" title="Chapter 9 Backup and Recovery">
Chapter 9,
<i>
Backup and Recovery
</i>
</a>
.
</p>
</li>
</ul>
</div>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
Several topics in this chapter are also addressed in the
<a class="ulink" href="/doc/mysql-secure-deployment-guide/en/" target="_top">
Secure
Deployment Guide
</a>
, which provides procedures for deploying
a generic binary distribution of MySQL Enterprise Edition Server with features for
managing the security of your MySQL installation.
</p>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/partitioning-pruning.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h2 class="title">
<a name="partitioning-pruning">
</a>
26.4 Partition Pruning
</h2>
</div>
</div>
</div>
<a class="indexterm" name="idm46045083359696">
</a>
<a class="indexterm" name="idm46045083358624">
</a>
<p>
The optimization known as
<span class="firstterm">
partition
pruning
</span>
is based on a relatively simple concept which
can be described as
<span class="quote">
“
<span class="quote">
Do not scan partitions where there can
be no matching values
</span>
”
</span>
. Suppose a partitioned table
<code class="literal">
t1
</code>
is created by this statement:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa2076728"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> t1 <span class="token punctuation">(</span>
fname <span class="token datatype">VARCHAR</span><span class="token punctuation">(</span><span class="token number">50</span><span class="token punctuation">)</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span><span class="token punctuation">,</span>
lname <span class="token datatype">VARCHAR</span><span class="token punctuation">(</span><span class="token number">50</span><span class="token punctuation">)</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span><span class="token punctuation">,</span>
region_code <span class="token datatype">TINYINT</span> <span class="token keyword">UNSIGNED</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span><span class="token punctuation">,</span>
dob <span class="token datatype">DATE</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span>
<span class="token punctuation">)</span>
<span class="token keyword">PARTITION</span> <span class="token keyword">BY</span> <span class="token keyword">RANGE</span><span class="token punctuation">(</span> region_code <span class="token punctuation">)</span> <span class="token punctuation">(</span>
<span class="token keyword">PARTITION</span> p0 <span class="token keyword">VALUES</span> <span class="token keyword">LESS</span> <span class="token keyword">THAN</span> <span class="token punctuation">(</span><span class="token number">64</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token keyword">PARTITION</span> p1 <span class="token keyword">VALUES</span> <span class="token keyword">LESS</span> <span class="token keyword">THAN</span> <span class="token punctuation">(</span><span class="token number">128</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token keyword">PARTITION</span> p2 <span class="token keyword">VALUES</span> <span class="token keyword">LESS</span> <span class="token keyword">THAN</span> <span class="token punctuation">(</span><span class="token number">192</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token keyword">PARTITION</span> p3 <span class="token keyword">VALUES</span> <span class="token keyword">LESS</span> <span class="token keyword">THAN</span> <span class="token keyword">MAXVALUE</span>
<span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
Suppose that you wish to obtain results from a
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
statement such as this one:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa56687889"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> fname<span class="token punctuation">,</span> lname<span class="token punctuation">,</span> region_code<span class="token punctuation">,</span> dob
<span class="token keyword">FROM</span> t1
<span class="token keyword">WHERE</span> region_code <span class="token operator">></span> <span class="token number">125</span> <span class="token operator">AND</span> region_code <span class="token operator"><</span> <span class="token number">130</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
It is easy to see that none of the rows which ought to be returned
are in either of the partitions
<code class="literal">
p0
</code>
or
<code class="literal">
p3
</code>
; that is, we need search only in partitions
<code class="literal">
p1
</code>
and
<code class="literal">
p2
</code>
to find matching
rows. By limiting the search, it is possible to expend much less
time and effort in finding matching rows than by scanning all
partitions in the table. This
<span class="quote">
“
<span class="quote">
cutting away
</span>
”
</span>
of
unneeded partitions is known as
<span class="firstterm">
pruning
</span>
. When the optimizer
can make use of partition pruning in performing this query,
execution of the query can be an order of magnitude faster than
the same query against a nonpartitioned table containing the same
column definitions and data.
</p>
<p>
The optimizer can perform pruning whenever a
<code class="literal">
WHERE
</code>
condition can be reduced to either one of
the following two cases:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
<em class="replaceable">
<code>
partition_column
</code>
</em>
=
<em class="replaceable">
<code>
constant
</code>
</em>
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<em class="replaceable">
<code>
partition_column
</code>
</em>
IN
(
<em class="replaceable">
<code>
constant1
</code>
</em>
,
<em class="replaceable">
<code>
constant2
</code>
</em>
, ...,
<em class="replaceable">
<code>
constantN
</code>
</em>
)
</code>
</p>
</li>
</ul>
</div>
<p>
In the first case, the optimizer simply evaluates the partitioning
expression for the value given, determines which partition
contains that value, and scans only this partition. In many cases,
the equal sign can be replaced with another arithmetic comparison,
including
<code class="literal">
<
</code>
,
<code class="literal">
>
</code>
,
<code class="literal">
<=
</code>
,
<code class="literal">
>=
</code>
, and
<code class="literal">
<>
</code>
. Some queries using
<code class="literal">
BETWEEN
</code>
in the
<code class="literal">
WHERE
</code>
clause
can also take advantage of partition pruning. See the examples
later in this section.
</p>
<p>
In the second case, the optimizer evaluates the partitioning
expression for each value in the list, creates a list of matching
partitions, and then scans only the partitions in this partition
list.
</p>
<p>
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
,
<a class="link" href="delete.html" title="15.2.2 DELETE Statement">
<code class="literal">
DELETE
</code>
</a>
, and
<a class="link" href="update.html" title="15.2.17 UPDATE Statement">
<code class="literal">
UPDATE
</code>
</a>
statements support partition
pruning. An
<a class="link" href="insert.html" title="15.2.7 INSERT Statement">
<code class="literal">
INSERT
</code>
</a>
statement also
accesses only one partition per inserted row; this is true even
for a table that is partitioned by
<code class="literal">
HASH
</code>
or
<code class="literal">
KEY
</code>
although this is not currently shown in the
output of
<a class="link" href="explain.html" title="15.8.2 EXPLAIN Statement">
<code class="literal">
EXPLAIN
</code>
</a>
.
</p>
<p>
Pruning can also be applied to short ranges, which the optimizer
can convert into equivalent lists of values. For instance, in the
previous example, the
<code class="literal">
WHERE
</code>
clause can be
converted to
<code class="literal">
WHERE region_code IN (126, 127, 128,
129)
</code>
. Then the optimizer can determine that the first
two values in the list are found in partition
<code class="literal">
p1
</code>
, the remaining two values in partition
<code class="literal">
p2
</code>
, and that the other partitions contain no
relevant values and so do not need to be searched for matching
rows.
</p>
<p>
The optimizer can also perform pruning for
<code class="literal">
WHERE
</code>
conditions that involve comparisons of
the preceding types on multiple columns for tables that use
<code class="literal">
RANGE COLUMNS
</code>
or
<code class="literal">
LIST
COLUMNS
</code>
partitioning.
</p>
<a class="indexterm" name="idm46045083318064">
</a>
<p>
This type of optimization can be applied whenever the partitioning
expression consists of an equality or a range which can be reduced
to a set of equalities, or when the partitioning expression
represents an increasing or decreasing relationship. Pruning can
also be applied for tables partitioned on a
<a class="link" href="datetime.html" title="13.2.2 The DATE, DATETIME, and TIMESTAMP Types">
<code class="literal">
DATE
</code>
</a>
or
<a class="link" href="datetime.html" title="13.2.2 The DATE, DATETIME, and TIMESTAMP Types">
<code class="literal">
DATETIME
</code>
</a>
column when the
partitioning expression uses the
<a class="link" href="date-and-time-functions.html#function_year">
<code class="literal">
YEAR()
</code>
</a>
or
<a class="link" href="date-and-time-functions.html#function_to-days">
<code class="literal">
TO_DAYS()
</code>
</a>
function. Pruning can
also be applied for such tables when the partitioning expression
uses the
<a class="link" href="date-and-time-functions.html#function_to-seconds">
<code class="literal">
TO_SECONDS()
</code>
</a>
function.
</p>
<p>
Suppose that table
<code class="literal">
t2
</code>
, partitioned on a
<a class="link" href="datetime.html" title="13.2.2 The DATE, DATETIME, and TIMESTAMP Types">
<code class="literal">
DATE
</code>
</a>
column, is created using the
statement shown here:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa48450255"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> t2 <span class="token punctuation">(</span>
fname <span class="token datatype">VARCHAR</span><span class="token punctuation">(</span><span class="token number">50</span><span class="token punctuation">)</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span><span class="token punctuation">,</span>
lname <span class="token datatype">VARCHAR</span><span class="token punctuation">(</span><span class="token number">50</span><span class="token punctuation">)</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span><span class="token punctuation">,</span>
region_code <span class="token datatype">TINYINT</span> <span class="token keyword">UNSIGNED</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span><span class="token punctuation">,</span>
dob <span class="token datatype">DATE</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span>
<span class="token punctuation">)</span>
<span class="token keyword">PARTITION</span> <span class="token keyword">BY</span> <span class="token keyword">RANGE</span><span class="token punctuation">(</span> <span class="token function">YEAR</span><span class="token punctuation">(</span>dob<span class="token punctuation">)</span> <span class="token punctuation">)</span> <span class="token punctuation">(</span>
<span class="token keyword">PARTITION</span> d0 <span class="token keyword">VALUES</span> <span class="token keyword">LESS</span> <span class="token keyword">THAN</span> <span class="token punctuation">(</span><span class="token number">1970</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token keyword">PARTITION</span> d1 <span class="token keyword">VALUES</span> <span class="token keyword">LESS</span> <span class="token keyword">THAN</span> <span class="token punctuation">(</span><span class="token number">1975</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token keyword">PARTITION</span> d2 <span class="token keyword">VALUES</span> <span class="token keyword">LESS</span> <span class="token keyword">THAN</span> <span class="token punctuation">(</span><span class="token number">1980</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token keyword">PARTITION</span> d3 <span class="token keyword">VALUES</span> <span class="token keyword">LESS</span> <span class="token keyword">THAN</span> <span class="token punctuation">(</span><span class="token number">1985</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token keyword">PARTITION</span> d4 <span class="token keyword">VALUES</span> <span class="token keyword">LESS</span> <span class="token keyword">THAN</span> <span class="token punctuation">(</span><span class="token number">1990</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token keyword">PARTITION</span> d5 <span class="token keyword">VALUES</span> <span class="token keyword">LESS</span> <span class="token keyword">THAN</span> <span class="token punctuation">(</span><span class="token number">2000</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token keyword">PARTITION</span> d6 <span class="token keyword">VALUES</span> <span class="token keyword">LESS</span> <span class="token keyword">THAN</span> <span class="token punctuation">(</span><span class="token number">2005</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token keyword">PARTITION</span> d7 <span class="token keyword">VALUES</span> <span class="token keyword">LESS</span> <span class="token keyword">THAN</span> <span class="token keyword">MAXVALUE</span>
<span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
The following statements using
<code class="literal">
t2
</code>
can make of
use partition pruning:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa11017501"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t2 <span class="token keyword">WHERE</span> dob <span class="token operator">=</span> <span class="token string">'1982-06-23'</span><span class="token punctuation">;</span>
<span class="token keyword">UPDATE</span> t2 <span class="token keyword">SET</span> region_code <span class="token operator">=</span> <span class="token number">8</span> <span class="token keyword">WHERE</span> dob <span class="token operator">BETWEEN</span> <span class="token string">'1991-02-15'</span> <span class="token operator">AND</span> <span class="token string">'1997-04-25'</span><span class="token punctuation">;</span>
<span class="token keyword">DELETE</span> <span class="token keyword">FROM</span> t2 <span class="token keyword">WHERE</span> dob <span class="token operator">>=</span> <span class="token string">'1984-06-21'</span> <span class="token operator">AND</span> dob <span class="token operator"><=</span> <span class="token string">'1999-06-21'</span></code></pre>
</div>
<p>
In the case of the last statement, the optimizer can also act as
follows:
</p>
<div class="orderedlist">
<ol class="orderedlist" type="1">
<li class="listitem">
<p>
<span class="emphasis">
<em>
Find the partition containing the low end of the
range
</em>
</span>
.
</p>
<p>
<a class="link" href="date-and-time-functions.html#function_year">
<code class="literal">
YEAR('1984-06-21')
</code>
</a>
yields the
value
<code class="literal">
1984
</code>
, which is found in partition
<code class="literal">
d3
</code>
.
</p>
</li>
<li class="listitem">
<p>
<span class="emphasis">
<em>
Find the partition containing the high end of the
range
</em>
</span>
.
</p>
<p>
<a class="link" href="date-and-time-functions.html#function_year">
<code class="literal">
YEAR('1999-06-21')
</code>
</a>
evaluates to
<code class="literal">
1999
</code>
, which is found in partition
<code class="literal">
d5
</code>
.
</p>
</li>
<li class="listitem">
<p>
<span class="emphasis">
<em>
Scan only these two partitions and any partitions
that may lie between them
</em>
</span>
.
</p>
<p>
In this case, this means that only partitions
<code class="literal">
d3
</code>
,
<code class="literal">
d4
</code>
, and
<code class="literal">
d5
</code>
are scanned. The remaining partitions
may be safely ignored (and are ignored).
</p>
</li>
</ol>
</div>
<div class="important" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Important
</div>
<p>
Invalid
<code class="literal">
DATE
</code>
and
<code class="literal">
DATETIME
</code>
values referenced in the
<code class="literal">
WHERE
</code>
condition of a
statement against a partitioned table are treated as
<code class="literal">
NULL
</code>
. This means that a query such as
<code class="literal">
SELECT * FROM
<em class="replaceable">
<code>
partitioned_table
</code>
</em>
WHERE
<em class="replaceable">
<code>
date_column
</code>
</em>
<
'2008-12-00'
</code>
does not return any values (see Bug
#40972).
</p>
</div>
<p>
So far, we have looked only at examples using
<code class="literal">
RANGE
</code>
partitioning, but pruning can be applied
with other partitioning types as well.
</p>
<p>
Consider a table that is partitioned by
<code class="literal">
LIST
</code>
,
where the partitioning expression is increasing or decreasing,
such as the table
<code class="literal">
t3
</code>
shown here. (In this
example, we assume for the sake of brevity that the
<code class="literal">
region_code
</code>
column is limited to values between
1 and 10 inclusive.)
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa88609797"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> t3 <span class="token punctuation">(</span>
fname <span class="token datatype">VARCHAR</span><span class="token punctuation">(</span><span class="token number">50</span><span class="token punctuation">)</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span><span class="token punctuation">,</span>
lname <span class="token datatype">VARCHAR</span><span class="token punctuation">(</span><span class="token number">50</span><span class="token punctuation">)</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span><span class="token punctuation">,</span>
region_code <span class="token datatype">TINYINT</span> <span class="token keyword">UNSIGNED</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span><span class="token punctuation">,</span>
dob <span class="token datatype">DATE</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span>
<span class="token punctuation">)</span>
<span class="token keyword">PARTITION</span> <span class="token keyword">BY</span> <span class="token keyword">LIST</span><span class="token punctuation">(</span>region_code<span class="token punctuation">)</span> <span class="token punctuation">(</span>
<span class="token keyword">PARTITION</span> r0 <span class="token keyword">VALUES</span> <span class="token keyword">IN</span> <span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token keyword">PARTITION</span> r1 <span class="token keyword">VALUES</span> <span class="token keyword">IN</span> <span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">5</span><span class="token punctuation">,</span> <span class="token number">8</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token keyword">PARTITION</span> r2 <span class="token keyword">VALUES</span> <span class="token keyword">IN</span> <span class="token punctuation">(</span><span class="token number">4</span><span class="token punctuation">,</span> <span class="token number">9</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token keyword">PARTITION</span> r3 <span class="token keyword">VALUES</span> <span class="token keyword">IN</span> <span class="token punctuation">(</span><span class="token number">6</span><span class="token punctuation">,</span> <span class="token number">7</span><span class="token punctuation">,</span> <span class="token number">10</span><span class="token punctuation">)</span>
<span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
For a statement such as
<code class="literal">
SELECT * FROM t3 WHERE
region_code BETWEEN 1 AND 3
</code>
, the optimizer determines in
which partitions the values 1, 2, and 3 are found
(
<code class="literal">
r0
</code>
and
<code class="literal">
r1
</code>
) and skips the
remaining ones (
<code class="literal">
r2
</code>
and
<code class="literal">
r3
</code>
).
</p>
<p>
For tables that are partitioned by
<code class="literal">
HASH
</code>
or
<code class="literal">
[LINEAR] KEY
</code>
, partition pruning is also
possible in cases in which the
<code class="literal">
WHERE
</code>
clause
uses a simple
<code class="literal">
=
</code>
relation against a column used
in the partitioning expression. Consider a table created like
this:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa58670312"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> t4 <span class="token punctuation">(</span>
fname <span class="token datatype">VARCHAR</span><span class="token punctuation">(</span><span class="token number">50</span><span class="token punctuation">)</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span><span class="token punctuation">,</span>
lname <span class="token datatype">VARCHAR</span><span class="token punctuation">(</span><span class="token number">50</span><span class="token punctuation">)</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span><span class="token punctuation">,</span>
region_code <span class="token datatype">TINYINT</span> <span class="token keyword">UNSIGNED</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span><span class="token punctuation">,</span>
dob <span class="token datatype">DATE</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span>
<span class="token punctuation">)</span>
<span class="token keyword">PARTITION</span> <span class="token keyword">BY</span> <span class="token keyword">KEY</span><span class="token punctuation">(</span>region_code<span class="token punctuation">)</span>
<span class="token keyword">PARTITIONS</span> <span class="token number">8</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
A statement that compares a column value with a constant can be
pruned:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa23312537"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">UPDATE</span> t4 <span class="token keyword">WHERE</span> region_code <span class="token operator">=</span> <span class="token number">7</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
Pruning can also be employed for short ranges, because the
optimizer can turn such conditions into
<code class="literal">
IN
</code>
relations. For example, using the same table
<code class="literal">
t4
</code>
as defined previously, queries such as these can be pruned:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa55862727"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t4 <span class="token keyword">WHERE</span> region_code <span class="token operator">></span> <span class="token number">2</span> <span class="token operator">AND</span> region_code <span class="token operator"><</span> <span class="token number">6</span><span class="token punctuation">;</span>
<span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t4 <span class="token keyword">WHERE</span> region_code <span class="token operator">BETWEEN</span> <span class="token number">3</span> <span class="token operator">AND</span> <span class="token number">5</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
In both these cases, the
<code class="literal">
WHERE
</code>
clause is
transformed by the optimizer into
<code class="literal">
WHERE region_code IN
(3, 4, 5)
</code>
.
</p>
<div class="important" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Important
</div>
<p>
This optimization is used only if the range size is smaller than
the number of partitions. Consider this statement:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa89894967"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">DELETE</span> <span class="token keyword">FROM</span> t4 <span class="token keyword">WHERE</span> region_code <span class="token operator">BETWEEN</span> <span class="token number">4</span> <span class="token operator">AND</span> <span class="token number">12</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
The range in the
<code class="literal">
WHERE
</code>
clause covers 9 values
(4, 5, 6, 7, 8, 9, 10, 11, 12), but
<code class="literal">
t4
</code>
has
only 8 partitions. This means that the
<code class="literal">
DELETE
</code>
cannot be pruned.
</p>
</div>
<p>
When a table is partitioned by
<code class="literal">
HASH
</code>
or
<code class="literal">
[LINEAR] KEY
</code>
, pruning can be used only on
integer columns. For example, this statement cannot use pruning
because
<code class="literal">
dob
</code>
is a
<a class="link" href="datetime.html" title="13.2.2 The DATE, DATETIME, and TIMESTAMP Types">
<code class="literal">
DATE
</code>
</a>
column:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa16811410"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t4 <span class="token keyword">WHERE</span> dob <span class="token operator">>=</span> <span class="token string">'2001-04-14'</span> <span class="token operator">AND</span> dob <span class="token operator"><=</span> <span class="token string">'2005-10-15'</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
However, if the table stores year values in an
<a class="link" href="integer-types.html" title="13.1.2 Integer Types (Exact Value) - INTEGER, INT, SMALLINT, TINYINT, MEDIUMINT, BIGINT">
<code class="literal">
INT
</code>
</a>
column, then a query having
<code class="literal">
WHERE year_col >= 2001 AND year_col <=
2005
</code>
can be pruned.
</p>
<p>
Tables using a storage engine that provides automatic
partitioning, such as the
<code class="literal">
NDB
</code>
storage engine
used by MySQL Cluster can be pruned if they are explicitly
partitioned.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/mysql.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="mysql">
</a>
6.5.1 mysql — The MySQL Command-Line Client
</h3>
</div>
</div>
</div>
<div class="toc">
<dl class="toc">
<dt>
<span class="section">
<a href="mysql-command-options.html">
6.5.1.1 mysql Client Options
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="mysql-commands.html">
6.5.1.2 mysql Client Commands
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="mysql-logging.html">
6.5.1.3 mysql Client Logging
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="mysql-server-side-help.html">
6.5.1.4 mysql Client Server-Side Help
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="mysql-batch-commands.html">
6.5.1.5 Executing SQL Statements from a Text File
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="mysql-tips.html">
6.5.1.6 mysql Client Tips
</a>
</span>
</dt>
</dl>
</div>
<a class="indexterm" name="idm46045320189424">
</a>
<a class="indexterm" name="idm46045320188512">
</a>
<a class="indexterm" name="idm46045320187568">
</a>
<a class="indexterm" name="idm46045320186208">
</a>
<a class="indexterm" name="idm46045320184880">
</a>
<a class="indexterm" name="idm46045320183936">
</a>
<p>
<a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
<span class="command">
<strong>
mysql
</strong>
</span>
</a>
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. The
output format can be changed using command options.
</p>
<p>
If you have problems due to insufficient memory for large result
sets, use the
<a class="link" href="mysql-command-options.html#option_mysql_quick">
<code class="option">
--quick
</code>
</a>
option. This
forces
<a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
<span class="command">
<strong>
mysql
</strong>
</span>
</a>
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
<a class="ulink" href="/doc/c-api/8.4/en/mysql-use-result.html" target="_top">
<code class="literal">
mysql_use_result()
</code>
</a>
C API
function in the client/server library rather than
<a class="ulink" href="/doc/c-api/8.4/en/mysql-store-result.html" target="_top">
<code class="literal">
mysql_store_result()
</code>
</a>
.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
Alternatively, MySQL Shell offers access to the X DevAPI.
For details, see
<a class="ulink" href="/doc/mysql-shell/8.4/en/" target="_top">
MySQL Shell 8.4
</a>
.
</p>
</div>
<p>
Using
<a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
<span class="command">
<strong>
mysql
</strong>
</span>
</a>
is very easy. Invoke it from the
prompt of your command interpreter as follows:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa82751612"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal">mysql <em class="replaceable">db_name</em></code></pre>
</div>
<p>
Or:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa68282614"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal">mysql <span class="token constant">--user</span><span class="token attr-value"><span class="token punctuation">=</span><em class="replaceable">user_name</em></span> <span class="token property">--password</span> <em class="replaceable">db_name</em></code></pre>
</div>
<p>
In this case, you'll need to enter your password in response to
the prompt that
<a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
<span class="command">
<strong>
mysql
</strong>
</span>
</a>
displays:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa12974386"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal">Enter password<span class="token punctuation">:</span> <em class="replaceable">your_password</em></code></pre>
</div>
<p>
Then type an SQL statement, end it with
<code class="literal">
;
</code>
,
<code class="literal">
\g
</code>
, or
<code class="literal">
\G
</code>
and press Enter.
</p>
<p>
Typing
<span class="keycap">
<strong>
Control+C
</strong>
</span>
interrupts the current
statement if there is one, or cancels any partial input line
otherwise.
</p>
<a class="indexterm" name="idm46045320161488">
</a>
<a class="indexterm" name="idm46045320160000">
</a>
<p>
You can execute SQL statements in a script file (batch file)
like this:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa33882092"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal">mysql <em class="replaceable">db_name</em> < <em class="replaceable">script<span class="token punctuation">.</span>sql</em> > <em class="replaceable">output<span class="token punctuation">.</span>tab</em></code></pre>
</div>
<p>
On Unix, the
<a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
<span class="command">
<strong>
mysql
</strong>
</span>
</a>
client logs statements
executed interactively to a history file. See
<a class="xref" href="mysql-logging.html" title="6.5.1.3 mysql Client Logging">
Section 6.5.1.3, “mysql Client Logging”
</a>
.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/innodb-compression-background.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="innodb-compression-background">
</a>
17.9.1.1 Overview of Table Compression
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045161751456">
</a>
<p>
Because processors and cache memories have increased in speed
more than disk storage devices, many workloads are
<a class="link" href="glossary.html#glos_disk_bound" title="disk-bound">
disk-bound
</a>
. Data
<a class="link" href="glossary.html#glos_compression" title="compression">
compression
</a>
enables
smaller database size, reduced I/O, and improved throughput, at
the small cost of increased CPU utilization. Compression is
especially valuable for read-intensive applications, on systems
with enough RAM to keep frequently used data in memory.
</p>
<p>
An
<code class="literal">
InnoDB
</code>
table created with
<code class="literal">
ROW_FORMAT=COMPRESSED
</code>
can use a smaller
<a class="link" href="glossary.html#glos_page_size" title="page size">
page size
</a>
on disk than the
configured
<a class="link" href="innodb-parameters.html#sysvar_innodb_page_size">
<code class="literal">
innodb_page_size
</code>
</a>
value. Smaller pages require less I/O to read from and write to
disk, which is especially valuable for
<a class="link" href="glossary.html#glos_ssd" title="SSD">
SSD
</a>
devices.
</p>
<p>
The compressed page size is specified through the
<a class="link" href="create-table.html" title="15.1.20 CREATE TABLE Statement">
<code class="literal">
CREATE TABLE
</code>
</a>
or
<a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
<code class="literal">
ALTER TABLE
</code>
</a>
<code class="literal">
KEY_BLOCK_SIZE
</code>
parameter. The different page
size requires that the table be placed in a
<a class="link" href="glossary.html#glos_file_per_table" title="file-per-table">
file-per-table
</a>
tablespace or
<a class="link" href="glossary.html#glos_general_tablespace" title="general tablespace">
general
tablespace
</a>
rather than in the
<a class="link" href="glossary.html#glos_system_tablespace" title="system tablespace">
system tablespace
</a>
,
as the system tablespace cannot store compressed tables. For
more information, see
<a class="xref" href="innodb-file-per-table-tablespaces.html" title="17.6.3.2 File-Per-Table Tablespaces">
Section 17.6.3.2, “File-Per-Table Tablespaces”
</a>
, and
<a class="xref" href="general-tablespaces.html" title="17.6.3.3 General Tablespaces">
Section 17.6.3.3, “General Tablespaces”
</a>
.
</p>
<p>
The level of compression is the same regardless of the
<code class="literal">
KEY_BLOCK_SIZE
</code>
value. As you specify smaller
values for
<code class="literal">
KEY_BLOCK_SIZE
</code>
, you get the I/O
benefits of increasingly smaller pages. But if you specify a
value that is too small, there is additional overhead to
reorganize the pages when data values cannot be compressed
enough to fit multiple rows in each page. There is a hard limit
on how small
<code class="literal">
KEY_BLOCK_SIZE
</code>
can be for a
table, based on the lengths of the key columns for each of its
indexes. Specify a value that is too small, and the
<a class="link" href="create-table.html" title="15.1.20 CREATE TABLE Statement">
<code class="literal">
CREATE TABLE
</code>
</a>
or
<a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
<code class="literal">
ALTER TABLE
</code>
</a>
statement fails.
</p>
<p>
In the buffer pool, the compressed data is held in small pages,
with a page size based on the
<code class="literal">
KEY_BLOCK_SIZE
</code>
value. For extracting or updating the column values, MySQL also
creates an uncompressed page in the buffer pool with the
uncompressed data. Within the buffer pool, any updates to the
uncompressed page are also re-written back to the equivalent
compressed page. You might need to size your buffer pool to
accommodate the additional data of both compressed and
uncompressed pages, although the uncompressed pages are
<a class="link" href="glossary.html#glos_eviction" title="eviction">
evicted
</a>
from the buffer
pool when space is needed, and then uncompressed again on the
next access.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/group-replication-online-upgrade.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="group-replication-online-upgrade">
</a>
20.8.3 Group Replication Online Upgrade
</h3>
</div>
</div>
</div>
<div class="toc">
<dl class="toc">
<dt>
<span class="section">
<a href="group-replication-online-upgrade-considerations.html">
20.8.3.1 Online Upgrade Considerations
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="group-replication-upgrading-member.html">
20.8.3.2 Upgrading a Group Replication Member
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="group-replication-online-upgrade-methods.html">
20.8.3.3 Group Replication Online Upgrade Methods
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="group-replication-upgrade-with-mysqlbackup.html">
20.8.3.4 Group Replication Upgrade with mysqlbackup
</a>
</span>
</dt>
</dl>
</div>
<a class="indexterm" name="idm46045131610112">
</a>
<p>
When you have a group running which you want to upgrade but you
need to keep the group online to serve your application, you need
to consider your approach to the upgrade. This section describes
the different elements involved in an online upgrade, and various
methods of how to upgrade your group.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/performance-schema-accounts-table.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="performance-schema-accounts-table">
</a>
29.12.8.1 The accounts Table
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045072098192">
</a>
<a class="indexterm" name="idm46045072096704">
</a>
<p>
The
<a class="link" href="performance-schema-accounts-table.html" title="29.12.8.1 The accounts Table">
<code class="literal">
accounts
</code>
</a>
table contains a row
for each account that has connected to the MySQL server. For
each account, the table counts the current and total number of
connections. The table size is autosized at server startup. To
set the table size explicitly, set the
<a class="link" href="performance-schema-system-variables.html#sysvar_performance_schema_accounts_size">
<code class="literal">
performance_schema_accounts_size
</code>
</a>
system variable at server startup. To disable account
statistics, set this variable to 0.
</p>
<p>
The
<a class="link" href="performance-schema-accounts-table.html" title="29.12.8.1 The accounts Table">
<code class="literal">
accounts
</code>
</a>
table has the
following columns. For a description of how the Performance
Schema maintains rows in this table, including the effect of
<a class="link" href="truncate-table.html" title="15.1.37 TRUNCATE TABLE Statement">
<code class="literal">
TRUNCATE TABLE
</code>
</a>
, see
<a class="xref" href="performance-schema-connection-tables.html" title="29.12.8 Performance Schema Connection Tables">
Section 29.12.8, “Performance Schema Connection Tables”
</a>
.
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
USER
</code>
</p>
<p>
The client user name for the connection. This is
<code class="literal">
NULL
</code>
for an internal thread, or for a
user session that failed to authenticate.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
HOST
</code>
</p>
<p>
The host from which the client connected. This is
<code class="literal">
NULL
</code>
for an internal thread, or for a
user session that failed to authenticate.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
CURRENT_CONNECTIONS
</code>
</p>
<p>
The current number of connections for the account.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
TOTAL_CONNECTIONS
</code>
</p>
<p>
The total number of connections for the account.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MAX_SESSION_CONTROLLED_MEMORY
</code>
</p>
<p>
Reports the maximum amount of controlled memory used by a
session belonging to the account.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MAX_SESSION_TOTAL_MEMORY
</code>
</p>
<p>
Reports the maximum amount of memory used by a session
belonging to the account.
</p>
</li>
</ul>
</div>
<p>
The
<a class="link" href="performance-schema-accounts-table.html" title="29.12.8.1 The accounts Table">
<code class="literal">
accounts
</code>
</a>
table has these
indexes:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Primary key on (
<code class="literal">
USER
</code>
,
<code class="literal">
HOST
</code>
)
</p>
</li>
</ul>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/innodb-benchmarking.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="innodb-benchmarking">
</a>
17.1.4 Testing and Benchmarking with InnoDB
</h3>
</div>
</div>
</div>
<p>
If
<code class="literal">
InnoDB
</code>
is not the default storage engine,
you can determine if your database server and applications work
correctly with
<code class="literal">
InnoDB
</code>
by restarting the server
with
<a class="link" href="server-system-variables.html#sysvar_default_storage_engine">
<code class="literal">
--default-storage-engine=InnoDB
</code>
</a>
defined on the command line or with
<a class="link" href="server-system-variables.html#sysvar_default_storage_engine">
<code class="literal">
default-storage-engine=innodb
</code>
</a>
defined in the
<code class="literal">
[mysqld]
</code>
section of the MySQL
server option file.
</p>
<p>
Since changing the default storage engine only affects newly
created tables, run your application installation and setup steps
to confirm that everything installs properly, then exercise the
application features to make sure the data loading, editing, and
querying features work. If a table relies on a feature that is
specific to another storage engine, you receive an error. In this
case, add the
<code class="literal">
ENGINE=
<em class="replaceable">
<code>
other_engine_name
</code>
</em>
</code>
clause to the
<a class="link" href="create-table.html" title="15.1.20 CREATE TABLE Statement">
<code class="literal">
CREATE TABLE
</code>
</a>
statement to avoid the error.
</p>
<p>
If you did not make a deliberate decision about the storage
engine, and you want to preview how certain tables work when
created using
<code class="literal">
InnoDB
</code>
, issue the command
<a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
<code class="literal">
ALTER TABLE
table_name ENGINE=InnoDB;
</code>
</a>
for each table. Alternatively,
to run test queries and other statements without disturbing the
original table, make a copy:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa17244465"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span> <span class="token keyword">ENGINE</span><span class="token operator">=</span>InnoDB <span class="token keyword">AS</span> <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> <em class="replaceable">other_engine_table</em><span class="token punctuation">;</span></code></pre>
</div>
<p>
To assess performance with a full application under a realistic
workload, install the latest MySQL server and run benchmarks.
</p>
<p>
Test the full application lifecycle, from installation, through
heavy usage, and server restart. Kill the server process while the
database is busy to simulate a power failure, and verify that the
data is recovered successfully when you restart the server.
</p>
<p>
Test any replication configurations, especially if you use
different MySQL versions and options on the source server and
replicas.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/performance-schema-consumer-configurations.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="performance-schema-consumer-configurations">
</a>
29.4.8 Example Consumer Configurations
</h3>
</div>
</div>
</div>
<p>
The consumer settings in the
<a class="link" href="performance-schema-setup-consumers-table.html" title="29.12.2.2 The setup_consumers Table">
<code class="literal">
setup_consumers
</code>
</a>
table form a
hierarchy from higher levels to lower. The following discussion
describes how consumers work, showing specific configurations
and their effects as consumer settings are enabled progressively
from high to low. The consumer values shown are representative.
The general principles described here apply to other consumer
values that may be available.
</p>
<p>
The configuration descriptions occur in order of increasing
functionality and overhead. If you do not need the information
provided by enabling lower-level settings, disable them so that
the Performance Schema executes less code on your behalf and
there is less information to sift through.
</p>
<p>
The
<a class="link" href="performance-schema-setup-consumers-table.html" title="29.12.2.2 The setup_consumers Table">
<code class="literal">
setup_consumers
</code>
</a>
table contains
the following hierarchy of values:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-none"><div class="docs-select-all right" id="sa46881541"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-none">global_instrumentation
thread_instrumentation
events_waits_current
events_waits_history
events_waits_history_long
events_stages_current
events_stages_history
events_stages_history_long
events_statements_current
events_statements_history
events_statements_history_long
events_transactions_current
events_transactions_history
events_transactions_history_long
statements_digest</code></pre>
</div>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
In the consumer hierarchy, the consumers for waits, stages,
statements, and transactions are all at the same level. This
differs from the event nesting hierarchy, for which wait
events nest within stage events, which nest within statement
events, which nest within transaction events.
</p>
</div>
<p>
If a given consumer setting is
<code class="literal">
NO
</code>
, the
Performance Schema disables the instrumentation associated with
the consumer and ignores all lower-level settings. If a given
setting is
<code class="literal">
YES
</code>
, the Performance Schema
enables the instrumentation associated with it and checks the
settings at the next lowest level. For a description of the
rules for each consumer, see
<a class="xref" href="performance-schema-consumer-filtering.html" title="29.4.7 Pre-Filtering by Consumer">
Section 29.4.7, “Pre-Filtering by Consumer”
</a>
.
</p>
<p>
For example, if
<code class="literal">
global_instrumentation
</code>
is
enabled,
<code class="literal">
thread_instrumentation
</code>
is checked.
If
<code class="literal">
thread_instrumentation
</code>
is enabled, the
<code class="literal">
events_
<em class="replaceable">
<code>
xxx
</code>
</em>
_current
</code>
consumers are checked. If of these
<code class="literal">
events_waits_current
</code>
is enabled,
<code class="literal">
events_waits_history
</code>
and
<code class="literal">
events_waits_history_long
</code>
are checked.
</p>
<p>
Each of the following configuration descriptions indicates which
setup elements the Performance Schema checks and which output
tables it maintains (that is, for which tables it collects
information).
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="xref" href="performance-schema-consumer-configurations.html#performance-schema-consumer-configurations-no-instrumentation" title="No Instrumentation">
No Instrumentation
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="performance-schema-consumer-configurations.html#performance-schema-consumer-configurations-global-instrumentation-only" title="Global Instrumentation Only">
Global Instrumentation Only
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="performance-schema-consumer-configurations.html#performance-schema-consumer-configurations-global-and-thread-instrumentation-only" title="Global and Thread Instrumentation Only">
Global and Thread Instrumentation Only
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="performance-schema-consumer-configurations.html#performance-schema-consumer-configurations-global-thread-and-current-event-instrumentation" title="Global, Thread, and Current-Event Instrumentation">
Global, Thread, and Current-Event Instrumentation
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="performance-schema-consumer-configurations.html#performance-schema-consumer-configurations-global-thread-current-event-and-event-history-instrumentation" title="Global, Thread, Current-Event, and Event-History instrumentation">
Global, Thread, Current-Event, and Event-History instrumentation
</a>
</p>
</li>
</ul>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h4 class="title">
<a name="performance-schema-consumer-configurations-no-instrumentation">
</a>
No Instrumentation
</h4>
</div>
</div>
</div>
<p>
Server configuration state:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa84373279"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> performance_schema<span class="token punctuation">.</span>setup_consumers<span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> NAME <span class="token punctuation">|</span> ENABLED <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> global_instrumentation <span class="token punctuation">|</span> NO <span class="token punctuation">|</span></span>
<span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
<p>
In this configuration, nothing is instrumented.
</p>
<p>
Setup elements checked:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Table
<a class="link" href="performance-schema-setup-consumers-table.html" title="29.12.2.2 The setup_consumers Table">
<code class="literal">
setup_consumers
</code>
</a>
,
consumer
<code class="literal">
global_instrumentation
</code>
</p>
</li>
</ul>
</div>
<p>
Output tables maintained:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
None
</p>
</li>
</ul>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h4 class="title">
<a name="performance-schema-consumer-configurations-global-instrumentation-only">
</a>
Global Instrumentation Only
</h4>
</div>
</div>
</div>
<p>
Server configuration state:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa87178558"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> performance_schema<span class="token punctuation">.</span>setup_consumers<span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> NAME <span class="token punctuation">|</span> ENABLED <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> global_instrumentation <span class="token punctuation">|</span> YES <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> thread_instrumentation <span class="token punctuation">|</span> NO <span class="token punctuation">|</span></span>
<span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
<p>
In this configuration, instrumentation is maintained only for
global states. Per-thread instrumentation is disabled.
</p>
<p>
Additional setup elements checked, relative to the preceding
configuration:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Table
<a class="link" href="performance-schema-setup-consumers-table.html" title="29.12.2.2 The setup_consumers Table">
<code class="literal">
setup_consumers
</code>
</a>
,
consumer
<code class="literal">
thread_instrumentation
</code>
</p>
</li>
<li class="listitem">
<p>
Table
<a class="link" href="performance-schema-setup-instruments-table.html" title="29.12.2.3 The setup_instruments Table">
<code class="literal">
setup_instruments
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
Table
<a class="link" href="performance-schema-setup-objects-table.html" title="29.12.2.4 The setup_objects Table">
<code class="literal">
setup_objects
</code>
</a>
</p>
</li>
</ul>
</div>
<p>
Additional output tables maintained, relative to the preceding
configuration:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="link" href="performance-schema-mutex-instances-table.html" title="29.12.3.3 The mutex_instances Table">
<code class="literal">
mutex_instances
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="performance-schema-rwlock-instances-table.html" title="29.12.3.4 The rwlock_instances Table">
<code class="literal">
rwlock_instances
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="performance-schema-cond-instances-table.html" title="29.12.3.1 The cond_instances Table">
<code class="literal">
cond_instances
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="performance-schema-file-instances-table.html" title="29.12.3.2 The file_instances Table">
<code class="literal">
file_instances
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="performance-schema-users-table.html" title="29.12.8.3 The users Table">
<code class="literal">
users
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="performance-schema-hosts-table.html" title="29.12.8.2 The hosts Table">
<code class="literal">
hosts
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="performance-schema-accounts-table.html" title="29.12.8.1 The accounts Table">
<code class="literal">
accounts
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="performance-schema-socket-summary-tables.html" title="29.12.20.9 Socket Summary Tables">
<code class="literal">
socket_summary_by_event_name
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="performance-schema-file-summary-tables.html" title="29.12.20.7 File I/O Summary Tables">
<code class="literal">
file_summary_by_instance
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="performance-schema-file-summary-tables.html" title="29.12.20.7 File I/O Summary Tables">
<code class="literal">
file_summary_by_event_name
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="performance-schema-objects-summary-global-by-type-table.html" title="29.12.20.6 Object Wait Summary Table">
<code class="literal">
objects_summary_global_by_type
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="performance-schema-memory-summary-tables.html" title="29.12.20.10 Memory Summary Tables">
<code class="literal">
memory_summary_global_by_event_name
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="performance-schema-table-wait-summary-tables.html#performance-schema-table-lock-waits-summary-by-table-table" title="29.12.20.8.3 The table_lock_waits_summary_by_table Table">
<code class="literal">
table_lock_waits_summary_by_table
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="performance-schema-table-wait-summary-tables.html#performance-schema-table-io-waits-summary-by-index-usage-table" title="29.12.20.8.2 The table_io_waits_summary_by_index_usage Table">
<code class="literal">
table_io_waits_summary_by_index_usage
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="performance-schema-table-wait-summary-tables.html#performance-schema-table-io-waits-summary-by-table-table" title="29.12.20.8.1 The table_io_waits_summary_by_table Table">
<code class="literal">
table_io_waits_summary_by_table
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="performance-schema-wait-summary-tables.html" title="29.12.20.1 Wait Event Summary Tables">
<code class="literal">
events_waits_summary_by_instance
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="performance-schema-wait-summary-tables.html" title="29.12.20.1 Wait Event Summary Tables">
<code class="literal">
events_waits_summary_global_by_event_name
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="performance-schema-stage-summary-tables.html" title="29.12.20.2 Stage Summary Tables">
<code class="literal">
events_stages_summary_global_by_event_name
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="performance-schema-statement-summary-tables.html" title="29.12.20.3 Statement Summary Tables">
<code class="literal">
events_statements_summary_global_by_event_name
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="performance-schema-transaction-summary-tables.html" title="29.12.20.5 Transaction Summary Tables">
<code class="literal">
events_transactions_summary_global_by_event_name
</code>
</a>
</p>
</li>
</ul>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h4 class="title">
<a name="performance-schema-consumer-configurations-global-and-thread-instrumentation-only">
</a>
Global and Thread Instrumentation Only
</h4>
</div>
</div>
</div>
<p>
Server configuration state:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa23692015"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> performance_schema<span class="token punctuation">.</span>setup_consumers<span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> NAME <span class="token punctuation">|</span> ENABLED <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> global_instrumentation <span class="token punctuation">|</span> YES <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> thread_instrumentation <span class="token punctuation">|</span> YES <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> events_waits_current <span class="token punctuation">|</span> NO <span class="token punctuation">|</span></span>
<span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
<span class="token output"><span class="token punctuation">|</span> events_stages_current <span class="token punctuation">|</span> NO <span class="token punctuation">|</span></span>
<span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
<span class="token output"><span class="token punctuation">|</span> events_statements_current <span class="token punctuation">|</span> NO <span class="token punctuation">|</span></span>
<span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
<span class="token output"><span class="token punctuation">|</span> events_transactions_current <span class="token punctuation">|</span> NO <span class="token punctuation">|</span></span>
<span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
<p>
In this configuration, instrumentation is maintained globally
and per thread. No individual events are collected in the
current-events or event-history tables.
</p>
<p>
Additional setup elements checked, relative to the preceding
configuration:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Table
<a class="link" href="performance-schema-setup-consumers-table.html" title="29.12.2.2 The setup_consumers Table">
<code class="literal">
setup_consumers
</code>
</a>
,
consumers
<code class="literal">
events_
<em class="replaceable">
<code>
xxx
</code>
</em>
_current
</code>
,
where
<em class="replaceable">
<code>
xxx
</code>
</em>
is
<code class="literal">
waits
</code>
,
<code class="literal">
stages
</code>
,
<code class="literal">
statements
</code>
,
<code class="literal">
transactions
</code>
</p>
</li>
<li class="listitem">
<p>
Table
<a class="link" href="performance-schema-setup-actors-table.html" title="29.12.2.1 The setup_actors Table">
<code class="literal">
setup_actors
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
Column
<code class="literal">
threads.instrumented
</code>
</p>
</li>
</ul>
</div>
<p>
Additional output tables maintained, relative to the preceding
configuration:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
events_
<em class="replaceable">
<code>
xxx
</code>
</em>
_summary_by_
<em class="replaceable">
<code>
yyy
</code>
</em>
_by_event_name
</code>
,
where
<em class="replaceable">
<code>
xxx
</code>
</em>
is
<code class="literal">
waits
</code>
,
<code class="literal">
stages
</code>
,
<code class="literal">
statements
</code>
,
<code class="literal">
transactions
</code>
; and
<em class="replaceable">
<code>
yyy
</code>
</em>
is
<code class="literal">
thread
</code>
,
<code class="literal">
user
</code>
,
<code class="literal">
host
</code>
,
<code class="literal">
account
</code>
</p>
</li>
</ul>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h4 class="title">
<a name="performance-schema-consumer-configurations-global-thread-and-current-event-instrumentation">
</a>
Global, Thread, and Current-Event Instrumentation
</h4>
</div>
</div>
</div>
<p>
Server configuration state:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa58757716"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> performance_schema<span class="token punctuation">.</span>setup_consumers<span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> NAME <span class="token punctuation">|</span> ENABLED <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> global_instrumentation <span class="token punctuation">|</span> YES <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> thread_instrumentation <span class="token punctuation">|</span> YES <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> events_waits_current <span class="token punctuation">|</span> YES <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> events_waits_history <span class="token punctuation">|</span> NO <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> events_waits_history_long <span class="token punctuation">|</span> NO <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> events_stages_current <span class="token punctuation">|</span> YES <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> events_stages_history <span class="token punctuation">|</span> NO <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> events_stages_history_long <span class="token punctuation">|</span> NO <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> events_statements_current <span class="token punctuation">|</span> YES <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> events_statements_history <span class="token punctuation">|</span> NO <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> events_statements_history_long <span class="token punctuation">|</span> NO <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> events_transactions_current <span class="token punctuation">|</span> YES <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> events_transactions_history <span class="token punctuation">|</span> NO <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> events_transactions_history_long <span class="token punctuation">|</span> NO <span class="token punctuation">|</span></span>
<span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
<p>
In this configuration, instrumentation is maintained globally
and per thread. Individual events are collected in the
current-events table, but not in the event-history tables.
</p>
<p>
Additional setup elements checked, relative to the preceding
configuration:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Consumers
<code class="literal">
events_
<em class="replaceable">
<code>
xxx
</code>
</em>
_history
</code>
,
where
<em class="replaceable">
<code>
xxx
</code>
</em>
is
<code class="literal">
waits
</code>
,
<code class="literal">
stages
</code>
,
<code class="literal">
statements
</code>
,
<code class="literal">
transactions
</code>
</p>
</li>
<li class="listitem">
<p>
Consumers
<code class="literal">
events_
<em class="replaceable">
<code>
xxx
</code>
</em>
_history_long
</code>
,
where
<em class="replaceable">
<code>
xxx
</code>
</em>
is
<code class="literal">
waits
</code>
,
<code class="literal">
stages
</code>
,
<code class="literal">
statements
</code>
,
<code class="literal">
transactions
</code>
</p>
</li>
</ul>
</div>
<p>
Additional output tables maintained, relative to the preceding
configuration:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
events_
<em class="replaceable">
<code>
xxx
</code>
</em>
_current
</code>
,
where
<em class="replaceable">
<code>
xxx
</code>
</em>
is
<code class="literal">
waits
</code>
,
<code class="literal">
stages
</code>
,
<code class="literal">
statements
</code>
,
<code class="literal">
transactions
</code>
</p>
</li>
</ul>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h4 class="title">
<a name="performance-schema-consumer-configurations-global-thread-current-event-and-event-history-instrumentation">
</a>
Global, Thread, Current-Event, and Event-History instrumentation
</h4>
</div>
</div>
</div>
<p>
The preceding configuration collects no event history because
the
<code class="literal">
events_
<em class="replaceable">
<code>
xxx
</code>
</em>
_history
</code>
and
<code class="literal">
events_
<em class="replaceable">
<code>
xxx
</code>
</em>
_history_long
</code>
consumers are disabled. Those consumers can be enabled
separately or together to collect event history per thread,
globally, or both.
</p>
<p>
This configuration collects event history per thread, but not
globally:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa14569361"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> performance_schema<span class="token punctuation">.</span>setup_consumers<span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> NAME <span class="token punctuation">|</span> ENABLED <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> global_instrumentation <span class="token punctuation">|</span> YES <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> thread_instrumentation <span class="token punctuation">|</span> YES <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> events_waits_current <span class="token punctuation">|</span> YES <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> events_waits_history <span class="token punctuation">|</span> YES <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> events_waits_history_long <span class="token punctuation">|</span> NO <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> events_stages_current <span class="token punctuation">|</span> YES <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> events_stages_history <span class="token punctuation">|</span> YES <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> events_stages_history_long <span class="token punctuation">|</span> NO <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> events_statements_current <span class="token punctuation">|</span> YES <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> events_statements_history <span class="token punctuation">|</span> YES <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> events_statements_history_long <span class="token punctuation">|</span> NO <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> events_transactions_current <span class="token punctuation">|</span> YES <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> events_transactions_history <span class="token punctuation">|</span> YES <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> events_transactions_history_long <span class="token punctuation">|</span> NO <span class="token punctuation">|</span></span>
<span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
<p>
Event-history tables maintained for this configuration:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
events_
<em class="replaceable">
<code>
xxx
</code>
</em>
_history
</code>
,
where
<em class="replaceable">
<code>
xxx
</code>
</em>
is
<code class="literal">
waits
</code>
,
<code class="literal">
stages
</code>
,
<code class="literal">
statements
</code>
,
<code class="literal">
transactions
</code>
</p>
</li>
</ul>
</div>
<p>
This configuration collects event history globally, but not
per thread:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa17336663"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> performance_schema<span class="token punctuation">.</span>setup_consumers<span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> NAME <span class="token punctuation">|</span> ENABLED <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> global_instrumentation <span class="token punctuation">|</span> YES <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> thread_instrumentation <span class="token punctuation">|</span> YES <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> events_waits_current <span class="token punctuation">|</span> YES <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> events_waits_history <span class="token punctuation">|</span> NO <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> events_waits_history_long <span class="token punctuation">|</span> YES <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> events_stages_current <span class="token punctuation">|</span> YES <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> events_stages_history <span class="token punctuation">|</span> NO <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> events_stages_history_long <span class="token punctuation">|</span> YES <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> events_statements_current <span class="token punctuation">|</span> YES <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> events_statements_history <span class="token punctuation">|</span> NO <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> events_statements_history_long <span class="token punctuation">|</span> YES <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> events_transactions_current <span class="token punctuation">|</span> YES <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> events_transactions_history <span class="token punctuation">|</span> NO <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> events_transactions_history_long <span class="token punctuation">|</span> YES <span class="token punctuation">|</span></span>
<span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
<p>
Event-history tables maintained for this configuration:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
events_
<em class="replaceable">
<code>
xxx
</code>
</em>
_history_long
</code>
,
where
<em class="replaceable">
<code>
xxx
</code>
</em>
is
<code class="literal">
waits
</code>
,
<code class="literal">
stages
</code>
,
<code class="literal">
statements
</code>
,
<code class="literal">
transactions
</code>
</p>
</li>
</ul>
</div>
<p>
This configuration collects event history per thread and
globally:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa6002415"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> performance_schema<span class="token punctuation">.</span>setup_consumers<span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> NAME <span class="token punctuation">|</span> ENABLED <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> global_instrumentation <span class="token punctuation">|</span> YES <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> thread_instrumentation <span class="token punctuation">|</span> YES <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> events_waits_current <span class="token punctuation">|</span> YES <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> events_waits_history <span class="token punctuation">|</span> YES <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> events_waits_history_long <span class="token punctuation">|</span> YES <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> events_stages_current <span class="token punctuation">|</span> YES <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> events_stages_history <span class="token punctuation">|</span> YES <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> events_stages_history_long <span class="token punctuation">|</span> YES <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> events_statements_current <span class="token punctuation">|</span> YES <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> events_statements_history <span class="token punctuation">|</span> YES <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> events_statements_history_long <span class="token punctuation">|</span> YES <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> events_transactions_current <span class="token punctuation">|</span> YES <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> events_transactions_history <span class="token punctuation">|</span> YES <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> events_transactions_history_long <span class="token punctuation">|</span> YES <span class="token punctuation">|</span></span>
<span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
<p>
Event-history tables maintained for this configuration:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
events_
<em class="replaceable">
<code>
xxx
</code>
</em>
_history
</code>
,
where
<em class="replaceable">
<code>
xxx
</code>
</em>
is
<code class="literal">
waits
</code>
,
<code class="literal">
stages
</code>
,
<code class="literal">
statements
</code>
,
<code class="literal">
transactions
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
events_
<em class="replaceable">
<code>
xxx
</code>
</em>
_history_long
</code>
,
where
<em class="replaceable">
<code>
xxx
</code>
</em>
is
<code class="literal">
waits
</code>
,
<code class="literal">
stages
</code>
,
<code class="literal">
statements
</code>
,
<code class="literal">
transactions
</code>
</p>
</li>
</ul>
</div>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/sys-metrics.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="sys-metrics">
</a>
30.4.3.21 The metrics View
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045062759680">
</a>
<a class="indexterm" name="idm46045062758192">
</a>
<p>
This view summarizes MySQL server metrics to show variable
names, values, types, and whether they are enabled. By
default, rows are sorted by variable type and name.
</p>
<p>
The
<a class="link" href="sys-metrics.html" title="30.4.3.21 The metrics View">
<code class="literal">
metrics
</code>
</a>
view includes this
information:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Global status variables from the Performance Schema
<a class="link" href="performance-schema-status-variable-tables.html" title="29.12.15 Performance Schema Status Variable Tables">
<code class="literal">
global_status
</code>
</a>
table
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
InnoDB
</code>
metrics from the
<code class="literal">
INFORMATION_SCHEMA
</code>
<a class="link" href="information-schema-innodb-metrics-table.html" title="28.4.21 The INFORMATION_SCHEMA INNODB_METRICS Table">
<code class="literal">
INNODB_METRICS
</code>
</a>
table
</p>
</li>
<li class="listitem">
<p>
Current and total memory allocation, based on the
Performance Schema memory instrumentation
</p>
</li>
<li class="listitem">
<p>
The current time (human readable and Unix timestamp
formats)
</p>
</li>
</ul>
</div>
<p>
There is some duplication of information between the
<a class="link" href="performance-schema-status-variable-tables.html" title="29.12.15 Performance Schema Status Variable Tables">
<code class="literal">
global_status
</code>
</a>
and
<a class="link" href="information-schema-innodb-metrics-table.html" title="28.4.21 The INFORMATION_SCHEMA INNODB_METRICS Table">
<code class="literal">
INNODB_METRICS
</code>
</a>
tables, which the
<a class="link" href="sys-metrics.html" title="30.4.3.21 The metrics View">
<code class="literal">
metrics
</code>
</a>
view eliminates.
</p>
<p>
The
<a class="link" href="sys-metrics.html" title="30.4.3.21 The metrics View">
<code class="literal">
metrics
</code>
</a>
view has these
columns:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
Variable_name
</code>
</p>
<p>
The metric name. The metric type determines the source
from which the name is taken:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
For global status variables: The
<code class="literal">
VARIABLE_NAME
</code>
column of the
<a class="link" href="performance-schema-status-variable-tables.html" title="29.12.15 Performance Schema Status Variable Tables">
<code class="literal">
global_status
</code>
</a>
table
</p>
</li>
<li class="listitem">
<p>
For
<code class="literal">
InnoDB
</code>
metrics: The
<code class="literal">
NAME
</code>
column of the
<a class="link" href="information-schema-innodb-metrics-table.html" title="28.4.21 The INFORMATION_SCHEMA INNODB_METRICS Table">
<code class="literal">
INNODB_METRICS
</code>
</a>
table
</p>
</li>
<li class="listitem">
<p>
For other metrics: A view-provided descriptive string
</p>
</li>
</ul>
</div>
</li>
<li class="listitem">
<p>
<code class="literal">
Variable_value
</code>
</p>
<p>
The metric value. The metric type determines the source
from which the value is taken:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
For global status variables: The
<code class="literal">
VARIABLE_VALUE
</code>
column of the
<a class="link" href="performance-schema-status-variable-tables.html" title="29.12.15 Performance Schema Status Variable Tables">
<code class="literal">
global_status
</code>
</a>
table
</p>
</li>
<li class="listitem">
<p>
For
<code class="literal">
InnoDB
</code>
metrics: The
<code class="literal">
COUNT
</code>
column of the
<a class="link" href="information-schema-innodb-metrics-table.html" title="28.4.21 The INFORMATION_SCHEMA INNODB_METRICS Table">
<code class="literal">
INNODB_METRICS
</code>
</a>
table
</p>
</li>
<li class="listitem">
<p>
For memory metrics: The relevant column from the
Performance Schema
<a class="link" href="performance-schema-memory-summary-tables.html" title="29.12.20.10 Memory Summary Tables">
<code class="literal">
memory_summary_global_by_event_name
</code>
</a>
table
</p>
</li>
<li class="listitem">
<p>
For the current time: The value of
<a class="link" href="date-and-time-functions.html#function_now">
<code class="literal">
NOW(3)
</code>
</a>
or
<a class="link" href="date-and-time-functions.html#function_unix-timestamp">
<code class="literal">
UNIX_TIMESTAMP(NOW(3))
</code>
</a>
</p>
</li>
</ul>
</div>
</li>
<li class="listitem">
<p>
<code class="literal">
Type
</code>
</p>
<p>
The metric type:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
For global status variables:
<code class="literal">
Global
Status
</code>
</p>
</li>
<li class="listitem">
<p>
For
<code class="literal">
InnoDB
</code>
metrics:
<code class="literal">
InnoDB
Metrics - %
</code>
, where
<code class="literal">
%
</code>
is
replaced by the value of the
<code class="literal">
SUBSYSTEM
</code>
column of the
<a class="link" href="information-schema-innodb-metrics-table.html" title="28.4.21 The INFORMATION_SCHEMA INNODB_METRICS Table">
<code class="literal">
INNODB_METRICS
</code>
</a>
table
</p>
</li>
<li class="listitem">
<p>
For memory metrics:
<code class="literal">
Performance
Schema
</code>
</p>
</li>
<li class="listitem">
<p>
For the current time:
<code class="literal">
System Time
</code>
</p>
</li>
</ul>
</div>
</li>
<li class="listitem">
<p>
<code class="literal">
Enabled
</code>
</p>
<p>
Whether the metric is enabled:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
For global status variables:
<code class="literal">
YES
</code>
</p>
</li>
<li class="listitem">
<p>
For
<code class="literal">
InnoDB
</code>
metrics:
<code class="literal">
YES
</code>
if the
<code class="literal">
STATUS
</code>
column of the
<a class="link" href="information-schema-innodb-metrics-table.html" title="28.4.21 The INFORMATION_SCHEMA INNODB_METRICS Table">
<code class="literal">
INNODB_METRICS
</code>
</a>
table is
<code class="literal">
enabled
</code>
,
<code class="literal">
NO
</code>
otherwise
</p>
</li>
<li class="listitem">
<p>
For memory metrics:
<code class="literal">
NO
</code>
,
<code class="literal">
YES
</code>
, or
<code class="literal">
PARTIAL
</code>
(currently,
<code class="literal">
PARTIAL
</code>
occurs only for
memory metrics and indicates that not all
<code class="literal">
memory/%
</code>
instruments are enabled;
Performance Schema memory instruments are always
enabled)
</p>
</li>
<li class="listitem">
<p>
For the current time:
<code class="literal">
YES
</code>
</p>
</li>
</ul>
</div>
</li>
</ul>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/numeric-type-attributes.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="numeric-type-attributes">
</a>
13.1.6 Numeric Type Attributes
</h3>
</div>
</div>
</div>
<a class="indexterm" name="idm46045213993056">
</a>
<a class="indexterm" name="idm46045213991984">
</a>
<a class="indexterm" name="idm46045213990912">
</a>
<p>
MySQL supports an extension for optionally specifying the
display width of integer data types in parentheses following the
base keyword for the type. For example,
<a class="link" href="integer-types.html" title="13.1.2 Integer Types (Exact Value) - INTEGER, INT, SMALLINT, TINYINT, MEDIUMINT, BIGINT">
<code class="literal">
INT(4)
</code>
</a>
specifies an
<a class="link" href="integer-types.html" title="13.1.2 Integer Types (Exact Value) - INTEGER, INT, SMALLINT, TINYINT, MEDIUMINT, BIGINT">
<code class="literal">
INT
</code>
</a>
with a display width of four
digits. This optional display width may be used by applications
to display integer values having a width less than the width
specified for the column by left-padding them with spaces. (That
is, this width is present in the metadata returned with result
sets. Whether it is used is up to the application.)
</p>
<p>
The display width does
<span class="emphasis">
<em>
not
</em>
</span>
constrain the
range of values that can be stored in the column. Nor does it
prevent values wider than the column display width from being
displayed correctly. For example, a column specified as
<a class="link" href="integer-types.html" title="13.1.2 Integer Types (Exact Value) - INTEGER, INT, SMALLINT, TINYINT, MEDIUMINT, BIGINT">
<code class="literal">
SMALLINT(3)
</code>
</a>
has the usual
<a class="link" href="integer-types.html" title="13.1.2 Integer Types (Exact Value) - INTEGER, INT, SMALLINT, TINYINT, MEDIUMINT, BIGINT">
<code class="literal">
SMALLINT
</code>
</a>
range of
<code class="literal">
-32768
</code>
to
<code class="literal">
32767
</code>
, and
values outside the range permitted by three digits are displayed
in full using more than three digits.
</p>
<p>
When used in conjunction with the optional (nonstandard)
<code class="literal">
ZEROFILL
</code>
attribute, the default padding of
spaces is replaced with zeros. For example, for a column
declared as
<a class="link" href="integer-types.html" title="13.1.2 Integer Types (Exact Value) - INTEGER, INT, SMALLINT, TINYINT, MEDIUMINT, BIGINT">
<code class="literal">
INT(4) ZEROFILL
</code>
</a>
, a
value of
<code class="literal">
5
</code>
is retrieved as
<code class="literal">
0005
</code>
.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
The
<code class="literal">
ZEROFILL
</code>
attribute is ignored for
columns involved in expressions or
<a class="link" href="union.html" title="15.2.18 UNION Clause">
<code class="literal">
UNION
</code>
</a>
queries.
</p>
<p>
If you store values larger than the display width in an
integer column that has the
<code class="literal">
ZEROFILL
</code>
attribute, you may experience problems when MySQL generates
temporary tables for some complicated joins. In these cases,
MySQL assumes that the data values fit within the column
display width.
</p>
</div>
<p>
The
<code class="literal">
ZEROFILL
</code>
attribute is deprecated for
numeric data types, as is the display width attribute for
integer data types. You should expect support for
<code class="literal">
ZEROFILL
</code>
and display widths for integer data
types to be removed in a future version of MySQL. Consider using
an alternative means of producing the effect of these
attributes. For example, applications can use the
<a class="link" href="string-functions.html#function_lpad">
<code class="literal">
LPAD()
</code>
</a>
function to zero-pad
numbers up to the desired width, or they can store the formatted
numbers in
<a class="link" href="char.html" title="13.3.2 The CHAR and VARCHAR Types">
<code class="literal">
CHAR
</code>
</a>
columns.
</p>
<p>
All integer types can have an optional (nonstandard)
<code class="literal">
UNSIGNED
</code>
attribute. An unsigned type can be
used to permit only nonnegative numbers in a column or when you
need a larger upper numeric range for the column. For example,
if an
<a class="link" href="integer-types.html" title="13.1.2 Integer Types (Exact Value) - INTEGER, INT, SMALLINT, TINYINT, MEDIUMINT, BIGINT">
<code class="literal">
INT
</code>
</a>
column is
<code class="literal">
UNSIGNED
</code>
, the size of the column's range is
the same but its endpoints shift up, from
<code class="literal">
-2147483648
</code>
and
<code class="literal">
2147483647
</code>
to
<code class="literal">
0
</code>
and
<code class="literal">
4294967295
</code>
.
</p>
<p>
Floating-point and fixed-point types also can be
<code class="literal">
UNSIGNED
</code>
. As with integer types, this
attribute prevents negative values from being stored in the
column. Unlike the integer types, the upper range of column
values remains the same.
<code class="literal">
UNSIGNED
</code>
is
deprecated for columns of type
<a class="link" href="floating-point-types.html" title="13.1.4 Floating-Point Types (Approximate Value) - FLOAT, DOUBLE">
<code class="literal">
FLOAT
</code>
</a>
,
<a class="link" href="floating-point-types.html" title="13.1.4 Floating-Point Types (Approximate Value) - FLOAT, DOUBLE">
<code class="literal">
DOUBLE
</code>
</a>
, and
<a class="link" href="fixed-point-types.html" title="13.1.3 Fixed-Point Types (Exact Value) - DECIMAL, NUMERIC">
<code class="literal">
DECIMAL
</code>
</a>
(and any synonyms) and
you should expect support for it to be removed in a future
version of MySQL. Consider using a simple
<code class="literal">
CHECK
</code>
constraint instead for such columns.
</p>
<p>
If you specify
<code class="literal">
ZEROFILL
</code>
for a numeric column,
MySQL automatically adds the
<code class="literal">
UNSIGNED
</code>
attribute.
</p>
<p>
Integer or floating-point data types can have the
<code class="literal">
AUTO_INCREMENT
</code>
attribute. When you insert a
value of
<code class="literal">
NULL
</code>
into an indexed
<code class="literal">
AUTO_INCREMENT
</code>
column, the column is set to
the next sequence value. Typically this is
<code class="literal">
<em class="replaceable">
<code>
value
</code>
</em>
+1
</code>
, where
<em class="replaceable">
<code>
value
</code>
</em>
is the largest value for the
column currently in the table.
(
<code class="literal">
AUTO_INCREMENT
</code>
sequences begin with
<code class="literal">
1
</code>
.)
</p>
<p>
Storing
<code class="literal">
0
</code>
into an
<code class="literal">
AUTO_INCREMENT
</code>
column has the same effect as
storing
<code class="literal">
NULL
</code>
, unless the
<a class="link" href="sql-mode.html#sqlmode_no_auto_value_on_zero">
<code class="literal">
NO_AUTO_VALUE_ON_ZERO
</code>
</a>
SQL mode
is enabled.
</p>
<p>
Inserting
<code class="literal">
NULL
</code>
to generate
<code class="literal">
AUTO_INCREMENT
</code>
values requires that the
column be declared
<code class="literal">
NOT NULL
</code>
. If the column is
declared
<code class="literal">
NULL
</code>
, inserting
<code class="literal">
NULL
</code>
stores a
<code class="literal">
NULL
</code>
. When
you insert any other value into an
<code class="literal">
AUTO_INCREMENT
</code>
column, the column is set to
that value and the sequence is reset so that the next
automatically generated value follows sequentially from the
inserted value.
</p>
<p>
Negative values for
<code class="literal">
AUTO_INCREMENT
</code>
columns
are not supported.
</p>
<p>
<code class="literal">
CHECK
</code>
constraints cannot refer to columns
that have the
<code class="literal">
AUTO_INCREMENT
</code>
attribute, nor
can the
<code class="literal">
AUTO_INCREMENT
</code>
attribute be added to
existing columns that are used in
<code class="literal">
CHECK
</code>
constraints.
</p>
<p>
<code class="literal">
AUTO_INCREMENT
</code>
is deprecated for
<a class="link" href="floating-point-types.html" title="13.1.4 Floating-Point Types (Approximate Value) - FLOAT, DOUBLE">
<code class="literal">
FLOAT
</code>
</a>
and
<a class="link" href="floating-point-types.html" title="13.1.4 Floating-Point Types (Approximate Value) - FLOAT, DOUBLE">
<code class="literal">
DOUBLE
</code>
</a>
columns; you should expect
support for it to be removed in a future version of MySQL.
Consider removing the
<code class="literal">
AUTO_INCREMENT
</code>
attribute from such columns to avoid potential compatibility
issues, or convert them to an integer type.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/mysql-cluster-mgm-definition.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="mysql-cluster-mgm-definition">
</a>
25.4.3.5 Defining an NDB Cluster Management Server
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045120466752">
</a>
<a class="indexterm" name="idm46045120465264">
</a>
<p>
The
<code class="literal">
[ndb_mgmd]
</code>
section is used to configure
the behavior of the management server. If multiple management
servers are employed, you can specify parameters common to all
of them in an
<code class="literal">
[ndb_mgmd default]
</code>
section.
<code class="literal">
[mgm]
</code>
and
<code class="literal">
[mgm default]
</code>
are older aliases for these, supported for backward
compatibility.
</p>
<p>
All parameters in the following list are optional and assume
their default values if omitted.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
If neither the
<code class="literal">
ExecuteOnComputer
</code>
nor the
<code class="literal">
HostName
</code>
parameter is present, the default
value
<code class="literal">
localhost
</code>
is assumed for both.
</p>
</div>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a name="ndbparam-mgmd-id">
</a>
<code class="literal">
Id
</code>
</p>
<a class="indexterm" name="idm46045120454816">
</a>
<div class="informaltable">
<a name="id-mgmd-table">
</a>
<table frame="box" rules="all" summary="Id management node configuration parameter type and value information" width="35%">
<colgroup>
<col style="width: 50%"/>
<col style="width: 50%"/>
</colgroup>
<tbody>
<tr>
<th>
Version (or later)
</th>
<td>
NDB 8.4.0
</td>
</tr>
<tr>
<th>
Type or units
</th>
<td>
unsigned
</td>
</tr>
<tr>
<th>
Default
</th>
<td>
[...]
</td>
</tr>
<tr>
<th>
Range
</th>
<td>
1 - 255
</td>
</tr>
<tr>
<th>
Restart Type
</th>
<td>
<p>
<span class="bold">
<strong>
Initial System Restart:
</strong>
</span>
Requires a complete shutdown of the
cluster, wiping and restoring the cluster file
system from a
<a class="link" href="mysql-cluster-backup.html" title="25.6.8 Online Backup of NDB Cluster">
backup
</a>
,
and then restarting the cluster. (NDB 8.4.0)
</p>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Each node in the cluster has a unique identity. For a
management node, this is represented by an integer value in
the range 1 to 255, inclusive. This ID is used by all
internal cluster messages for addressing the node, and so
must be unique for each NDB Cluster node, regardless of the
type of node.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
Data node IDs must be less than 145. If you plan to deploy
a large number of data nodes, it is a good idea to limit
the node IDs for management nodes (and API nodes) to
values greater than 144.
</p>
</div>
<p>
The use of the
<code class="literal">
Id
</code>
parameter for
identifying management nodes is deprecated in favor of
<a class="link" href="mysql-cluster-mgm-definition.html#ndbparam-mgmd-nodeid">
<code class="literal">
NodeId
</code>
</a>
. Although
<code class="literal">
Id
</code>
continues to be supported for backward
compatibility, it now generates a warning and is subject to
removal in a future version of NDB Cluster.
</p>
</li>
<li class="listitem">
<p>
<a name="ndbparam-mgmd-nodeid">
</a>
<code class="literal">
NodeId
</code>
</p>
<a class="indexterm" name="idm46045120430256">
</a>
<div class="informaltable">
<a name="nodeid-mgmd-table">
</a>
<table frame="box" rules="all" summary="NodeId management node configuration parameter type and value information" width="35%">
<colgroup>
<col style="width: 50%"/>
<col style="width: 50%"/>
</colgroup>
<tbody>
<tr>
<th>
Version (or later)
</th>
<td>
NDB 8.4.0
</td>
</tr>
<tr>
<th>
Type or units
</th>
<td>
unsigned
</td>
</tr>
<tr>
<th>
Default
</th>
<td>
[...]
</td>
</tr>
<tr>
<th>
Range
</th>
<td>
1 - 255
</td>
</tr>
<tr>
<th>
Restart Type
</th>
<td>
<p>
<span class="bold">
<strong>
Initial System Restart:
</strong>
</span>
Requires a complete shutdown of the
cluster, wiping and restoring the cluster file
system from a
<a class="link" href="mysql-cluster-backup.html" title="25.6.8 Online Backup of NDB Cluster">
backup
</a>
,
and then restarting the cluster. (NDB 8.4.0)
</p>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Each node in the cluster has a unique identity. For a
management node, this is represented by an integer value in
the range 1 to 255 inclusive. This ID is used by all
internal cluster messages for addressing the node, and so
must be unique for each NDB Cluster node, regardless of the
type of node.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
Data node IDs must be less than 145. If you plan to deploy
a large number of data nodes, it is a good idea to limit
the node IDs for management nodes (and API nodes) to
values greater than 144.
</p>
</div>
<p>
<code class="literal">
NodeId
</code>
is the preferred parameter name to
use when identifying management nodes. Although the older
<a class="link" href="mysql-cluster-mgm-definition.html#ndbparam-mgmd-id">
<code class="literal">
Id
</code>
</a>
continues to be
supported for backward compatibility, it is now deprecated
and generates a warning when used; it is also subject to
removal in a future NDB Cluster release.
</p>
</li>
<li class="listitem">
<p>
<a name="ndbparam-mgmd-executeoncomputer">
</a>
<code class="literal">
ExecuteOnComputer
</code>
</p>
<a class="indexterm" name="idm46045120406240">
</a>
<div class="informaltable">
<a name="executeoncomputer-mgmd-table">
</a>
<table frame="box" rules="all" summary="ExecuteOnComputer management node configuration parameter type and value information" width="35%">
<colgroup>
<col style="width: 50%"/>
<col style="width: 50%"/>
</colgroup>
<tbody>
<tr>
<th>
Version (or later)
</th>
<td>
NDB 8.4.0
</td>
</tr>
<tr>
<th>
Type or units
</th>
<td>
name
</td>
</tr>
<tr>
<th>
Default
</th>
<td>
[...]
</td>
</tr>
<tr>
<th>
Range
</th>
<td>
...
</td>
</tr>
<tr>
<th>
Deprecated
</th>
<td>
Yes (in NDB 7.5)
</td>
</tr>
<tr>
<th>
Restart Type
</th>
<td>
<p>
<span class="bold">
<strong>
System Restart:
</strong>
</span>
Requires a complete shutdown and restart
of the cluster. (NDB 8.4.0)
</p>
</td>
</tr>
</tbody>
</table>
</div>
<p>
This refers to the
<code class="literal">
Id
</code>
set for one of the
computers defined in a
<code class="literal">
[computer]
</code>
section
of the
<code class="filename">
config.ini
</code>
file.
</p>
<div class="important" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Important
</div>
<p>
This parameter is deprecated, and is subject to removal in
a future release. Use the
<a class="link" href="mysql-cluster-mgm-definition.html#ndbparam-mgmd-hostname">
<code class="literal">
HostName
</code>
</a>
parameter
instead.
</p>
</div>
</li>
<li class="listitem">
<p>
<a name="ndbparam-mgmd-portnumber">
</a>
<code class="literal">
PortNumber
</code>
</p>
<a class="indexterm" name="idm46045120380768">
</a>
<div class="informaltable">
<a name="portnumber-mgmd-table">
</a>
<table frame="box" rules="all" summary="PortNumber management node configuration parameter type and value information" width="35%">
<colgroup>
<col style="width: 50%"/>
<col style="width: 50%"/>
</colgroup>
<tbody>
<tr>
<th>
Version (or later)
</th>
<td>
NDB 8.4.0
</td>
</tr>
<tr>
<th>
Type or units
</th>
<td>
unsigned
</td>
</tr>
<tr>
<th>
Default
</th>
<td>
1186
</td>
</tr>
<tr>
<th>
Range
</th>
<td>
0 - 64K
</td>
</tr>
<tr>
<th>
Restart Type
</th>
<td>
<p>
<span class="bold">
<strong>
System Restart:
</strong>
</span>
Requires a complete shutdown and restart
of the cluster. (NDB 8.4.0)
</p>
</td>
</tr>
</tbody>
</table>
</div>
<p>
This is the port number on which the management server
listens for configuration requests and management commands.
</p>
</li>
<li class="listitem">
<a name="ndbparam-mgmd-dedicated">
</a>
<a class="indexterm" name="idm46045120362720">
</a>
<p>
</p>
<p>
The node ID for this node can be given out only to
connections that explicitly request it. A management server
that requests
<span class="quote">
“
<span class="quote">
any
</span>
”
</span>
node ID cannot use this
one. This parameter can be used when running multiple
management servers on the same host, and
<a class="link" href="mysql-cluster-mgm-definition.html#ndbparam-mgmd-hostname">
<code class="literal">
HostName
</code>
</a>
is not
sufficient for distinguishing among processes.
</p>
</li>
<li class="listitem">
<p>
<a name="ndbparam-mgmd-hostname">
</a>
<code class="literal">
HostName
</code>
</p>
<a class="indexterm" name="idm46045120356496">
</a>
<div class="informaltable">
<a name="hostname-mgmd-table">
</a>
<table frame="box" rules="all" summary="HostName management node configuration parameter type and value information" width="35%">
<colgroup>
<col style="width: 50%"/>
<col style="width: 50%"/>
</colgroup>
<tbody>
<tr>
<th>
Version (or later)
</th>
<td>
NDB 8.4.0
</td>
</tr>
<tr>
<th>
Type or units
</th>
<td>
name or IP address
</td>
</tr>
<tr>
<th>
Default
</th>
<td>
[...]
</td>
</tr>
<tr>
<th>
Range
</th>
<td>
...
</td>
</tr>
<tr>
<th>
Restart Type
</th>
<td>
<p>
<span class="bold">
<strong>
Node Restart:
</strong>
</span>
Requires a
<a class="link" href="mysql-cluster-rolling-restart.html" title="25.6.5 Performing a Rolling Restart of an NDB Cluster">
rolling
restart
</a>
of the cluster. (NDB 8.4.0)
</p>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Specifying this parameter defines the hostname of the
computer on which the management node is to reside. Use
<code class="literal">
HostName
</code>
to specify a host name other
than
<code class="literal">
localhost
</code>
.
</p>
</li>
<li class="listitem">
<p>
<a name="ndbparam-mgmd-locationdomainid">
</a>
<a class="link" href="mysql-cluster-mgm-definition.html#ndbparam-mgmd-locationdomainid">
<code class="literal">
LocationDomainId
</code>
</a>
</p>
<a class="indexterm" name="idm46045120334512">
</a>
<div class="informaltable">
<a name="locationdomainid-mgmd-table">
</a>
<table frame="box" rules="all" summary="LocationDomainId management node configuration parameter type and value information" width="35%">
<colgroup>
<col style="width: 50%"/>
<col style="width: 50%"/>
</colgroup>
<tbody>
<tr>
<th>
Version (or later)
</th>
<td>
NDB 8.4.0
</td>
</tr>
<tr>
<th>
Type or units
</th>
<td>
integer
</td>
</tr>
<tr>
<th>
Default
</th>
<td>
0
</td>
</tr>
<tr>
<th>
Range
</th>
<td>
0 - 16
</td>
</tr>
<tr>
<th>
Restart Type
</th>
<td>
<p>
<span class="bold">
<strong>
System Restart:
</strong>
</span>
Requires a complete shutdown and restart
of the cluster. (NDB 8.4.0)
</p>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Assigns a management node to a specific
<a class="ulink" href="https://docs.us-phoenix-1.oraclecloud.com/Content/General/Concepts/regions.htm" target="_blank">
availability
domain
</a>
(also known as an availability zone) within a
cloud. By informing
<code class="literal">
NDB
</code>
which nodes are
in which availability domains, performance can be improved
in a cloud environment in the following ways:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
If requested data is not found on the same node, reads
can be directed to another node in the same availability
domain.
</p>
</li>
<li class="listitem">
<p>
Communication between nodes in different availability
domains are guaranteed to use
<code class="literal">
NDB
</code>
transporters' WAN support without any further
manual intervention.
</p>
</li>
<li class="listitem">
<p>
The transporter's group number can be based on
which availability domain is used, such that also SQL
and other API nodes communicate with local data nodes in
the same availability domain whenever possible.
</p>
</li>
<li class="listitem">
<p>
The arbitrator can be selected from an availability
domain in which no data nodes are present, or, if no
such availability domain can be found, from a third
availability domain.
</p>
</li>
</ul>
</div>
<p>
<code class="literal">
LocationDomainId
</code>
takes an integer value
between 0 and 16 inclusive, with 0 being the default; using
0 is the same as leaving the parameter unset.
</p>
</li>
<li class="listitem">
<p>
<a name="ndbparam-mgmd-logdestination">
</a>
<a class="link" href="mysql-cluster-mgm-definition.html#ndbparam-mgmd-logdestination">
<code class="literal">
LogDestination
</code>
</a>
</p>
<a class="indexterm" name="idm46045120306896">
</a>
<div class="informaltable">
<a name="logdestination-mgmd-table">
</a>
<table frame="box" rules="all" summary="LogDestination management node configuration parameter type and value information" width="35%">
<colgroup>
<col style="width: 50%"/>
<col style="width: 50%"/>
</colgroup>
<tbody>
<tr>
<th>
Version (or later)
</th>
<td>
NDB 8.4.0
</td>
</tr>
<tr>
<th>
Type or units
</th>
<td>
{CONSOLE|SYSLOG|FILE}
</td>
</tr>
<tr>
<th>
Default
</th>
<td>
FILE: filename=ndb_nodeid_cluster.log, maxsize=1000000, maxfiles=6
</td>
</tr>
<tr>
<th>
Range
</th>
<td>
...
</td>
</tr>
<tr>
<th>
Restart Type
</th>
<td>
<p>
<span class="bold">
<strong>
Node Restart:
</strong>
</span>
Requires a
<a class="link" href="mysql-cluster-rolling-restart.html" title="25.6.5 Performing a Rolling Restart of an NDB Cluster">
rolling
restart
</a>
of the cluster. (NDB 8.4.0)
</p>
</td>
</tr>
</tbody>
</table>
</div>
<p>
This parameter specifies where to send cluster logging
information. There are three options in this
regard—
<code class="literal">
CONSOLE
</code>
,
<code class="literal">
SYSLOG
</code>
, and
<code class="literal">
FILE
</code>
—with
<code class="literal">
FILE
</code>
being the default:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
<code class="literal">
CONSOLE
</code>
outputs the log to
<code class="literal">
stdout
</code>
:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-simple"><div class="docs-select-all right" id="sa53493963"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-simple">CONSOLE</code></pre>
</div>
</li>
<li class="listitem">
<p>
<code class="literal">
SYSLOG
</code>
sends the log to a
<code class="literal">
syslog
</code>
facility, possible values
being one of
<code class="literal">
auth
</code>
,
<code class="literal">
authpriv
</code>
,
<code class="literal">
cron
</code>
,
<code class="literal">
daemon
</code>
,
<code class="literal">
ftp
</code>
,
<code class="literal">
kern
</code>
,
<code class="literal">
lpr
</code>
,
<code class="literal">
mail
</code>
,
<code class="literal">
news
</code>
,
<code class="literal">
syslog
</code>
,
<code class="literal">
user
</code>
,
<code class="literal">
uucp
</code>
,
<code class="literal">
local0
</code>
,
<code class="literal">
local1
</code>
,
<code class="literal">
local2
</code>
,
<code class="literal">
local3
</code>
,
<code class="literal">
local4
</code>
,
<code class="literal">
local5
</code>
,
<code class="literal">
local6
</code>
, or
<code class="literal">
local7
</code>
.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
Not every facility is necessarily supported by every
operating system.
</p>
</div>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-simple"><div class="docs-select-all right" id="sa41465471"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-simple">SYSLOG<span class="token operator">:</span>facility<span class="token operator">=</span>syslog</code></pre>
</div>
</li>
<li class="listitem">
<p>
<code class="literal">
FILE
</code>
pipes the cluster log output to
a regular file on the same machine. The following values
can be specified:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: square; ">
<li class="listitem">
<p>
<code class="literal">
filename
</code>
: The name of the log
file.
</p>
<p>
The default log file name used in such cases is
<code class="filename">
ndb_
<em class="replaceable">
<code>
nodeid
</code>
</em>
_cluster.log
</code>
.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
maxsize
</code>
: The maximum size (in
bytes) to which the file can grow before logging
rolls over to a new file. When this occurs, the old
log file is renamed by appending
<em class="replaceable">
<code>
.N
</code>
</em>
to the file name,
where
<em class="replaceable">
<code>
N
</code>
</em>
is the next
number not yet used with this name.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
maxfiles
</code>
: The maximum number of
log files.
</p>
</li>
</ul>
</div>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-simple"><div class="docs-select-all right" id="sa30304262"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-simple">FILE<span class="token operator">:</span>filename<span class="token operator">=</span>cluster<span class="token punctuation">.</span>log<span class="token punctuation">,</span>maxsize<span class="token operator">=</span>1000000<span class="token punctuation">,</span>maxfiles<span class="token operator">=</span>6</code></pre>
</div>
<p>
The default value for the
<code class="literal">
FILE
</code>
parameter is
<code class="literal">
FILE:filename=ndb_
<em class="replaceable">
<code>
node_id
</code>
</em>
_cluster.log,maxsize=1000000,maxfiles=6
</code>
,
where
<em class="replaceable">
<code>
node_id
</code>
</em>
is the ID of
the node.
</p>
</li>
</ul>
</div>
<p>
It is possible to specify multiple log destinations
separated by semicolons as shown here:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-simple"><div class="docs-select-all right" id="sa89445517"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-simple">CONSOLE<span class="token punctuation">;</span>SYSLOG<span class="token operator">:</span>facility<span class="token operator">=</span>local0<span class="token punctuation">;</span>FILE<span class="token operator">:</span>filename<span class="token operator">=</span><span class="token operator">/</span>var<span class="token operator">/</span>log<span class="token operator">/</span>mgmd</code></pre>
</div>
</li>
<li class="listitem">
<p>
<a name="ndbparam-mgmd-arbitrationrank">
</a>
<code class="literal">
ArbitrationRank
</code>
</p>
<a class="indexterm" name="idm46045120247232">
</a>
<div class="informaltable">
<a name="arbitrationrank-mgmd-table">
</a>
<table frame="box" rules="all" summary="ArbitrationRank management node configuration parameter type and value information" width="35%">
<colgroup>
<col style="width: 50%"/>
<col style="width: 50%"/>
</colgroup>
<tbody>
<tr>
<th>
Version (or later)
</th>
<td>
NDB 8.4.0
</td>
</tr>
<tr>
<th>
Type or units
</th>
<td>
0-2
</td>
</tr>
<tr>
<th>
Default
</th>
<td>
1
</td>
</tr>
<tr>
<th>
Range
</th>
<td>
0 - 2
</td>
</tr>
<tr>
<th>
Restart Type
</th>
<td>
<p>
<span class="bold">
<strong>
Node Restart:
</strong>
</span>
Requires a
<a class="link" href="mysql-cluster-rolling-restart.html" title="25.6.5 Performing a Rolling Restart of an NDB Cluster">
rolling
restart
</a>
of the cluster. (NDB 8.4.0)
</p>
</td>
</tr>
</tbody>
</table>
</div>
<p>
This parameter is used to define which nodes can act as
arbitrators. Only management nodes and SQL nodes can be
arbitrators.
<code class="literal">
ArbitrationRank
</code>
can take one
of the following values:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
<code class="literal">
0
</code>
: The node is never used as an
arbitrator.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
1
</code>
: The node has high priority; that
is, it is preferred as an arbitrator over low-priority
nodes.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
2
</code>
: Indicates a low-priority node
which is used as an arbitrator only if a node with a
higher priority is not available for that purpose.
</p>
</li>
</ul>
</div>
<p>
Normally, the management server should be configured as an
arbitrator by setting its
<code class="literal">
ArbitrationRank
</code>
to 1 (the default for management nodes) and those for all
SQL nodes to 0 (the default for SQL nodes).
</p>
<p>
You can disable arbitration completely either by setting
<code class="literal">
ArbitrationRank
</code>
to 0 on all management
and SQL nodes, or by setting the
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-arbitration">
<code class="literal">
Arbitration
</code>
</a>
parameter in the
<code class="literal">
[ndbd default]
</code>
section
of the
<code class="filename">
config.ini
</code>
global configuration
file. Setting
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-arbitration">
<code class="literal">
Arbitration
</code>
</a>
causes
any settings for
<code class="literal">
ArbitrationRank
</code>
to be
disregarded.
</p>
</li>
<li class="listitem">
<p>
<a name="ndbparam-mgmd-arbitrationdelay">
</a>
<code class="literal">
ArbitrationDelay
</code>
</p>
<a class="indexterm" name="idm46045120214000">
</a>
<div class="informaltable">
<a name="arbitrationdelay-mgmd-table">
</a>
<table frame="box" rules="all" summary="ArbitrationDelay management node configuration parameter type and value information" width="35%">
<colgroup>
<col style="width: 50%"/>
<col style="width: 50%"/>
</colgroup>
<tbody>
<tr>
<th>
Version (or later)
</th>
<td>
NDB 8.4.0
</td>
</tr>
<tr>
<th>
Type or units
</th>
<td>
milliseconds
</td>
</tr>
<tr>
<th>
Default
</th>
<td>
0
</td>
</tr>
<tr>
<th>
Range
</th>
<td>
0 - 4294967039 (0xFFFFFEFF)
</td>
</tr>
<tr>
<th>
Restart Type
</th>
<td>
<p>
<span class="bold">
<strong>
Node Restart:
</strong>
</span>
Requires a
<a class="link" href="mysql-cluster-rolling-restart.html" title="25.6.5 Performing a Rolling Restart of an NDB Cluster">
rolling
restart
</a>
of the cluster. (NDB 8.4.0)
</p>
</td>
</tr>
</tbody>
</table>
</div>
<p>
An integer value which causes the management server's
responses to arbitration requests to be delayed by that
number of milliseconds. By default, this value is 0; it is
normally not necessary to change it.
</p>
</li>
<li class="listitem">
<p>
<a name="ndbparam-mgmd-datadir">
</a>
<code class="literal">
DataDir
</code>
</p>
<a class="indexterm" name="idm46045120193984">
</a>
<div class="informaltable">
<a name="datadir-mgmd-table">
</a>
<table frame="box" rules="all" summary="DataDir management node configuration parameter type and value information" width="35%">
<colgroup>
<col style="width: 50%"/>
<col style="width: 50%"/>
</colgroup>
<tbody>
<tr>
<th>
Version (or later)
</th>
<td>
NDB 8.4.0
</td>
</tr>
<tr>
<th>
Type or units
</th>
<td>
path
</td>
</tr>
<tr>
<th>
Default
</th>
<td>
.
</td>
</tr>
<tr>
<th>
Range
</th>
<td>
...
</td>
</tr>
<tr>
<th>
Restart Type
</th>
<td>
<p>
<span class="bold">
<strong>
Node Restart:
</strong>
</span>
Requires a
<a class="link" href="mysql-cluster-rolling-restart.html" title="25.6.5 Performing a Rolling Restart of an NDB Cluster">
rolling
restart
</a>
of the cluster. (NDB 8.4.0)
</p>
</td>
</tr>
</tbody>
</table>
</div>
<p>
This specifies the directory where output files from the
management server are placed. These files include cluster
log files, process output files, and the daemon's
process ID (PID) file. (For log files, this location can be
overridden by setting the
<code class="literal">
FILE
</code>
parameter
for
<a class="link" href="mysql-cluster-mgm-definition.html#ndbparam-mgmd-logdestination">
<code class="literal">
LogDestination
</code>
</a>
,
as discussed previously in this section.)
</p>
<p>
The default value for this parameter is the directory in
which
<a class="link" href="mysql-cluster-programs-ndb-mgmd.html" title="25.5.4 ndb_mgmd — The NDB Cluster Management Server Daemon">
<span class="command">
<strong>
ndb_mgmd
</strong>
</span>
</a>
is located.
</p>
</li>
<li class="listitem">
<p>
<a name="ndbparam-mgmd-portnumberstats">
</a>
<code class="literal">
PortNumberStats
</code>
</p>
<a class="indexterm" name="idm46045120170064">
</a>
<div class="informaltable">
<a name="portnumberstats-mgmd-table">
</a>
<table frame="box" rules="all" summary="PortNumberStats management node configuration parameter type and value information" width="35%">
<colgroup>
<col style="width: 50%"/>
<col style="width: 50%"/>
</colgroup>
<tbody>
<tr>
<th>
Version (or later)
</th>
<td>
NDB 8.4.0
</td>
</tr>
<tr>
<th>
Type or units
</th>
<td>
unsigned
</td>
</tr>
<tr>
<th>
Default
</th>
<td>
[...]
</td>
</tr>
<tr>
<th>
Range
</th>
<td>
0 - 64K
</td>
</tr>
<tr>
<th>
Restart Type
</th>
<td>
<p>
<span class="bold">
<strong>
Node Restart:
</strong>
</span>
Requires a
<a class="link" href="mysql-cluster-rolling-restart.html" title="25.6.5 Performing a Rolling Restart of an NDB Cluster">
rolling
restart
</a>
of the cluster. (NDB 8.4.0)
</p>
</td>
</tr>
</tbody>
</table>
</div>
<p>
This parameter specifies the port number used to obtain
statistical information from an NDB Cluster management
server. It has no default value.
</p>
</li>
<li class="listitem">
<p>
<a name="ndbparam-mgmd-wan">
</a>
<a class="link" href="mysql-cluster-mgm-definition.html#ndbparam-mgmd-wan">
<code class="literal">
Wan
</code>
</a>
</p>
<a class="indexterm" name="idm46045120149520">
</a>
<div class="informaltable">
<a name="wan-mgmd-table">
</a>
<table frame="box" rules="all" summary="wan management node configuration parameter type and value information" width="35%">
<colgroup>
<col style="width: 50%"/>
<col style="width: 50%"/>
</colgroup>
<tbody>
<tr>
<th>
Version (or later)
</th>
<td>
NDB 8.4.0
</td>
</tr>
<tr>
<th>
Type or units
</th>
<td>
boolean
</td>
</tr>
<tr>
<th>
Default
</th>
<td>
false
</td>
</tr>
<tr>
<th>
Range
</th>
<td>
true, false
</td>
</tr>
<tr>
<th>
Restart Type
</th>
<td>
<p>
<span class="bold">
<strong>
Node Restart:
</strong>
</span>
Requires a
<a class="link" href="mysql-cluster-rolling-restart.html" title="25.6.5 Performing a Rolling Restart of an NDB Cluster">
rolling
restart
</a>
of the cluster. (NDB 8.4.0)
</p>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Use WAN TCP setting as default.
</p>
</li>
<li class="listitem">
<p>
<a name="ndbparam-mgmd-heartbeatthreadpriority">
</a>
<code class="literal">
HeartbeatThreadPriority
</code>
</p>
<a class="indexterm" name="idm46045120129728">
</a>
<div class="informaltable">
<a name="heartbeatthreadpriority-mgmd-table">
</a>
<table frame="box" rules="all" summary="HeartbeatThreadPriority management node configuration parameter type and value information" width="35%">
<colgroup>
<col style="width: 50%"/>
<col style="width: 50%"/>
</colgroup>
<tbody>
<tr>
<th>
Version (or later)
</th>
<td>
NDB 8.4.0
</td>
</tr>
<tr>
<th>
Type or units
</th>
<td>
string
</td>
</tr>
<tr>
<th>
Default
</th>
<td>
[...]
</td>
</tr>
<tr>
<th>
Range
</th>
<td>
...
</td>
</tr>
<tr>
<th>
Restart Type
</th>
<td>
<p>
<span class="bold">
<strong>
Node Restart:
</strong>
</span>
Requires a
<a class="link" href="mysql-cluster-rolling-restart.html" title="25.6.5 Performing a Rolling Restart of an NDB Cluster">
rolling
restart
</a>
of the cluster. (NDB 8.4.0)
</p>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Set the scheduling policy and priority of heartbeat threads
for management and API nodes.
</p>
<p>
The syntax for setting this parameter is shown here:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-ini"><div class="docs-select-all right" id="sa23080046"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-ini"><span class="token constant">HeartbeatThreadPriority</span> <span class="token attr-value"><span class="token punctuation">=</span> <em class="replaceable">policy</em>[, <em class="replaceable">priority</em>]</span>
<em class="replaceable">policy</em>:
{FIFO | RR}</code></pre>
</div>
<p>
When setting this parameter, you must specify a policy. This
is one of
<code class="literal">
FIFO
</code>
(first in, first out) or
<code class="literal">
RR
</code>
(round robin). The policy value is
followed optionally by the priority (an integer).
</p>
</li>
<li class="listitem">
<p>
<a name="ndbparam-mgmd-extrasendbuffermemory">
</a>
<code class="literal">
ExtraSendBufferMemory
</code>
</p>
<a class="indexterm" name="idm46045120105072">
</a>
<div class="informaltable">
<a name="extrasendbuffermemory-mgmd-table">
</a>
<table frame="box" rules="all" summary="ExtraSendBufferMemory management node configuration parameter type and value information" width="35%">
<colgroup>
<col style="width: 50%"/>
<col style="width: 50%"/>
</colgroup>
<tbody>
<tr>
<th>
Version (or later)
</th>
<td>
NDB 8.4.0
</td>
</tr>
<tr>
<th>
Type or units
</th>
<td>
bytes
</td>
</tr>
<tr>
<th>
Default
</th>
<td>
0
</td>
</tr>
<tr>
<th>
Range
</th>
<td>
0 - 32G
</td>
</tr>
<tr>
<th>
Restart Type
</th>
<td>
<p>
<span class="bold">
<strong>
Node Restart:
</strong>
</span>
Requires a
<a class="link" href="mysql-cluster-rolling-restart.html" title="25.6.5 Performing a Rolling Restart of an NDB Cluster">
rolling
restart
</a>
of the cluster. (NDB 8.4.0)
</p>
</td>
</tr>
</tbody>
</table>
</div>
<p>
This parameter specifies the amount of transporter send
buffer memory to allocate in addition to any that has been
set using
<a class="link" href="mysql-cluster-mgm-definition.html#ndbparam-mgmd-totalsendbuffermemory">
<code class="literal">
TotalSendBufferMemory
</code>
</a>
,
<a class="link" href="mysql-cluster-tcp-definition.html#ndbparam-tcp-sendbuffermemory">
<code class="literal">
SendBufferMemory
</code>
</a>
, or
both.
</p>
</li>
<li class="listitem">
<p>
<a name="ndbparam-mgmd-requiretls">
</a>
<code class="literal">
RequireTls
</code>
</p>
<a class="indexterm" name="idm46045120082176">
</a>
<div class="informaltable">
<a name="requiretls-mgmd-table">
</a>
<table frame="box" rules="all" summary="RequireTls management node configuration parameter type and value information" width="35%">
<colgroup>
<col style="width: 50%"/>
<col style="width: 50%"/>
</colgroup>
<tbody>
<tr>
<th>
Version (or later)
</th>
<td>
NDB 8.4.0
</td>
</tr>
<tr>
<th>
Type or units
</th>
<td>
boolean
</td>
</tr>
<tr>
<th>
Default
</th>
<td>
false
</td>
</tr>
<tr>
<th>
Range
</th>
<td>
...
</td>
</tr>
<tr>
<th>
Restart Type
</th>
<td>
<p>
<span class="bold">
<strong>
Node Restart:
</strong>
</span>
Requires a
<a class="link" href="mysql-cluster-rolling-restart.html" title="25.6.5 Performing a Rolling Restart of an NDB Cluster">
rolling
restart
</a>
of the cluster. (NDB 8.4.0)
</p>
</td>
</tr>
</tbody>
</table>
</div>
<p>
If this parameter is set to
<code class="literal">
true
</code>
, a
client, once connected to this management node, must be
authenticated using TLS before the connection can be used
for anything else.
</p>
</li>
<li class="listitem">
<p>
<a name="ndbparam-mgmd-totalsendbuffermemory">
</a>
<code class="literal">
TotalSendBufferMemory
</code>
</p>
<a class="indexterm" name="idm46045120061120">
</a>
<div class="informaltable">
<a name="totalsendbuffermemory-mgmd-table">
</a>
<table frame="box" rules="all" summary="TotalSendBufferMemory management node configuration parameter type and value information" width="35%">
<colgroup>
<col style="width: 50%"/>
<col style="width: 50%"/>
</colgroup>
<tbody>
<tr>
<th>
Version (or later)
</th>
<td>
NDB 8.4.0
</td>
</tr>
<tr>
<th>
Type or units
</th>
<td>
bytes
</td>
</tr>
<tr>
<th>
Default
</th>
<td>
0
</td>
</tr>
<tr>
<th>
Range
</th>
<td>
256K - 4294967039 (0xFFFFFEFF)
</td>
</tr>
<tr>
<th>
Restart Type
</th>
<td>
<p>
<span class="bold">
<strong>
Node Restart:
</strong>
</span>
Requires a
<a class="link" href="mysql-cluster-rolling-restart.html" title="25.6.5 Performing a Rolling Restart of an NDB Cluster">
rolling
restart
</a>
of the cluster. (NDB 8.4.0)
</p>
</td>
</tr>
</tbody>
</table>
</div>
<p>
This parameter is used to determine the total amount of
memory to allocate on this node for shared send buffer
memory among all configured transporters.
</p>
<p>
If this parameter is set, its minimum permitted value is
256KB; 0 indicates that the parameter has not been set. For
more detailed information, see
<a class="xref" href="mysql-cluster-config-send-buffers.html" title="25.4.3.14 Configuring NDB Cluster Send Buffer Parameters">
Section 25.4.3.14, “Configuring NDB Cluster Send Buffer Parameters”
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="ndbparam-mgmd-heartbeatintervalmgmdmgmd">
</a>
<code class="literal">
HeartbeatIntervalMgmdMgmd
</code>
</p>
<a class="indexterm" name="idm46045120039280">
</a>
<div class="informaltable">
<a name="heartbeatintervalmgmdmgmd-mgmd-table">
</a>
<table frame="box" rules="all" summary="HeartbeatIntervalMgmdMgmd management node configuration parameter type and value information" width="35%">
<colgroup>
<col style="width: 50%"/>
<col style="width: 50%"/>
</colgroup>
<tbody>
<tr>
<th>
Version (or later)
</th>
<td>
NDB 8.4.0
</td>
</tr>
<tr>
<th>
Type or units
</th>
<td>
milliseconds
</td>
</tr>
<tr>
<th>
Default
</th>
<td>
1500
</td>
</tr>
<tr>
<th>
Range
</th>
<td>
100 - 4294967039 (0xFFFFFEFF)
</td>
</tr>
<tr>
<th>
Restart Type
</th>
<td>
<p>
<span class="bold">
<strong>
Node Restart:
</strong>
</span>
Requires a
<a class="link" href="mysql-cluster-rolling-restart.html" title="25.6.5 Performing a Rolling Restart of an NDB Cluster">
rolling
restart
</a>
of the cluster. (NDB 8.4.0)
</p>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Specify the interval between heartbeat messages used to
determine whether another management node is on contact with
this one. The management node waits after 3 of these
intervals to declare the connection dead; thus, the default
setting of 1500 milliseconds causes the management node to
wait for approximately 1600 ms before timing out.
</p>
</li>
</ul>
</div>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
After making changes in a management node's
configuration, it is necessary to perform a rolling restart of
the cluster for the new configuration to take effect.
</p>
<p>
To add new management servers to a running NDB Cluster, it is
also necessary to perform a rolling restart of all cluster
nodes after modifying any existing
<code class="filename">
config.ini
</code>
files. For more information
about issues arising when using multiple management nodes, see
<a class="xref" href="mysql-cluster-limitations-multiple-nodes.html" title="25.2.7.10 Limitations Relating to Multiple NDB Cluster Nodes">
Section 25.2.7.10, “Limitations Relating to Multiple NDB Cluster Nodes”
</a>
.
</p>
</div>
<p>
<a name="mysql-cluster-mgm-definition-restart-types">
</a>
<b>
Restart types.
</b>
Information about the restart types used by the parameter
descriptions in this section is shown in the following table:
</p>
<div class="table">
<a name="idm46045120015136">
</a>
<p class="title">
<b>
Table 25.8 NDB Cluster restart types
</b>
</p>
<div class="table-contents">
<table>
<colgroup>
<col style="width: 10%"/>
<col style="width: 30%"/>
<col style="width: 60%"/>
</colgroup>
<thead>
<tr>
<th scope="col">
Symbol
</th>
<th scope="col">
Restart Type
</th>
<th scope="col">
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">
N
</th>
<td>
Node
</td>
<td>
The parameter can be updated using a rolling restart (see
<a class="xref" href="mysql-cluster-rolling-restart.html" title="25.6.5 Performing a Rolling Restart of an NDB Cluster">
Section 25.6.5, “Performing a Rolling Restart of an NDB Cluster”
</a>
)
</td>
</tr>
<tr>
<th scope="row">
S
</th>
<td>
System
</td>
<td>
All cluster nodes must be shut down completely, then restarted, to
effect a change in this parameter
</td>
</tr>
<tr>
<th scope="row">
I
</th>
<td>
Initial
</td>
<td>
Data nodes must be restarted using the
<a class="link" href="mysql-cluster-programs-ndbd.html#option_ndbd_initial">
<code class="option">
--initial
</code>
</a>
option
</td>
</tr>
</tbody>
</table>
</div>
</div>
<br class="table-break"/>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/checking-gpg-signature.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="checking-gpg-signature">
</a>
2.1.4.2 Signature Checking Using GnuPG
</h4>
</div>
</div>
</div>
<p>
Another method of verifying the integrity and authenticity of a
package is to use cryptographic signatures. This is more
reliable than using
<a class="link" href="verifying-md5-checksum.html" title="2.1.4.1 Verifying the MD5 Checksum">
MD5
checksums
</a>
, but requires more work.
</p>
<p>
We sign MySQL downloadable packages with
<span class="command">
<strong>
GnuPG
</strong>
</span>
(GNU Privacy Guard).
<span class="command">
<strong>
GnuPG
</strong>
</span>
is an Open Source alternative to the
well-known Pretty Good Privacy (
<span class="command">
<strong>
PGP
</strong>
</span>
) by Phil
Zimmermann. Most Linux distributions ship with
<span class="command">
<strong>
GnuPG
</strong>
</span>
installed by default. Otherwise, see
<a class="ulink" href="http://www.gnupg.org/" target="_blank">
http://www.gnupg.org/
</a>
for more information about
<span class="command">
<strong>
GnuPG
</strong>
</span>
and how to obtain and install it.
</p>
<p>
To verify the signature for a specific package, you first need
to obtain a copy of our public GPG build key, which you can
download from
<a class="ulink" href="http://pgp.mit.edu/" target="_blank">
http://pgp.mit.edu/
</a>
. The key that
you want to obtain is named
<code class="literal">
[email protected]
</code>
. The keyID for
MySQL 8.0.36 packages and higher, and MySQL 8.3.0 and higher, is
<code class="literal">
A8D3785C
</code>
. After obtaining this key, you
should compare it with the key following value before using it
verify MySQL packages. Alternatively, you can copy and paste the
key directly from the text below.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
The public GPG build key for earlier MySQL release packages
(keyID
<code class="literal">
5072E1F5
</code>
or
<code class="literal">
3A79BD29
</code>
), see
<a class="xref" href="gpg-key-archived-packages.html" title="2.1.4.5 GPG Public Build Key for Archived Packages">
Section 2.1.4.5, “GPG Public Build Key for Archived Packages”
</a>
.
</p>
</div>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-none"><div class="docs-select-all right" id="sa51614036"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-none">-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: SKS 1.1.6
Comment: Hostname: pgp.mit.edu
mQINBGU2rNoBEACSi5t0nL6/Hj3d0PwsbdnbY+SqLUIZ3uWZQm6tsNhvTnahvPPZBGdl99iW
YTt2KmXp0KeN2s9pmLKkGAbacQP1RqzMFnoHawSMf0qTUVjAvhnI4+qzMDjTNSBq9fa3nHmO
YxownnrRkpiQUM/yD7/JmVENgwWb6akZeGYrXch9jd4XV3t8OD6TGzTedTki0TDNr6YZYhC7
jUm9fK9Zs299pzOXSxRRNGd+3H9gbXizrBu4L/3lUrNf//rM7OvV9Ho7u9YYyAQ3L3+OABK9
FKHNhrpi8Q0cbhvWkD4oCKJ+YZ54XrOG0YTg/YUAs5/3//FATI1sWdtLjJ5pSb0onV3LIbar
RTN8lC4Le/5kd3lcot9J8b3EMXL5p9OGW7wBfmNVRSUI74Vmwt+v9gyp0Hd0keRCUn8lo/1V
0YD9i92KsE+/IqoYTjnya/5kX41jB8vr1ebkHFuJ404+G6ETd0owwxq64jLIcsp/GBZHGU0R
KKAo9DRLH7rpQ7PVlnw8TDNlOtWt5EJlBXFcPL+NgWbqkADAyA/XSNeWlqonvPlYfmasnAHA
pMd9NhPQhC7hJTjCiAwG8UyWpV8Dj07DHFQ5xBbkTnKH2OrJtguPqSNYtTASbsWz09S8ujoT
DXFT17NbFM2dMIiq0a4VQB3SzH13H2io9Cbg/TzJrJGmwgoXgwARAQABtDZNeVNRTCBSZWxl
YXNlIEVuZ2luZWVyaW5nIDxteXNxbC1idWlsZEBvc3Mub3JhY2xlLmNvbT6JAlQEEwEIAD4W
IQS8pDQXw7SF3RKOxtS3s7eIqNN4XAUCZTas2gIbAwUJA8JnAAULCQgHAgYVCgkICwIEFgID
AQIeAQIXgAAKCRC3s7eIqNN4XLzoD/9PlpWtfHlI8eQTHwGsGIwFA+fgipyDElapHw3MO+K9
VOEYRZCZSuBXHJe9kjGEVCGUDrfImvgTuNuqYmVUV+wyhP+w46W/cWVkqZKAW0hNp0TTvu3e
Dwap7gdk80VF24Y2Wo0bbiGkpPiPmB59oybGKaJ756JlKXIL4hTtK3/hjIPFnb64Ewe4YLZy
oJu0fQOyA8gXuBoalHhUQTbRpXI0XI3tpZiQemNbfBfJqXo6LP3/LgChAuOfHIQ8alvnhCwx
hNUSYGIRqx+BEbJw1X99Az8XvGcZ36VOQAZztkW7mEfH9NDPz7MXwoEvduc61xwlMvEsUIaS
fn6SGLFzWPClA98UMSJgF6sKb+JNoNbzKaZ8V5w13msLb/pq7hab72HH99XJbyKNliYj3+KA
3q0YLf+Hgt4Y4EhIJ8x2+g690Np7zJF4KXNFbi1BGloLGm78akY1rQlzpndKSpZq5KWw8FY/
1PEXORezg/BPD3Etp0AVKff4YdrDlOkNB7zoHRfFHAvEuuqti8aMBrbRnRSG0xunMUOEhbYS
/wOOTl0g3bF9NpAkfU1Fun57N96Us2T9gKo9AiOY5DxMe+IrBg4zaydEOovgqNi2wbU0MOBQ
b23Puhj7ZCIXcpILvcx9ygjkONr75w+XQrFDNeux4Znzay3ibXtAPqEykPMZHsZ2sbkCDQRl
NqzaARAAsdvBo8WRqZ5WVVk6lReD8b6Zx83eJUkV254YX9zn5t8KDRjYOySwS75mJIaZLsv0
YQjJk+5rt10tejyCrJIFo9CMvCmjUKtVbgmhfS5+fUDRrYCEZBBSa0Dvn68EBLiHugr+SPXF
6o1hXEUqdMCpB6oVp6X45JVQroCKIH5vsCtw2jU8S2/IjjV0V+E/zitGCiZaoZ1f6NG7ozyF
ep1CSAReZu/sssk0pCLlfCebRd9Rz3QjSrQhWYuJa+eJmiF4oahnpUGktxMD632I9aG+IMfj
tNJNtX32MbO+Se+cCtVc3cxSa/pR+89a3cb9IBA5tFF2Qoekhqo/1mmLi93Xn6uDUhl5tVxT
nB217dBT27tw+p0hjd9hXZRQbrIZUTyh3+8EMfmAjNSIeR+th86xRd9XFRr9EOqrydnALOUr
9cT7TfXWGEkFvn6ljQX7f4RvjJOTbc4jJgVFyu8K+VU6u1NnFJgDiNGsWvnYxAf7gDDbUSXE
uC2anhWvxPvpLGmsspngge4yl+3nv+UqZ9sm6LCebR/7UZ67tYz3p6xzAOVgYsYcxoIUuEZX
jHQtsYfTZZhrjUWBJ09jrMvlKUHLnS437SLbgoXVYZmcqwAWpVNOLZf+fFm4IE5aGBG5Dho2
CZ6ujngW9Zkn98T1d4N0MEwwXa2V6T1ijzcqD7GApZUAEQEAAYkCPAQYAQgAJhYhBLykNBfD
tIXdEo7G1Lezt4io03hcBQJlNqzaAhsMBQkDwmcAAAoJELezt4io03hcXqMP/01aPT3A3Sg7
oTQoHdCxj04ELkzrezNWGM+YwbSKrR2LoXR8zf2tBFzc2/Tl98V0+68f/eCvkvqCuOtq4392
Ps23j9W3r5XG+GDOwDsx0gl0E+Qkw07pwdJctA6efsmnRkjF2YVO0N9MiJA1tc8NbNXpEEHJ
Z7F8Ri5cpQrGUz/AY0eae2b7QefyP4rpUELpMZPjc8Px39Fe1DzRbT+5E19TZbrpbwlSYs1i
CzS5YGFmpCRyZcLKXo3zS6N22+82cnRBSPPipiO6WaQawcVMlQO1SX0giB+3/DryfN9VuIYd
1EWCGQa3O0MVu6o5KVHwPgl9R1P6xPZhurkDpAd0b1s4fFxin+MdxwmG7RslZA9CXRPpzo7/
fCMW8sYOH15DP+YfUckoEreBt+zezBxbIX2CGGWEV9v3UBXadRtwxYQ6sN9bqW4jm1b41vNA
17b6CVH6sVgtU3eN+5Y9an1e5jLD6kFYx+OIeqIIId/TEqwS61csY9aav4j4KLOZFCGNU0FV
ji7NQewSpepTcJwfJDOzmtiDP4vol1ApJGLRwZZZ9PB6wsOgDOoP6sr0YrDI/NNX2RyXXbgl
nQ1yJZVSH3/3eo6knG2qTthUKHCRDNKdy9Qqc1x4WWWtSRjh+zX8AvJK2q1rVLH2/3ilxe9w
cAZUlaj3id3TxquAlud4lWDz
=h5nH
-----END PGP PUBLIC KEY BLOCK-----</code></pre>
</div>
<p>
To import the build key into your personal public GPG keyring,
use
<span class="command">
<strong>
gpg --import
</strong>
</span>
. For example, if you have
saved the key in a file named
<code class="filename">
mysql_pubkey.asc
</code>
, the import command looks
like this:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa57803534"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$> </span><span class="token command">gpg</span> <span class="token property">--import</span> mysql_pubkey<span class="token punctuation">.</span>asc
gpg<span class="token punctuation">:</span> key B7B3B788A8D3785C<span class="token punctuation">:</span> public key "MySQL Release Engineering
<mysql-build@oss<span class="token punctuation">.</span>oracle<span class="token punctuation">.</span>com>" imported
gpg<span class="token punctuation">:</span> Total number processed<span class="token punctuation">:</span> 1
gpg<span class="token punctuation">:</span> imported<span class="token punctuation">:</span> 1</code></pre>
</div>
<p>
You can also download the key from the public keyserver using
the public key id,
<code class="literal">
A8D3785C
</code>
:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa2715482"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$> </span><span class="token command">gpg</span> <span class="token property">--recv-keys</span> A8D3785C
gpg<span class="token punctuation">:</span> requesting key A8D3785C from hkp server keys<span class="token punctuation">.</span>gnupg<span class="token punctuation">.</span>net
gpg<span class="token punctuation">:</span> key A8D3785C<span class="token punctuation">:</span> <span class="token atrule">"MySQL Release Engineering <[email protected]>"</span>
1 new user ID
gpg<span class="token punctuation">:</span> key A8D3785C<span class="token punctuation">:</span> <span class="token atrule">"MySQL Release Engineering <[email protected]>"</span>
53 new signatures
gpg<span class="token punctuation">:</span> no ultimately trusted keys found
gpg<span class="token punctuation">:</span> Total number processed<span class="token punctuation">:</span> 1
gpg<span class="token punctuation">:</span> new user IDs<span class="token punctuation">:</span> 1
gpg<span class="token punctuation">:</span> new signatures<span class="token punctuation">:</span> 53</code></pre>
</div>
<p>
If you want to import the key into your RPM configuration to
validate RPM install packages, you should be able to import the
key directly:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa44017767"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$> </span><span class="token command">rpm</span> <span class="token property">--import</span> mysql_pubkey<span class="token punctuation">.</span>asc</code></pre>
</div>
<p>
If you experience problems or require RPM specific information,
see
<a class="xref" href="checking-rpm-signature.html" title="2.1.4.4 Signature Checking Using RPM">
Section 2.1.4.4, “Signature Checking Using RPM”
</a>
.
</p>
<p>
After you have downloaded and imported the public build key,
download your desired MySQL package and the corresponding
signature, which also is available from the download page. The
signature file has the same name as the distribution file with
an
<code class="filename">
.asc
</code>
extension, as shown by the examples
in the following table.
</p>
<div class="table">
<a name="idm46045332876896">
</a>
<p class="title">
<b>
Table 2.1 MySQL Package and Signature Files for Source files
</b>
</p>
<div class="table-contents">
<table>
<colgroup>
<col style="width: 25%"/>
<col style="width: 75%"/>
</colgroup>
<thead>
<tr>
<th>
File Type
</th>
<th>
File Name
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
Distribution file
</td>
<td>
<code class="literal">
mysql-8.4.3-linux-glibc2.28-x86_64.tar.xz
</code>
</td>
</tr>
<tr>
<td>
Signature file
</td>
<td>
<code class="literal">
mysql-8.4.3-linux-glibc2.28-x86_64.tar.xz.asc
</code>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<br class="table-break"/>
<p>
Make sure that both files are stored in the same directory and
then run the following command to verify the signature for the
distribution file:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa59746146"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$> </span><span class="token command">gpg</span> <span class="token property">--verify</span> <em class="replaceable">package_name</em><span class="token punctuation">.</span>asc</code></pre>
</div>
<p>
If the downloaded package is valid, you should see a
<code class="literal">
Good signature
</code>
message similar to this:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa40195091"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$> </span><span class="token command">gpg</span> <span class="token property">--verify</span> mysql-8<span class="token punctuation">.</span>4<span class="token punctuation">.</span>3-linux-glibc2<span class="token punctuation">.</span>28-x86_64<span class="token punctuation">.</span>tar<span class="token punctuation">.</span>xz<span class="token punctuation">.</span>asc
gpg<span class="token punctuation">:</span> Signature made Fri 15 Dec 2023 06<span class="token punctuation">:</span>55<span class="token punctuation">:</span>13 AM EST
gpg<span class="token punctuation">:</span> using RSA key BCA43417C3B485DD128EC6D4B7B3B788A8D3785C
gpg<span class="token punctuation">:</span> Good signature from <span class="token atrule">"MySQL Release Engineering <[email protected]>"</span></code></pre>
</div>
<p>
The
<code class="literal">
Good signature
</code>
message indicates that the
file signature is valid, when compared to the signature listed
on our site. But you might also see warnings, like so:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa40189226"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$> </span><span class="token command">gpg</span> <span class="token property">--verify</span> mysql-8<span class="token punctuation">.</span>4<span class="token punctuation">.</span>3-linux-glibc2<span class="token punctuation">.</span>28-x86_64<span class="token punctuation">.</span>tar<span class="token punctuation">.</span>xz<span class="token punctuation">.</span>asc
gpg<span class="token punctuation">:</span> Signature made Fri 15 Dec 2023 06<span class="token punctuation">:</span>55<span class="token punctuation">:</span>13 AM EST
gpg<span class="token punctuation">:</span> using RSA key BCA43417C3B485DD128EC6D4B7B3B788A8D3785C
gpg<span class="token punctuation">:</span> Good signature from <span class="token atrule">"MySQL Release Engineering <[email protected]>"</span>
gpg<span class="token punctuation">:</span> WARNING<span class="token punctuation">:</span> This key is not certified with a trusted signature!
gpg<span class="token punctuation">:</span> There is no indication that the signature belongs to the owner<span class="token punctuation">.</span>
Primary key fingerprint<span class="token punctuation">:</span> BCA4 3417 C3B4 85DD 128E C6D4 B7B3 B788 A8D3 785C</code></pre>
</div>
<p>
That is normal, as they depend on your setup and configuration.
Here are explanations for these warnings:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<span class="emphasis">
<em>
gpg: no ultimately trusted keys found
</em>
</span>
:
This means that the specific key is not "ultimately trusted"
by you or your web of trust, which is okay for the purposes
of verifying file signatures.
</p>
</li>
<li class="listitem">
<p>
<span class="emphasis">
<em>
WARNING: This key is not certified with a trusted
signature! There is no indication that the signature belongs
to the owner.
</em>
</span>
: This refers to your level of trust
in your belief that you possess our real public key. This is
a personal decision. Ideally, a MySQL developer would hand
you the key in person, but more commonly, you downloaded it.
Was the download tampered with? Probably not, but this
decision is up to you. Setting up a web of trust is one
method for trusting them.
</p>
</li>
</ul>
</div>
<p>
See the GPG documentation for more information on how to work
with public keys.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/replace.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="replace">
</a>
15.2.12 REPLACE Statement
</h3>
</div>
</div>
</div>
<a class="indexterm" name="idm46045181156480">
</a>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa96506151"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">REPLACE</span> <span class="token punctuation">[</span><span class="token keyword">LOW_PRIORITY</span> <span class="token operator">|</span> <span class="token keyword">DELAYED</span><span class="token punctuation">]</span>
<span class="token punctuation">[</span><span class="token keyword">INTO</span><span class="token punctuation">]</span> <em class="replaceable">tbl_name</em>
<span class="token punctuation">[</span><span class="token keyword">PARTITION</span> <span class="token punctuation">(</span><em class="replaceable">partition_name</em> <span class="token punctuation">[</span><span class="token punctuation">,</span> <em class="replaceable">partition_name</em><span class="token punctuation">]</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">)</span><span class="token punctuation">]</span>
<span class="token punctuation">[</span><span class="token punctuation">(</span><em class="replaceable">col_name</em> <span class="token punctuation">[</span><span class="token punctuation">,</span> <em class="replaceable">col_name</em><span class="token punctuation">]</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">)</span><span class="token punctuation">]</span>
{ {<span class="token keyword">VALUES</span> <span class="token operator">|</span> <span class="token keyword">VALUE</span>} <span class="token punctuation">(</span><em class="replaceable">value_list</em><span class="token punctuation">)</span> <span class="token punctuation">[</span><span class="token punctuation">,</span> <span class="token punctuation">(</span><em class="replaceable">value_list</em><span class="token punctuation">)</span><span class="token punctuation">]</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
<span class="token operator">|</span>
<span class="token keyword">VALUES</span> <em class="replaceable">row_constructor_list</em>
}
<span class="token keyword">REPLACE</span> <span class="token punctuation">[</span><span class="token keyword">LOW_PRIORITY</span> <span class="token operator">|</span> <span class="token keyword">DELAYED</span><span class="token punctuation">]</span>
<span class="token punctuation">[</span><span class="token keyword">INTO</span><span class="token punctuation">]</span> <em class="replaceable">tbl_name</em>
<span class="token punctuation">[</span><span class="token keyword">PARTITION</span> <span class="token punctuation">(</span><em class="replaceable">partition_name</em> <span class="token punctuation">[</span><span class="token punctuation">,</span> <em class="replaceable">partition_name</em><span class="token punctuation">]</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">)</span><span class="token punctuation">]</span>
<span class="token keyword">SET</span> <em class="replaceable">assignment_list</em>
<span class="token keyword">REPLACE</span> <span class="token punctuation">[</span><span class="token keyword">LOW_PRIORITY</span> <span class="token operator">|</span> <span class="token keyword">DELAYED</span><span class="token punctuation">]</span>
<span class="token punctuation">[</span><span class="token keyword">INTO</span><span class="token punctuation">]</span> <em class="replaceable">tbl_name</em>
<span class="token punctuation">[</span><span class="token keyword">PARTITION</span> <span class="token punctuation">(</span><em class="replaceable">partition_name</em> <span class="token punctuation">[</span><span class="token punctuation">,</span> <em class="replaceable">partition_name</em><span class="token punctuation">]</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">)</span><span class="token punctuation">]</span>
<span class="token punctuation">[</span><span class="token punctuation">(</span><em class="replaceable">col_name</em> <span class="token punctuation">[</span><span class="token punctuation">,</span> <em class="replaceable">col_name</em><span class="token punctuation">]</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">)</span><span class="token punctuation">]</span>
{<span class="token keyword">SELECT</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span> <span class="token operator">|</span> <span class="token keyword">TABLE</span> <span class="token keyword"><em class="replaceable">table_name</em></span>}
<span class="token keyword"><em class="replaceable">value</em></span>:
{<em class="replaceable">expr</em> <span class="token operator">|</span> <span class="token keyword">DEFAULT</span>}
<em class="replaceable">value_list</em>:
<span class="token keyword"><em class="replaceable">value</em></span> <span class="token punctuation">[</span><span class="token punctuation">,</span> <span class="token keyword"><em class="replaceable">value</em></span><span class="token punctuation">]</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
<em class="replaceable">row_constructor_list</em>:
<span class="token keyword">ROW</span><span class="token punctuation">(</span><em class="replaceable">value_list</em><span class="token punctuation">)</span><span class="token punctuation">[</span><span class="token punctuation">,</span> <span class="token keyword">ROW</span><span class="token punctuation">(</span><em class="replaceable">value_list</em><span class="token punctuation">)</span><span class="token punctuation">]</span><span class="token punctuation">[</span><span class="token punctuation">,</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">]</span>
<em class="replaceable">assignment</em>:
<em class="replaceable">col_name</em> <span class="token operator">=</span> <span class="token keyword"><em class="replaceable">value</em></span>
<em class="replaceable">assignment_list</em>:
<em class="replaceable">assignment</em> <span class="token punctuation">[</span><span class="token punctuation">,</span> <em class="replaceable">assignment</em><span class="token punctuation">]</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span></code></pre>
</div>
<p>
<a class="link" href="replace.html" title="15.2.12 REPLACE Statement">
<code class="literal">
REPLACE
</code>
</a>
works exactly like
<a class="link" href="insert.html" title="15.2.7 INSERT Statement">
<code class="literal">
INSERT
</code>
</a>
, except that if an old row
in the table has the same value as a new row for a
<code class="literal">
PRIMARY KEY
</code>
or a
<code class="literal">
UNIQUE
</code>
index, the old row is deleted before the new row is inserted. See
<a class="xref" href="insert.html" title="15.2.7 INSERT Statement">
Section 15.2.7, “INSERT Statement”
</a>
.
</p>
<p>
<a class="link" href="replace.html" title="15.2.12 REPLACE Statement">
<code class="literal">
REPLACE
</code>
</a>
is a MySQL extension to the
SQL standard. It either inserts, or
<span class="emphasis">
<em>
deletes
</em>
</span>
and inserts. For another MySQL extension to standard
SQL—that either inserts or
<span class="emphasis">
<em>
updates
</em>
</span>
—see
<a class="xref" href="insert-on-duplicate.html" title="15.2.7.2 INSERT ... ON DUPLICATE KEY UPDATE Statement">
Section 15.2.7.2, “INSERT ... ON DUPLICATE KEY UPDATE Statement”
</a>
.
</p>
<p>
<code class="literal">
DELAYED
</code>
inserts and replaces were deprecated in
MySQL 5.6. In MySQL 8.4,
<code class="literal">
DELAYED
</code>
is not supported. The server recognizes but ignores the
<code class="literal">
DELAYED
</code>
keyword, handles the replace as a
nondelayed replace, and generates an
<a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html#error_er_warn_legacy_syntax_converted" target="_top">
<code class="literal">
ER_WARN_LEGACY_SYNTAX_CONVERTED
</code>
</a>
warning:
<span class="errortext">
REPLACE DELAYED is no longer supported. The
statement was converted to REPLACE
</span>
. The
<code class="literal">
DELAYED
</code>
keyword is scheduled for removal in a
future release. release.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
<a class="link" href="replace.html" title="15.2.12 REPLACE Statement">
<code class="literal">
REPLACE
</code>
</a>
makes sense only if a
table has a
<code class="literal">
PRIMARY KEY
</code>
or
<code class="literal">
UNIQUE
</code>
index. Otherwise, it becomes
equivalent to
<a class="link" href="insert.html" title="15.2.7 INSERT Statement">
<code class="literal">
INSERT
</code>
</a>
, because
there is no index to be used to determine whether a new row
duplicates another.
</p>
</div>
<p>
Values for all columns are taken from the values specified in the
<a class="link" href="replace.html" title="15.2.12 REPLACE Statement">
<code class="literal">
REPLACE
</code>
</a>
statement. Any missing
columns are set to their default values, just as happens for
<a class="link" href="insert.html" title="15.2.7 INSERT Statement">
<code class="literal">
INSERT
</code>
</a>
. You cannot refer to values
from the current row and use them in the new row. If you use an
assignment such as
<code class="literal">
SET
<em class="replaceable">
<code>
col_name
</code>
</em>
=
<em class="replaceable">
<code>
col_name
</code>
</em>
+ 1
</code>
, the reference
to the column name on the right hand side is treated as
<a class="link" href="miscellaneous-functions.html#function_default">
<code class="literal">
DEFAULT(
<em class="replaceable">
<code>
col_name
</code>
</em>
)
</code>
</a>
,
so the assignment is equivalent to
<code class="literal">
SET
<em class="replaceable">
<code>
col_name
</code>
</em>
=
DEFAULT(
<em class="replaceable">
<code>
col_name
</code>
</em>
) + 1
</code>
.
</p>
<p>
You can specify the column values that
<code class="literal">
REPLACE
</code>
attempts to insert using
<a class="link" href="values.html" title="15.2.19 VALUES Statement">
<code class="literal">
VALUES ROW()
</code>
</a>
.
</p>
<p>
To use
<a class="link" href="replace.html" title="15.2.12 REPLACE Statement">
<code class="literal">
REPLACE
</code>
</a>
, you must have both
the
<a class="link" href="privileges-provided.html#priv_insert">
<code class="literal">
INSERT
</code>
</a>
and
<a class="link" href="privileges-provided.html#priv_delete">
<code class="literal">
DELETE
</code>
</a>
privileges for the table.
</p>
<a class="indexterm" name="idm46045181103648">
</a>
<p>
If a generated column is replaced explicitly, the only permitted
value is
<code class="literal">
DEFAULT
</code>
. For information about
generated columns, see
<a class="xref" href="create-table-generated-columns.html" title="15.1.20.8 CREATE TABLE and Generated Columns">
Section 15.1.20.8, “CREATE TABLE and Generated Columns”
</a>
.
</p>
<p>
<code class="literal">
REPLACE
</code>
supports explicit partition selection
using the
<code class="literal">
PARTITION
</code>
clause with a list of
comma-separated names of partitions, subpartitions, or both. As
with
<a class="link" href="insert.html" title="15.2.7 INSERT Statement">
<code class="literal">
INSERT
</code>
</a>
, if it is not possible
to insert the new row into any of these partitions or
subpartitions, the
<code class="literal">
REPLACE
</code>
statement fails with
the error
<span class="errortext">
Found a row not matching the given partition
set
</span>
. For more information and examples, see
<a class="xref" href="partitioning-selection.html" title="26.5 Partition Selection">
Section 26.5, “Partition Selection”
</a>
.
</p>
<p>
The
<a class="link" href="replace.html" title="15.2.12 REPLACE Statement">
<code class="literal">
REPLACE
</code>
</a>
statement returns a
count to indicate the number of rows affected. This is the sum of
the rows deleted and inserted. If the count is 1 for a single-row
<a class="link" href="replace.html" title="15.2.12 REPLACE Statement">
<code class="literal">
REPLACE
</code>
</a>
, a row was inserted and no
rows were deleted. If the count is greater than 1, one or more old
rows were deleted before the new row was inserted. It is possible
for a single row to replace more than one old row if the table
contains multiple unique indexes and the new row duplicates values
for different old rows in different unique indexes.
</p>
<p>
The affected-rows count makes it easy to determine whether
<a class="link" href="replace.html" title="15.2.12 REPLACE Statement">
<code class="literal">
REPLACE
</code>
</a>
only added a row or whether
it also replaced any rows: Check whether the count is 1 (added) or
greater (replaced).
</p>
<p>
If you are using the C API, the affected-rows count can be
obtained using the
<a class="ulink" href="/doc/c-api/8.4/en/mysql-affected-rows.html" target="_top">
<code class="literal">
mysql_affected_rows()
</code>
</a>
function.
</p>
<p>
You cannot replace into a table and select from the same table in
a subquery.
</p>
<p>
MySQL uses the following algorithm for
<a class="link" href="replace.html" title="15.2.12 REPLACE Statement">
<code class="literal">
REPLACE
</code>
</a>
(and
<a class="link" href="load-data.html" title="15.2.9 LOAD DATA Statement">
<code class="literal">
LOAD DATA ...
REPLACE
</code>
</a>
):
</p>
<div class="orderedlist">
<ol class="orderedlist" type="1">
<li class="listitem">
<p>
Try to insert the new row into the table
</p>
</li>
<li class="listitem">
<p>
While the insertion fails because a duplicate-key error occurs
for a primary key or unique index:
</p>
<div class="orderedlist">
<ol class="orderedlist" type="a">
<li class="listitem">
<p>
Delete from the table the conflicting row that has the
duplicate key value
</p>
</li>
<li class="listitem">
<p>
Try again to insert the new row into the table
</p>
</li>
</ol>
</div>
</li>
</ol>
</div>
<p>
It is possible that in the case of a duplicate-key error, a
storage engine may perform the
<code class="literal">
REPLACE
</code>
as an
update rather than a delete plus insert, but the semantics are the
same. There are no user-visible effects other than a possible
difference in how the storage engine increments
<code class="literal">
Handler_
<em class="replaceable">
<code>
xxx
</code>
</em>
</code>
status
variables.
</p>
<p>
Because the results of
<code class="literal">
REPLACE ... SELECT
</code>
statements depend on the ordering of rows from the
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
and this order cannot always
be guaranteed, it is possible when logging these statements for
the source and the replica to diverge. For this reason,
<code class="literal">
REPLACE ... SELECT
</code>
statements are flagged as
unsafe for statement-based replication. such statements produce a
warning in the error log when using statement-based mode and are
written to the binary log using the row-based format when using
<code class="literal">
MIXED
</code>
mode. See also
<a class="xref" href="replication-sbr-rbr.html" title="19.2.1.1 Advantages and Disadvantages of Statement-Based and Row-Based Replication">
Section 19.2.1.1, “Advantages and Disadvantages of Statement-Based and Row-Based
Replication”
</a>
.
</p>
<p>
MySQL 8.4 supports
<a class="link" href="table.html" title="15.2.16 TABLE Statement">
<code class="literal">
TABLE
</code>
</a>
as well as
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
with
<code class="literal">
REPLACE
</code>
, just as it does with
<a class="link" href="insert.html" title="15.2.7 INSERT Statement">
<code class="literal">
INSERT
</code>
</a>
. See
<a class="xref" href="insert-select.html" title="15.2.7.1 INSERT ... SELECT Statement">
Section 15.2.7.1, “INSERT ... SELECT Statement”
</a>
, for more information and
examples.
</p>
<p>
When modifying an existing table that is not partitioned to
accommodate partitioning, or, when modifying the partitioning of
an already partitioned table, you may consider altering the
table's primary key (see
<a class="xref" href="partitioning-limitations-partitioning-keys-unique-keys.html" title="26.6.1 Partitioning Keys, Primary Keys, and Unique Keys">
Section 26.6.1, “Partitioning Keys, Primary Keys, and Unique Keys”
</a>
).
You should be aware that, if you do this, the results of
<code class="literal">
REPLACE
</code>
statements may be affected, just as
they would be if you modified the primary key of a nonpartitioned
table. Consider the table created by the following
<a class="link" href="create-table.html" title="15.1.20 CREATE TABLE Statement">
<code class="literal">
CREATE TABLE
</code>
</a>
statement:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa22372664"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> test <span class="token punctuation">(</span>
id <span class="token datatype">INT</span> <span class="token keyword">UNSIGNED</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span> <span class="token keyword">AUTO_INCREMENT</span><span class="token punctuation">,</span>
<span class="token keyword">data</span> <span class="token datatype">VARCHAR</span><span class="token punctuation">(</span><span class="token number">64</span><span class="token punctuation">)</span> <span class="token keyword">DEFAULT</span> <span class="token boolean">NULL</span><span class="token punctuation">,</span>
ts <span class="token datatype">TIMESTAMP</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span> <span class="token keyword">DEFAULT</span> <span class="token keyword">CURRENT_TIMESTAMP</span> <span class="token keyword">ON</span> <span class="token keyword">UPDATE</span> <span class="token keyword">CURRENT_TIMESTAMP</span><span class="token punctuation">,</span>
<span class="token keyword">PRIMARY</span> <span class="token keyword">KEY</span> <span class="token punctuation">(</span>id<span class="token punctuation">)</span>
<span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
When we create this table and run the statements shown in the
mysql client, the result is as follows:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa87980893"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">REPLACE</span> <span class="token keyword">INTO</span> test <span class="token keyword">VALUES</span> <span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token string">'Old'</span><span class="token punctuation">,</span> <span class="token string">'2014-08-20 18:47:00'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 1 row affected (0.04 sec)</span>
<span class="token prompt">mysql></span> <span class="token keyword">REPLACE</span> <span class="token keyword">INTO</span> test <span class="token keyword">VALUES</span> <span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token string">'New'</span><span class="token punctuation">,</span> <span class="token string">'2014-08-20 18:47:42'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 2 rows affected (0.04 sec)</span>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> test<span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> id <span class="token punctuation">|</span> data <span class="token punctuation">|</span> ts <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 1 <span class="token punctuation">|</span> New <span class="token punctuation">|</span> 2014<span class="token punctuation">-</span>08<span class="token punctuation">-</span>20 18:47:42 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">1 row in set (0.00 sec)</span></code></pre>
</div>
<p>
Now we create a second table almost identical to the first, except
that the primary key now covers 2 columns, as shown here
(emphasized text):
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa3815161"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> test2 <span class="token punctuation">(</span>
id <span class="token datatype">INT</span> <span class="token keyword">UNSIGNED</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span> <span class="token keyword">AUTO_INCREMENT</span><span class="token punctuation">,</span>
<span class="token keyword">data</span> <span class="token datatype">VARCHAR</span><span class="token punctuation">(</span><span class="token number">64</span><span class="token punctuation">)</span> <span class="token keyword">DEFAULT</span> <span class="token boolean">NULL</span><span class="token punctuation">,</span>
ts <span class="token datatype">TIMESTAMP</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span> <span class="token keyword">DEFAULT</span> <span class="token keyword">CURRENT_TIMESTAMP</span> <span class="token keyword">ON</span> <span class="token keyword">UPDATE</span> <span class="token keyword">CURRENT_TIMESTAMP</span><span class="token punctuation">,</span>
<span class="token keyword"></span><em><span class="token keyword">PRIMARY</span> <span class="token keyword">KEY</span> <span class="token punctuation">(</span>id<span class="token punctuation">,</span> ts<span class="token punctuation">)</span></em><span class="token punctuation"></span>
<span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
When we run on
<code class="literal">
test2
</code>
the same two
<code class="literal">
REPLACE
</code>
statements as we did on the original
<code class="literal">
test
</code>
table, we obtain a different result:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa11983085"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">REPLACE</span> <span class="token keyword">INTO</span> test2 <span class="token keyword">VALUES</span> <span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token string">'Old'</span><span class="token punctuation">,</span> <span class="token string">'2014-08-20 18:47:00'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 1 row affected (0.05 sec)</span>
<span class="token prompt">mysql></span> <span class="token keyword">REPLACE</span> <span class="token keyword">INTO</span> test2 <span class="token keyword">VALUES</span> <span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token string">'New'</span><span class="token punctuation">,</span> <span class="token string">'2014-08-20 18:47:42'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 1 row affected (0.06 sec)</span>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> test2<span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> id <span class="token punctuation">|</span> data <span class="token punctuation">|</span> ts <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 1 <span class="token punctuation">|</span> Old <span class="token punctuation">|</span> 2014<span class="token punctuation">-</span>08<span class="token punctuation">-</span>20 18:47:00 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 1 <span class="token punctuation">|</span> New <span class="token punctuation">|</span> 2014<span class="token punctuation">-</span>08<span class="token punctuation">-</span>20 18:47:42 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">2 rows in set (0.00 sec)</span></code></pre>
</div>
<p>
This is due to the fact that, when run on
<code class="literal">
test2
</code>
, both the
<code class="literal">
id
</code>
and
<code class="literal">
ts
</code>
column values must match those of an
existing row for the row to be replaced; otherwise, a row is
inserted.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/charset-unicode-utf8mb3.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="charset-unicode-utf8mb3">
</a>
12.9.2 The utf8mb3 Character Set (3-Byte UTF-8 Unicode Encoding)
</h3>
</div>
</div>
</div>
<a class="indexterm" name="idm46045216663440">
</a>
<a class="indexterm" name="idm46045216662400">
</a>
<a class="indexterm" name="idm46045216660912">
</a>
<p>
The
<code class="literal">
utf8mb3
</code>
character set has these
characteristics:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Supports BMP characters only (no support for supplementary
characters)
</p>
</li>
<li class="listitem">
<p>
Requires a maximum of three bytes per multibyte character.
</p>
</li>
</ul>
</div>
<p>
Applications that use UTF-8 data but require supplementary
character support should use
<code class="literal">
utf8mb4
</code>
rather
than
<code class="literal">
utf8mb3
</code>
(see
<a class="xref" href="charset-unicode-utf8mb4.html" title="12.9.1 The utf8mb4 Character Set (4-Byte UTF-8 Unicode Encoding)">
Section 12.9.1, “The utf8mb4 Character Set (4-Byte UTF-8 Unicode Encoding)”
</a>
).
</p>
<a class="indexterm" name="idm46045216653344">
</a>
<a class="indexterm" name="idm46045216652256">
</a>
<p>
Exactly the same set of characters is available in
<code class="literal">
utf8mb3
</code>
and
<code class="literal">
ucs2
</code>
. That is,
they have the same
<a class="link" href="glossary.html#glos_repertoire" title="repertoire">
repertoire
</a>
.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
The recommended character set for MySQL is
<code class="literal">
utf8mb4
</code>
. All new applications should use
<code class="literal">
utf8mb4
</code>
.
</p>
<p>
The
<code class="literal">
utf8mb3
</code>
character set is deprecated.
<code class="literal">
utf8mb3
</code>
remains supported for the lifetimes
of the MySQL 8.0.x and MySQL 8.4.x LTS release series.
</p>
<p>
Expect
<code class="literal">
utf8mb3
</code>
to be removed in a future
major release of MySQL.
</p>
<p>
Since changing character sets can be a complex and
time-consuming task, you should begin to prepare for this
change now by using
<code class="literal">
utf8mb4
</code>
for new
applications. For guidance in converting existing applications
which use utfmb3, see
<a class="xref" href="charset-unicode-conversion.html" title="12.9.8 Converting Between 3-Byte and 4-Byte Unicode Character Sets">
Section 12.9.8, “Converting Between 3-Byte and 4-Byte Unicode Character Sets”
</a>
.
</p>
</div>
<p>
<code class="literal">
utf8mb3
</code>
can be used in
<code class="literal">
CHARACTER
SET
</code>
clauses, and
<code class="literal">
utf8mb3_
<em class="replaceable">
<code>
collation_substring
</code>
</em>
</code>
in
<code class="literal">
COLLATE
</code>
clauses, where
<em class="replaceable">
<code>
collation_substring
</code>
</em>
is
<code class="literal">
bin
</code>
,
<code class="literal">
czech_ci
</code>
,
<code class="literal">
danish_ci
</code>
,
<code class="literal">
esperanto_ci
</code>
,
<code class="literal">
estonian_ci
</code>
, and so forth. For example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa16389361"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> t <span class="token punctuation">(</span>s1 <span class="token datatype">CHAR</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token keyword">CHARACTER</span> <span class="token keyword">SET</span> utf8mb3<span class="token punctuation">;</span>
<span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t <span class="token keyword">WHERE</span> s1 <span class="token keyword">COLLATE</span> utf8mb3_general_ci <span class="token operator">=</span> <span class="token string">'x'</span><span class="token punctuation">;</span>
<span class="token keyword">DECLARE</span> x <span class="token datatype">VARCHAR</span><span class="token punctuation">(</span><span class="token number">5</span><span class="token punctuation">)</span> <span class="token keyword">CHARACTER</span> <span class="token keyword">SET</span> utf8mb3 <span class="token keyword">COLLATE</span> utf8mb3_danish_ci<span class="token punctuation">;</span>
<span class="token keyword">SELECT</span> <span class="token function">CAST</span><span class="token punctuation">(</span><span class="token string">'a'</span> <span class="token keyword">AS</span> <span class="token datatype">CHAR</span> <span class="token keyword">CHARACTER</span> <span class="token keyword">SET</span> utf8mb4<span class="token punctuation">)</span> <span class="token keyword">COLLATE</span> utf8mb4_czech_ci<span class="token punctuation">;</span></code></pre>
</div>
<p>
In statements such as
<code class="literal">
SHOW CREATE TABLE
</code>
or
<code class="literal">
SELECT CHARACTER_SET_NAME FROM
INFORMATION_SCHEMA.COLUMNS
</code>
or
<code class="literal">
SELECT
COLLATION_NAME FROM INFORMATION_SCHEMA.COLUMNS
</code>
,
character sets or collation names prefixed with
<code class="literal">
utf8
</code>
or
<code class="literal">
utf8_
</code>
are
displayed using
<code class="literal">
utf8mb3
</code>
or
<code class="literal">
utf8mb3_
</code>
, respectively.
</p>
<p>
<code class="literal">
utf8mb3
</code>
is also valid (but deprecated) in
contexts other than
<code class="literal">
CHARACTER SET
</code>
clauses.
For example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa72957781"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal">mysqld <span class="token constant">--character-set-server</span><span class="token attr-value"><span class="token punctuation">=</span>utf8mb3</span></code></pre>
</div>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa9248442"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SET</span> <span class="token keyword">NAMES</span> <span class="token string">'utf8mb3'</span><span class="token punctuation">;</span> <span class="token comment" spellcheck="true">/* and other SET statements that have similar effect */</span>
<span class="token keyword">SELECT</span> _utf8mb3 <span class="token string">'a'</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
For information about data type storage as it relates to
multibyte character sets, see
<a class="xref" href="storage-requirements.html#data-types-storage-reqs-strings" title="String Type Storage Requirements">
String Type Storage Requirements
</a>
.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/show-create-user.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="show-create-user">
</a>
15.7.7.13 SHOW CREATE USER Statement
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045170799968">
</a>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa62671369"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SHOW</span> <span class="token keyword">CREATE</span> <span class="token keyword">USER</span> <span class="token keyword"><em class="replaceable">user</em></span></code></pre>
</div>
<p>
This statement shows the
<a class="link" href="create-user.html" title="15.7.1.3 CREATE USER Statement">
<code class="literal">
CREATE
USER
</code>
</a>
statement that creates the named user. An error
occurs if the user does not exist. The statement requires the
<a class="link" href="privileges-provided.html#priv_select">
<code class="literal">
SELECT
</code>
</a>
privilege for the
<code class="literal">
mysql
</code>
system schema, except to see
information for the current user. For the current user, the
<a class="link" href="privileges-provided.html#priv_select">
<code class="literal">
SELECT
</code>
</a>
privilege for the
<code class="literal">
mysql.user
</code>
system table is required for
display of the password hash in the
<code class="literal">
IDENTIFIED
AS
</code>
clause; otherwise, the hash displays as
<code class="literal">
<secret>
</code>
.
</p>
<p>
To name the account, use the format described in
<a class="xref" href="account-names.html" title="8.2.4 Specifying Account Names">
Section 8.2.4, “Specifying Account Names”
</a>
. The host name part of the
account name, if omitted, defaults to
<code class="literal">
'%'
</code>
. It
is also possible to specify
<a class="link" href="information-functions.html#function_current-user">
<code class="literal">
CURRENT_USER
</code>
</a>
or
<a class="link" href="information-functions.html#function_current-user">
<code class="literal">
CURRENT_USER()
</code>
</a>
to refer to the
account associated with the current session.
</p>
<p>
Password hash values displayed in the
<code class="literal">
IDENTIFIED
WITH
</code>
clause of output from
<a class="link" href="show-create-user.html" title="15.7.7.13 SHOW CREATE USER Statement">
<code class="literal">
SHOW
CREATE USER
</code>
</a>
may contain unprintable characters that
have adverse effects on terminal displays and in other
environments. Enabling the
<a class="link" href="server-system-variables.html#sysvar_print_identified_with_as_hex">
<code class="literal">
print_identified_with_as_hex
</code>
</a>
system variable causes
<a class="link" href="show-create-user.html" title="15.7.7.13 SHOW CREATE USER Statement">
<code class="literal">
SHOW CREATE
USER
</code>
</a>
to display such hash values as hexadecimal
strings rather than as regular string literals. Hash values that
do not contain unprintable characters still display as regular
string literals, even with this variable enabled.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa18591970"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">CREATE</span> <span class="token keyword">USER</span> <span class="token string">'u1'</span>@<span class="token string">'localhost'</span> <span class="token keyword">IDENTIFIED</span> <span class="token keyword">BY</span> <span class="token string">'secret'</span><span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">SET</span> print_identified_with_as_hex <span class="token operator">=</span> <span class="token keyword">ON</span><span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">SHOW</span> <span class="token keyword">CREATE</span> <span class="token keyword">USER</span> <span class="token string">'u1'</span>@<span class="token string">'localhost'</span>\G
<span class="token output"><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span> 1. row <span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span>
CREATE USER for u1@localhost<span class="token punctuation">:</span> CREATE USER `u1`@`localhost`
IDENTIFIED WITH 'caching_sha2_password'
AS 0x244124303035240C7745603626313D613C4C10633E0A104B1E14135A544A7871567245614F4872344643546336546F624F6C7861326932752F45622F4F473273597557627139
REQUIRE NONE PASSWORD EXPIRE DEFAULT ACCOUNT UNLOCK
PASSWORD HISTORY DEFAULT PASSWORD REUSE INTERVAL DEFAULT
PASSWORD REQUIRE CURRENT DEFAULT</span></code></pre>
</div>
<p>
To display the privileges granted to an account, use the
<a class="link" href="show-grants.html" title="15.7.7.22 SHOW GRANTS Statement">
<code class="literal">
SHOW GRANTS
</code>
</a>
statement. See
<a class="xref" href="show-grants.html" title="15.7.7.22 SHOW GRANTS Statement">
Section 15.7.7.22, “SHOW GRANTS Statement”
</a>
.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/show-profile.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="show-profile">
</a>
15.7.7.32 SHOW PROFILE Statement
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045169824480">
</a>
<a class="indexterm" name="idm46045169823408">
</a>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa46723182"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SHOW</span> <span class="token keyword">PROFILE</span> <span class="token punctuation">[</span><span class="token keyword"><em class="replaceable">type</em></span> <span class="token punctuation">[</span><span class="token punctuation">,</span> <span class="token keyword"><em class="replaceable">type</em></span><span class="token punctuation">]</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span> <span class="token punctuation">]</span>
<span class="token punctuation">[</span><span class="token keyword">FOR</span> <span class="token keyword">QUERY</span> <em class="replaceable">n</em><span class="token punctuation">]</span>
<span class="token punctuation">[</span><span class="token keyword">LIMIT</span> <span class="token keyword"><em class="replaceable">row_count</em></span> <span class="token punctuation">[</span><span class="token keyword">OFFSET</span> <span class="token keyword"><em class="replaceable">offset</em></span><span class="token punctuation">]</span><span class="token punctuation">]</span>
<span class="token keyword"><em class="replaceable">type</em></span>: {
<span class="token keyword">ALL</span>
<span class="token operator">|</span> <span class="token keyword">BLOCK</span> <span class="token keyword">IO</span>
<span class="token operator">|</span> <span class="token keyword">CONTEXT</span> <span class="token keyword">SWITCHES</span>
<span class="token operator">|</span> <span class="token keyword">CPU</span>
<span class="token operator">|</span> <span class="token keyword">IPC</span>
<span class="token operator">|</span> <span class="token keyword">MEMORY</span>
<span class="token operator">|</span> <span class="token keyword">PAGE</span> <span class="token keyword">FAULTS</span>
<span class="token operator">|</span> <span class="token keyword">SOURCE</span>
<span class="token operator">|</span> <span class="token keyword">SWAPS</span>
}</code></pre>
</div>
<p>
The
<a class="link" href="show-profile.html" title="15.7.7.32 SHOW PROFILE Statement">
<code class="literal">
SHOW PROFILE
</code>
</a>
and
<a class="link" href="show-profiles.html" title="15.7.7.33 SHOW PROFILES Statement">
<code class="literal">
SHOW PROFILES
</code>
</a>
statements display
profiling information that indicates resource usage for
statements executed during the course of the current session.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
The
<a class="link" href="show-profile.html" title="15.7.7.32 SHOW PROFILE Statement">
<code class="literal">
SHOW PROFILE
</code>
</a>
and
<a class="link" href="show-profiles.html" title="15.7.7.33 SHOW PROFILES Statement">
<code class="literal">
SHOW PROFILES
</code>
</a>
statements are
deprecated; expect them to be removed in a future MySQL
release. Use the
<a class="link" href="performance-schema.html" title="Chapter 29 MySQL Performance Schema">
Performance Schema
</a>
instead; see
<a class="xref" href="performance-schema-query-profiling.html" title="29.19.1 Query Profiling Using Performance Schema">
Section 29.19.1, “Query Profiling Using Performance Schema”
</a>
.
</p>
</div>
<p>
To control profiling, use the
<a class="link" href="server-system-variables.html#sysvar_profiling">
<code class="literal">
profiling
</code>
</a>
session variable,
which has a default value of 0 (
<code class="literal">
OFF
</code>
). Enable
profiling by setting
<a class="link" href="server-system-variables.html#sysvar_profiling">
<code class="literal">
profiling
</code>
</a>
to 1 or
<code class="literal">
ON
</code>
:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa93814122"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SET</span> profiling <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
<a class="link" href="show-profiles.html" title="15.7.7.33 SHOW PROFILES Statement">
<code class="literal">
SHOW PROFILES
</code>
</a>
displays a list of
the most recent statements sent to the server. The size of the
list is controlled by the
<a class="link" href="server-system-variables.html#sysvar_profiling_history_size">
<code class="literal">
profiling_history_size
</code>
</a>
session
variable, which has a default value of 15. The maximum value is
100. Setting the value to 0 has the practical effect of
disabling profiling.
</p>
<p>
All statements are profiled except
<a class="link" href="show-profile.html" title="15.7.7.32 SHOW PROFILE Statement">
<code class="literal">
SHOW
PROFILE
</code>
</a>
and
<a class="link" href="show-profiles.html" title="15.7.7.33 SHOW PROFILES Statement">
<code class="literal">
SHOW
PROFILES
</code>
</a>
, so neither of those statements appears in
the profile list. Malformed statements are profiled. For
example,
<code class="literal">
SHOW PROFILING
</code>
is an illegal
statement, and a syntax error occurs if you try to execute it,
but it shows up in the profiling list.
</p>
<p>
<a class="link" href="show-profile.html" title="15.7.7.32 SHOW PROFILE Statement">
<code class="literal">
SHOW PROFILE
</code>
</a>
displays detailed
information about a single statement. Without the
<code class="literal">
FOR
QUERY
<em class="replaceable">
<code>
n
</code>
</em>
</code>
clause, the output
pertains to the most recently executed statement. If
<code class="literal">
FOR QUERY
<em class="replaceable">
<code>
n
</code>
</em>
</code>
is
included,
<a class="link" href="show-profile.html" title="15.7.7.32 SHOW PROFILE Statement">
<code class="literal">
SHOW PROFILE
</code>
</a>
displays
information for statement
<em class="replaceable">
<code>
n
</code>
</em>
. The
values of
<em class="replaceable">
<code>
n
</code>
</em>
correspond to the
<code class="literal">
Query_ID
</code>
values displayed by
<a class="link" href="show-profiles.html" title="15.7.7.33 SHOW PROFILES Statement">
<code class="literal">
SHOW PROFILES
</code>
</a>
.
</p>
<p>
The
<code class="literal">
LIMIT
<em class="replaceable">
<code>
row_count
</code>
</em>
</code>
clause may be
given to limit the output to
<em class="replaceable">
<code>
row_count
</code>
</em>
rows. If
<code class="literal">
LIMIT
</code>
is given,
<code class="literal">
OFFSET
<em class="replaceable">
<code>
offset
</code>
</em>
</code>
may be added to
begin the output
<em class="replaceable">
<code>
offset
</code>
</em>
rows into the
full set of rows.
</p>
<p>
By default,
<a class="link" href="show-profile.html" title="15.7.7.32 SHOW PROFILE Statement">
<code class="literal">
SHOW PROFILE
</code>
</a>
displays
<code class="literal">
Status
</code>
and
<code class="literal">
Duration
</code>
columns. The
<code class="literal">
Status
</code>
values are like the
<code class="literal">
State
</code>
values displayed by
<a class="link" href="show-processlist.html" title="15.7.7.31 SHOW PROCESSLIST Statement">
<code class="literal">
SHOW PROCESSLIST
</code>
</a>
, although there
might be some minor differences in interpretation for the two
statements for some status values (see
<a class="xref" href="thread-information.html" title="10.14 Examining Server Thread (Process) Information">
Section 10.14, “Examining Server Thread (Process) Information”
</a>
).
</p>
<p>
Optional
<em class="replaceable">
<code>
type
</code>
</em>
values may be specified
to display specific additional types of information:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
ALL
</code>
displays all information
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
BLOCK IO
</code>
displays counts for block input
and output operations
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
CONTEXT SWITCHES
</code>
displays counts for
voluntary and involuntary context switches
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
CPU
</code>
displays user and system CPU usage
times
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
IPC
</code>
displays counts for messages sent and
received
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MEMORY
</code>
is not currently implemented
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
PAGE FAULTS
</code>
displays counts for major and
minor page faults
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SOURCE
</code>
displays the names of functions
from the source code, together with the name and line number
of the file in which the function occurs
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SWAPS
</code>
displays swap counts
</p>
</li>
</ul>
</div>
<p>
Profiling is enabled per session. When a session ends, its
profiling information is lost.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa10812481"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token variable">@@profiling</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> @@profiling <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 0 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">1 row in set (0.00 sec)</span>
<span class="token prompt">mysql></span> <span class="token keyword">SET</span> profiling <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected (0.00 sec)</span>
<span class="token prompt">mysql></span> <span class="token keyword">DROP</span> <span class="token keyword">TABLE</span> <span class="token keyword">IF</span> <span class="token keyword">EXISTS</span> t1<span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected, 1 warning (0.00 sec)</span>
<span class="token prompt">mysql></span> <span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> T1 <span class="token punctuation">(</span>id <span class="token datatype">INT</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected (0.01 sec)</span>
<span class="token prompt">mysql></span> <span class="token keyword">SHOW</span> <span class="token keyword">PROFILES</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> Query_ID <span class="token punctuation">|</span> Duration <span class="token punctuation">|</span> Query <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 0 <span class="token punctuation">|</span> 0.000088 <span class="token punctuation">|</span> SET PROFILING = 1 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 1 <span class="token punctuation">|</span> 0.000136 <span class="token punctuation">|</span> DROP TABLE IF EXISTS t1 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 2 <span class="token punctuation">|</span> 0.011947 <span class="token punctuation">|</span> CREATE TABLE t1 (id INT) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">3 rows in set (0.00 sec)</span>
<span class="token prompt">mysql></span> <span class="token keyword">SHOW</span> <span class="token keyword">PROFILE</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> Status <span class="token punctuation">|</span> Duration <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> checking permissions <span class="token punctuation">|</span> 0.000040 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> creating table <span class="token punctuation">|</span> 0.000056 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> After create <span class="token punctuation">|</span> 0.011363 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> query end <span class="token punctuation">|</span> 0.000375 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> freeing items <span class="token punctuation">|</span> 0.000089 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> logging slow query <span class="token punctuation">|</span> 0.000019 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> cleaning up <span class="token punctuation">|</span> 0.000005 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">7 rows in set (0.00 sec)</span>
<span class="token prompt">mysql></span> <span class="token keyword">SHOW</span> <span class="token keyword">PROFILE</span> <span class="token keyword">FOR</span> <span class="token keyword">QUERY</span> <span class="token number">1</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> Status <span class="token punctuation">|</span> Duration <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> query end <span class="token punctuation">|</span> 0.000107 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> freeing items <span class="token punctuation">|</span> 0.000008 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> logging slow query <span class="token punctuation">|</span> 0.000015 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> cleaning up <span class="token punctuation">|</span> 0.000006 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">4 rows in set (0.00 sec)</span>
<span class="token prompt">mysql></span> <span class="token keyword">SHOW</span> <span class="token keyword">PROFILE</span> <span class="token keyword">CPU</span> <span class="token keyword">FOR</span> <span class="token keyword">QUERY</span> <span class="token number">2</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> Status <span class="token punctuation">|</span> Duration <span class="token punctuation">|</span> CPU_user <span class="token punctuation">|</span> CPU_system <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> checking permissions <span class="token punctuation">|</span> 0.000040 <span class="token punctuation">|</span> 0.000038 <span class="token punctuation">|</span> 0.000002 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> creating table <span class="token punctuation">|</span> 0.000056 <span class="token punctuation">|</span> 0.000028 <span class="token punctuation">|</span> 0.000028 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> After create <span class="token punctuation">|</span> 0.011363 <span class="token punctuation">|</span> 0.000217 <span class="token punctuation">|</span> 0.001571 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> query end <span class="token punctuation">|</span> 0.000375 <span class="token punctuation">|</span> 0.000013 <span class="token punctuation">|</span> 0.000028 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> freeing items <span class="token punctuation">|</span> 0.000089 <span class="token punctuation">|</span> 0.000010 <span class="token punctuation">|</span> 0.000014 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> logging slow query <span class="token punctuation">|</span> 0.000019 <span class="token punctuation">|</span> 0.000009 <span class="token punctuation">|</span> 0.000010 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> cleaning up <span class="token punctuation">|</span> 0.000005 <span class="token punctuation">|</span> 0.000003 <span class="token punctuation">|</span> 0.000002 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">7 rows in set (0.00 sec)</span></code></pre>
</div>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
Profiling is only partially functional on some architectures.
For values that depend on the
<code class="literal">
getrusage()
</code>
system call,
<code class="literal">
NULL
</code>
is returned on systems
such as Windows that do not support the call. In addition,
profiling is per process and not per thread. This means that
activity on threads within the server other than your own may
affect the timing information that you see.
</p>
</div>
<p>
Profiling information is also available from the
<code class="literal">
INFORMATION_SCHEMA
</code>
<a class="link" href="information-schema-profiling-table.html" title="28.3.24 The INFORMATION_SCHEMA PROFILING Table">
<code class="literal">
PROFILING
</code>
</a>
table. See
<a class="xref" href="information-schema-profiling-table.html" title="28.3.24 The INFORMATION_SCHEMA PROFILING Table">
Section 28.3.24, “The INFORMATION_SCHEMA PROFILING Table”
</a>
. For
example, the following queries are equivalent:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa9688795"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SHOW</span> <span class="token keyword">PROFILE</span> <span class="token keyword">FOR</span> <span class="token keyword">QUERY</span> <span class="token number">2</span><span class="token punctuation">;</span>
<span class="token keyword">SELECT</span> STATE<span class="token punctuation">,</span> <span class="token function">FORMAT</span><span class="token punctuation">(</span>DURATION<span class="token punctuation">,</span> <span class="token number">6</span><span class="token punctuation">)</span> <span class="token keyword">AS</span> DURATION
<span class="token keyword">FROM</span> INFORMATION_SCHEMA<span class="token punctuation">.</span>PROFILING
<span class="token keyword">WHERE</span> QUERY_ID <span class="token operator">=</span> <span class="token number">2</span> <span class="token keyword">ORDER</span> <span class="token keyword">BY</span> SEQ<span class="token punctuation">;</span></code></pre>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/mysql-cluster-programs.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h2 class="title">
<a name="mysql-cluster-programs">
</a>
25.5 NDB Cluster Programs
</h2>
</div>
</div>
</div>
<div class="toc">
<dl class="toc">
<dt>
<span class="section">
<a href="mysql-cluster-programs-ndbd.html">
25.5.1 ndbd — The NDB Cluster Data Node Daemon
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="mysql-cluster-programs-ndbinfo-select-all.html">
25.5.2 ndbinfo_select_all — Select From ndbinfo Tables
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="mysql-cluster-programs-ndbmtd.html">
25.5.3 ndbmtd — The NDB Cluster Data Node Daemon (Multi-Threaded)
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="mysql-cluster-programs-ndb-mgmd.html">
25.5.4 ndb_mgmd — The NDB Cluster Management Server Daemon
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="mysql-cluster-programs-ndb-mgm.html">
25.5.5 ndb_mgm — The NDB Cluster Management Client
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="mysql-cluster-programs-ndb-blob-tool.html">
25.5.6 ndb_blob_tool — Check and Repair BLOB and TEXT columns of NDB Cluster
Tables
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="mysql-cluster-programs-ndb-config.html">
25.5.7 ndb_config — Extract NDB Cluster Configuration Information
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="mysql-cluster-programs-ndb-delete-all.html">
25.5.8 ndb_delete_all — Delete All Rows from an NDB Table
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="mysql-cluster-programs-ndb-desc.html">
25.5.9 ndb_desc — Describe NDB Tables
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="mysql-cluster-programs-ndb-drop-index.html">
25.5.10 ndb_drop_index — Drop Index from an NDB Table
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="mysql-cluster-programs-ndb-drop-table.html">
25.5.11 ndb_drop_table — Drop an NDB Table
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="mysql-cluster-programs-ndb-error-reporter.html">
25.5.12 ndb_error_reporter — NDB Error-Reporting Utility
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="mysql-cluster-programs-ndb-import.html">
25.5.13 ndb_import — Import CSV Data Into NDB
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="mysql-cluster-programs-ndb-index-stat.html">
25.5.14 ndb_index_stat — NDB Index Statistics Utility
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="mysql-cluster-programs-ndb-move-data.html">
25.5.15 ndb_move_data — NDB Data Copy Utility
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="mysql-cluster-programs-ndb-perror.html">
25.5.16 ndb_perror — Obtain NDB Error Message Information
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="mysql-cluster-programs-ndb-print-backup-file.html">
25.5.17 ndb_print_backup_file — Print NDB Backup File Contents
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="mysql-cluster-programs-ndb-print-file.html">
25.5.18 ndb_print_file — Print NDB Disk Data File Contents
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="mysql-cluster-programs-ndb-print-frag-file.html">
25.5.19 ndb_print_frag_file — Print NDB Fragment List File Contents
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="mysql-cluster-programs-ndb-print-schema-file.html">
25.5.20 ndb_print_schema_file — Print NDB Schema File Contents
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="mysql-cluster-programs-ndb-print-sys-file.html">
25.5.21 ndb_print_sys_file — Print NDB System File Contents
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="mysql-cluster-programs-ndb-redo-log-reader.html">
25.5.22 ndb_redo_log_reader — Check and Print Content of Cluster Redo Log
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="mysql-cluster-programs-ndb-restore.html">
25.5.23 ndb_restore — Restore an NDB Cluster Backup
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="mysql-cluster-programs-ndb-secretsfile-reader.html">
25.5.24 ndb_secretsfile_reader — Obtain Key Information from an Encrypted NDB
Data File
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="mysql-cluster-programs-ndb-select-all.html">
25.5.25 ndb_select_all — Print Rows from an NDB Table
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="mysql-cluster-programs-ndb-select-count.html">
25.5.26 ndb_select_count — Print Row Counts for NDB Tables
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="mysql-cluster-programs-ndb-show-tables.html">
25.5.27 ndb_show_tables — Display List of NDB Tables
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="mysql-cluster-programs-ndb-sign-keys.html">
25.5.28 ndb_sign_keys — Create, Sign, and Manage TLS Keys and Certificates for NDB
Cluster
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="mysql-cluster-programs-ndb-size-pl.html">
25.5.29 ndb_size.pl — NDBCLUSTER Size Requirement Estimator
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="mysql-cluster-programs-ndb-top.html">
25.5.30 ndb_top — View CPU usage information for NDB threads
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="mysql-cluster-programs-ndb-waiter.html">
25.5.31 ndb_waiter — Wait for NDB Cluster to Reach a Given Status
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="mysql-cluster-programs-ndbxfrm.html">
25.5.32 ndbxfrm — Compress, Decompress, Encrypt, and Decrypt
Files Created by NDB Cluster
</a>
</span>
</dt>
</dl>
</div>
<a class="indexterm" name="idm46045108493280">
</a>
<a class="indexterm" name="idm46045108491792">
</a>
<a class="indexterm" name="idm46045108490704">
</a>
<a class="indexterm" name="idm46045108489616">
</a>
<a class="indexterm" name="idm46045108488544">
</a>
<a class="indexterm" name="idm46045108487456">
</a>
<a class="indexterm" name="idm46045108486384">
</a>
<a class="indexterm" name="idm46045108485312">
</a>
<a class="indexterm" name="idm46045108484240">
</a>
<a class="indexterm" name="idm46045108483168">
</a>
<a class="indexterm" name="idm46045108482096">
</a>
<a class="indexterm" name="idm46045108481024">
</a>
<a class="indexterm" name="idm46045108479952">
</a>
<a class="indexterm" name="idm46045108478880">
</a>
<a class="indexterm" name="idm46045108477808">
</a>
<a class="indexterm" name="idm46045108476736">
</a>
<a class="indexterm" name="idm46045108475664">
</a>
<a class="indexterm" name="idm46045108474592">
</a>
<a class="indexterm" name="idm46045108473520">
</a>
<a class="indexterm" name="idm46045108472448">
</a>
<a class="indexterm" name="idm46045108471376">
</a>
<a class="indexterm" name="idm46045108470304">
</a>
<a class="indexterm" name="idm46045108469232">
</a>
<a class="indexterm" name="idm46045108468160">
</a>
<a class="indexterm" name="idm46045108467088">
</a>
<a class="indexterm" name="idm46045108466016">
</a>
<a class="indexterm" name="idm46045108464944">
</a>
<a class="indexterm" name="idm46045108463872">
</a>
<a class="indexterm" name="idm46045108462800">
</a>
<a class="indexterm" name="idm46045108461728">
</a>
<a class="indexterm" name="idm46045108459840">
</a>
<a class="indexterm" name="idm46045108458768">
</a>
<a class="indexterm" name="idm46045108457696">
</a>
<a class="indexterm" name="idm46045108456624">
</a>
<a class="indexterm" name="idm46045108455552">
</a>
<a class="indexterm" name="idm46045108454480">
</a>
<p>
Using and managing an NDB Cluster requires several specialized
programs, which we describe in this chapter. We discuss the purposes
of these programs in an NDB Cluster, how to use the programs, and
what startup options are available for each of them.
</p>
<p>
These programs include the NDB Cluster data, management, and SQL
node processes (
<a class="link" href="mysql-cluster-programs-ndbd.html" title="25.5.1 ndbd — The NDB Cluster Data Node Daemon">
<span class="command">
<strong>
ndbd
</strong>
</span>
</a>
,
<a class="link" href="mysql-cluster-programs-ndbmtd.html" title="25.5.3 ndbmtd — The NDB Cluster Data Node Daemon (Multi-Threaded)">
<span class="command">
<strong>
ndbmtd
</strong>
</span>
</a>
,
<a class="link" href="mysql-cluster-programs-ndb-mgmd.html" title="25.5.4 ndb_mgmd — The NDB Cluster Management Server Daemon">
<span class="command">
<strong>
ndb_mgmd
</strong>
</span>
</a>
, and
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
) and the
management client (
<a class="link" href="mysql-cluster-programs-ndb-mgm.html" title="25.5.5 ndb_mgm — The NDB Cluster Management Client">
<span class="command">
<strong>
ndb_mgm
</strong>
</span>
</a>
).
</p>
<p>
For information about using
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
as an NDB
Cluster process, see
<a class="xref" href="mysql-cluster-mysqld.html" title="25.6.10 MySQL Server Usage for NDB Cluster">
Section 25.6.10, “MySQL Server Usage for NDB Cluster”
</a>
.
</p>
<p>
Other
<a class="link" href="mysql-cluster.html" title="Chapter 25 MySQL NDB Cluster 8.4">
<code class="literal">
NDB
</code>
</a>
utility, diagnostic, and
example programs are included with the NDB Cluster distribution.
These include
<a class="link" href="mysql-cluster-programs-ndb-restore.html" title="25.5.23 ndb_restore — Restore an NDB Cluster Backup">
<span class="command">
<strong>
ndb_restore
</strong>
</span>
</a>
,
<a class="link" href="mysql-cluster-programs-ndb-show-tables.html" title="25.5.27 ndb_show_tables — Display List of NDB Tables">
<span class="command">
<strong>
ndb_show_tables
</strong>
</span>
</a>
, and
<a class="link" href="mysql-cluster-programs-ndb-config.html" title="25.5.7 ndb_config — Extract NDB Cluster Configuration Information">
<span class="command">
<strong>
ndb_config
</strong>
</span>
</a>
. These programs are also covered in
this section.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/mysql-shell-tutorial-javascript-collections-operations.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="mysql-shell-tutorial-javascript-collections-operations">
</a>
22.3.3.1 Create, List, and Drop Collections
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045127951952">
</a>
<p>
In MySQL Shell, you can create new collections, get a list of
the existing collections in a schema, and remove an existing
collection from a schema. Collection names are case-sensitive
and each collection name must be unique.
</p>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="idm46045127949776">
</a>
Confirm the Schema
</h5>
</div>
</div>
</div>
<a class="indexterm" name="idm46045127949104">
</a>
<p>
To show the value that is assigned to the schema variable,
issue:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-mysqlsh"><div class="docs-select-all right" id="sa30121401"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-mysqlsh"><span class="token prompt">mysql-js></span> db</code></pre>
</div>
<p>
If the schema value is not
<code class="literal">
Schema:world_x
</code>
,
then set the
<code class="literal">
db
</code>
variable by issuing:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-mysqlsh"><div class="docs-select-all right" id="sa11068568"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-mysqlsh"><span class="token prompt">mysql-js></span> \use world_x</code></pre>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="mysql-shell-tutorial-javascript-collections-create">
</a>
Create a Collection
</h5>
</div>
</div>
</div>
<a class="indexterm" name="idm46045127940624">
</a>
<p>
To create a new collection in an existing schema, use the
<code class="literal">
db
</code>
object's
<code class="literal">
createCollection()
</code>
method. The following
example creates a collection called
<code class="literal">
flags
</code>
in the
<code class="literal">
world_x
</code>
schema.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-mysqlsh"><div class="docs-select-all right" id="sa61481641"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-mysqlsh"><span class="token prompt">mysql-js></span> db<span class="token punctuation">.</span><span class="token function">createCollection</span><span class="token punctuation">(</span><span class="token string">"flags"</span><span class="token punctuation">)</span></code></pre>
</div>
<p>
The method returns a collection object.
</p>
<pre class="screen"><Collection:flags></pre>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="mysql-shell-tutorial-javascript-collections-get">
</a>
List Collections
</h5>
</div>
</div>
</div>
<a class="indexterm" name="idm46045127931616">
</a>
<p>
To display all collections in the
<code class="literal">
world_x
</code>
schema, use the
<code class="literal">
db
</code>
object's
<code class="literal">
getCollections()
</code>
method. Collections
returned by the server you are currently connected to appear
between brackets.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-mysqlsh"><div class="docs-select-all right" id="sa21046767"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-mysqlsh"><span class="token prompt">mysql-js></span> db<span class="token punctuation">.</span><span class="token function">getCollections</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
<span class="token punctuation">[</span>
<span class="token operator"><</span>Collection<span class="token punctuation">:</span>countryinfo<span class="token operator">></span><span class="token punctuation">,</span>
<span class="token operator"><</span>Collection<span class="token punctuation">:</span>flags<span class="token operator">></span>
<span class="token punctuation">]</span></code></pre>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="mysql-shell-tutorial-javascript-collections-drop">
</a>
Drop a Collection
</h5>
</div>
</div>
</div>
<a class="indexterm" name="idm46045127924384">
</a>
<p>
To drop an existing collection from a schema, use the
<code class="literal">
db
</code>
object's
<code class="literal">
dropCollection()
</code>
method. For example, to
drop the
<code class="literal">
flags
</code>
collection from the current
schema, issue:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-mysqlsh"><div class="docs-select-all right" id="sa98177640"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-mysqlsh"><span class="token prompt">mysql-js></span> db<span class="token punctuation">.</span><span class="token function">dropCollection</span><span class="token punctuation">(</span><span class="token string">"flags"</span><span class="token punctuation">)</span></code></pre>
</div>
<p>
The
<code class="literal">
dropCollection()
</code>
method is also used in
MySQL Shell to drop a relational table from a schema.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="idm46045127917248">
</a>
Related Information
</h5>
</div>
</div>
</div>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
See
<a class="ulink" href="/doc/x-devapi-userguide/en/collection-objects.html" target="_top">
Collection Objects
</a>
for more
examples.
</p>
</li>
</ul>
</div>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/check-table.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="check-table">
</a>
15.7.3.2 CHECK TABLE Statement
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045172472432">
</a>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa37598266"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">CHECK</span> <span class="token keyword">TABLE</span> <em class="replaceable">tbl_name</em> <span class="token punctuation">[</span><span class="token punctuation">,</span> <em class="replaceable">tbl_name</em><span class="token punctuation">]</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span> <span class="token punctuation">[</span><span class="token keyword"><em class="replaceable">option</em></span><span class="token punctuation">]</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
<span class="token keyword"><em class="replaceable">option</em></span>: {
<span class="token keyword">FOR</span> <span class="token keyword">UPGRADE</span>
<span class="token operator">|</span> <span class="token keyword">QUICK</span>
<span class="token operator">|</span> <span class="token keyword">FAST</span>
<span class="token operator">|</span> <span class="token keyword">MEDIUM</span>
<span class="token operator">|</span> <span class="token keyword">EXTENDED</span>
<span class="token operator">|</span> <span class="token keyword">CHANGED</span>
}</code></pre>
</div>
<p>
<a class="link" href="check-table.html" title="15.7.3.2 CHECK TABLE Statement">
<code class="literal">
CHECK TABLE
</code>
</a>
checks a table or
tables for errors.
<a class="link" href="check-table.html" title="15.7.3.2 CHECK TABLE Statement">
<code class="literal">
CHECK TABLE
</code>
</a>
can also check views for problems, such as tables that are
referenced in the view definition that no longer exist.
</p>
<p>
To check a table, you must have some privilege for it.
</p>
<p>
<a class="link" href="check-table.html" title="15.7.3.2 CHECK TABLE Statement">
<code class="literal">
CHECK TABLE
</code>
</a>
works for
<a class="link" href="innodb-storage-engine.html" title="Chapter 17 The InnoDB Storage Engine">
<code class="literal">
InnoDB
</code>
</a>
,
<a class="link" href="myisam-storage-engine.html" title="18.2 The MyISAM Storage Engine">
<code class="literal">
MyISAM
</code>
</a>
,
<a class="link" href="archive-storage-engine.html" title="18.5 The ARCHIVE Storage Engine">
<code class="literal">
ARCHIVE
</code>
</a>
, and
<a class="link" href="csv-storage-engine.html" title="18.4 The CSV Storage Engine">
<code class="literal">
CSV
</code>
</a>
tables.
</p>
<p>
Before running
<a class="link" href="check-table.html" title="15.7.3.2 CHECK TABLE Statement">
<code class="literal">
CHECK TABLE
</code>
</a>
on
<code class="literal">
InnoDB
</code>
tables, see
<a class="xref" href="check-table.html#check-table-innodb" title="CHECK TABLE Usage Notes for InnoDB Tables">
CHECK TABLE Usage Notes for InnoDB Tables
</a>
.
</p>
<p>
<a class="link" href="check-table.html" title="15.7.3.2 CHECK TABLE Statement">
<code class="literal">
CHECK TABLE
</code>
</a>
is supported for
partitioned tables, and you can use
<code class="literal">
ALTER TABLE ...
CHECK PARTITION
</code>
to check one or more partitions; for
more information, see
<a class="xref" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
Section 15.1.9, “ALTER TABLE Statement”
</a>
, and
<a class="xref" href="partitioning-maintenance.html" title="26.3.4 Maintenance of Partitions">
Section 26.3.4, “Maintenance of Partitions”
</a>
.
</p>
<p>
<a class="link" href="check-table.html" title="15.7.3.2 CHECK TABLE Statement">
<code class="literal">
CHECK TABLE
</code>
</a>
ignores virtual
generated columns that are not indexed.
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="xref" href="check-table.html#check-table-output" title="CHECK TABLE Output">
CHECK TABLE Output
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="check-table.html#check-table-version-compatibility" title="Checking Version Compatibility">
Checking Version Compatibility
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="check-table.html#check-table-data-consistency" title="Checking Data Consistency">
Checking Data Consistency
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="check-table.html#check-table-innodb" title="CHECK TABLE Usage Notes for InnoDB Tables">
CHECK TABLE Usage Notes for InnoDB Tables
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="check-table.html#check-table-myisam" title="CHECK TABLE Usage Notes for MyISAM Tables">
CHECK TABLE Usage Notes for MyISAM Tables
</a>
</p>
</li>
</ul>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="check-table-output">
</a>
CHECK TABLE Output
</h5>
</div>
</div>
</div>
<p>
<a class="link" href="check-table.html" title="15.7.3.2 CHECK TABLE Statement">
<code class="literal">
CHECK TABLE
</code>
</a>
returns a result
set with the columns shown in the following table.
</p>
<div class="informaltable">
<table summary="Columns of the CHECK TABLE result set.">
<colgroup>
<col style="width: 15%"/>
<col style="width: 60%"/>
</colgroup>
<thead>
<tr>
<th>
Column
</th>
<th>
Value
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<code class="literal">
Table
</code>
</td>
<td>
The table name
</td>
</tr>
<tr>
<td>
<code class="literal">
Op
</code>
</td>
<td>
Always
<code class="literal">
check
</code>
</td>
</tr>
<tr>
<td>
<code class="literal">
Msg_type
</code>
</td>
<td>
<code class="literal">
status
</code>
,
<code class="literal">
error
</code>
,
<code class="literal">
info
</code>
,
<code class="literal">
note
</code>
, or
<code class="literal">
warning
</code>
</td>
</tr>
<tr>
<td>
<code class="literal">
Msg_text
</code>
</td>
<td>
An informational message
</td>
</tr>
</tbody>
</table>
</div>
<p>
The statement might produce many rows of information for each
checked table. The last row has a
<code class="literal">
Msg_type
</code>
value of
<code class="literal">
status
</code>
and the
<code class="literal">
Msg_text
</code>
normally should be
<code class="literal">
OK
</code>
.
<code class="literal">
Table is already up to
date
</code>
means that the storage engine for the table
indicated that there was no need to check the table.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="check-table-version-compatibility">
</a>
Checking Version Compatibility
</h5>
</div>
</div>
</div>
<p>
The
<code class="literal">
FOR UPGRADE
</code>
option checks whether the
named tables are compatible with the current version of MySQL.
With
<code class="literal">
FOR UPGRADE
</code>
, the server checks each
table to determine whether there have been any incompatible
changes in any of the table's data types or indexes since the
table was created. If not, the check succeeds. Otherwise, if
there is a possible incompatibility, the server runs a full
check on the table (which might take some time).
</p>
<p>
Incompatibilities might occur because the storage format for a
data type has changed or because its sort order has changed.
Our aim is to avoid these changes, but occasionally they are
necessary to correct problems that would be worse than an
incompatibility between releases.
</p>
<p>
<code class="literal">
FOR UPGRADE
</code>
discovers these
incompatibilities:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
The indexing order for end-space in
<a class="link" href="blob.html" title="13.3.4 The BLOB and TEXT Types">
<code class="literal">
TEXT
</code>
</a>
columns for
<code class="literal">
InnoDB
</code>
and
<code class="literal">
MyISAM
</code>
tables changed between MySQL 4.1 and 5.0.
</p>
</li>
<li class="listitem">
<p>
The storage method of the new
<a class="link" href="fixed-point-types.html" title="13.1.3 Fixed-Point Types (Exact Value) - DECIMAL, NUMERIC">
<code class="literal">
DECIMAL
</code>
</a>
data type changed
between MySQL 5.0.3 and 5.0.5.
</p>
</li>
<li class="listitem">
<p>
Changes are sometimes made to character sets or collations
that require table indexes to be rebuilt. For details
about such changes, see
<a class="xref" href="upgrading-from-previous-series.html" title="3.5 Changes in MySQL 8.4">
Section 3.5, “Changes in MySQL 8.4”
</a>
. For
information about rebuilding tables, see
<a class="xref" href="rebuilding-tables.html" title="3.14 Rebuilding or Repairing Tables or Indexes">
Section 3.14, “Rebuilding or Repairing Tables or Indexes”
</a>
.
</p>
</li>
<li class="listitem">
<p>
MySQL 8.4 does not support the 2-digit
<a class="link" href="year.html" title="13.2.4 The YEAR Type">
<code class="literal">
YEAR(2)
</code>
</a>
data type permitted
in older versions of MySQL. For tables containing
<a class="link" href="year.html" title="13.2.4 The YEAR Type">
<code class="literal">
YEAR(2)
</code>
</a>
columns,
<a class="link" href="check-table.html" title="15.7.3.2 CHECK TABLE Statement">
<code class="literal">
CHECK TABLE
</code>
</a>
recommends
<a class="link" href="repair-table.html" title="15.7.3.5 REPAIR TABLE Statement">
<code class="literal">
REPAIR TABLE
</code>
</a>
, which
converts 2-digit
<a class="link" href="year.html" title="13.2.4 The YEAR Type">
<code class="literal">
YEAR(2)
</code>
</a>
columns to 4-digit
<a class="link" href="year.html" title="13.2.4 The YEAR Type">
<code class="literal">
YEAR
</code>
</a>
columns.
</p>
</li>
<li class="listitem">
<p>
Trigger creation time is maintained.
</p>
</li>
<li class="listitem">
<p>
A table is reported as needing a rebuild if it contains
old temporal columns in pre-5.6.4 format
(
<a class="link" href="time.html" title="13.2.3 The TIME Type">
<code class="literal">
TIME
</code>
</a>
,
<a class="link" href="datetime.html" title="13.2.2 The DATE, DATETIME, and TIMESTAMP Types">
<code class="literal">
DATETIME
</code>
</a>
, and
<a class="link" href="datetime.html" title="13.2.2 The DATE, DATETIME, and TIMESTAMP Types">
<code class="literal">
TIMESTAMP
</code>
</a>
columns without
support for fractional seconds precision). This helps the
MySQL upgrade procedure detect and upgrade tables
containing old temporal columns.
</p>
</li>
<li class="listitem">
<p>
Warnings are issued for tables that use nonnative
partitioning because nonnative partitioning is removed in
MySQL 8.4. See
<a class="xref" href="partitioning.html" title="Chapter 26 Partitioning">
Chapter 26,
<i>
Partitioning
</i>
</a>
.
</p>
</li>
</ul>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="check-table-data-consistency">
</a>
Checking Data Consistency
</h5>
</div>
</div>
</div>
<p>
The following table shows the other check options that can be
given. These options are passed to the storage engine, which
may use or ignore them.
</p>
<div class="informaltable">
<table summary="Other CHECK TABLE options.">
<colgroup>
<col style="width: 15%"/>
<col style="width: 85%"/>
</colgroup>
<thead>
<tr>
<th>
Type
</th>
<th>
Meaning
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<code class="literal">
QUICK
</code>
</td>
<td>
Do not scan the rows to check for incorrect links. Applies to
<code class="literal">
InnoDB
</code>
and
<code class="literal">
MyISAM
</code>
tables and views.
</td>
</tr>
<tr>
<td>
<code class="literal">
FAST
</code>
</td>
<td>
Check only tables that have not been closed properly. Ignored for
<code class="literal">
InnoDB
</code>
; applies only to
<code class="literal">
MyISAM
</code>
tables and views.
</td>
</tr>
<tr>
<td>
<code class="literal">
CHANGED
</code>
</td>
<td>
Check only tables that have been changed since the last check or that
have not been closed properly. Ignored for
<code class="literal">
InnoDB
</code>
; applies only to
<code class="literal">
MyISAM
</code>
tables and views.
</td>
</tr>
<tr>
<td>
<code class="literal">
MEDIUM
</code>
</td>
<td>
Scan rows to verify that deleted links are valid. This also calculates a
key checksum for the rows and verifies this with a
calculated checksum for the keys. Ignored for
<code class="literal">
InnoDB
</code>
; applies only to
<code class="literal">
MyISAM
</code>
tables and views.
</td>
</tr>
<tr>
<td>
<code class="literal">
EXTENDED
</code>
</td>
<td>
Do a full key lookup for all keys for each row. This ensures that the
table is 100% consistent, but takes a long time. Ignored
for
<code class="literal">
InnoDB
</code>
; applies only to
<code class="literal">
MyISAM
</code>
tables and views.
</td>
</tr>
</tbody>
</table>
</div>
<p>
You can combine check options, as in the following example
that does a quick check on the table to determine whether it
was closed properly:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa38351969"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">CHECK</span> <span class="token keyword">TABLE</span> test_table <span class="token keyword">FAST</span> <span class="token keyword">QUICK</span><span class="token punctuation">;</span></code></pre>
</div>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
If
<a class="link" href="check-table.html" title="15.7.3.2 CHECK TABLE Statement">
<code class="literal">
CHECK TABLE
</code>
</a>
finds no
problems with a table that is marked as
<span class="quote">
“
<span class="quote">
corrupted
</span>
”
</span>
or
<span class="quote">
“
<span class="quote">
not closed
properly
</span>
”
</span>
,
<a class="link" href="check-table.html" title="15.7.3.2 CHECK TABLE Statement">
<code class="literal">
CHECK TABLE
</code>
</a>
may remove the mark.
</p>
</div>
<p>
If a table is corrupted, the problem is most likely in the
indexes and not in the data part. All of the preceding check
types check the indexes thoroughly and should thus find most
errors.
</p>
<p>
To check a table that you assume is okay, use no check options
or the
<code class="literal">
QUICK
</code>
option. The latter should be
used when you are in a hurry and can take the very small risk
that
<code class="literal">
QUICK
</code>
does not find an error in the
data file. (In most cases, under normal usage, MySQL should
find any error in the data file. If this happens, the table is
marked as
<span class="quote">
“
<span class="quote">
corrupted
</span>
”
</span>
and cannot be used until it
is repaired.)
</p>
<p>
<code class="literal">
FAST
</code>
and
<code class="literal">
CHANGED
</code>
are
mostly intended to be used from a script (for example, to be
executed from
<span class="command">
<strong>
cron
</strong>
</span>
) to check tables
periodically. In most cases,
<code class="literal">
FAST
</code>
is to be
preferred over
<code class="literal">
CHANGED
</code>
. (The only case when
it is not preferred is when you suspect that you have found a
bug in the
<code class="literal">
MyISAM
</code>
code.)
</p>
<p>
<code class="literal">
EXTENDED
</code>
is to be used only after you have
run a normal check but still get errors from a table when
MySQL tries to update a row or find a row by key. This is very
unlikely if a normal check has succeeded.
</p>
<p>
Use of
<a class="link" href="check-table.html" title="15.7.3.2 CHECK TABLE Statement">
<code class="literal">
CHECK
TABLE ... EXTENDED
</code>
</a>
might influence execution plans
generated by the query optimizer.
</p>
<p>
Some problems reported by
<a class="link" href="check-table.html" title="15.7.3.2 CHECK TABLE Statement">
<code class="literal">
CHECK
TABLE
</code>
</a>
cannot be corrected automatically:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
Found row where the auto_increment column has the
value 0
</code>
.
</p>
<p>
This means that you have a row in the table where the
<code class="literal">
AUTO_INCREMENT
</code>
index column contains
the value 0. (It is possible to create a row where the
<code class="literal">
AUTO_INCREMENT
</code>
column is 0 by
explicitly setting the column to 0 with an
<a class="link" href="update.html" title="15.2.17 UPDATE Statement">
<code class="literal">
UPDATE
</code>
</a>
statement.)
</p>
<p>
This is not an error in itself, but could cause trouble if
you decide to dump the table and restore it or do an
<a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
<code class="literal">
ALTER TABLE
</code>
</a>
on the table.
In this case, the
<code class="literal">
AUTO_INCREMENT
</code>
column
changes value according to the rules of
<code class="literal">
AUTO_INCREMENT
</code>
columns, which could
cause problems such as a duplicate-key error.
</p>
<p>
To get rid of the warning, execute an
<a class="link" href="update.html" title="15.2.17 UPDATE Statement">
<code class="literal">
UPDATE
</code>
</a>
statement to set the
column to some value other than 0.
</p>
</li>
</ul>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="check-table-innodb">
</a>
CHECK TABLE Usage Notes for InnoDB Tables
</h5>
</div>
</div>
</div>
<p>
The following notes apply to
<a class="link" href="innodb-storage-engine.html" title="Chapter 17 The InnoDB Storage Engine">
<code class="literal">
InnoDB
</code>
</a>
tables:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
If
<a class="link" href="check-table.html" title="15.7.3.2 CHECK TABLE Statement">
<code class="literal">
CHECK TABLE
</code>
</a>
encounters a
corrupt page, the server exits to prevent error
propagation (Bug #10132). If the corruption occurs in a
secondary index but table data is readable, running
<a class="link" href="check-table.html" title="15.7.3.2 CHECK TABLE Statement">
<code class="literal">
CHECK TABLE
</code>
</a>
can still cause
a server exit.
</p>
</li>
<li class="listitem">
<p>
If
<a class="link" href="check-table.html" title="15.7.3.2 CHECK TABLE Statement">
<code class="literal">
CHECK TABLE
</code>
</a>
encounters a
corrupted
<code class="literal">
DB_TRX_ID
</code>
or
<code class="literal">
DB_ROLL_PTR
</code>
field in a clustered index,
<a class="link" href="check-table.html" title="15.7.3.2 CHECK TABLE Statement">
<code class="literal">
CHECK TABLE
</code>
</a>
can cause
<code class="literal">
InnoDB
</code>
to access an invalid undo log
record, resulting in an
<a class="link" href="glossary.html#glos_mvcc" title="MVCC">
MVCC
</a>
-related server exit.
</p>
</li>
<li class="listitem">
<p>
If
<a class="link" href="check-table.html" title="15.7.3.2 CHECK TABLE Statement">
<code class="literal">
CHECK TABLE
</code>
</a>
encounters
errors in
<code class="literal">
InnoDB
</code>
tables or indexes, it
reports an error, and usually marks the index and
sometimes marks the table as corrupted, preventing further
use of the index or table. Such errors include an
incorrect number of entries in a secondary index or
incorrect links.
</p>
</li>
<li class="listitem">
<p>
If
<a class="link" href="check-table.html" title="15.7.3.2 CHECK TABLE Statement">
<code class="literal">
CHECK TABLE
</code>
</a>
finds an
incorrect number of entries in a secondary index, it
reports an error but does not cause a server exit or
prevent access to the file.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="check-table.html" title="15.7.3.2 CHECK TABLE Statement">
<code class="literal">
CHECK TABLE
</code>
</a>
surveys the
index page structure, then surveys each key entry. It does
not validate the key pointer to a clustered record or
follow the path for
<a class="link" href="blob.html" title="13.3.4 The BLOB and TEXT Types">
<code class="literal">
BLOB
</code>
</a>
pointers.
</p>
</li>
<li class="listitem">
<p>
When an
<code class="literal">
InnoDB
</code>
table is stored in its
own
<a class="link" href="glossary.html#glos_ibd_file" title=".ibd file">
<code class="filename">
.ibd
</code>
file
</a>
, the first 3
<a class="link" href="glossary.html#glos_page" title="page">
pages
</a>
of the
<code class="literal">
.ibd
</code>
file contain header information
rather than table or index data. The
<a class="link" href="check-table.html" title="15.7.3.2 CHECK TABLE Statement">
<code class="literal">
CHECK TABLE
</code>
</a>
statement does
not detect inconsistencies that affect only the header
data. To verify the entire contents of an
<code class="literal">
InnoDB
</code>
<code class="literal">
.ibd
</code>
file,
use the
<a class="link" href="innochecksum.html" title="6.6.2 innochecksum — Offline InnoDB File Checksum Utility">
<span class="command">
<strong>
innochecksum
</strong>
</span>
</a>
command.
</p>
</li>
<li class="listitem">
<p>
When running
<a class="link" href="check-table.html" title="15.7.3.2 CHECK TABLE Statement">
<code class="literal">
CHECK TABLE
</code>
</a>
on
large
<code class="literal">
InnoDB
</code>
tables, other threads may
be blocked during
<a class="link" href="check-table.html" title="15.7.3.2 CHECK TABLE Statement">
<code class="literal">
CHECK
TABLE
</code>
</a>
execution. To avoid timeouts, the
semaphore wait threshold (600 seconds) is extended by 2
hours (7200 seconds) for
<a class="link" href="check-table.html" title="15.7.3.2 CHECK TABLE Statement">
<code class="literal">
CHECK
TABLE
</code>
</a>
operations. If
<code class="literal">
InnoDB
</code>
detects semaphore waits of 240 seconds or more, it starts
printing
<code class="literal">
InnoDB
</code>
monitor output to the
error log. If a lock request extends beyond the semaphore
wait threshold,
<code class="literal">
InnoDB
</code>
aborts the
process. To avoid the possibility of a semaphore wait
timeout entirely, run
<a class="link" href="check-table.html" title="15.7.3.2 CHECK TABLE Statement">
<code class="literal">
CHECK TABLE
QUICK
</code>
</a>
instead of
<a class="link" href="check-table.html" title="15.7.3.2 CHECK TABLE Statement">
<code class="literal">
CHECK
TABLE
</code>
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="check-table.html" title="15.7.3.2 CHECK TABLE Statement">
<code class="literal">
CHECK TABLE
</code>
</a>
functionality
for
<code class="literal">
InnoDB
</code>
<code class="literal">
SPATIAL
</code>
indexes includes an R-tree validity check and a check to
ensure that the R-tree row count matches the clustered
index.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="check-table.html" title="15.7.3.2 CHECK TABLE Statement">
<code class="literal">
CHECK TABLE
</code>
</a>
supports
secondary indexes on virtual generated columns, which are
supported by
<code class="literal">
InnoDB
</code>
.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="innodb-storage-engine.html" title="Chapter 17 The InnoDB Storage Engine">
<code class="literal">
InnoDB
</code>
</a>
supports parallel
clustered index reads, which can improve
<a class="link" href="check-table.html" title="15.7.3.2 CHECK TABLE Statement">
<code class="literal">
CHECK TABLE
</code>
</a>
performance.
<code class="literal">
InnoDB
</code>
reads the clustered index twice
during a
<a class="link" href="check-table.html" title="15.7.3.2 CHECK TABLE Statement">
<code class="literal">
CHECK TABLE
</code>
</a>
operation. The second read can be performed in parallel.
The
<a class="link" href="innodb-parameters.html#sysvar_innodb_parallel_read_threads">
<code class="literal">
innodb_parallel_read_threads
</code>
</a>
session variable must be set to a value greater than 1 for
parallel clustered index reads to occur. The actual number
of threads used to perform a parallel clustered index read
is determined by the
<a class="link" href="innodb-parameters.html#sysvar_innodb_parallel_read_threads">
<code class="literal">
innodb_parallel_read_threads
</code>
</a>
setting or the number of index subtrees to scan, whichever
is smaller.
</p>
</li>
</ul>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="check-table-myisam">
</a>
CHECK TABLE Usage Notes for MyISAM Tables
</h5>
</div>
</div>
</div>
<p>
The following notes apply to
<a class="link" href="myisam-storage-engine.html" title="18.2 The MyISAM Storage Engine">
<code class="literal">
MyISAM
</code>
</a>
tables:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="link" href="check-table.html" title="15.7.3.2 CHECK TABLE Statement">
<code class="literal">
CHECK TABLE
</code>
</a>
updates key
statistics for
<code class="literal">
MyISAM
</code>
tables.
</p>
</li>
<li class="listitem">
<p>
If
<a class="link" href="check-table.html" title="15.7.3.2 CHECK TABLE Statement">
<code class="literal">
CHECK TABLE
</code>
</a>
output does
not return
<code class="literal">
OK
</code>
or
<code class="literal">
Table is
already up to date
</code>
, you should normally run a
repair of the table. See
<a class="xref" href="myisam-table-maintenance.html" title="9.6 MyISAM Table Maintenance and Crash Recovery">
Section 9.6, “MyISAM Table Maintenance and Crash Recovery”
</a>
.
</p>
</li>
<li class="listitem">
<p>
If none of the
<a class="link" href="check-table.html" title="15.7.3.2 CHECK TABLE Statement">
<code class="literal">
CHECK TABLE
</code>
</a>
options
<code class="literal">
QUICK
</code>
,
<code class="literal">
MEDIUM
</code>
, or
<code class="literal">
EXTENDED
</code>
are specified, the default check type for dynamic-format
<code class="literal">
MyISAM
</code>
tables is
<code class="literal">
MEDIUM
</code>
. This has the same result as
running
<a class="link" href="myisamchk.html" title="6.6.4 myisamchk — MyISAM Table-Maintenance Utility">
<span class="command">
<strong>
myisamchk --medium-check
<em class="replaceable">
<code>
tbl_name
</code>
</em>
</strong>
</span>
</a>
on the
table. The default check type also is
<code class="literal">
MEDIUM
</code>
for static-format
<code class="literal">
MyISAM
</code>
tables, unless
<code class="literal">
CHANGED
</code>
or
<code class="literal">
FAST
</code>
is
specified. In that case, the default is
<code class="literal">
QUICK
</code>
. The row scan is skipped for
<code class="literal">
CHANGED
</code>
and
<code class="literal">
FAST
</code>
because the rows are very seldom corrupted.
</p>
</li>
</ul>
</div>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/uninstall-component.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="uninstall-component">
</a>
15.7.4.5 UNINSTALL COMPONENT Statement
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045171675808">
</a>
<a class="indexterm" name="idm46045171674720">
</a>
<a class="indexterm" name="idm46045171673648">
</a>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa59776986"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">UNINSTALL</span> <span class="token keyword">COMPONENT</span> <em class="replaceable">component_name</em> <span class="token punctuation">[</span><span class="token punctuation">,</span> <em class="replaceable">component_name</em> <span class="token punctuation">]</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span></code></pre>
</div>
<p>
This statement deactivates and uninstalls one or more
components. A component provides services that are available to
the server and other components; see
<a class="xref" href="components.html" title="7.5 MySQL Components">
Section 7.5, “MySQL Components”
</a>
.
<a class="link" href="uninstall-component.html" title="15.7.4.5 UNINSTALL COMPONENT Statement">
<code class="literal">
UNINSTALL
COMPONENT
</code>
</a>
is the complement of
<a class="link" href="install-component.html" title="15.7.4.3 INSTALL COMPONENT Statement">
<code class="literal">
INSTALL COMPONENT
</code>
</a>
. It requires
the
<a class="link" href="privileges-provided.html#priv_delete">
<code class="literal">
DELETE
</code>
</a>
privilege for the
<code class="literal">
mysql.component
</code>
system table because it
removes the row from that table that registers the component.
<a class="link" href="uninstall-component.html" title="15.7.4.5 UNINSTALL COMPONENT Statement">
<code class="literal">
UNINSTALL COMPONENT
</code>
</a>
does not undo
persisted variables, including the variables persisted using
<code class="literal">
INSTALL COMPONENT ... SET PERSIST
</code>
.
</p>
<p>
Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa580704"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">UNINSTALL</span> <span class="token keyword">COMPONENT</span> <span class="token string">'file://component1'</span><span class="token punctuation">,</span> <span class="token string">'file://component2'</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
For information about component naming, see
<a class="xref" href="install-component.html" title="15.7.4.3 INSTALL COMPONENT Statement">
Section 15.7.4.3, “INSTALL COMPONENT Statement”
</a>
.
</p>
<p>
If any error occurs, the statement fails and has no effect. For
example, this happens if a component name is erroneous, a named
component is not installed, or cannot be uninstalled because
other installed components depend on it.
</p>
<p>
A loader service handles component unloading, which includes
removing uninstalled components from the
<code class="literal">
mysql.component
</code>
system table that serves as a
registry. As a result, unloaded components are not loaded during
the startup sequence for subsequent server restarts.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
This statement has no effect for keyring components, which are
loaded using a manifest file and cannot be uninstalled. See
<a class="xref" href="keyring-component-installation.html" title="8.4.4.2 Keyring Component Installation">
Section 8.4.4.2, “Keyring Component Installation”
</a>
.
</p>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/charset-national.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="charset-national">
</a>
12.3.7 The National Character Set
</h3>
</div>
</div>
</div>
<p>
Standard SQL defines
<a class="link" href="char.html" title="13.3.2 The CHAR and VARCHAR Types">
<code class="literal">
NCHAR
</code>
</a>
or
<a class="link" href="char.html" title="13.3.2 The CHAR and VARCHAR Types">
<code class="literal">
NATIONAL CHAR
</code>
</a>
as a way to
indicate that a
<a class="link" href="char.html" title="13.3.2 The CHAR and VARCHAR Types">
<code class="literal">
CHAR
</code>
</a>
column
should use some predefined character set. MySQL uses
<code class="literal">
utf8
</code>
as this predefined character set. For
example, these data type declarations are equivalent:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa76373317"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token datatype">CHAR</span><span class="token punctuation">(</span><span class="token number">10</span><span class="token punctuation">)</span> <span class="token keyword">CHARACTER</span> <span class="token keyword">SET</span> utf8
<span class="token keyword">NATIONAL</span> <span class="token keyword">CHARACTER</span><span class="token punctuation">(</span><span class="token number">10</span><span class="token punctuation">)</span>
<span class="token datatype">NCHAR</span><span class="token punctuation">(</span><span class="token number">10</span><span class="token punctuation">)</span></code></pre>
</div>
<p>
As are these:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa52624511"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token datatype">VARCHAR</span><span class="token punctuation">(</span><span class="token number">10</span><span class="token punctuation">)</span> <span class="token keyword">CHARACTER</span> <span class="token keyword">SET</span> utf8
<span class="token keyword">NATIONAL</span> <span class="token datatype">VARCHAR</span><span class="token punctuation">(</span><span class="token number">10</span><span class="token punctuation">)</span>
<span class="token datatype">NVARCHAR</span><span class="token punctuation">(</span><span class="token number">10</span><span class="token punctuation">)</span>
<span class="token datatype">NCHAR</span> <span class="token datatype">VARCHAR</span><span class="token punctuation">(</span><span class="token number">10</span><span class="token punctuation">)</span>
<span class="token keyword">NATIONAL</span> <span class="token keyword">CHARACTER</span> <span class="token keyword">VARYING</span><span class="token punctuation">(</span><span class="token number">10</span><span class="token punctuation">)</span>
<span class="token keyword">NATIONAL</span> <span class="token datatype">CHAR</span> <span class="token keyword">VARYING</span><span class="token punctuation">(</span><span class="token number">10</span><span class="token punctuation">)</span></code></pre>
</div>
<p>
You can use
<code class="literal">
N'
<em class="replaceable">
<code>
literal
</code>
</em>
'
</code>
(or
<code class="literal">
n'
<em class="replaceable">
<code>
literal
</code>
</em>
'
</code>
) to
create a string in the national character set. These statements
are equivalent:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa61123835"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> N<span class="token string">'some text'</span><span class="token punctuation">;</span>
<span class="token keyword">SELECT</span> n<span class="token string">'some text'</span><span class="token punctuation">;</span>
<span class="token keyword">SELECT</span> _utf8<span class="token string">'some text'</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
MySQL 8.4 interprets the national character set as
<code class="literal">
utf8mb3
</code>
, which is now deprecated. Thus, using
<code class="literal">
NATIONAL CHARACTER
</code>
or one of its synonyms to
define the character set for a database, table, or column raises
a warning similar to this one:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa77296006"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">NATIONAL</span><span class="token operator">/</span><span class="token datatype">NCHAR</span><span class="token operator">/</span><span class="token datatype">NVARCHAR</span> implies the <span class="token keyword">character</span> <span class="token keyword">set</span> UTF8MB3<span class="token punctuation">,</span> which will be
replaced <span class="token keyword">by</span> UTF8MB4 <span class="token keyword">in</span> a future <span class="token keyword">release</span><span class="token punctuation">.</span> Please consider <span class="token keyword">using</span> <span class="token datatype">CHAR</span><span class="token punctuation">(</span>x<span class="token punctuation">)</span> <span class="token keyword">CHARACTER</span>
<span class="token keyword">SET</span> UTF8MB4 <span class="token keyword">in</span> <span class="token keyword">order</span> <span class="token keyword">to</span> be unambiguous<span class="token punctuation">.</span></code></pre>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/innodb-troubleshooting-recovery.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="innodb-troubleshooting-recovery">
</a>
17.20.2 Troubleshooting Recovery Failures
</h3>
</div>
</div>
</div>
<p>
Checkpoints and advancing the checkpoint LSN are not permitted
until redo log recovery is complete and data dictionary dynamic
metadata (
<code class="literal">
srv_dict_metadata
</code>
) is transferred to
data dictionary table (
<code class="literal">
dict_table_t
</code>
) objects.
Should the redo log run out of space during recovery or after
recovery (but before data dictionary dynamic metadata is
transferred to data dictionary table objects) as a result of this
change, an
<a class="link" href="innodb-parameters.html#sysvar_innodb_force_recovery">
<code class="literal">
innodb_force_recovery
</code>
</a>
restart may be required, starting with at least the
<code class="literal">
SRV_FORCE_NO_IBUF_MERGE
</code>
setting or, in case
that fails, the
<code class="literal">
SRV_FORCE_NO_LOG_REDO
</code>
setting.
If an
<a class="link" href="innodb-parameters.html#sysvar_innodb_force_recovery">
<code class="literal">
innodb_force_recovery
</code>
</a>
restart fails in this scenario, recovery from backup may be
necessary.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/connectors-apis.html | <div id="docs-body">
<div class="chapter">
<div class="titlepage">
<div>
<div>
<h1 class="title">
<a name="connectors-apis">
</a>
Chapter 31 Connectors and APIs
</h1>
</div>
</div>
</div>
<div class="toc">
<p>
<b>
Table of Contents
</b>
</p>
<dl class="toc">
<dt>
<span class="section">
<a href="connector-cpp-info.html">
31.1 MySQL Connector/C++
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="connector-j-info.html">
31.2 MySQL Connector/J
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="connector-net-info.html">
31.3 MySQL Connector/NET
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="connector-odbc-info.html">
31.4 MySQL Connector/ODBC
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="connector-python-info.html">
31.5 MySQL Connector/Python
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="connector-nodejs-info.html">
31.6 MySQL Connector/Node.js
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="c-api-info.html">
31.7 MySQL C API
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="apis-php-info.html">
31.8 MySQL PHP API
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="apis-perl.html">
31.9 MySQL Perl API
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="apis-python.html">
31.10 MySQL Python API
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="apis-ruby.html">
31.11 MySQL Ruby APIs
</a>
</span>
</dt>
<dd>
<dl>
<dt>
<span class="section">
<a href="apis-ruby-mysqlruby.html">
31.11.1 The MySQL/Ruby API
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="apis-ruby-rubymysql.html">
31.11.2 The Ruby/MySQL API
</a>
</span>
</dt>
</dl>
</dd>
<dt>
<span class="section">
<a href="apis-tcl.html">
31.12 MySQL Tcl API
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="apis-eiffel.html">
31.13 MySQL Eiffel Wrapper
</a>
</span>
</dt>
</dl>
</div>
<a class="indexterm" name="idm46045060619472">
</a>
<a class="indexterm" name="idm46045060618400">
</a>
<a class="indexterm" name="idm46045060617328">
</a>
<a class="indexterm" name="idm46045060616256">
</a>
<a class="indexterm" name="idm46045060615184">
</a>
<a class="indexterm" name="idm46045060614112">
</a>
<a class="indexterm" name="idm46045060613040">
</a>
<a class="indexterm" name="idm46045060611968">
</a>
<a class="indexterm" name="idm46045060610896">
</a>
<a class="indexterm" name="idm46045060609824">
</a>
<a class="indexterm" name="idm46045060608752">
</a>
<a class="indexterm" name="idm46045060607680">
</a>
<a class="indexterm" name="idm46045060606608">
</a>
<a class="indexterm" name="idm46045060605120">
</a>
<p>
MySQL Connectors provide connectivity to the MySQL server for client
programs. APIs provide low-level access to MySQL resources using
either the classic MySQL protocol or X Protocol. Both Connectors and the
APIs enable you to connect and execute MySQL statements from another
language or environment, including ODBC, Java (JDBC), C++, Python,
Node.js, PHP, Perl, Ruby, and C.
</p>
<h2>
<a name="idm46045060602832">
</a>
MySQL Connectors
</h2>
<p>
Oracle develops a number of connectors:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="ulink" href="/doc/connector-cpp/9.1/en/" target="_top">
Connector/C++
</a>
enables C++ applications to connect to MySQL.
</p>
</li>
<li class="listitem">
<p>
<a class="ulink" href="/doc/connector-j/en/" target="_top">
Connector/J
</a>
provides driver
support for connecting to MySQL from Java applications using the
standard Java Database Connectivity (JDBC) API.
</p>
</li>
<li class="listitem">
<p>
<a class="ulink" href="/doc/connector-net/en/" target="_top">
Connector/NET
</a>
enables developers
to create .NET applications that connect to MySQL. Connector/NET
implements a fully functional ADO.NET interface and provides
support for use with ADO.NET aware tools. Applications that use
Connector/NET can be written in any supported .NET language.
</p>
</li>
<li class="listitem">
<p>
<a class="ulink" href="/doc/connector-odbc/en/" target="_top">
Connector/ODBC
</a>
provides
driver support for connecting to MySQL using the Open Database
Connectivity (ODBC) API. Support is available for ODBC
connectivity from Windows, Unix, and macOS platforms.
</p>
</li>
<li class="listitem">
<p>
<a class="ulink" href="/doc/connector-python/en/" target="_top">
Connector/Python
</a>
provides driver support for connecting to MySQL from Python
applications using an API that is compliant with the
<a class="ulink" href="http://www.python.org/dev/peps/pep-0249/" target="_blank">
Python DB
API version 2.0
</a>
. No additional Python modules or MySQL
client libraries are required.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
Connector/Node.js
</code>
provides an asynchronous
API for connecting to MySQL from Node.js applications using
X Protocol. Connector/Node.js supports managing database
sessions and schemas, working with MySQL Document Store
collections and using raw SQL statements.
</p>
</li>
</ul>
</div>
<h2>
<a name="idm46045060590336">
</a>
The MySQL C API
</h2>
<p>
For direct access to using MySQL natively within a C application,
the
<a class="ulink" href="/doc/c-api/8.4/en/" target="_top">
C API
</a>
provides low-level access to
the MySQL client/server protocol through the
<code class="literal">
libmysqlclient
</code>
client library. This is the
primary method used to connect to an instance of the MySQL server,
and is used both by MySQL command-line clients and many of the MySQL
Connectors and third-party APIs detailed here.
</p>
<p>
<code class="literal">
libmysqlclient
</code>
is included in MySQL distributions
distributions.
</p>
<p>
See also
<a class="ulink" href="/doc/c-api/8.4/en/c-api-implementations.html" target="_top">
MySQL C API Implementations
</a>
.
</p>
<p>
To access MySQL from a C application, or to build an interface to
MySQL for a language not supported by the Connectors or APIs in this
chapter, the
<a class="ulink" href="/doc/c-api/8.4/en/" target="_top">
C API
</a>
is where to start. A
number of programmer's utilities are available to help with the
process; see
<a class="xref" href="programs-development.html" title="6.7 Program Development Utilities">
Section 6.7, “Program Development Utilities”
</a>
.
</p>
<h2>
<a name="idm46045060582960">
</a>
Third-Party MySQL APIs
</h2>
<p>
The remaining APIs described in this chapter provide an interface to
MySQL from specific application languages. These third-party
solutions are not developed or supported by Oracle. Basic
information on their usage and abilities is provided here for
reference purposes only.
</p>
<p>
All the third-party language APIs are developed using one of two
methods, using
<code class="literal">
libmysqlclient
</code>
or by implementing
a
<span class="firstterm">
native driver
</span>
. The two
solutions offer different benefits:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Using
<span class="emphasis">
<em>
<code class="literal">
libmysqlclient
</code>
</em>
</span>
offers complete compatibility with MySQL because it uses the
same libraries as the MySQL client applications. However, the
feature set is limited to the implementation and interfaces
exposed through
<code class="literal">
libmysqlclient
</code>
and the
performance may be lower as data is copied between the native
language, and the MySQL API components.
</p>
</li>
<li class="listitem">
<p>
<span class="emphasis">
<em>
Native drivers
</em>
</span>
are an implementation of the
MySQL network protocol entirely within the host language or
environment. Native drivers are fast, as there is less copying
of data between components, and they can offer advanced
functionality not available through the standard MySQL API.
Native drivers are also easier for end users to build and deploy
because no copy of the MySQL client libraries is needed to build
the native driver components.
</p>
</li>
</ul>
</div>
<p>
<a class="xref" href="connectors-apis.html#connectors-apis-summary" title="Table 31.1 MySQL APIs and Interfaces">
Table 31.1, “MySQL APIs and Interfaces”
</a>
lists many of the
libraries and interfaces available for MySQL.
</p>
<div class="table">
<a name="connectors-apis-summary">
</a>
<p class="title">
<b>
Table 31.1 MySQL APIs and Interfaces
</b>
</p>
<div class="table-contents">
<table summary="Summary of MySQL APIs and interfaces showing the environment, API, type, and related notes.">
<colgroup>
<col style="width: 10%"/>
<col style="width: 35%"/>
<col style="width: 15%"/>
<col style="width: 40%"/>
</colgroup>
<thead>
<tr>
<th scope="col">
Environment
</th>
<th scope="col">
API
</th>
<th scope="col">
Type
</th>
<th scope="col">
Notes
</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">
Ada
</th>
<td>
GNU Ada MySQL Bindings
</td>
<td>
<code class="literal">
libmysqlclient
</code>
</td>
<td>
See
<a class="ulink" href="http://gnade.sourceforge.net/" target="_blank">
MySQL Bindings for GNU
Ada
</a>
</td>
</tr>
<tr>
<th scope="row">
C
</th>
<td>
C API
</td>
<td>
<code class="literal">
libmysqlclient
</code>
</td>
<td>
See
<a class="ulink" href="/doc/c-api/8.4/en/" target="_top">
MySQL 8.4 C API Developer Guide
</a>
.
</td>
</tr>
<tr>
<th scope="row">
C++
</th>
<td>
Connector/C++
</td>
<td>
<code class="literal">
libmysqlclient
</code>
</td>
<td>
See
<a class="ulink" href="/doc/connector-cpp/9.1/en/" target="_top">
MySQL Connector/C++ 9.1 Developer Guide
</a>
.
</td>
</tr>
<tr>
<th scope="row">
</th>
<td>
MySQL++
</td>
<td>
<code class="literal">
libmysqlclient
</code>
</td>
<td>
See
<a class="ulink" href="http://tangentsoft.net/mysql++/doc/" target="_blank">
MySQL++
website
</a>
.
</td>
</tr>
<tr>
<th scope="row">
</th>
<td>
MySQL wrapped
</td>
<td>
<code class="literal">
libmysqlclient
</code>
</td>
<td>
See
<a class="ulink" href="http://www.alhem.net/project/mysql/" target="_blank">
MySQL
wrapped
</a>
.
</td>
</tr>
<tr>
<th scope="row">
Cocoa
</th>
<td>
MySQL-Cocoa
</td>
<td>
<code class="literal">
libmysqlclient
</code>
</td>
<td>
Compatible with the Objective-C Cocoa environment. See
<a class="ulink" href="http://mysql-cocoa.sourceforge.net/" target="_blank">
http://mysql-cocoa.sourceforge.net/
</a>
</td>
</tr>
<tr>
<th scope="row">
D
</th>
<td>
MySQL for D
</td>
<td>
<code class="literal">
libmysqlclient
</code>
</td>
<td>
See
<a class="ulink" href="http://www.steinmole.de/d/" target="_blank">
MySQL for D
</a>
.
</td>
</tr>
<tr>
<th scope="row">
Eiffel
</th>
<td>
Eiffel MySQL
</td>
<td>
<code class="literal">
libmysqlclient
</code>
</td>
<td>
See
<a class="xref" href="apis-eiffel.html" title="31.13 MySQL Eiffel Wrapper">
Section 31.13, “MySQL Eiffel Wrapper”
</a>
.
</td>
</tr>
<tr>
<th scope="row">
Erlang
</th>
<td>
<code class="literal">
erlang-mysql-driver
</code>
</td>
<td>
<code class="literal">
libmysqlclient
</code>
</td>
<td>
See
<a class="ulink" href="http://code.google.com/p/erlang-mysql-driver/" target="_blank">
<code class="literal">
erlang-mysql-driver
</code>
.
</a>
</td>
</tr>
<tr>
<th scope="row">
Haskell
</th>
<td>
Haskell MySQL Bindings
</td>
<td>
Native Driver
</td>
<td>
See
<a class="ulink" href="http://www.serpentine.com/blog/software/mysql/" target="_blank">
Brian
O'Sullivan's pure Haskell MySQL bindings
</a>
.
</td>
</tr>
<tr>
<th scope="row">
</th>
<td>
<code class="literal">
hsql-mysql
</code>
</td>
<td>
<code class="literal">
libmysqlclient
</code>
</td>
<td>
See
<a class="ulink" href="http://hackage.haskell.org/cgi-bin/hackage-scripts/package/hsql-mysql-1.7" target="_blank">
MySQL
driver for Haskell
</a>
.
</td>
</tr>
<tr>
<th scope="row">
Java/JDBC
</th>
<td>
Connector/J
</td>
<td>
Native Driver
</td>
<td>
See
<a class="ulink" href="/doc/connector-j/en/" target="_top">
MySQL Connector/J Developer Guide
</a>
.
</td>
</tr>
<tr>
<th scope="row">
Kaya
</th>
<td>
MyDB
</td>
<td>
<code class="literal">
libmysqlclient
</code>
</td>
<td>
See
<a class="ulink" href="http://kayalang.org/library/latest/MyDB" target="_blank">
MyDB
</a>
.
</td>
</tr>
<tr>
<th scope="row">
Lua
</th>
<td>
LuaSQL
</td>
<td>
<code class="literal">
libmysqlclient
</code>
</td>
<td>
See
<a class="ulink" href="http://keplerproject.github.io/luasql/doc/us/" target="_blank">
LuaSQL
</a>
.
</td>
</tr>
<tr>
<th scope="row">
.NET/Mono
</th>
<td>
Connector/NET
</td>
<td>
Native Driver
</td>
<td>
See
<a class="ulink" href="/doc/connector-net/en/" target="_top">
MySQL Connector/NET Developer Guide
</a>
.
</td>
</tr>
<tr>
<th scope="row">
Objective Caml
</th>
<td>
OBjective Caml MySQL Bindings
</td>
<td>
<code class="literal">
libmysqlclient
</code>
</td>
<td>
See
<a class="ulink" href="http://raevnos.pennmush.org/code/ocaml-mysql/" target="_blank">
MySQL
Bindings for Objective Caml
</a>
.
</td>
</tr>
<tr>
<th scope="row">
Octave
</th>
<td>
Database bindings for GNU Octave
</td>
<td>
<code class="literal">
libmysqlclient
</code>
</td>
<td>
See
<a class="ulink" href="http://octave.sourceforge.net/database/index.html" target="_blank">
Database
bindings for GNU Octave
</a>
.
</td>
</tr>
<tr>
<th scope="row">
ODBC
</th>
<td>
Connector/ODBC
</td>
<td>
<code class="literal">
libmysqlclient
</code>
</td>
<td>
See
<a class="ulink" href="/doc/connector-odbc/en/" target="_top">
MySQL Connector/ODBC Developer Guide
</a>
.
</td>
</tr>
<tr>
<th scope="row">
Perl
</th>
<td>
<code class="literal">
DBI
</code>
/
<code class="literal">
DBD::mysql
</code>
</td>
<td>
<code class="literal">
libmysqlclient
</code>
</td>
<td>
See
<a class="xref" href="apis-perl.html" title="31.9 MySQL Perl API">
Section 31.9, “MySQL Perl API”
</a>
.
</td>
</tr>
<tr>
<th scope="row">
</th>
<td>
<code class="literal">
Net::MySQL
</code>
</td>
<td>
Native Driver
</td>
<td>
See
<a class="ulink" href="http://search.cpan.org/dist/Net-MySQL/MySQL.pm" target="_blank">
<code class="literal">
Net::MySQL
</code>
</a>
at CPAN
</td>
</tr>
<tr>
<th scope="row">
PHP
</th>
<td>
<code class="literal">
mysql
</code>
,
<code class="literal">
ext/mysql
</code>
interface
(deprecated)
</td>
<td>
<code class="literal">
libmysqlclient
</code>
</td>
<td>
See
<a class="ulink" href="/doc/apis-php/en/" target="_top">
MySQL and PHP
</a>
.
</td>
</tr>
<tr>
<th scope="row">
</th>
<td>
<code class="literal">
mysqli
</code>
,
<code class="literal">
ext/mysqli
</code>
interface
</td>
<td>
<code class="literal">
libmysqlclient
</code>
</td>
<td>
See
<a class="ulink" href="/doc/apis-php/en/" target="_top">
MySQL and PHP
</a>
.
</td>
</tr>
<tr>
<th scope="row">
</th>
<td>
<code class="literal">
PDO_MYSQL
</code>
</td>
<td>
<code class="literal">
libmysqlclient
</code>
</td>
<td>
See
<a class="ulink" href="/doc/apis-php/en/" target="_top">
MySQL and PHP
</a>
.
</td>
</tr>
<tr>
<th scope="row">
</th>
<td>
PDO mysqlnd
</td>
<td>
Native Driver
</td>
<td>
</td>
</tr>
<tr>
<th scope="row">
Python
</th>
<td>
Connector/Python
</td>
<td>
Native Driver
</td>
<td>
See
<a class="ulink" href="/doc/connector-python/en/" target="_top">
MySQL Connector/Python Developer Guide
</a>
.
</td>
</tr>
<tr>
<th scope="row">
Python
</th>
<td>
Connector/Python C Extension
</td>
<td>
<code class="literal">
libmysqlclient
</code>
</td>
<td>
See
<a class="ulink" href="/doc/connector-python/en/" target="_top">
MySQL Connector/Python Developer Guide
</a>
.
</td>
</tr>
<tr>
<th scope="row">
</th>
<td>
MySQLdb
</td>
<td>
<code class="literal">
libmysqlclient
</code>
</td>
<td>
See
<a class="xref" href="apis-python.html" title="31.10 MySQL Python API">
Section 31.10, “MySQL Python API”
</a>
.
</td>
</tr>
<tr>
<th scope="row">
Ruby
</th>
<td>
mysql2
</td>
<td>
<code class="literal">
libmysqlclient
</code>
</td>
<td>
Uses
<code class="literal">
libmysqlclient
</code>
. See
<a class="xref" href="apis-ruby.html" title="31.11 MySQL Ruby APIs">
Section 31.11, “MySQL Ruby APIs”
</a>
.
</td>
</tr>
<tr>
<th scope="row">
Scheme
</th>
<td>
<code class="literal">
Myscsh
</code>
</td>
<td>
<code class="literal">
libmysqlclient
</code>
</td>
<td>
See
<a class="ulink" href="https://github.com/aehrisch/myscsh" target="_blank">
<code class="literal">
Myscsh
</code>
</a>
.
</td>
</tr>
<tr>
<th scope="row">
SPL
</th>
<td>
<code class="literal">
sql_mysql
</code>
</td>
<td>
<code class="literal">
libmysqlclient
</code>
</td>
<td>
See
<a class="ulink" href="http://www.clifford.at/spl/spldoc/sql_mysql.html" target="_blank">
<code class="literal">
sql_mysql
</code>
for SPL
</a>
.
</td>
</tr>
<tr>
<th scope="row">
Tcl
</th>
<td>
MySQLtcl
</td>
<td>
<code class="literal">
libmysqlclient
</code>
</td>
<td>
See
<a class="xref" href="apis-tcl.html" title="31.12 MySQL Tcl API">
Section 31.12, “MySQL Tcl API”
</a>
.
</td>
</tr>
</tbody>
</table>
</div>
<div class="table-contents">
<table cellpadding="0" cellspacing="0" style="position: fixed; top: 0px; display: none; left: 401px; width: 739px;">
<thead>
<tr>
<th scope="col" style="width: 99.1406px;">
Environment
</th>
<th scope="col" style="width: 241.047px;">
API
</th>
<th scope="col" style="width: 120.766px;">
Type
</th>
<th scope="col" style="width: 277.047px;">
Notes
</th>
</tr>
</thead>
</table>
</div>
</div>
<br class="table-break"/>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/replication-features-blackhole.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="replication-features-blackhole">
</a>
19.5.1.2 Replication and BLACKHOLE Tables
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045135964960">
</a>
<a class="indexterm" name="idm46045135963472">
</a>
<a class="indexterm" name="idm46045135961984">
</a>
<a class="indexterm" name="idm46045135960496">
</a>
<p>
The
<a class="link" href="blackhole-storage-engine.html" title="18.6 The BLACKHOLE Storage Engine">
<code class="literal">
BLACKHOLE
</code>
</a>
storage engine
accepts data but discards it and does not store it. When
performing binary logging, all inserts to such tables are always
logged, regardless of the logging format in use. Updates and
deletes are handled differently depending on whether statement
based or row based logging is in use. With the statement based
logging format, all statements affecting
<code class="literal">
BLACKHOLE
</code>
tables are logged, but their
effects ignored. When using row-based logging, updates and
deletes to such tables are simply skipped—they are not
written to the binary log. A warning is logged whenever this
occurs.
</p>
<p>
For this reason we recommend when you replicate to tables using
the
<a class="link" href="blackhole-storage-engine.html" title="18.6 The BLACKHOLE Storage Engine">
<code class="literal">
BLACKHOLE
</code>
</a>
storage engine that
you have the
<a class="link" href="replication-options-binary-log.html#sysvar_binlog_format">
<code class="literal">
binlog_format
</code>
</a>
server variable set to
<code class="literal">
STATEMENT
</code>
, and not to
either
<code class="literal">
ROW
</code>
or
<code class="literal">
MIXED
</code>
.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/error-log-configuration.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="error-log-configuration">
</a>
7.4.2.1 Error Log Configuration
</h4>
</div>
</div>
</div>
<p>
In MySQL 8.4, error logging uses the MySQL
component architecture described at
<a class="xref" href="components.html" title="7.5 MySQL Components">
Section 7.5, “MySQL Components”
</a>
. The error log subsystem consists
of components that perform log event filtering and writing, as
well as a system variable that configures which components to
load and enable to achieve the desired logging result.
</p>
<p>
This section discusses how to load and enable components for
error logging. For instructions specific to log filters, see
<a class="xref" href="error-log-filtering.html" title="7.4.2.4 Types of Error Log Filtering">
Section 7.4.2.4, “Types of Error Log Filtering”
</a>
. For instructions specific
to the JSON and system log sinks, see
<a class="xref" href="error-log-json.html" title="7.4.2.7 Error Logging in JSON Format">
Section 7.4.2.7, “Error Logging in JSON Format”
</a>
, and
<a class="xref" href="error-log-syslog.html" title="7.4.2.8 Error Logging to the System Log">
Section 7.4.2.8, “Error Logging to the System Log”
</a>
. For additional details about
all available log components, see
<a class="xref" href="error-log-components.html" title="7.5.3 Error Log Components">
Section 7.5.3, “Error Log Components”
</a>
.
</p>
<p>
Component-based error logging offers these features:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Log events that can be filtered by filter components to
affect the information available for writing.
</p>
</li>
<li class="listitem">
<p>
Log events that are output by sink (writer) components.
Multiple sink components can be enabled, to write error log
output to multiple destinations.
</p>
</li>
<li class="listitem">
<p>
Built-in filter and sink components that implement the
default error log format.
</p>
</li>
<li class="listitem">
<p>
A loadable sink that enables logging in JSON format.
</p>
</li>
<li class="listitem">
<p>
A loadable sink that enables logging to the system log.
</p>
</li>
<li class="listitem">
<p>
System variables that control which log components to load
and enable and how each component operates.
</p>
</li>
</ul>
</div>
<p>
Error log configuration is described under the following topics
in this section:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="xref" href="error-log-configuration.html#error-log-default-configuration" title="The Default Error Log Configuration">
The Default Error Log Configuration
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="error-log-configuration.html#error-log-configuration-methods" title="Error Log Configuration Methods">
Error Log Configuration Methods
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="error-log-configuration.html#error-log-implicit-configuration" title="Implicit Error Log Configuration">
Implicit Error Log Configuration
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="error-log-configuration.html#error-log-explicit-configuration" title="Explicit Error Log Configuration">
Explicit Error Log Configuration
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="error-log-configuration.html#error-log-configuration-change-method" title="Changing the Error Log Configuration Method">
Changing the Error Log Configuration Method
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="error-log-configuration.html#error-log-configuration-troubleshooting" title="Troubleshooting Configuration Issues">
Troubleshooting Configuration Issues
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="error-log-configuration.html#error-log-configuration-multiple-log-sinks" title="Configuring Multiple Log Sinks">
Configuring Multiple Log Sinks
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="error-log-configuration.html#error-log-configuration-log-sink-ps-support" title="Log Sink Performance Schema Support">
Log Sink Performance Schema Support
</a>
</p>
</li>
</ul>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="error-log-default-configuration">
</a>
The Default Error Log Configuration
</h5>
</div>
</div>
</div>
<p>
The
<a class="link" href="server-system-variables.html#sysvar_log_error_services">
<code class="literal">
log_error_services
</code>
</a>
system
variable controls which loadable log components to load, and
which log components to enable for error logging. By default,
<code class="literal">
log_error_services
</code>
has the value shown
here:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa37243220"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token variable">@@GLOBAL.log_error_services</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> @@GLOBAL.log_error_services <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> log_filter_internal; log_sink_internal <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
<p>
That value indicates that log events first pass through the
<code class="literal">
log_filter_internal
</code>
filter component, then
through the
<code class="literal">
log_sink_internal
</code>
sink
component, both of which are built-in components. A filter
modifies log events seen by components named later in the
<a class="link" href="server-system-variables.html#sysvar_log_error_services">
<code class="literal">
log_error_services
</code>
</a>
value. A
sink is a destination for log events. Typically, a sink
processes log events into log messages that have a particular
format and writes these messages to its associated output,
such as a file or the system log.
</p>
<p>
The combination of
<code class="literal">
log_filter_internal
</code>
and
<code class="literal">
log_sink_internal
</code>
implements the default
error log filtering and output behavior. The action of these
components is affected by other server options and system
variables:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
The output destination is determined by the
<a class="link" href="server-options.html#option_mysqld_log-error">
<code class="option">
--log-error
</code>
</a>
option (and, on
Windows,
<a class="link" href="server-system-variables.html#sysvar_pid_file">
<code class="option">
--pid-file
</code>
</a>
and
<a class="link" href="server-options.html#option_mysqld_console">
<code class="option">
--console
</code>
</a>
). These determine
whether to write error messages to the console or a file
and, if to a file, the error log file name. See
<a class="xref" href="error-log-destination-configuration.html" title="7.4.2.2 Default Error Log Destination Configuration">
Section 7.4.2.2, “Default Error Log Destination Configuration”
</a>
.
</p>
</li>
<li class="listitem">
<p>
The
<a class="link" href="server-system-variables.html#sysvar_log_error_verbosity">
<code class="literal">
log_error_verbosity
</code>
</a>
and
<a class="link" href="server-system-variables.html#sysvar_log_error_suppression_list">
<code class="literal">
log_error_suppression_list
</code>
</a>
system variables affect which types of log events
<code class="literal">
log_filter_internal
</code>
permits or
suppresses. See
<a class="xref" href="error-log-priority-based-filtering.html" title="7.4.2.5 Priority-Based Error Log Filtering (log_filter_internal)">
Section 7.4.2.5, “Priority-Based Error Log Filtering (log_filter_internal)”
</a>
.
</p>
</li>
</ul>
</div>
<p>
When configuring
<a class="link" href="server-system-variables.html#sysvar_log_error_services">
<code class="literal">
log_error_services
</code>
</a>
, be aware
of the following characteristics:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
A list of log components may be delimited by semicolons or
commas, optionally followed by spaces. A given setting
cannot use both semicolon and comma separators. Component
order is significant because the server executes
components in the order listed.
</p>
</li>
<li class="listitem">
<p>
The final component in the
<a class="link" href="server-system-variables.html#sysvar_log_error_services">
<code class="literal">
log_error_services
</code>
</a>
value
cannot be a filter. This is an error because any changes
it has on events would have no effect on output:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa81201832"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SET</span> <span class="token keyword">GLOBAL</span> log_error_services <span class="token operator">=</span> <span class="token string">'log_filter_internal'</span><span class="token punctuation">;</span>
<span class="token output">ERROR 1231 (42000)<span class="token punctuation">:</span> Variable 'log_error_services' can't be set to the value
of 'log_filter_internal'</span></code></pre>
</div>
<p>
To correct the problem, include a sink at the end of the
value:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa30912458"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SET</span> <span class="token keyword">GLOBAL</span> log_error_services <span class="token operator">=</span> <span class="token string">'log_filter_internal; log_sink_internal'</span><span class="token punctuation">;</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
The order of components named in
<a class="link" href="server-system-variables.html#sysvar_log_error_services">
<code class="literal">
log_error_services
</code>
</a>
is
significant, particularly with respect to the relative
order of filters and sinks. Consider this
<a class="link" href="server-system-variables.html#sysvar_log_error_services">
<code class="literal">
log_error_services
</code>
</a>
value:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-none"><div class="docs-select-all right" id="sa20567247"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-none">log_filter_internal; log_sink_1; log_sink_2</code></pre>
</div>
<p>
In this case, log events pass to the built-in filter, then
to the first sink, then to the second sink. Both sinks
receive the filtered log events.
</p>
<p>
Compare that to this
<a class="link" href="server-system-variables.html#sysvar_log_error_services">
<code class="literal">
log_error_services
</code>
</a>
value:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-none"><div class="docs-select-all right" id="sa77798578"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-none">log_sink_1; log_filter_internal; log_sink_2</code></pre>
</div>
<p>
In this case, log events pass to the first sink, then to
the built-in filter, then to the second sink. The first
sink receives unfiltered events. The second sink receives
filtered events. You might configure error logging this
way if you want one log that contains messages for all log
events, and another log that contains messages only for a
subset of log events.
</p>
</li>
</ul>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="error-log-configuration-methods">
</a>
Error Log Configuration Methods
</h5>
</div>
</div>
</div>
<p>
Error log configuration involves loading and enabling error
log components as necessary and performing component-specific
configuration.
</p>
<p>
There are two error log configuration methods,
<span class="emphasis">
<em>
implicit
</em>
</span>
and
<span class="emphasis">
<em>
explicit
</em>
</span>
. It is recommended that one
configuration method is selected and used exclusively. Using
both methods can result in warnings at startup. For more
information, see
<a class="xref" href="error-log-configuration.html#error-log-configuration-troubleshooting" title="Troubleshooting Configuration Issues">
Troubleshooting Configuration Issues
</a>
.
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<span class="emphasis">
<em>
Implicit Error Log Configuration
</em>
</span>
</p>
<p>
This configuration method loads and enables the log
components defined by the
<a class="link" href="server-system-variables.html#sysvar_log_error_services">
<code class="literal">
log_error_services
</code>
</a>
variable. Loadable components that are not already loaded
are loaded implicitly at startup before the
<code class="literal">
InnoDB
</code>
storage engine is fully
available. This configuration method has the following
advantages:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
Log components are loaded early in the startup
sequence, before the
<code class="literal">
InnoDB
</code>
storage
engine, making logged information available sooner.
</p>
</li>
<li class="listitem">
<p>
It avoids loss of buffered log information should a
failure occur during startup.
</p>
</li>
<li class="listitem">
<p>
Installing error log components using
<a class="link" href="install-component.html" title="15.7.4.3 INSTALL COMPONENT Statement">
<code class="literal">
INSTALL COMPONENT
</code>
</a>
is
not required, simplifying error log configuration.
</p>
</li>
</ul>
</div>
<p>
To use this method, see
<a class="xref" href="error-log-configuration.html#error-log-implicit-configuration" title="Implicit Error Log Configuration">
Implicit Error Log Configuration
</a>
.
</p>
</li>
</ul>
</div>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<span class="emphasis">
<em>
Explicit Error Log Configuration
</em>
</span>
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
This configuration method is supported for backward
compatibility. The implicit configuration method is
recommended.
</p>
</div>
<p>
This configuration method requires loading error log
components using
<a class="link" href="install-component.html" title="15.7.4.3 INSTALL COMPONENT Statement">
<code class="literal">
INSTALL
COMPONENT
</code>
</a>
and then configuring
<a class="link" href="server-system-variables.html#sysvar_log_error_services">
<code class="literal">
log_error_services
</code>
</a>
to
enable the log components.
<a class="link" href="install-component.html" title="15.7.4.3 INSTALL COMPONENT Statement">
<code class="literal">
INSTALL
COMPONENT
</code>
</a>
adds the component to the
<code class="literal">
mysql.component
</code>
table (an
<code class="literal">
InnoDB
</code>
table), and the components to
load at startup are read from this table, which is only
accessible after
<code class="literal">
InnoDB
</code>
is initialized.
</p>
<p>
Logged information is buffered during the startup sequence
while the
<code class="literal">
InnoDB
</code>
storage engine is
initialized, which is sometimes prolonged by operations
such as recovery and data dictionary upgrade that occur
during the
<code class="literal">
InnoDB
</code>
startup sequence.
</p>
<p>
To use this method, see
<a class="xref" href="error-log-configuration.html#error-log-explicit-configuration" title="Explicit Error Log Configuration">
Explicit Error Log Configuration
</a>
.
</p>
</li>
</ul>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="error-log-implicit-configuration">
</a>
Implicit Error Log Configuration
</h5>
</div>
</div>
</div>
<p>
This procedure describes how to load and enable error logging
components implicitly using
<a class="link" href="server-system-variables.html#sysvar_log_error_services">
<code class="literal">
log_error_services
</code>
</a>
. For a
discussion of error log configuration methods, see
<a class="xref" href="error-log-configuration.html#error-log-configuration-methods" title="Error Log Configuration Methods">
Error Log Configuration Methods
</a>
.
</p>
<p>
To load and enable error logging components implicitly:
</p>
<div class="orderedlist">
<ol class="orderedlist" type="1">
<li class="listitem">
<p>
List the error log components in the
<a class="link" href="server-system-variables.html#sysvar_log_error_services">
<code class="literal">
log_error_services
</code>
</a>
value.
</p>
<p>
To load and enable the error log components at server
startup, set
<a class="link" href="server-system-variables.html#sysvar_log_error_services">
<code class="literal">
log_error_services
</code>
</a>
in an
option file. The following example configures the use of
the JSON log sink (
<code class="literal">
log_sink_json
</code>
) in
addition to the built-in log filter and sink
(
<code class="literal">
log_filter_internal
</code>
,
<code class="literal">
log_sink_internal
</code>
).
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-ini"><div class="docs-select-all right" id="sa76924721"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-ini"><span class="token selector">[mysqld]</span>
<span class="token constant">log_error_services</span><span class="token attr-value"><span class="token punctuation">=</span>'log_filter_internal; log_sink_internal; log_sink_json'</span></code></pre>
</div>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
To use the JSON log sink
(
<code class="literal">
log_sink_syseventlog
</code>
) instead of the
default sink (
<code class="literal">
log_sink_internal
</code>
), you
would replace
<code class="literal">
log_sink_internal
</code>
with
<code class="literal">
log_sink_json
</code>
.
</p>
</div>
<p>
To load and enable the component immediately and for
subsequent restarts, set
<a class="link" href="server-system-variables.html#sysvar_log_error_services">
<code class="literal">
log_error_services
</code>
</a>
using
<a class="link" href="set-variable.html" title="15.7.6.1 SET Syntax for Variable Assignment">
<code class="literal">
SET
PERSIST
</code>
</a>
:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa6486525"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SET</span> <span class="token keyword">PERSIST</span> log_error_services <span class="token operator">=</span> <span class="token string">'log_filter_internal; log_sink_internal; log_sink_json'</span><span class="token punctuation">;</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
If the error log component exposes any system variables
that must be set for component initialization to succeed,
assign those variables appropriate values. You can set
these variables in an option file or using
<a class="link" href="set-variable.html" title="15.7.6.1 SET Syntax for Variable Assignment">
<code class="literal">
SET
PERSIST
</code>
</a>
.
</p>
<div class="important" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Important
</div>
<p>
When implementing an implicit configuration, set
<a class="link" href="server-system-variables.html#sysvar_log_error_services">
<code class="literal">
log_error_services
</code>
</a>
first to load a component and expose its system
variables, and then set component system variables
afterward. This configuration order is required
regardless of whether variable assignment is performed
on the command-line, in an option file, or using
<a class="link" href="set-variable.html" title="15.7.6.1 SET Syntax for Variable Assignment">
<code class="literal">
SET
PERSIST
</code>
</a>
.
</p>
</div>
</li>
</ol>
</div>
<p>
To disable a log component, remove it from the
<a class="link" href="server-system-variables.html#sysvar_log_error_services">
<code class="literal">
log_error_services
</code>
</a>
value.
Also remove any associated component variables settings that
you have defined.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
Loading a log component implicitly using
<a class="link" href="server-system-variables.html#sysvar_log_error_services">
<code class="literal">
log_error_services
</code>
</a>
has no
effect on the
<code class="literal">
mysql.component
</code>
table. It
does not add the component to the
<code class="literal">
mysql.component
</code>
table, nor does it remove
a component previously installed using
<a class="link" href="install-component.html" title="15.7.4.3 INSTALL COMPONENT Statement">
<code class="literal">
INSTALL COMPONENT
</code>
</a>
from the
<code class="literal">
mysql.component
</code>
table.
</p>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="error-log-explicit-configuration">
</a>
Explicit Error Log Configuration
</h5>
</div>
</div>
</div>
<p>
This procedure describes how to load and enable error logging
components explicitly by loading components using
<a class="link" href="install-component.html" title="15.7.4.3 INSTALL COMPONENT Statement">
<code class="literal">
INSTALL COMPONENT
</code>
</a>
and then
enabling using
<a class="link" href="server-system-variables.html#sysvar_log_error_services">
<code class="literal">
log_error_services
</code>
</a>
. For a
discussion of error log configuration methods, see
<a class="xref" href="error-log-configuration.html#error-log-configuration-methods" title="Error Log Configuration Methods">
Error Log Configuration Methods
</a>
.
</p>
<p>
To load and enable error logging components explicitly:
</p>
<div class="orderedlist">
<ol class="orderedlist" type="1">
<li class="listitem">
<p>
Load the component using
<a class="link" href="install-component.html" title="15.7.4.3 INSTALL COMPONENT Statement">
<code class="literal">
INSTALL
COMPONENT
</code>
</a>
(unless it is built in or already
loaded). For example, to load the JSON log sink, issue the
following statement:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa57455818"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">INSTALL</span> <span class="token keyword">COMPONENT</span> <span class="token string">'file://component_log_sink_json'</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
Loading a component using
<a class="link" href="install-component.html" title="15.7.4.3 INSTALL COMPONENT Statement">
<code class="literal">
INSTALL
COMPONENT
</code>
</a>
registers it in the
<code class="literal">
mysql.component
</code>
system table so that
the server loads it automatically for subsequent startups,
after
<code class="literal">
InnoDB
</code>
is initialized.
</p>
<p>
The URN to use when loading a log component with
<a class="link" href="install-component.html" title="15.7.4.3 INSTALL COMPONENT Statement">
<code class="literal">
INSTALL COMPONENT
</code>
</a>
is the
component name prefixed with
<code class="literal">
file://component_
</code>
. For example, for the
<code class="literal">
log_sink_json
</code>
component, the
corresponding URN is
<code class="literal">
file://component_log_sink_json
</code>
. For
error log component URNs, see
<a class="xref" href="error-log-components.html" title="7.5.3 Error Log Components">
Section 7.5.3, “Error Log Components”
</a>
.
</p>
</li>
<li class="listitem">
<p>
If the error log component exposes any system variables
that must be set for component initialization to succeed,
assign those variables appropriate values. You can set
these variables in an option file or using
<a class="link" href="set-variable.html" title="15.7.6.1 SET Syntax for Variable Assignment">
<code class="literal">
SET
PERSIST
</code>
</a>
.
</p>
</li>
<li class="listitem">
<p>
Enable the component by listing it in the
<a class="link" href="server-system-variables.html#sysvar_log_error_services">
<code class="literal">
log_error_services
</code>
</a>
value.
</p>
<div class="important" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Important
</div>
<p>
When loading log components explicitly using
<a class="link" href="install-component.html" title="15.7.4.3 INSTALL COMPONENT Statement">
<code class="literal">
INSTALL COMPONENT
</code>
</a>
, do not
persist or set
<a class="link" href="server-system-variables.html#sysvar_log_error_services">
<code class="literal">
log_error_services
</code>
</a>
in
an option file, which loads log components implicitly at
startup. Instead, enable log components at runtime using
a
<code class="literal">
SET
GLOBAL
</code>
statement.
</p>
</div>
<p>
The following example configures the use of the JSON log
sink (
<code class="literal">
log_sink_json
</code>
) in addition to the
built-in log filter and sink
(
<code class="literal">
log_filter_internal
</code>
,
<code class="literal">
log_sink_internal
</code>
).
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa51187408"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SET</span> <span class="token keyword">GLOBAL</span> log_error_services <span class="token operator">=</span> <span class="token string">'log_filter_internal; log_sink_internal; log_sink_json'</span><span class="token punctuation">;</span></code></pre>
</div>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
To use the JSON log sink
(
<code class="literal">
log_sink_syseventlog
</code>
) instead of the
default sink (
<code class="literal">
log_sink_internal
</code>
), you
would replace
<code class="literal">
log_sink_internal
</code>
with
<code class="literal">
log_sink_json
</code>
.
</p>
</div>
</li>
</ol>
</div>
<p>
To disable a log component, remove it from the
<a class="link" href="server-system-variables.html#sysvar_log_error_services">
<code class="literal">
log_error_services
</code>
</a>
value.
Then, if the component is loadable and you also want to unload
it, use
<a class="link" href="uninstall-component.html" title="15.7.4.5 UNINSTALL COMPONENT Statement">
<code class="literal">
UNINSTALL COMPONENT
</code>
</a>
.
Also remove any associated component variables settings that
you have defined.
</p>
<p>
Attempts to use
<a class="link" href="uninstall-component.html" title="15.7.4.5 UNINSTALL COMPONENT Statement">
<code class="literal">
UNINSTALL
COMPONENT
</code>
</a>
to unload a loadable component that is
still named in the
<a class="link" href="server-system-variables.html#sysvar_log_error_services">
<code class="literal">
log_error_services
</code>
</a>
value
produce an error.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="error-log-configuration-change-method">
</a>
Changing the Error Log Configuration Method
</h5>
</div>
</div>
</div>
<p>
If you have previously loaded error log components explicitly
using
<a class="link" href="install-component.html" title="15.7.4.3 INSTALL COMPONENT Statement">
<code class="literal">
INSTALL COMPONENT
</code>
</a>
and
want to switch to an implicit configuration, as described in
<a class="xref" href="error-log-configuration.html#error-log-implicit-configuration" title="Implicit Error Log Configuration">
Implicit Error Log Configuration
</a>
, the
following steps are recommended:
</p>
<div class="orderedlist">
<ol class="orderedlist" type="1">
<li class="listitem">
<p>
Set
<a class="link" href="server-system-variables.html#sysvar_log_error_services">
<code class="literal">
log_error_services
</code>
</a>
back to its default configuration.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa35065571"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SET</span> <span class="token keyword">GLOBAL</span> log_error_services <span class="token operator">=</span> <span class="token string">'log_filter_internal,log_sink_internal'</span><span class="token punctuation">;</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
Use
<a class="link" href="uninstall-component.html" title="15.7.4.5 UNINSTALL COMPONENT Statement">
<code class="literal">
UNINSTALL COMPONENT
</code>
</a>
to
uninstall any loadable logging components that you
installed previously. For example, if you installed the
JSON log sink previously, uninstall it as shown:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa78985800"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">UNINSTALL</span> <span class="token keyword">COMPONENT</span> <span class="token string">'file://component_log_sink_json'</span><span class="token punctuation">;</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
Remove any component variable settings for the uninstalled
component. For example, if component variables were set in
an option file, remove the settings from the option file.
If component variables were set using
<a class="link" href="set-variable.html" title="15.7.6.1 SET Syntax for Variable Assignment">
<code class="literal">
SET
PERSIST
</code>
</a>
, use
<a class="link" href="set-variable.html" title="15.7.6.1 SET Syntax for Variable Assignment">
<code class="literal">
RESET
PERSIST
</code>
</a>
to clear the settings.
</p>
</li>
<li class="listitem">
<p>
Follow the steps in
<a class="xref" href="error-log-configuration.html#error-log-implicit-configuration" title="Implicit Error Log Configuration">
Implicit Error Log Configuration
</a>
to
reimplement your configuration.
</p>
</li>
</ol>
</div>
<p>
If you need to revert from an implicit configuration to an
explicit configuration, perform the following steps:
</p>
<div class="orderedlist">
<ol class="orderedlist" type="1">
<li class="listitem">
<p>
Set
<a class="link" href="server-system-variables.html#sysvar_log_error_services">
<code class="literal">
log_error_services
</code>
</a>
back to its default configuration to unload implicitly
loaded log components.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa88837594"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SET</span> <span class="token keyword">GLOBAL</span> log_error_services <span class="token operator">=</span> <span class="token string">'log_filter_internal,log_sink_internal'</span><span class="token punctuation">;</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
Remove any component variable settings associated with the
uninstalled components. For example, if component
variables were set in an option file, remove the settings
from the option file. If component variables were set
using
<a class="link" href="set-variable.html" title="15.7.6.1 SET Syntax for Variable Assignment">
<code class="literal">
SET
PERSIST
</code>
</a>
, use
<a class="link" href="set-variable.html" title="15.7.6.1 SET Syntax for Variable Assignment">
<code class="literal">
RESET
PERSIST
</code>
</a>
to clear the settings.
</p>
</li>
<li class="listitem">
<p>
Restart the server to uninstall the log components that
were implicitly loaded.
</p>
</li>
<li class="listitem">
<p>
Follow the steps in
<a class="xref" href="error-log-configuration.html#error-log-explicit-configuration" title="Explicit Error Log Configuration">
Explicit Error Log Configuration
</a>
to
reimplement your configuration.
</p>
</li>
</ol>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="error-log-configuration-troubleshooting">
</a>
Troubleshooting Configuration Issues
</h5>
</div>
</div>
</div>
<p>
Log components listed in the
<a class="link" href="server-system-variables.html#sysvar_log_error_services">
<code class="literal">
log_error_services
</code>
</a>
value at
startup are loaded implicitly early in the MySQL Server
startup sequence. If the log component was loaded previously
using
<a class="link" href="install-component.html" title="15.7.4.3 INSTALL COMPONENT Statement">
<code class="literal">
INSTALL COMPONENT
</code>
</a>
, the
server attempts to load the component again later in the
startup sequence, which produces the warning
<span class="errortext">
Cannot
load component from specified URN:
'file://component_
<em class="replaceable">
<code>
component_name
</code>
</em>
'
</span>
.
</p>
<p>
You can check for this warning in the error log or by querying
the Performance Schema
<a class="link" href="performance-schema-error-log-table.html" title="29.12.22.2 The error_log Table">
<code class="literal">
error_log
</code>
</a>
table using the following query:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa3322949"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> error_code<span class="token punctuation">,</span> <span class="token keyword">data</span>
<span class="token keyword">FROM</span> performance_schema<span class="token punctuation">.</span>error_log
<span class="token keyword">WHERE</span> <span class="token keyword">data</span> <span class="token operator">LIKE</span> <span class="token string">"%'file://component_%"</span>
<span class="token operator">AND</span> error_code<span class="token operator">=</span><span class="token string">"MY-013129"</span> <span class="token operator">AND</span> <span class="token keyword">data</span> <span class="token operator">LIKE</span> <span class="token string">"%MY-003529%"</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
To prevent this warning, follow the instructions in
<a class="xref" href="error-log-configuration.html#error-log-configuration-change-method" title="Changing the Error Log Configuration Method">
Changing the Error Log Configuration Method
</a>
to
adjust your error log configuration. Either an implicit or
explicit error log configuration should be used, but not both.
</p>
<p>
A similar error occurs when attempting to explicitly load a
component that was implicitly loaded at startup. For example,
if
<a class="link" href="server-system-variables.html#sysvar_log_error_services">
<code class="literal">
log_error_services
</code>
</a>
lists
the JSON log sink component, that component is implicitly
loaded at startup. Attempting to explicitly load the same
component later returns this error:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa89032377"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">INSTALL</span> <span class="token keyword">COMPONENT</span> <span class="token string">'file://component_log_sink_json'</span><span class="token punctuation">;</span>
<span class="token output">ERROR 3529 (HY000)<span class="token punctuation">:</span> Cannot load component from specified URN<span class="token punctuation">:</span> 'file<span class="token punctuation">:</span>//component_log_sink_json'.</span></code></pre>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="error-log-configuration-multiple-log-sinks">
</a>
Configuring Multiple Log Sinks
</h5>
</div>
</div>
</div>
<p>
It is possible to configure multiple log sinks, which enables
sending output to multiple destinations. To enable the JSON
log sink in addition to (rather than instead of) the default
sink, set the
<a class="link" href="server-system-variables.html#sysvar_log_error_services">
<code class="literal">
log_error_services
</code>
</a>
value like
this:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa24189685"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SET</span> <span class="token keyword">GLOBAL</span> log_error_services <span class="token operator">=</span> <span class="token string">'log_filter_internal; log_sink_internal; log_sink_json'</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
To revert to using only the default sink and unload the system
log sink, execute these statements:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa39078936"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SET</span> <span class="token keyword">GLOBAL</span> log_error_services <span class="token operator">=</span> <span class="token string">'log_filter_internal; log_sink_internal;
UNINSTALL COMPONENT '</span><span class="token keyword">file</span>:<span class="token comment" spellcheck="true">//component_log_sink_json';</span></code></pre>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="error-log-configuration-log-sink-ps-support">
</a>
Log Sink Performance Schema Support
</h5>
</div>
</div>
</div>
<p>
If enabled log components include a sink that provides
Performance Schema support, events written to the error log
are also written to the Performance Schema
<a class="link" href="performance-schema-error-log-table.html" title="29.12.22.2 The error_log Table">
<code class="literal">
error_log
</code>
</a>
table. This enables
examining error log contents using SQL queries. Currently, the
traditional-format
<code class="literal">
log_sink_internal
</code>
and
JSON-format
<code class="literal">
log_sink_json
</code>
sinks support
this capability. See
<a class="xref" href="performance-schema-error-log-table.html" title="29.12.22.2 The error_log Table">
Section 29.12.22.2, “The error_log Table”
</a>
.
</p>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/innodb-buffer-pool-optimization.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="innodb-buffer-pool-optimization">
</a>
10.10.1 InnoDB Buffer Pool Optimization
</h3>
</div>
</div>
</div>
<a class="indexterm" name="idm46045223115296">
</a>
<a class="indexterm" name="idm46045223114224">
</a>
<a class="indexterm" name="idm46045223113152">
</a>
<p>
<a class="link" href="innodb-storage-engine.html" title="Chapter 17 The InnoDB Storage Engine">
<code class="literal">
InnoDB
</code>
</a>
maintains a storage area
called the
<a class="link" href="glossary.html#glos_buffer_pool" title="buffer pool">
buffer pool
</a>
for caching data and indexes in memory. Knowing how the
<code class="literal">
InnoDB
</code>
buffer pool works, and taking
advantage of it to keep frequently accessed data in memory, is
an important aspect of MySQL tuning.
</p>
<p>
For an explanation of the inner workings of the
<code class="literal">
InnoDB
</code>
buffer pool, an overview of its LRU
replacement algorithm, and general configuration information,
see
<a class="xref" href="innodb-buffer-pool.html" title="17.5.1 Buffer Pool">
Section 17.5.1, “Buffer Pool”
</a>
.
</p>
<p>
For additional
<code class="literal">
InnoDB
</code>
buffer pool
configuration and tuning information, see these sections:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="xref" href="innodb-performance-read_ahead.html" title="17.8.3.4 Configuring InnoDB Buffer Pool Prefetching (Read-Ahead)">
Section 17.8.3.4, “Configuring InnoDB Buffer Pool Prefetching (Read-Ahead)”
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="innodb-buffer-pool-flushing.html" title="17.8.3.5 Configuring Buffer Pool Flushing">
Section 17.8.3.5, “Configuring Buffer Pool Flushing”
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="innodb-performance-midpoint_insertion.html" title="17.8.3.3 Making the Buffer Pool Scan Resistant">
Section 17.8.3.3, “Making the Buffer Pool Scan Resistant”
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="innodb-multiple-buffer-pools.html" title="17.8.3.2 Configuring Multiple Buffer Pool Instances">
Section 17.8.3.2, “Configuring Multiple Buffer Pool Instances”
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="innodb-preload-buffer-pool.html" title="17.8.3.6 Saving and Restoring the Buffer Pool State">
Section 17.8.3.6, “Saving and Restoring the Buffer Pool State”
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="innodb-buffer-pool-resize.html" title="17.8.3.1 Configuring InnoDB Buffer Pool Size">
Section 17.8.3.1, “Configuring InnoDB Buffer Pool Size”
</a>
</p>
</li>
</ul>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/performance-schema-thread-pool-tables.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="performance-schema-thread-pool-tables">
</a>
29.12.16 Performance Schema Thread Pool Tables
</h3>
</div>
</div>
</div>
<div class="toc">
<dl class="toc">
<dt>
<span class="section">
<a href="performance-schema-tp-connections-table.html">
29.12.16.1 The tp_connections Table
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="performance-schema-tp-thread-group-state-table.html">
29.12.16.2 The tp_thread_group_state Table
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="performance-schema-tp-thread-group-stats-table.html">
29.12.16.3 The tp_thread_group_stats Table
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="performance-schema-tp-thread-state-table.html">
29.12.16.4 The tp_thread_state Table
</a>
</span>
</dt>
</dl>
</div>
<a class="indexterm" name="idm46045069922240">
</a>
<p>
The following sections describe the Performance Schema tables
associated with the thread pool plugin (see
<a class="xref" href="thread-pool.html" title="7.6.3 MySQL Enterprise Thread Pool">
Section 7.6.3, “MySQL Enterprise Thread Pool”
</a>
). They provide information about
thread pool operation:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="link" href="performance-schema-tp-connections-table.html" title="29.12.16.1 The tp_connections Table">
<code class="literal">
tp_connections
</code>
</a>
: Information
about thread pool connections.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="performance-schema-tp-thread-group-state-table.html" title="29.12.16.2 The tp_thread_group_state Table">
<code class="literal">
tp_thread_group_state
</code>
</a>
:
Information about thread pool thread group states.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="performance-schema-tp-thread-group-stats-table.html" title="29.12.16.3 The tp_thread_group_stats Table">
<code class="literal">
tp_thread_group_stats
</code>
</a>
: Thread
group statistics.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="performance-schema-tp-thread-state-table.html" title="29.12.16.4 The tp_thread_state Table">
<code class="literal">
tp_thread_state
</code>
</a>
: Information
about thread pool thread states.
</p>
</li>
</ul>
</div>
<p>
Rows in these tables represent snapshots in time. In the case of
<a class="link" href="performance-schema-tp-thread-state-table.html" title="29.12.16.4 The tp_thread_state Table">
<code class="literal">
tp_thread_state
</code>
</a>
, all rows for a
thread group comprise a snapshot in time. Thus, the MySQL server
holds the mutex of the thread group while producing the
snapshot. But it does not hold mutexes on all thread groups at
the same time, to prevent a statement against
<a class="link" href="performance-schema-tp-thread-state-table.html" title="29.12.16.4 The tp_thread_state Table">
<code class="literal">
tp_thread_state
</code>
</a>
from blocking the
entire MySQL server.
</p>
<p>
The Performance Schema thread pool tables are implemented by the
thread pool plugin and are loaded and unloaded when that plugin
is loaded and unloaded (see
<a class="xref" href="thread-pool-installation.html" title="7.6.3.2 Thread Pool Installation">
Section 7.6.3.2, “Thread Pool Installation”
</a>
). No special
configuration step for the tables is needed. However, the tables
depend on the thread pool plugin being enabled. If the thread
pool plugin is loaded but disabled, the tables are not created.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/reloading-delimited-text-dumps.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="reloading-delimited-text-dumps">
</a>
9.4.4 Reloading Delimited-Text Format Backups
</h3>
</div>
</div>
</div>
<p>
For backups produced with
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump --tab
</strong>
</span>
</a>
,
each table is represented in the output directory by an
<code class="filename">
.sql
</code>
file containing the
<a class="link" href="create-table.html" title="15.1.20 CREATE TABLE Statement">
<code class="literal">
CREATE TABLE
</code>
</a>
statement for the
table, and a
<code class="filename">
.txt
</code>
file containing the table
data. To reload a table, first change location into the output
directory. Then process the
<code class="filename">
.sql
</code>
file with
<a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
<span class="command">
<strong>
mysql
</strong>
</span>
</a>
to create an empty table and process
the
<code class="filename">
.txt
</code>
file to load the data into the
table:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa22645829"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$> </span><span class="token command">mysql</span> db1 < t1<span class="token punctuation">.</span>sql
<span class="token prompt">$> </span><span class="token command">mysqlimport</span> db1 t1<span class="token punctuation">.</span>txt</code></pre>
</div>
<p>
An alternative to using
<a class="link" href="mysqlimport.html" title="6.5.5 mysqlimport — A Data Import Program">
<span class="command">
<strong>
mysqlimport
</strong>
</span>
</a>
to load
the data file is to use the
<a class="link" href="load-data.html" title="15.2.9 LOAD DATA Statement">
<code class="literal">
LOAD
DATA
</code>
</a>
statement from within the
<a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
<span class="command">
<strong>
mysql
</strong>
</span>
</a>
client:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa71261435"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">USE</span> db1<span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">LOAD</span> <span class="token keyword">DATA</span> <span class="token keyword">INFILE</span> <span class="token string">'t1.txt'</span> <span class="token keyword">INTO</span> <span class="token keyword">TABLE</span> t1<span class="token punctuation">;</span></code></pre>
</div>
<p>
If you used any data-formatting options with
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
when you initially dumped the
table, you must use the same options with
<a class="link" href="mysqlimport.html" title="6.5.5 mysqlimport — A Data Import Program">
<span class="command">
<strong>
mysqlimport
</strong>
</span>
</a>
or
<a class="link" href="load-data.html" title="15.2.9 LOAD DATA Statement">
<code class="literal">
LOAD
DATA
</code>
</a>
to ensure proper interpretation of the data file
contents:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa26501356"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$> </span><span class="token command">mysqlimport</span> <span class="token constant">--fields-terminated-by</span><span class="token attr-value"><span class="token punctuation">=</span>,</span>
<span class="token constant">--fields-enclosed-by</span>=<span class="token atrule">'"'</span> <span class="token constant">--lines-terminated-by</span><span class="token attr-value"><span class="token punctuation">=</span>0x0d0a</span> db1 t1<span class="token punctuation">.</span>txt</code></pre>
</div>
<p>
Or:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa64954929"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">USE</span> db1<span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">LOAD</span> <span class="token keyword">DATA</span> <span class="token keyword">INFILE</span> <span class="token string">'t1.txt'</span> <span class="token keyword">INTO</span> <span class="token keyword">TABLE</span> t1
<span class="token keyword">FIELDS</span> <span class="token keyword">TERMINATED</span> <span class="token keyword">BY</span> <span class="token string">','</span> <span class="token keyword">FIELDS</span> <span class="token keyword">ENCLOSED</span> <span class="token keyword">BY</span> <span class="token string">'"'</span>
<span class="token keyword">LINES</span> <span class="token keyword">TERMINATED</span> <span class="token keyword">BY</span> <span class="token string">'\r\n'</span><span class="token punctuation">;</span></code></pre>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/error-log-event-fields.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="error-log-event-fields">
</a>
7.4.2.3 Error Event Fields
</h4>
</div>
</div>
</div>
<p>
Error events intended for the error log contain a set of fields,
each of which consists of a key/value pair. An event field may
be classified as core, optional, or user-defined:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
A core field is set up automatically for error events.
However, its presence in the event during event processing
is not guaranteed because a core field, like any type of
field, may be unset by a log filter. If this happens, the
field cannot be found by subsequent processing within that
filter and by components that execute after the filter (such
as log sinks).
</p>
</li>
<li class="listitem">
<p>
An optional field is normally absent but may be present for
certain event types. When present, an optional field
provides additional event information as appropriate and
available.
</p>
</li>
<li class="listitem">
<p>
A user-defined field is any field with a name that is not
already defined as a core or optional field. A user-defined
field does not exist until created by a log filter.
</p>
</li>
</ul>
</div>
<p>
As implied by the preceding description, any given field may be
absent during event processing, either because it was not
present in the first place, or was discarded by a filter. For
log sinks, the effect of field absence is sink specific. For
example, a sink might omit the field from the log message,
indicate that the field is missing, or substitute a default.
When in doubt, test: use a filter that unsets the field, then
check what the log sink does with it.
</p>
<p>
The following sections describe the core and optional error
event fields. For individual log filter components, there may be
additional filter-specific considerations for these fields, or
filters may add user-defined fields not listed here. For
details, see the documentation for specific filters.
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="xref" href="error-log-event-fields.html#error-log-event-core-fields" title="Core Error Event Fields">
Core Error Event Fields
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="error-log-event-fields.html#error-log-event-optional-fields" title="Optional Error Event Fields">
Optional Error Event Fields
</a>
</p>
</li>
</ul>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="error-log-event-core-fields">
</a>
Core Error Event Fields
</h5>
</div>
</div>
</div>
<p>
These error event fields are core fields:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
time
</code>
</p>
<p>
The event timestamp, with microsecond precision.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
msg
</code>
</p>
<p>
The event message string.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
prio
</code>
</p>
<p>
The event priority, to indicate a system, error, warning,
or note/information event. This field corresponds to
severity in
<code class="literal">
syslog
</code>
. The following table
shows the possible priority levels.
</p>
<div class="informaltable">
<table summary="Error event priority levels.">
<colgroup>
<col style="width: 35%"/>
<col style="width: 35%"/>
</colgroup>
<thead>
<tr>
<th>
Event Type
</th>
<th>
Numeric Priority
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
System event
</td>
<td>
0
</td>
</tr>
<tr>
<td>
Error event
</td>
<td>
1
</td>
</tr>
<tr>
<td>
Warning event
</td>
<td>
2
</td>
</tr>
<tr>
<td>
Note/information event
</td>
<td>
3
</td>
</tr>
</tbody>
</table>
</div>
<p>
The
<code class="literal">
prio
</code>
value is numeric. Related to
it, an error event may also include an optional
<code class="literal">
label
</code>
field representing the priority
as a string. For example, an event with a
<code class="literal">
prio
</code>
value of 2 may have a
<code class="literal">
label
</code>
value of
<code class="literal">
'Warning'
</code>
.
</p>
<p>
Filter components may include or drop error events based
on priority, except that system events are mandatory and
cannot be dropped.
</p>
<p>
In general, message priorities are determined as follows:
</p>
<p>
Is the situation or event actionable?
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
Yes: Is the situation or event ignorable?
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: square; ">
<li class="listitem">
<p>
Yes: Priority is warning.
</p>
</li>
<li class="listitem">
<p>
No: Priority is error.
</p>
</li>
</ul>
</div>
</li>
<li class="listitem">
<p>
No: Is the situation or event mandatory?
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: square; ">
<li class="listitem">
<p>
Yes: Priority is system.
</p>
</li>
<li class="listitem">
<p>
No: Priority is note/information.
</p>
</li>
</ul>
</div>
</li>
</ul>
</div>
</li>
<li class="listitem">
<p>
<code class="literal">
err_code
</code>
</p>
<p>
The event error code, as a number (for example,
<code class="literal">
1022
</code>
).
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
err_symbol
</code>
</p>
<p>
The event error symbol, as a string (for example,
<a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html#error_er_dup_key" target="_top">
<code class="literal">
'ER_DUP_KEY'
</code>
</a>
).
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SQL_state
</code>
</p>
<p>
The event SQLSTATE value, as a string (for example,
<code class="literal">
'23000'
</code>
).
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
subsystem
</code>
</p>
<p>
The subsystem in which the event occurred. Possible values
are
<code class="literal">
InnoDB
</code>
(the
<code class="literal">
InnoDB
</code>
storage engine),
<code class="literal">
Repl
</code>
(the replication subsystem),
<code class="literal">
Server
</code>
(otherwise).
</p>
</li>
</ul>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="error-log-event-optional-fields">
</a>
Optional Error Event Fields
</h5>
</div>
</div>
</div>
<p>
Optional error event fields fall into the following
categories:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Additional information about the error, such as the error
signaled by the operating system or the error label:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
<code class="literal">
OS_errno
</code>
</p>
<p>
The operating system error number.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
OS_errmsg
</code>
</p>
<p>
The operating system error message.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
label
</code>
</p>
<p>
The label corresponding to the
<code class="literal">
prio
</code>
value, as a string.
</p>
</li>
</ul>
</div>
</li>
<li class="listitem">
<p>
Identification of the client for which the event occurred:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
<code class="literal">
user
</code>
</p>
<p>
The client user.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
host
</code>
</p>
<p>
The client host.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
thread
</code>
</p>
<p>
The ID of the thread within
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
responsible for producing the error event. This ID
indicates which part of the server produced the event,
and is consistent with general query log and slow
query log messages, which include the connection
thread ID.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
query_id
</code>
</p>
<p>
The query ID.
</p>
</li>
</ul>
</div>
</li>
<li class="listitem">
<p>
Debugging information:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
<code class="literal">
source_file
</code>
</p>
<p>
The source file in which the event occurred, without
any leading path.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
source_line
</code>
</p>
<p>
The line within the source file at which the event
occurred.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
function
</code>
</p>
<p>
The function in which the event occurred.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
component
</code>
</p>
<p>
The component or plugin in which the event occurred.
</p>
</li>
</ul>
</div>
</li>
</ul>
</div>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/information-schema-statistics-table.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="information-schema-statistics-table">
</a>
28.3.34 The INFORMATION_SCHEMA STATISTICS Table
</h3>
</div>
</div>
</div>
<a class="indexterm" name="idm46045078684800">
</a>
<p>
The
<a class="link" href="information-schema-statistics-table.html" title="28.3.34 The INFORMATION_SCHEMA STATISTICS Table">
<code class="literal">
STATISTICS
</code>
</a>
table provides
information about table indexes.
</p>
<p>
Columns in
<a class="link" href="information-schema-statistics-table.html" title="28.3.34 The INFORMATION_SCHEMA STATISTICS Table">
<code class="literal">
STATISTICS
</code>
</a>
that represent
table statistics hold cached values. The
<a class="link" href="server-system-variables.html#sysvar_information_schema_stats_expiry">
<code class="literal">
information_schema_stats_expiry
</code>
</a>
system variable defines the period of time before cached table
statistics expire. The default is 86400 seconds (24 hours). If
there are no cached statistics or statistics have expired,
statistics are retrieved from storage engines when querying table
statistics columns. To update cached values at any time for a
given table, use
<a class="link" href="analyze-table.html" title="15.7.3.1 ANALYZE TABLE Statement">
<code class="literal">
ANALYZE TABLE
</code>
</a>
. To
always retrieve the latest statistics directly from storage
engines, set
<a class="link" href="server-system-variables.html#sysvar_information_schema_stats_expiry">
<code class="literal">
information_schema_stats_expiry=0
</code>
</a>
.
For more information, see
<a class="xref" href="information-schema-optimization.html" title="10.2.3 Optimizing INFORMATION_SCHEMA Queries">
Section 10.2.3, “Optimizing INFORMATION_SCHEMA Queries”
</a>
.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
If the
<a class="link" href="innodb-parameters.html#sysvar_innodb_read_only">
<code class="literal">
innodb_read_only
</code>
</a>
system
variable is enabled,
<a class="link" href="analyze-table.html" title="15.7.3.1 ANALYZE TABLE Statement">
<code class="literal">
ANALYZE
TABLE
</code>
</a>
may fail because it cannot update statistics
tables in the data dictionary, which use
<code class="literal">
InnoDB
</code>
. For
<a class="link" href="analyze-table.html" title="15.7.3.1 ANALYZE TABLE Statement">
<code class="literal">
ANALYZE
TABLE
</code>
</a>
operations that update the key distribution,
failure may occur even if the operation updates the table itself
(for example, if it is a
<code class="literal">
MyISAM
</code>
table). To
obtain the updated distribution statistics, set
<a class="link" href="server-system-variables.html#sysvar_information_schema_stats_expiry">
<code class="literal">
information_schema_stats_expiry=0
</code>
</a>
.
</p>
</div>
<p>
The
<a class="link" href="information-schema-statistics-table.html" title="28.3.34 The INFORMATION_SCHEMA STATISTICS Table">
<code class="literal">
STATISTICS
</code>
</a>
table has these
columns:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
TABLE_CATALOG
</code>
</p>
<p>
The name of the catalog to which the table containing the
index belongs. This value is always
<code class="literal">
def
</code>
.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
TABLE_SCHEMA
</code>
</p>
<p>
The name of the schema (database) to which the table
containing the index belongs.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
TABLE_NAME
</code>
</p>
<p>
The name of the table containing the index.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
NON_UNIQUE
</code>
</p>
<p>
0 if the index cannot contain duplicates, 1 if it can.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
INDEX_SCHEMA
</code>
</p>
<p>
The name of the schema (database) to which the index belongs.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
INDEX_NAME
</code>
</p>
<p>
The name of the index. If the index is the primary key, the
name is always
<code class="literal">
PRIMARY
</code>
.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SEQ_IN_INDEX
</code>
</p>
<p>
The column sequence number in the index, starting with 1.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
COLUMN_NAME
</code>
</p>
<p>
The column name. See also the description for the
<code class="literal">
EXPRESSION
</code>
column.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
COLLATION
</code>
</p>
<p>
How the column is sorted in the index. This can have values
<code class="literal">
A
</code>
(ascending),
<code class="literal">
D
</code>
(descending), or
<code class="literal">
NULL
</code>
(not sorted).
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
CARDINALITY
</code>
</p>
<p>
An estimate of the number of unique values in the index. To
update this number, run
<a class="link" href="analyze-table.html" title="15.7.3.1 ANALYZE TABLE Statement">
<code class="literal">
ANALYZE
TABLE
</code>
</a>
or (for
<code class="literal">
MyISAM
</code>
tables)
<a class="link" href="myisamchk.html" title="6.6.4 myisamchk — MyISAM Table-Maintenance Utility">
<span class="command">
<strong>
myisamchk -a
</strong>
</span>
</a>
.
</p>
<p>
<code class="literal">
CARDINALITY
</code>
is counted based on statistics
stored as integers, so the value is not necessarily exact even
for small tables. The higher the cardinality, the greater the
chance that MySQL uses the index when doing joins.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SUB_PART
</code>
</p>
<p>
The index prefix. That is, the number of indexed characters if
the column is only partly indexed,
<code class="literal">
NULL
</code>
if
the entire column is indexed.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
Prefix
<span class="emphasis">
<em>
limits
</em>
</span>
are measured in bytes.
However, prefix
<span class="emphasis">
<em>
lengths
</em>
</span>
for index
specifications in
<a class="link" href="create-table.html" title="15.1.20 CREATE TABLE Statement">
<code class="literal">
CREATE
TABLE
</code>
</a>
,
<a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
<code class="literal">
ALTER TABLE
</code>
</a>
,
and
<a class="link" href="create-index.html" title="15.1.15 CREATE INDEX Statement">
<code class="literal">
CREATE INDEX
</code>
</a>
statements
are interpreted as number of characters for nonbinary string
types (
<a class="link" href="char.html" title="13.3.2 The CHAR and VARCHAR Types">
<code class="literal">
CHAR
</code>
</a>
,
<a class="link" href="char.html" title="13.3.2 The CHAR and VARCHAR Types">
<code class="literal">
VARCHAR
</code>
</a>
,
<a class="link" href="blob.html" title="13.3.4 The BLOB and TEXT Types">
<code class="literal">
TEXT
</code>
</a>
) and number of bytes for
binary string types (
<a class="link" href="binary-varbinary.html" title="13.3.3 The BINARY and VARBINARY Types">
<code class="literal">
BINARY
</code>
</a>
,
<a class="link" href="binary-varbinary.html" title="13.3.3 The BINARY and VARBINARY Types">
<code class="literal">
VARBINARY
</code>
</a>
,
<a class="link" href="blob.html" title="13.3.4 The BLOB and TEXT Types">
<code class="literal">
BLOB
</code>
</a>
). Take this into account
when specifying a prefix length for a nonbinary string
column that uses a multibyte character set.
</p>
</div>
<p>
For additional information about index prefixes, see
<a class="xref" href="column-indexes.html" title="10.3.5 Column Indexes">
Section 10.3.5, “Column Indexes”
</a>
, and
<a class="xref" href="create-index.html" title="15.1.15 CREATE INDEX Statement">
Section 15.1.15, “CREATE INDEX Statement”
</a>
.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
PACKED
</code>
</p>
<p>
Indicates how the key is packed.
<code class="literal">
NULL
</code>
if it
is not.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
NULLABLE
</code>
</p>
<p>
Contains
<code class="literal">
YES
</code>
if the column may contain
<code class="literal">
NULL
</code>
values and
<code class="literal">
''
</code>
if
not.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
INDEX_TYPE
</code>
</p>
<p>
The index method used (
<code class="literal">
BTREE
</code>
,
<code class="literal">
FULLTEXT
</code>
,
<code class="literal">
HASH
</code>
,
<code class="literal">
RTREE
</code>
).
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
COMMENT
</code>
</p>
<p>
Information about the index not described in its own column,
such as
<code class="literal">
disabled
</code>
if the index is disabled.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
INDEX_COMMENT
</code>
</p>
<p>
Any comment provided for the index with a
<code class="literal">
COMMENT
</code>
attribute when the index was
created.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
IS_VISIBLE
</code>
</p>
<p>
Whether the index is visible to the optimizer. See
<a class="xref" href="invisible-indexes.html" title="10.3.12 Invisible Indexes">
Section 10.3.12, “Invisible Indexes”
</a>
.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
EXPRESSION
</code>
</p>
<p>
MySQL supports functional key parts (see
<a class="xref" href="create-index.html#create-index-functional-key-parts" title="Functional Key Parts">
Functional Key Parts
</a>
), which
affects both the
<code class="literal">
COLUMN_NAME
</code>
and
<code class="literal">
EXPRESSION
</code>
columns:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
For a nonfunctional key part,
<code class="literal">
COLUMN_NAME
</code>
indicates the column
indexed by the key part and
<code class="literal">
EXPRESSION
</code>
is
<code class="literal">
NULL
</code>
.
</p>
</li>
<li class="listitem">
<p>
For a functional key part,
<code class="literal">
COLUMN_NAME
</code>
column is
<code class="literal">
NULL
</code>
and
<code class="literal">
EXPRESSION
</code>
indicates the expression for
the key part.
</p>
</li>
</ul>
</div>
</li>
</ul>
</div>
<h4>
<a name="idm46045078589488">
</a>
Notes
</h4>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
There is no standard
<code class="literal">
INFORMATION_SCHEMA
</code>
table for indexes. The MySQL column list is similar to what
SQL Server 2000 returns for
<code class="literal">
sp_statistics
</code>
,
except that
<code class="literal">
QUALIFIER
</code>
and
<code class="literal">
OWNER
</code>
are replaced with
<code class="literal">
CATALOG
</code>
and
<code class="literal">
SCHEMA
</code>
,
respectively.
</p>
</li>
</ul>
</div>
<p>
Information about table indexes is also available from the
<a class="link" href="show-index.html" title="15.7.7.23 SHOW INDEX Statement">
<code class="literal">
SHOW INDEX
</code>
</a>
statement. See
<a class="xref" href="show-index.html" title="15.7.7.23 SHOW INDEX Statement">
Section 15.7.7.23, “SHOW INDEX Statement”
</a>
. The following statements are
equivalent:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa31883238"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> INFORMATION_SCHEMA<span class="token punctuation">.</span>STATISTICS
<span class="token keyword">WHERE</span> <span class="token keyword">table_name</span> <span class="token operator">=</span> <span class="token string">'<em class="replaceable">tbl_name</em>'</span>
<span class="token operator">AND</span> table_schema <span class="token operator">=</span> <span class="token string">'<em class="replaceable">db_name</em>'</span>
<span class="token keyword">SHOW</span> <span class="token keyword">INDEX</span>
<span class="token keyword">FROM</span> <em class="replaceable">tbl_name</em>
<span class="token keyword">FROM</span> <em class="replaceable">db_name</em></code></pre>
</div>
<p>
Information about generated invisible primary key columns is
visible in this table by default. You can cause such information
to be hidden by setting
<a class="link" href="server-system-variables.html#sysvar_show_gipk_in_create_table_and_information_schema">
<code class="literal">
show_gipk_in_create_table_and_information_schema
= OFF
</code>
</a>
. For more information, see
<a class="xref" href="create-table-gipks.html" title="15.1.20.11 Generated Invisible Primary Keys">
Section 15.1.20.11, “Generated Invisible Primary Keys”
</a>
.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/drop-role.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="drop-role">
</a>
15.7.1.4 DROP ROLE Statement
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045174078112">
</a>
<a class="indexterm" name="idm46045174077040">
</a>
<a class="indexterm" name="idm46045174075552">
</a>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa27591155"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">DROP</span> <span class="token keyword">ROLE</span> <span class="token punctuation">[</span><span class="token keyword">IF</span> <span class="token keyword">EXISTS</span><span class="token punctuation">]</span> <span class="token keyword"><em class="replaceable">role</em></span> <span class="token punctuation">[</span><span class="token punctuation">,</span> <span class="token keyword"><em class="replaceable">role</em></span> <span class="token punctuation">]</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span></code></pre>
</div>
<p>
<a class="link" href="drop-role.html" title="15.7.1.4 DROP ROLE Statement">
<code class="literal">
DROP ROLE
</code>
</a>
removes one or more
roles (named collections of privileges). To use this statement,
you must have the global
<a class="link" href="privileges-provided.html#priv_drop-role">
<code class="literal">
DROP
ROLE
</code>
</a>
or
<a class="link" href="privileges-provided.html#priv_create-user">
<code class="literal">
CREATE USER
</code>
</a>
privilege. When the
<a class="link" href="server-system-variables.html#sysvar_read_only">
<code class="literal">
read_only
</code>
</a>
system variable is enabled,
<a class="link" href="drop-role.html" title="15.7.1.4 DROP ROLE Statement">
<code class="literal">
DROP
ROLE
</code>
</a>
additionally requires the
<a class="link" href="privileges-provided.html#priv_connection-admin">
<code class="literal">
CONNECTION_ADMIN
</code>
</a>
privilege (or
the deprecated
<a class="link" href="privileges-provided.html#priv_super">
<code class="literal">
SUPER
</code>
</a>
privilege).
</p>
<p>
Users who have the
<a class="link" href="privileges-provided.html#priv_create-user">
<code class="literal">
CREATE USER
</code>
</a>
privilege can use this statement to drop accounts that are
locked or unlocked. Users who have the
<a class="link" href="privileges-provided.html#priv_drop-role">
<code class="literal">
DROP
ROLE
</code>
</a>
privilege can use this statement only to drop
accounts that are locked (unlocked accounts are presumably user
accounts used to log in to the server and not just as roles).
</p>
<p>
Roles named in the
<a class="link" href="server-system-variables.html#sysvar_mandatory_roles">
<code class="literal">
mandatory_roles
</code>
</a>
system variable
value cannot be dropped.
</p>
<p>
<a class="link" href="drop-role.html" title="15.7.1.4 DROP ROLE Statement">
<code class="literal">
DROP ROLE
</code>
</a>
either succeeds for all
named roles or rolls back and has no effect if any error occurs.
By default, an error occurs if you try to drop a role that does
not exist. If the
<code class="literal">
IF EXISTS
</code>
clause is given,
the statement produces a warning for each named role that does
not exist, rather than an error.
</p>
<p>
The statement is written to the binary log if it succeeds, but
not if it fails; in that case, rollback occurs and no changes
are made. A statement written to the binary log includes all
named roles. If the
<code class="literal">
IF EXISTS
</code>
clause is
given, this includes even roles that do not exist and were not
dropped.
</p>
<p>
Each role name uses the format described in
<a class="xref" href="role-names.html" title="8.2.5 Specifying Role Names">
Section 8.2.5, “Specifying Role Names”
</a>
. For example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa89582696"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">DROP</span> <span class="token keyword">ROLE</span> <span class="token string">'admin'</span><span class="token punctuation">,</span> <span class="token string">'developer'</span><span class="token punctuation">;</span>
<span class="token keyword">DROP</span> <span class="token keyword">ROLE</span> <span class="token string">'webapp'</span>@<span class="token string">'localhost'</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
The host name part of the role name, if omitted, defaults to
<code class="literal">
'%'
</code>
.
</p>
<p>
A dropped role is automatically revoked from any user account
(or role) to which the role was granted. Within any current
session for such an account, its adjusted privileges apply
beginning with the next statement executed.
</p>
<p>
For role usage examples, see
<a class="xref" href="roles.html" title="8.2.10 Using Roles">
Section 8.2.10, “Using Roles”
</a>
.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/group-replication-functions-for-mode.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="group-replication-functions-for-mode">
</a>
14.18.1.2 Functions which Configure the Group Replication Mode
</h4>
</div>
</div>
</div>
<p>
The following functions enable you to control the mode which a
replication group is running in, either single-primary or
multi-primary mode.
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a name="function_group-replication-switch-to-multi-primary-mode">
</a>
<a class="link" href="group-replication-functions-for-mode.html#function_group-replication-switch-to-multi-primary-mode">
<code class="literal">
group_replication_switch_to_multi_primary_mode()
</code>
</a>
</p>
<a class="indexterm" name="idm46045193870864">
</a>
<a class="indexterm" name="idm46045193869744">
</a>
<p>
Changes a group running in single-primary mode to
multi-primary mode. Must be issued on a member of a
replication group running in single-primary mode.
</p>
<p>
Syntax:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-clike"><div class="docs-select-all right" id="sa66967576"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-clike">STRING <span class="token function">group_replication_switch_to_multi_primary_mode</span><span class="token punctuation">(</span><span class="token punctuation">)</span></code></pre>
</div>
<p>
This function has no parameters.
</p>
<p>
Return value:
</p>
<p>
A string containing the result of the operation, for
example whether it was successful or not.
</p>
<p>
Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa44833871"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> group_replication_switch_to_multi_primary_mode<span class="token punctuation">(</span><span class="token punctuation">)</span></code></pre>
</div>
<p>
All members which belong to the group become primaries.
</p>
<p>
For more information, see
<a class="xref" href="group-replication-changing-group-mode.html" title="20.5.1.2 Changing the Group Mode">
Section 20.5.1.2, “Changing the Group Mode”
</a>
</p>
</li>
<li class="listitem">
<p>
<a name="function_group-replication-switch-to-single-primary-mode">
</a>
<a class="link" href="group-replication-functions-for-mode.html#function_group-replication-switch-to-single-primary-mode">
<code class="literal">
group_replication_switch_to_single_primary_mode()
</code>
</a>
</p>
<a class="indexterm" name="idm46045193858880">
</a>
<a class="indexterm" name="idm46045193857840">
</a>
<p>
Changes a group running in multi-primary mode to
single-primary mode, without the need to stop Group
Replication. Must be issued on a member of a replication
group running in multi-primary mode. When you change to
single-primary mode, strict consistency checks are also
disabled on all group members, as required in
single-primary mode
(
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_enforce_update_everywhere_checks">
<code class="literal">
group_replication_enforce_update_everywhere_checks=OFF
</code>
</a>
).
</p>
<p>
Syntax:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-clike"><div class="docs-select-all right" id="sa30130918"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-clike">STRING <span class="token function">group_replication_switch_to_single_primary_mode</span><span class="token punctuation">(</span><span class="token punctuation">[</span><em class="replaceable">str</em><span class="token punctuation">]</span><span class="token punctuation">)</span></code></pre>
</div>
<p>
Arguments:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
<em class="replaceable">
<code>
str
</code>
</em>
: A string containing
the UUID of a member of the group which should become
the new single primary. Other members of the group
become secondaries.
</p>
</li>
</ul>
</div>
<p>
Return value:
</p>
<p>
A string containing the result of the operation, for
example whether it was successful or not.
</p>
<p>
Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa41478722"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> group_replication_switch_to_single_primary_mode<span class="token punctuation">(</span><em class="replaceable">member_uuid</em><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
For more information, see
<a class="xref" href="group-replication-changing-group-mode.html" title="20.5.1.2 Changing the Group Mode">
Section 20.5.1.2, “Changing the Group Mode”
</a>
</p>
</li>
</ul>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/gis-polygon-property-functions.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="gis-polygon-property-functions">
</a>
14.16.7.4 Polygon and MultiPolygon Property Functions
</h4>
</div>
</div>
</div>
<p>
Functions in this section return properties of
<code class="literal">
Polygon
</code>
or
<code class="literal">
MultiPolygon
</code>
values.
</p>
<p>
Unless otherwise specified, functions in this section handle
their geometry arguments as follows:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
If any argument is
<code class="literal">
NULL
</code>
or any geometry
argument is an empty geometry, the return value is
<code class="literal">
NULL
</code>
.
</p>
</li>
<li class="listitem">
<p>
If any geometry argument is not a syntactically well-formed
geometry, an
<a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html#error_er_gis_invalid_data" target="_top">
<code class="literal">
ER_GIS_INVALID_DATA
</code>
</a>
error
occurs.
</p>
</li>
<li class="listitem">
<p>
If any geometry argument is a syntactically well-formed
geometry in an undefined spatial reference system (SRS), an
<a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html#error_er_srs_not_found" target="_top">
<code class="literal">
ER_SRS_NOT_FOUND
</code>
</a>
error
occurs.
</p>
</li>
<li class="listitem">
<p>
For functions that take multiple geometry arguments, if
those arguments are not in the same SRS, an
<a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html#error_er_gis_different_srids" target="_top">
<code class="literal">
ER_GIS_DIFFERENT_SRIDS
</code>
</a>
error
occurs.
</p>
</li>
<li class="listitem">
<p>
Otherwise, the return value is non-
<code class="literal">
NULL
</code>
.
</p>
</li>
</ul>
</div>
<p>
These functions are available for obtaining polygon properties:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<a name="function_st-area">
</a>
<p>
<a class="link" href="gis-polygon-property-functions.html#function_st-area">
<code class="literal">
ST_Area({
<em class="replaceable">
<code>
poly
</code>
</em>
|
<em class="replaceable">
<code>
mpoly
</code>
</em>
})
</code>
</a>
</p>
<a class="indexterm" name="idm46045197144208">
</a>
<p>
Returns a double-precision number indicating the area of the
<code class="literal">
Polygon
</code>
or
<code class="literal">
MultiPolygon
</code>
argument, as measured in its
spatial reference system.
</p>
<p>
<a class="link" href="gis-polygon-property-functions.html#function_st-area">
<code class="literal">
ST_Area()
</code>
</a>
handles its
arguments as described in the introduction to this section,
with these exceptions:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
If the geometry is geometrically invalid, either the
result is an undefined area (that is, it can be any
number), or an error occurs.
</p>
</li>
<li class="listitem">
<p>
If the geometry is valid but is not a
<code class="literal">
Polygon
</code>
or
<code class="literal">
MultiPolygon
</code>
object, an
<a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html#error_er_unexpected_geometry_type" target="_top">
<code class="literal">
ER_UNEXPECTED_GEOMETRY_TYPE
</code>
</a>
error occurs.
</p>
</li>
<li class="listitem">
<p>
If the geometry is a valid
<code class="literal">
Polygon
</code>
in
a Cartesian SRS, the result is the Cartesian area of the
polygon.
</p>
</li>
<li class="listitem">
<p>
If the geometry is a valid
<code class="literal">
MultiPolygon
</code>
in a Cartesian SRS, the
result is the sum of the Cartesian area of the polygons.
</p>
</li>
<li class="listitem">
<p>
If the geometry is a valid
<code class="literal">
Polygon
</code>
in
a geographic SRS, the result is the geodetic area of the
polygon in that SRS, in square meters.
</p>
</li>
<li class="listitem">
<p>
If the geometry is a valid
<code class="literal">
MultiPolygon
</code>
in a geographic SRS, the
result is the sum of geodetic area of the polygons in
that SRS, in square meters.
</p>
</li>
<li class="listitem">
<p>
If an area computation results in
<code class="literal">
+inf
</code>
, an
<a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html#error_er_data_out_of_range" target="_top">
<code class="literal">
ER_DATA_OUT_OF_RANGE
</code>
</a>
error occurs.
</p>
</li>
<li class="listitem">
<p>
If the geometry has a geographic SRS with a longitude or
latitude that is out of range, an error occurs:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: square; ">
<li class="listitem">
<p>
If a longitude value is not in the range
(−180, 180], an
<a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html#error_er_geometry_param_longitude_out_of_range" target="_top">
<code class="literal">
ER_GEOMETRY_PARAM_LONGITUDE_OUT_OF_RANGE
</code>
</a>
error occurs.
</p>
</li>
<li class="listitem">
<p>
If a latitude value is not in the range [−90,
90], an
<a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html#error_er_geometry_param_latitude_out_of_range" target="_top">
<code class="literal">
ER_GEOMETRY_PARAM_LATITUDE_OUT_OF_RANGE
</code>
</a>
error occurs.
</p>
</li>
</ul>
</div>
<p>
Ranges shown are in degrees. The exact range limits
deviate slightly due to floating-point arithmetic.
</p>
</li>
</ul>
</div>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa91083537"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SET</span> <span class="token variable">@poly</span> <span class="token operator">=</span>
<span class="token string">'Polygon((0 0,0 3,3 0,0 0),(1 1,1 2,2 1,1 1))'</span><span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token function">ST_Area</span><span class="token punctuation">(</span><span class="token function">ST_GeomFromText</span><span class="token punctuation">(</span><span class="token variable">@poly</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> ST_Area(ST_GeomFromText(@poly)) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 4 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token prompt">mysql></span> <span class="token keyword">SET</span> <span class="token variable">@mpoly</span> <span class="token operator">=</span>
<span class="token string">'MultiPolygon(((0 0,0 3,3 3,3 0,0 0),(1 1,1 2,2 2,2 1,1 1)))'</span><span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token function">ST_Area</span><span class="token punctuation">(</span><span class="token function">ST_GeomFromText</span><span class="token punctuation">(</span><span class="token variable">@mpoly</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> ST_Area(ST_GeomFromText(@mpoly)) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 8 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
</li>
<li class="listitem">
<a name="function_st-centroid">
</a>
<p>
<a class="link" href="gis-polygon-property-functions.html#function_st-centroid">
<code class="literal">
ST_Centroid({
<em class="replaceable">
<code>
poly
</code>
</em>
|
<em class="replaceable">
<code>
mpoly
</code>
</em>
})
</code>
</a>
</p>
<a class="indexterm" name="idm46045197105808">
</a>
<p>
Returns the mathematical centroid for the
<code class="literal">
Polygon
</code>
or
<code class="literal">
MultiPolygon
</code>
argument as a
<code class="literal">
Point
</code>
. The result is not guaranteed to be
on the
<code class="literal">
MultiPolygon
</code>
.
</p>
<p>
This function processes geometry collections by computing
the centroid point for components of highest dimension in
the collection. Such components are extracted and made into
a single
<code class="literal">
MultiPolygon
</code>
,
<code class="literal">
MultiLineString
</code>
, or
<code class="literal">
MultiPoint
</code>
for centroid computation.
</p>
<p>
<a class="link" href="gis-polygon-property-functions.html#function_st-centroid">
<code class="literal">
ST_Centroid()
</code>
</a>
handles its
arguments as described in the introduction to this section,
with these exceptions:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
The return value is
<code class="literal">
NULL
</code>
for the
additional condition that the argument is an empty
geometry collection.
</p>
</li>
<li class="listitem">
<p>
If the geometry has an SRID value for a geographic
spatial reference system (SRS), an
<a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html#error_er_not_implemented_for_geographic_srs" target="_top">
<code class="literal">
ER_NOT_IMPLEMENTED_FOR_GEOGRAPHIC_SRS
</code>
</a>
error occurs.
</p>
</li>
</ul>
</div>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa95681294"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SET</span> <span class="token variable">@poly</span> <span class="token operator">=</span>
<span class="token function">ST_GeomFromText</span><span class="token punctuation">(</span><span class="token string">'POLYGON((0 0,10 0,10 10,0 10,0 0),(5 5,7 5,7 7,5 7,5 5))'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token function">ST_GeometryType</span><span class="token punctuation">(</span><span class="token variable">@poly</span><span class="token punctuation">)</span><span class="token punctuation">,</span><span class="token function">ST_AsText</span><span class="token punctuation">(</span><span class="token function">ST_Centroid</span><span class="token punctuation">(</span><span class="token variable">@poly</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> ST_GeometryType(@poly) <span class="token punctuation">|</span> ST_AsText(ST_Centroid(@poly)) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> POLYGON <span class="token punctuation">|</span> POINT(4.958333333333333 4.958333333333333) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
</li>
<li class="listitem">
<a name="function_st-exteriorring">
</a>
<p>
<a class="link" href="gis-polygon-property-functions.html#function_st-exteriorring">
<code class="literal">
ST_ExteriorRing(
<em class="replaceable">
<code>
poly
</code>
</em>
)
</code>
</a>
</p>
<a class="indexterm" name="idm46045197082512">
</a>
<p>
Returns the exterior ring of the
<code class="literal">
Polygon
</code>
value
<em class="replaceable">
<code>
poly
</code>
</em>
as a
<code class="literal">
LineString
</code>
.
</p>
<p>
<a class="link" href="gis-polygon-property-functions.html#function_st-exteriorring">
<code class="literal">
ST_ExteriorRing()
</code>
</a>
handles its
arguments as described in the introduction to this section.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa72093698"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SET</span> <span class="token variable">@poly</span> <span class="token operator">=</span>
<span class="token string">'Polygon((0 0,0 3,3 3,3 0,0 0),(1 1,1 2,2 2,2 1,1 1))'</span><span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token function">ST_AsText</span><span class="token punctuation">(</span><span class="token function">ST_ExteriorRing</span><span class="token punctuation">(</span><span class="token function">ST_GeomFromText</span><span class="token punctuation">(</span><span class="token variable">@poly</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> ST_AsText(ST_ExteriorRing(ST_GeomFromText(@poly))) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> LINESTRING(0 0,0 3,3 3,3 0,0 0) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
</li>
<li class="listitem">
<a name="function_st-interiorringn">
</a>
<p>
<a class="link" href="gis-polygon-property-functions.html#function_st-interiorringn">
<code class="literal">
ST_InteriorRingN(
<em class="replaceable">
<code>
poly
</code>
</em>
,
<em class="replaceable">
<code>
N
</code>
</em>
)
</code>
</a>
</p>
<a class="indexterm" name="idm46045197067584">
</a>
<p>
Returns the
<em class="replaceable">
<code>
N
</code>
</em>
-th interior ring
for the
<code class="literal">
Polygon
</code>
value
<em class="replaceable">
<code>
poly
</code>
</em>
as a
<code class="literal">
LineString
</code>
. Rings are numbered beginning
with 1.
</p>
<p>
<a class="link" href="gis-polygon-property-functions.html#function_st-interiorringn">
<code class="literal">
ST_InteriorRingN()
</code>
</a>
handles
its arguments as described in the introduction to this
section.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa96867082"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SET</span> <span class="token variable">@poly</span> <span class="token operator">=</span>
<span class="token string">'Polygon((0 0,0 3,3 3,3 0,0 0),(1 1,1 2,2 2,2 1,1 1))'</span><span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token function">ST_AsText</span><span class="token punctuation">(</span><span class="token function">ST_InteriorRingN</span><span class="token punctuation">(</span><span class="token function">ST_GeomFromText</span><span class="token punctuation">(</span><span class="token variable">@poly</span><span class="token punctuation">)</span><span class="token punctuation">,</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> ST_AsText(ST_InteriorRingN(ST_GeomFromText(@poly),1)) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> LINESTRING(1 1,1 2,2 2,2 1,1 1) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
</li>
<li class="listitem">
<a name="function_st-numinteriorrings">
</a>
<p>
<a class="link" href="gis-polygon-property-functions.html#function_st-numinteriorrings">
<code class="literal">
ST_NumInteriorRing(
<em class="replaceable">
<code>
poly
</code>
</em>
)
</code>
</a>
,
<a class="link" href="gis-polygon-property-functions.html#function_st-numinteriorrings">
<code class="literal">
ST_NumInteriorRings(
<em class="replaceable">
<code>
poly
</code>
</em>
)
</code>
</a>
</p>
<a class="indexterm" name="idm46045197050880">
</a>
<a class="indexterm" name="idm46045197049808">
</a>
<p>
Returns the number of interior rings in the
<code class="literal">
Polygon
</code>
value
<em class="replaceable">
<code>
poly
</code>
</em>
.
</p>
<p>
<a class="link" href="gis-polygon-property-functions.html#function_st-numinteriorrings">
<code class="literal">
ST_NumInteriorRing()
</code>
</a>
and
<a class="link" href="gis-polygon-property-functions.html#function_st-numinteriorrings">
<code class="literal">
ST_NuminteriorRings()
</code>
</a>
handle their arguments as described in the introduction to
this section.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa12729138"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SET</span> <span class="token variable">@poly</span> <span class="token operator">=</span>
<span class="token string">'Polygon((0 0,0 3,3 3,3 0,0 0),(1 1,1 2,2 2,2 1,1 1))'</span><span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token function">ST_NumInteriorRings</span><span class="token punctuation">(</span><span class="token function">ST_GeomFromText</span><span class="token punctuation">(</span><span class="token variable">@poly</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> ST_NumInteriorRings(ST_GeomFromText(@poly)) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 1 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
</li>
</ul>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/upgrade-before-you-begin.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h2 class="title">
<a name="upgrade-before-you-begin">
</a>
3.1 Before You Begin
</h2>
</div>
</div>
</div>
<p>
Review the information in this section before upgrading. Perform
any recommended actions.
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Understand what may occur during an upgrade. See
<a class="xref" href="upgrading-what-is-upgraded.html" title="3.4 What the MySQL Upgrade Process Upgrades">
Section 3.4, “What the MySQL Upgrade Process Upgrades”
</a>
.
</p>
</li>
<li class="listitem">
<p>
Protect your data by creating a backup. The backup should
include the
<code class="literal">
mysql
</code>
system database, which
contains the MySQL data dictionary tables and system tables.
See
<a class="xref" href="backup-methods.html" title="9.2 Database Backup Methods">
Section 9.2, “Database Backup Methods”
</a>
.
</p>
<div class="important" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Important
</div>
<p>
Downgrade from MySQL 8.4 to MySQL
8.3, or from a MySQL 8.4 release
to a previous MySQL 8.4 release, is not
supported. The only supported alternative is to restore a
backup taken
<span class="emphasis">
<em>
before
</em>
</span>
upgrading. It is
therefore imperative that you back up your data before
starting the upgrade process.
</p>
</div>
</li>
<li class="listitem">
<p>
Review
<a class="xref" href="upgrade-paths.html" title="3.2 Upgrade Paths">
Section 3.2, “Upgrade Paths”
</a>
to ensure that your
intended upgrade path is supported.
</p>
</li>
<li class="listitem">
<p>
Review
<a class="xref" href="upgrading-from-previous-series.html" title="3.5 Changes in MySQL 8.4">
Section 3.5, “Changes in MySQL 8.4”
</a>
for
changes that you should be aware of before upgrading. Some
changes may require action.
</p>
</li>
<li class="listitem">
<p>
Review
<a class="xref" href="mysql-nutshell.html" title="1.4 What Is New in MySQL 8.4 since MySQL 8.0">
Section 1.4, “What Is New in MySQL 8.4 since MySQL 8.0”
</a>
for deprecated and
removed features. An upgrade may require changes with respect
to those features if you use any of them.
</p>
</li>
<li class="listitem">
<p>
Review
<a class="xref" href="added-deprecated-removed.html" title="1.5 Server and Status Variables and Options Added, Deprecated, or Removed in MySQL 8.4 since 8.0">
Section 1.5, “Server and Status Variables and Options Added, Deprecated, or Removed in
MySQL 8.4 since 8.0”
</a>
. If you use
deprecated or removed variables, an upgrade may require
configuration changes.
</p>
</li>
<li class="listitem">
<p>
Review the
<a class="ulink" href="/doc/relnotes/mysql/8.4/en/" target="_top">
Release
Notes
</a>
for information about fixes, changes, and new
features.
</p>
</li>
<li class="listitem">
<p>
If you use replication, review
<a class="xref" href="replication-upgrade.html" title="19.5.3 Upgrading or Downgrading a Replication Topology">
Section 19.5.3, “Upgrading or Downgrading a Replication Topology”
</a>
.
</p>
</li>
<li class="listitem">
<p>
Review
<a class="xref" href="upgrade-best-practices.html" title="3.3 Upgrade Best Practices">
Section 3.3, “Upgrade Best Practices”
</a>
and plan
accordingly.
</p>
</li>
<li class="listitem">
<p>
Upgrade procedures vary by platform and how the initial
installation was performed. Use the procedure that applies to
your current MySQL installation:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
For binary and package-based installations on non-Windows
platforms, refer to
<a class="xref" href="upgrade-binary-package.html" title="3.7 Upgrading MySQL Binary or Package-based Installations on Unix/Linux">
Section 3.7, “Upgrading MySQL Binary or Package-based Installations on Unix/Linux”
</a>
.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
For supported Linux distributions, the preferred method
for upgrading package-based installations is to use the
MySQL software repositories (MySQL Yum Repository, MySQL
APT Repository, and MySQL SLES Repository).
</p>
</div>
</li>
<li class="listitem">
<p>
For installations on an Enterprise Linux platform or
Fedora using the MySQL Yum Repository, refer to
<a class="xref" href="updating-yum-repo.html" title="3.8 Upgrading MySQL with the MySQL Yum Repository">
Section 3.8, “Upgrading MySQL with the MySQL Yum Repository”
</a>
.
</p>
</li>
<li class="listitem">
<p>
For installations on Ubuntu using the MySQL APT
repository, refer to
<a class="xref" href="updating-apt-repo.html" title="3.9 Upgrading MySQL with the MySQL APT Repository">
Section 3.9, “Upgrading MySQL with the MySQL APT Repository”
</a>
.
</p>
</li>
<li class="listitem">
<p>
For installations on SLES using the MySQL SLES repository,
refer to
<a class="xref" href="updating-sles-repo.html" title="3.10 Upgrading MySQL with the MySQL SLES Repository">
Section 3.10, “Upgrading MySQL with the MySQL SLES Repository”
</a>
.
</p>
</li>
<li class="listitem">
<p>
For installations performed using Docker, refer to
<a class="xref" href="upgrade-docker-mysql.html" title="3.12 Upgrading a Docker Installation of MySQL">
Section 3.12, “Upgrading a Docker Installation of MySQL”
</a>
.
</p>
</li>
<li class="listitem">
<p>
For installations on Windows, refer to
<a class="xref" href="windows-upgrading.html" title="3.11 Upgrading MySQL on Windows">
Section 3.11, “Upgrading MySQL on Windows”
</a>
.
</p>
</li>
</ul>
</div>
</li>
<li class="listitem">
<p>
If your MySQL installation contains a large amount of data
that might take a long time to convert after an in-place
upgrade, it may be useful to create a test instance for
assessing the conversions that are required and the work
involved to perform them. To create a test instance, make a
copy of your MySQL instance that contains the
<code class="literal">
mysql
</code>
database and other databases without
the data. Run the upgrade procedure on the test instance to
assess the work involved to perform the actual data
conversion.
</p>
</li>
<li class="listitem">
<p>
Rebuilding and reinstalling MySQL language interfaces is
recommended when you install or upgrade to a new release of
MySQL. This applies to MySQL interfaces such as PHP
<code class="literal">
mysql
</code>
extensions and the Perl
<code class="literal">
DBD::mysql
</code>
module.
</p>
</li>
</ul>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/group-replication-summary.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="group-replication-summary">
</a>
20.1.1.2 Group Replication
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045134550768">
</a>
<p>
Group Replication is a technique that can be used to implement
fault-tolerant systems. A replication group is a set of servers,
each of which has a complete copy of the data (a shared-nothing
replication scheme), which interact with each other through
message passing. The communication layer provides a set of
guarantees such as atomic message and total order message
delivery. These are very powerful properties that translate into
very useful abstractions that one can resort to build more
advanced database replication solutions.
</p>
<p>
MySQL Group Replication builds on top of such properties and
abstractions and implements a multi-source update everywhere
replication protocol. A replication group is formed by multiple
servers; each server in the group may execute transactions
independently at any time. Read/write transactions commit only
after they have been approved by the group. In other words, for
any read/write transaction the group needs to decide whether it
commits or not, so the commit operation is not a unilateral
decision from the originating server. Read-only transactions
need no coordination within the group and commit immediately.
</p>
<p>
When a read/write transaction is ready to commit at the
originating server, the server atomically broadcasts the write
values (the rows that were changed) and the corresponding write
set (the unique identifiers of the rows that were updated).
Because the transaction is sent through an atomic broadcast,
either all servers in the group receive the transaction or none
do. If they receive it, then they all receive it in the same
order with respect to other transactions that were sent before.
All servers therefore receive the same set of transactions in
the same order, and a global total order is established for the
transactions.
</p>
<p>
However, there may be conflicts between transactions that
execute concurrently on different servers. Such conflicts are
detected by inspecting and comparing the write sets of two
different and concurrent transactions, in a process called
<span class="emphasis">
<em>
certification
</em>
</span>
. During certification,
conflict detection is carried out at row level: if two
concurrent transactions, that executed on different servers,
update the same row, then there is a conflict. The conflict
resolution procedure states that the transaction that was
ordered first commits on all servers, and the transaction
ordered second aborts, and is therefore rolled back on the
originating server and dropped by the other servers in the
group. For example, if t1 and t2 execute concurrently at
different sites, both changing the same row, and t2 is ordered
before t1, then t2 wins the conflict and t1 is rolled back. This
is in fact a distributed first commit wins rule. Note that if
two transactions are bound to conflict more often than not, then
it is a good practice to start them on the same server, where
they have a chance to synchronize on the local lock manager
instead of being rolled back as a result of certification.
</p>
<p>
For applying and externalizing the certified transactions, Group
Replication permits servers to deviate from the agreed order of
the transactions if this does not break consistency and
validity. Group Replication is an eventual consistency system,
meaning that as soon as the incoming traffic slows down or
stops, all group members have the same data content. While
traffic is flowing, transactions can be externalized in a
slightly different order, or externalized on some members before
the others. For example, in multi-primary mode, a local
transaction might be externalized immediately following
certification, although a remote transaction that is earlier in
the global order has not yet been applied. This is permitted
when the certification process has established that there is no
conflict between the transactions. In single-primary mode, on
the primary server, there is a small chance that concurrent,
non-conflicting local transactions might be committed and
externalized in a different order from the global order agreed
by Group Replication. On the secondaries, which do not accept
writes from clients, transactions are always committed and
externalized in the agreed order.
</p>
<p>
The following figure depicts the MySQL Group Replication
protocol and by comparing it to MySQL Replication (or even MySQL
semisynchronous replication) you can see some differences. Some
underlying consensus and Paxos related messages are missing from
this picture for the sake of clarity.
</p>
<div class="figure">
<a name="idm46045134540320">
</a>
<p class="title">
<b>
Figure 20.3 MySQL Group Replication Protocol
</b>
</p>
<div class="figure-contents">
<div class="mediaobject">
<img alt="A transaction received by Source 1 is executed. Source 1 then sends a message to the replication group, consisting of itself, Source 2, and Source 3. When all three members have reached consensus, they certify the transaction. Source 1 then writes the transaction to its binary log, commits it, and sends a response to the client application. Sources 2 and 3 write the transaction to their relay logs, then apply it, write it to the binary log, and commit it." src="images/gr-replication-diagram.png" style="width: 100%; max-width: 725px;"/>
</div>
</div>
</div>
<br class="figure-break"/>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/performance-schema-setup-meters-table.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="performance-schema-setup-meters-table">
</a>
29.12.21.1 The setup_meters Table
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045067845808">
</a>
<a class="indexterm" name="idm46045067844320">
</a>
<p>
The
<a class="link" href="performance-schema-setup-meters-table.html" title="29.12.21.1 The setup_meters Table">
<code class="literal">
setup_meters
</code>
</a>
table lists the
registered meters:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa22851095"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">select</span> <span class="token operator">*</span> <span class="token keyword">from</span> performance_schema<span class="token punctuation">.</span>setup_meters<span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> NAME <span class="token punctuation">|</span> FREQUENCY <span class="token punctuation">|</span> ENABLED <span class="token punctuation">|</span> DESCRIPTION <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> mysql.inno <span class="token punctuation">|</span> 10 <span class="token punctuation">|</span> YES <span class="token punctuation">|</span> MySql InnoDB metrics <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> mysql.inno.buffer_pool <span class="token punctuation">|</span> 10 <span class="token punctuation">|</span> YES <span class="token punctuation">|</span> MySql InnoDB buffer pool metrics <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> mysql.inno.data <span class="token punctuation">|</span> 10 <span class="token punctuation">|</span> YES <span class="token punctuation">|</span> MySql InnoDB data metrics <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> mysql.x <span class="token punctuation">|</span> 10 <span class="token punctuation">|</span> YES <span class="token punctuation">|</span> MySql X plugin metrics <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> mysql.x.stmt <span class="token punctuation">|</span> 10 <span class="token punctuation">|</span> YES <span class="token punctuation">|</span> MySql X plugin statement statistics <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> mysql.stats <span class="token punctuation">|</span> 10 <span class="token punctuation">|</span> YES <span class="token punctuation">|</span> MySql core metrics <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> mysql.stats.com <span class="token punctuation">|</span> 10 <span class="token punctuation">|</span> YES <span class="token punctuation">|</span> MySql command stats <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> mysql.stats.connection <span class="token punctuation">|</span> 10 <span class="token punctuation">|</span> YES <span class="token punctuation">|</span> MySql connection stats <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> mysql.stats.handler <span class="token punctuation">|</span> 10 <span class="token punctuation">|</span> YES <span class="token punctuation">|</span> MySql handler stats <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> mysql.stats.ssl <span class="token punctuation">|</span> 10 <span class="token punctuation">|</span> YES <span class="token punctuation">|</span> MySql TLS related stats <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> mysql.myisam <span class="token punctuation">|</span> 10 <span class="token punctuation">|</span> YES <span class="token punctuation">|</span> MySql MyISAM storage engine stats <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> mysql.perf_schema <span class="token punctuation">|</span> 10 <span class="token punctuation">|</span> YES <span class="token punctuation">|</span> MySql performance_schema lost instruments <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
NAME
</code>
: Name of the meter.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
FREQUENCY
</code>
: Frequency in seconds of
metric export. Default is every 10 seconds. This value can
be edited for registered meters.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ENABLED
</code>
: Whether the meter is enabled.
The value is YES or NO. A disabled meter exports no
metrics. This column can be modified
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
DESCRIPTION
</code>
: A string describing the
meter.
</p>
</li>
</ul>
</div>
<p>
<code class="literal">
FREQUENCY
</code>
and
<code class="literal">
ENABLED
</code>
can be edited.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/user-names.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="user-names">
</a>
8.2.1 Account User Names and Passwords
</h3>
</div>
</div>
</div>
<a class="indexterm" name="idm46045252290896">
</a>
<a class="indexterm" name="idm46045252289440">
</a>
<p>
MySQL stores accounts in the
<code class="literal">
user
</code>
table of the
<code class="literal">
mysql
</code>
system database. An account is defined in
terms of a user name and the client host or hosts from which the
user can connect to the server. For information about account
representation in the
<code class="literal">
user
</code>
table, see
<a class="xref" href="grant-tables.html" title="8.2.3 Grant Tables">
Section 8.2.3, “Grant Tables”
</a>
.
</p>
<p>
An account may also have authentication credentials such as a
password. The credentials are handled by the account
authentication plugin. MySQL supports multiple authentication
plugins. Some of them use built-in authentication methods, whereas
others enable authentication using external authentication
methods. See
<a class="xref" href="pluggable-authentication.html" title="8.2.17 Pluggable Authentication">
Section 8.2.17, “Pluggable Authentication”
</a>
.
</p>
<p>
There are several distinctions between the way user names and
passwords are used by MySQL and your operating system:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
User names, as used by MySQL for authentication purposes, have
nothing to do with user names (login names) as used by Windows
or Unix. On Unix, most MySQL clients by default try to log in
using the current Unix user name as the MySQL user name, but
that is for convenience only. The default can be overridden
easily, because client programs permit any user name to be
specified with a
<code class="option">
-u
</code>
or
<code class="option">
--user
</code>
option. This means that anyone can
attempt to connect to the server using any user name, so you
cannot make a database secure in any way unless all MySQL
accounts have passwords. Anyone who specifies a user name for
an account that has no password can connect successfully to
the server.
</p>
</li>
<li class="listitem">
<p>
MySQL user names are up to 32 characters long. Operating
system user names may have a different maximum length.
</p>
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Warning
</div>
<p>
The MySQL user name length limit is hardcoded in MySQL
servers and clients, and trying to circumvent it by
modifying the definitions of the tables in the
<code class="literal">
mysql
</code>
database
<span class="emphasis">
<em>
does not
work
</em>
</span>
.
</p>
<p>
You should never alter the structure of tables in the
<code class="literal">
mysql
</code>
database in any manner whatsoever
except by means of the procedure that is described in
<a class="xref" href="upgrading.html" title="Chapter 3 Upgrading MySQL">
Chapter 3,
<i>
Upgrading MySQL
</i>
</a>
. Attempting to redefine the
MySQL system tables in any other fashion results in
undefined and unsupported behavior. The server is free to
ignore rows that become malformed as a result of such
modifications.
</p>
</div>
</li>
<li class="listitem">
<p>
To authenticate client connections for accounts that use
built-in authentication methods, the server uses passwords
stored in the
<code class="literal">
user
</code>
table. These passwords
are distinct from passwords for logging in to your operating
system. There is no necessary connection between the
<span class="quote">
“
<span class="quote">
external
</span>
”
</span>
password you use to log in to a
Windows or Unix machine and the password you use to access the
MySQL server on that machine.
</p>
<p>
If the server authenticates a client using some other plugin,
the authentication method that the plugin implements may or
may not use a password stored in the
<code class="literal">
user
</code>
table. In this case, it is possible that an external password
is also used to authenticate to the MySQL server.
</p>
</li>
<li class="listitem">
<p>
Passwords stored in the
<code class="literal">
user
</code>
table are
encrypted using plugin-specific algorithms.
</p>
</li>
<li class="listitem">
<p>
If the user name and password contain only ASCII characters,
it is possible to connect to the server regardless of
character set settings. To enable connections when the user
name or password contain non-ASCII characters, client
applications should call the
<a class="ulink" href="/doc/c-api/8.4/en/mysql-options.html" target="_top">
<code class="literal">
mysql_options()
</code>
</a>
C API function
with the
<code class="literal">
MYSQL_SET_CHARSET_NAME
</code>
option and
appropriate character set name as arguments. This causes
authentication to take place using the specified character
set. Otherwise, authentication fails unless the server default
character set is the same as the encoding in the
authentication defaults.
</p>
<p>
Standard MySQL client programs support a
<code class="option">
--default-character-set
</code>
option that causes
<a class="ulink" href="/doc/c-api/8.4/en/mysql-options.html" target="_top">
<code class="literal">
mysql_options()
</code>
</a>
to be called
as just described. In addition, character set autodetection is
supported as described in
<a class="xref" href="charset-connection.html" title="12.4 Connection Character Sets and Collations">
Section 12.4, “Connection Character Sets and Collations”
</a>
. For programs that use a
connector that is not based on the C API, the connector may
provide an equivalent to
<a class="ulink" href="/doc/c-api/8.4/en/mysql-options.html" target="_top">
<code class="literal">
mysql_options()
</code>
</a>
that can be
used instead. Check the connector documentation.
</p>
<p>
The preceding notes do not apply for
<code class="literal">
ucs2
</code>
,
<code class="literal">
utf16
</code>
, and
<code class="literal">
utf32
</code>
, which
are not permitted as client character sets.
</p>
</li>
</ul>
</div>
<p>
The MySQL installation process populates the grant tables with an
initial
<code class="literal">
root
</code>
account, as described in
<a class="xref" href="default-privileges.html" title="2.9.4 Securing the Initial MySQL Account">
Section 2.9.4, “Securing the Initial MySQL Account”
</a>
, which also discusses how to
assign a password to it. Thereafter, you normally set up, modify,
and remove MySQL accounts using statements such as
<a class="link" href="create-user.html" title="15.7.1.3 CREATE USER Statement">
<code class="literal">
CREATE USER
</code>
</a>
,
<a class="link" href="drop-user.html" title="15.7.1.5 DROP USER Statement">
<code class="literal">
DROP USER
</code>
</a>
,
<a class="link" href="grant.html" title="15.7.1.6 GRANT Statement">
<code class="literal">
GRANT
</code>
</a>
, and
<a class="link" href="revoke.html" title="15.7.1.8 REVOKE Statement">
<code class="literal">
REVOKE
</code>
</a>
. See
<a class="xref" href="creating-accounts.html" title="8.2.8 Adding Accounts, Assigning Privileges, and Dropping Accounts">
Section 8.2.8, “Adding Accounts, Assigning Privileges, and Dropping Accounts”
</a>
, and
<a class="xref" href="account-management-statements.html" title="15.7.1 Account Management Statements">
Section 15.7.1, “Account Management Statements”
</a>
.
</p>
<p>
To connect to a MySQL server with a command-line client, specify
user name and password options as necessary for the account that
you want to use:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa55316859"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$> </span><span class="token command">mysql</span> <span class="token constant">--user</span><span class="token attr-value"><span class="token punctuation">=</span>finley</span> <span class="token property">--password</span> <em class="replaceable">db_name</em></code></pre>
</div>
<p>
If you prefer short options, the command looks like this:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa23346708"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$> </span><span class="token command">mysql</span> <span class="token property">-u</span> finley <span class="token property">-p</span> <em class="replaceable">db_name</em></code></pre>
</div>
<p>
If you omit the password value following the
<a class="link" href="connection-options.html#option_general_password">
<code class="option">
--password
</code>
</a>
or
<code class="option">
-p
</code>
option on the command line (as just shown), the client prompts for
one. Alternatively, the password can be specified on the command
line:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa68341090"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$> </span><span class="token command">mysql</span> <span class="token constant">--user</span><span class="token attr-value"><span class="token punctuation">=</span>finley</span> <span class="token constant">--password</span><span class="token attr-value"><span class="token punctuation">=</span><em class="replaceable">password</em></span> <em class="replaceable">db_name</em>
<span class="token prompt">$> </span><span class="token command">mysql</span> <span class="token property">-u</span> finley <span class="token property">-p<em class="replaceable">password</em></span> <em class="replaceable">db_name</em></code></pre>
</div>
<p>
If you use the
<code class="option">
-p
</code>
option, there must be
<span class="emphasis">
<em>
no space
</em>
</span>
between
<code class="option">
-p
</code>
and the
following password value.
</p>
<p>
Specifying a password on the command line should be considered
insecure. See
<a class="xref" href="password-security-user.html" title="8.1.2.1 End-User Guidelines for Password Security">
Section 8.1.2.1, “End-User Guidelines for Password Security”
</a>
. To avoid
giving the password on the command line, use an option file or a
login path file. See
<a class="xref" href="option-files.html" title="6.2.2.2 Using Option Files">
Section 6.2.2.2, “Using Option Files”
</a>
, and
<a class="xref" href="mysql-config-editor.html" title="6.6.7 mysql_config_editor — MySQL Configuration Utility">
Section 6.6.7, “mysql_config_editor — MySQL Configuration Utility”
</a>
.
</p>
<p>
For additional information about specifying user names, passwords,
and other connection parameters, see
<a class="xref" href="connecting.html" title="6.2.4 Connecting to the MySQL Server Using Command Options">
Section 6.2.4, “Connecting to the MySQL Server Using Command Options”
</a>
.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/change-replication-filter.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="change-replication-filter">
</a>
15.4.2.1 CHANGE REPLICATION FILTER Statement
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045177761360">
</a>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa98250680"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">CHANGE</span> <span class="token keyword">REPLICATION</span> <span class="token keyword">FILTER</span> <span class="token keyword"><em class="replaceable">filter</em></span><span class="token punctuation">[</span><span class="token punctuation">,</span> <span class="token keyword"><em class="replaceable">filter</em></span><span class="token punctuation">]</span>
<span class="token punctuation">[</span><span class="token punctuation">,</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">]</span> <span class="token punctuation">[</span><span class="token keyword">FOR</span> <span class="token keyword">CHANNEL</span> <span class="token keyword"><em class="replaceable">channel</em></span><span class="token punctuation">]</span>
<span class="token keyword"><em class="replaceable">filter</em></span>: {
<span class="token keyword">REPLICATE_DO_DB</span> <span class="token operator">=</span> <span class="token punctuation">(</span><em class="replaceable">db_list</em><span class="token punctuation">)</span>
<span class="token operator">|</span> <span class="token keyword">REPLICATE_IGNORE_DB</span> <span class="token operator">=</span> <span class="token punctuation">(</span><em class="replaceable">db_list</em><span class="token punctuation">)</span>
<span class="token operator">|</span> <span class="token keyword">REPLICATE_DO_TABLE</span> <span class="token operator">=</span> <span class="token punctuation">(</span><em class="replaceable">tbl_list</em><span class="token punctuation">)</span>
<span class="token operator">|</span> <span class="token keyword">REPLICATE_IGNORE_TABLE</span> <span class="token operator">=</span> <span class="token punctuation">(</span><em class="replaceable">tbl_list</em><span class="token punctuation">)</span>
<span class="token operator">|</span> <span class="token keyword">REPLICATE_WILD_DO_TABLE</span> <span class="token operator">=</span> <span class="token punctuation">(</span><em class="replaceable">wild_tbl_list</em><span class="token punctuation">)</span>
<span class="token operator">|</span> <span class="token keyword">REPLICATE_WILD_IGNORE_TABLE</span> <span class="token operator">=</span> <span class="token punctuation">(</span><em class="replaceable">wild_tbl_list</em><span class="token punctuation">)</span>
<span class="token operator">|</span> <span class="token keyword">REPLICATE_REWRITE_DB</span> <span class="token operator">=</span> <span class="token punctuation">(</span><em class="replaceable">db_pair_list</em><span class="token punctuation">)</span>
}
<em class="replaceable">db_list</em>:
<em class="replaceable">db_name</em><span class="token punctuation">[</span><span class="token punctuation">,</span> <em class="replaceable">db_name</em><span class="token punctuation">]</span><span class="token punctuation">[</span><span class="token punctuation">,</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">]</span>
<em class="replaceable">tbl_list</em>:
<em class="replaceable">db_name<span class="token punctuation">.</span><span class="token keyword">table_name</span></em><span class="token keyword"></span><span class="token punctuation">[</span><span class="token punctuation">,</span> <em class="replaceable">db_name<span class="token punctuation">.</span><span class="token keyword">table_name</span></em><span class="token keyword"></span><span class="token punctuation">]</span><span class="token punctuation">[</span><span class="token punctuation">,</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">]</span>
<em class="replaceable">wild_tbl_list</em>:
<span class="token string">'<em class="replaceable">db_pattern.table_pattern</em>'</span><span class="token punctuation">[</span><span class="token punctuation">,</span> <span class="token string">'<em class="replaceable">db_pattern.table_pattern</em>'</span><span class="token punctuation">]</span><span class="token punctuation">[</span><span class="token punctuation">,</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">]</span>
<em class="replaceable">db_pair_list</em>:
<span class="token punctuation">(</span><em class="replaceable">db_pair</em><span class="token punctuation">)</span><span class="token punctuation">[</span><span class="token punctuation">,</span> <span class="token punctuation">(</span><em class="replaceable">db_pair</em><span class="token punctuation">)</span><span class="token punctuation">]</span><span class="token punctuation">[</span><span class="token punctuation">,</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">]</span>
<em class="replaceable">db_pair</em>:
<em class="replaceable">from_db</em><span class="token punctuation">,</span> <em class="replaceable">to_db</em></code></pre>
</div>
<p>
<code class="literal">
CHANGE REPLICATION FILTER
</code>
sets one or more
replication filtering rules on the replica in the same way as
starting the replica
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
with replication
filtering options such as
<a class="link" href="replication-options-replica.html#option_mysqld_replicate-do-db">
<code class="option">
--replicate-do-db
</code>
</a>
or
<a class="link" href="replication-options-replica.html#option_mysqld_replicate-wild-ignore-table">
<code class="option">
--replicate-wild-ignore-table
</code>
</a>
.
Filters set using this statement differ from those set using the
server options in two key respects:
</p>
<div class="orderedlist">
<ol class="orderedlist" type="1">
<li class="listitem">
<p>
The statement does not require restarting the server to take
effect, only that the replication SQL thread be stopped
using
<a class="link" href="stop-replica.html" title="15.4.2.5 STOP REPLICA Statement">
<code class="literal">
STOP
REPLICA SQL_THREAD
</code>
</a>
first (and restarted with
<a class="link" href="start-replica.html" title="15.4.2.4 START REPLICA Statement">
<code class="literal">
START REPLICA
SQL_THREAD
</code>
</a>
afterwards).
</p>
</li>
<li class="listitem">
<p>
The effects of the statement are not persistent; any filters
set using
<code class="literal">
CHANGE REPLICATION FILTER
</code>
are
lost following a restart of the replica
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
.
</p>
</li>
</ol>
</div>
<p>
<a class="link" href="change-replication-filter.html" title="15.4.2.1 CHANGE REPLICATION FILTER Statement">
<code class="literal">
CHANGE REPLICATION FILTER
</code>
</a>
requires the
<a class="link" href="privileges-provided.html#priv_replication-slave-admin">
<code class="literal">
REPLICATION_SLAVE_ADMIN
</code>
</a>
privilege
(or the deprecated
<a class="link" href="privileges-provided.html#priv_super">
<code class="literal">
SUPER
</code>
</a>
privilege).
</p>
<p>
Use the
<code class="literal">
FOR CHANNEL
<em class="replaceable">
<code>
channel
</code>
</em>
</code>
clause to make a
replication filter specific to a replication channel, for
example on a multi-source replica. Filters applied without a
specific
<code class="literal">
FOR CHANNEL
</code>
clause are considered
global filters, meaning that they are applied to all replication
channels.
</p>
<p>
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
Global replication filters cannot be set on a MySQL server
instance that is configured for Group Replication, because
filtering transactions on some servers would make the group
unable to reach agreement on a consistent state. Channel
specific replication filters can be set on replication
channels that are not directly involved with Group
Replication, such as where a group member also acts as a
replica to a source that is outside the group. They cannot
be set on the
<code class="literal">
group_replication_applier
</code>
or
<code class="literal">
group_replication_recovery
</code>
channels.
</p>
</div>
<p>
</p>
<p>
The following list shows the
<code class="literal">
CHANGE REPLICATION
FILTER
</code>
options and how they relate to
<code class="option">
--replicate-*
</code>
server options:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
REPLICATE_DO_DB
</code>
: Include updates based on
database name. Equivalent to
<a class="link" href="replication-options-replica.html#option_mysqld_replicate-do-db">
<code class="option">
--replicate-do-db
</code>
</a>
.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
REPLICATE_IGNORE_DB
</code>
: Exclude updates
based on database name. Equivalent to
<a class="link" href="replication-options-replica.html#option_mysqld_replicate-ignore-db">
<code class="option">
--replicate-ignore-db
</code>
</a>
.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
REPLICATE_DO_TABLE
</code>
: Include updates based
on table name. Equivalent to
<a class="link" href="replication-options-replica.html#option_mysqld_replicate-do-table">
<code class="option">
--replicate-do-table
</code>
</a>
.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
REPLICATE_IGNORE_TABLE
</code>
: Exclude updates
based on table name. Equivalent to
<a class="link" href="replication-options-replica.html#option_mysqld_replicate-ignore-table">
<code class="option">
--replicate-ignore-table
</code>
</a>
.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
REPLICATE_WILD_DO_TABLE
</code>
: Include updates
based on wildcard pattern matching table name. Equivalent to
<a class="link" href="replication-options-replica.html#option_mysqld_replicate-wild-do-table">
<code class="option">
--replicate-wild-do-table
</code>
</a>
.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
REPLICATE_WILD_IGNORE_TABLE
</code>
: Exclude
updates based on wildcard pattern matching table name.
Equivalent to
<a class="link" href="replication-options-replica.html#option_mysqld_replicate-wild-ignore-table">
<code class="option">
--replicate-wild-ignore-table
</code>
</a>
.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
REPLICATE_REWRITE_DB
</code>
: Perform updates on
replica after substituting new name on replica for specified
database on source. Equivalent to
<a class="link" href="replication-options-replica.html#option_mysqld_replicate-rewrite-db">
<code class="option">
--replicate-rewrite-db
</code>
</a>
.
</p>
</li>
</ul>
</div>
<p>
The precise effects of
<code class="literal">
REPLICATE_DO_DB
</code>
and
<code class="literal">
REPLICATE_IGNORE_DB
</code>
filters are dependent on
whether statement-based or row-based replication is in effect.
See
<a class="xref" href="replication-rules.html" title="19.2.5 How Servers Evaluate Replication Filtering Rules">
Section 19.2.5, “How Servers Evaluate Replication Filtering Rules”
</a>
, for more information.
</p>
<p>
Multiple replication filtering rules can be created in a single
<code class="literal">
CHANGE REPLICATION FILTER
</code>
statement by
separating the rules with commas, as shown here:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa92036304"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">CHANGE</span> <span class="token keyword">REPLICATION</span> <span class="token keyword">FILTER</span>
<span class="token keyword">REPLICATE_DO_DB</span> <span class="token operator">=</span> <span class="token punctuation">(</span>d1<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token keyword">REPLICATE_IGNORE_DB</span> <span class="token operator">=</span> <span class="token punctuation">(</span>d2<span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
Issuing the statement just shown is equivalent to starting the
replica
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
with the options
<a class="link" href="replication-options-replica.html#option_mysqld_replicate-do-db">
<code class="option">
--replicate-do-db=d1
</code>
</a>
<a class="link" href="replication-options-replica.html#option_mysqld_replicate-ignore-db">
<code class="option">
--replicate-ignore-db=d2
</code>
</a>
.
</p>
<p>
On a multi-source replica, which uses multiple replication
channels to process transaction from different sources, use the
<code class="literal">
FOR CHANNEL
<em class="replaceable">
<code>
channel
</code>
</em>
</code>
clause to set a
replication filter on a replication channel:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa55006583"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">CHANGE</span> <span class="token keyword">REPLICATION</span> <span class="token keyword">FILTER</span> <span class="token keyword">REPLICATE_DO_DB</span> <span class="token operator">=</span> <span class="token punctuation">(</span>d1<span class="token punctuation">)</span> <span class="token keyword">FOR</span> <span class="token keyword">CHANNEL</span> channel_1<span class="token punctuation">;</span></code></pre>
</div>
<p>
This enables you to create a channel specific replication filter
to filter out selected data from a source. When a
<code class="literal">
FOR
CHANNEL
</code>
clause is provided, the replication filter
statement acts on that replication channel, removing any
existing replication filter which has the same filter type as
the specified replication filters, and replacing them with the
specified filter. Filter types not explicitly listed in the
statement are not modified. If issued against a replication
channel which is not configured, the statement fails with an
<span class="errortext">
ER_SLAVE_CONFIGURATION
</span>
error. If issued
against Group Replication channels, the statement fails with an
<span class="errortext">
ER_SLAVE_CHANNEL_OPERATION_NOT_ALLOWED
</span>
error.
</p>
<p>
On a replica with multiple replication channels configured,
issuing
<a class="link" href="change-replication-filter.html" title="15.4.2.1 CHANGE REPLICATION FILTER Statement">
<code class="literal">
CHANGE REPLICATION FILTER
</code>
</a>
with no
<code class="literal">
FOR CHANNEL
</code>
clause configures the
replication filter for every configured replication channel, and
for the global replication filters. For every filter type, if
the filter type is listed in the statement, then any existing
filter rules of that type are replaced by the filter rules
specified in the most recently issued statement, otherwise the
old value of the filter type is retained. For more information
see
<a class="xref" href="replication-rules-channel-based-filters.html" title="19.2.5.4 Replication Channel Based Filters">
Section 19.2.5.4, “Replication Channel Based Filters”
</a>
.
</p>
<p>
If the same filtering rule is specified multiple times, only the
<span class="emphasis">
<em>
last
</em>
</span>
such rule is actually used. For
example, the two statements shown here have exactly the same
effect, because the first
<code class="literal">
REPLICATE_DO_DB
</code>
rule in the first statement is ignored:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa11741692"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">CHANGE</span> <span class="token keyword">REPLICATION</span> <span class="token keyword">FILTER</span>
<span class="token keyword">REPLICATE_DO_DB</span> <span class="token operator">=</span> <span class="token punctuation">(</span>db1<span class="token punctuation">,</span> db2<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token keyword">REPLICATE_DO_DB</span> <span class="token operator">=</span> <span class="token punctuation">(</span>db3<span class="token punctuation">,</span> db4<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">CHANGE</span> <span class="token keyword">REPLICATION</span> <span class="token keyword">FILTER</span>
<span class="token keyword">REPLICATE_DO_DB</span> <span class="token operator">=</span> <span class="token punctuation">(</span>db3<span class="token punctuation">,</span> db4<span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
</div>
<div class="caution" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Caution
</div>
<p>
This behavior differs from that of the
<code class="option">
--replicate-*
</code>
filter options where specifying
the same option multiple times causes the creation of multiple
filter rules.
</p>
</div>
<p>
Names of tables and database not containing any special
characters need not be quoted. Values used with
<code class="literal">
REPLICATION_WILD_TABLE
</code>
and
<code class="literal">
REPLICATION_WILD_IGNORE_TABLE
</code>
are string
expressions, possibly containing (special) wildcard characters,
and so must be quoted. This is shown in the following example
statements:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa78531592"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">CHANGE</span> <span class="token keyword">REPLICATION</span> <span class="token keyword">FILTER</span>
<span class="token keyword">REPLICATE_WILD_DO_TABLE</span> <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token string">'db1.old%'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">CHANGE</span> <span class="token keyword">REPLICATION</span> <span class="token keyword">FILTER</span>
<span class="token keyword">REPLICATE_WILD_IGNORE_TABLE</span> <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token string">'db1.new%'</span><span class="token punctuation">,</span> <span class="token string">'db2.new%'</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
Values used with
<code class="literal">
REPLICATE_REWRITE_DB
</code>
represent
<span class="emphasis">
<em>
pairs
</em>
</span>
of database names; each
such value must be enclosed in parentheses. The following
statement rewrites statements occurring on database
<code class="literal">
db1
</code>
on the source to database
<code class="literal">
db2
</code>
on the replica:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa40936301"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">CHANGE</span> <span class="token keyword">REPLICATION</span> <span class="token keyword">FILTER</span> <span class="token keyword">REPLICATE_REWRITE_DB</span> <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token punctuation">(</span>db1<span class="token punctuation">,</span> db2<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
The statement just shown contains two sets of parentheses, one
enclosing the pair of database names, and the other enclosing
the entire list. This is perhaps more easily seen in the
following example, which creates two
<code class="literal">
rewrite-db
</code>
rules, one rewriting database
<code class="literal">
dbA
</code>
to
<code class="literal">
dbB
</code>
, and one
rewriting database
<code class="literal">
dbC
</code>
to
<code class="literal">
dbD
</code>
:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa38667808"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">CHANGE</span> <span class="token keyword">REPLICATION</span> <span class="token keyword">FILTER</span>
<span class="token keyword">REPLICATE_REWRITE_DB</span> <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token punctuation">(</span>dbA<span class="token punctuation">,</span> dbB<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token punctuation">(</span>dbC<span class="token punctuation">,</span> dbD<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
The
<a class="link" href="change-replication-filter.html" title="15.4.2.1 CHANGE REPLICATION FILTER Statement">
<code class="literal">
CHANGE REPLICATION FILTER
</code>
</a>
statement replaces replication filtering rules only for the
filter types and replication channels affected by the statement,
and leaves other rules and channels unchanged. If you want to
unset all filters of a given type, set the filter's value
to an explicitly empty list, as shown in this example, which
removes all existing
<code class="literal">
REPLICATE_DO_DB
</code>
and
<code class="literal">
REPLICATE_IGNORE_DB
</code>
rules:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa55637938"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">CHANGE</span> <span class="token keyword">REPLICATION</span> <span class="token keyword">FILTER</span>
<span class="token keyword">REPLICATE_DO_DB</span> <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token keyword">REPLICATE_IGNORE_DB</span> <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
Setting a filter to empty in this way removes all existing
rules, does not create any new ones, and does not restore any
rules set at mysqld startup using
<code class="option">
--replicate-*
</code>
options on the command line or in the configuration file.
</p>
<p>
The
<a class="link" href="reset-replica.html" title="15.4.2.3 RESET REPLICA Statement">
<code class="literal">
RESET REPLICA
ALL
</code>
</a>
statement removes channel specific replication
filters that were set on channels deleted by the statement. When
the deleted channel or channels are recreated, any global
replication filters specified for the replica are copied to
them, and no channel specific replication filters are applied.
</p>
<p>
For more information, see
<a class="xref" href="replication-rules.html" title="19.2.5 How Servers Evaluate Replication Filtering Rules">
Section 19.2.5, “How Servers Evaluate Replication Filtering Rules”
</a>
.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/windows-symbolic-links.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="windows-symbolic-links">
</a>
10.12.2.3 Using Symbolic Links for Databases on Windows
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045222402272">
</a>
<a class="indexterm" name="idm46045222401232">
</a>
<a class="indexterm" name="idm46045222399744">
</a>
<a class="indexterm" name="idm46045222398656">
</a>
<p>
On Windows, symbolic links can be used for database
directories. This enables you to put a database directory at a
different location (for example, on a different disk) by
setting up a symbolic link to it. Use of database symlinks on
Windows is similar to their use on Unix, although the
procedure for setting up the link differs.
</p>
<p>
Suppose that you want to place the database directory for a
database named
<code class="literal">
mydb
</code>
at
<code class="filename">
D:\data\mydb
</code>
. To do this, create a
symbolic link in the MySQL data directory that points to
<code class="filename">
D:\data\mydb
</code>
. However, before creating
the symbolic link, make sure that the
<code class="filename">
D:\data\mydb
</code>
directory exists by creating
it if necessary. If you already have a database directory
named
<code class="filename">
mydb
</code>
in the data directory, move it
to
<code class="filename">
D:\data
</code>
. Otherwise, the symbolic link
has no effect. To avoid problems, make sure that the server is
not running when you move the database directory.
</p>
<p>
On Windows, you can create a symlink using the
<span class="command">
<strong>
mklink
</strong>
</span>
command. This command
requires administrative privileges.
</p>
<div class="orderedlist">
<ol class="orderedlist" type="1">
<li class="listitem">
<p>
Make sure that the desired path to the database exists.
For this example, we use
<code class="filename">
D:\data\mydb
</code>
, and a database named
<code class="literal">
mydb
</code>
.
</p>
</li>
<li class="listitem">
<p>
If the database does not already exist, issue
<code class="literal">
CREATE DATABASE mydb
</code>
in the
<a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
<span class="command">
<strong>
mysql
</strong>
</span>
</a>
client to create it.
</p>
</li>
<li class="listitem">
<p>
Stop the MySQL service.
</p>
</li>
<li class="listitem">
<p>
Using Windows Explorer or the command line, move the
directory
<code class="filename">
mydb
</code>
from the data
directory to
<code class="filename">
D:\data
</code>
, replacing the
directory of the same name.
</p>
</li>
<li class="listitem">
<p>
If you are not already using the command prompt, open it,
and change location to the data directory, like this:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa82269575"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">C:\></span><span class="token command"> cd</span> <em class="replaceable">\path\to\datadir</em></code></pre>
</div>
<p>
If your MySQL installation is in the default location, you
can use this:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa60688621"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">C:\></span><span class="token command"> cd</span> C<span class="token punctuation">:</span>\ProgramData\MySQL\MySQL Server 8<span class="token punctuation">.</span>4\Data</code></pre>
</div>
</li>
<li class="listitem">
<p>
In the data directory, create a symlink named
<code class="filename">
mydb
</code>
that points to the location of
the database directory:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa6383972"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">C:\></span><span class="token command"> mklink</span> /d mydb D<span class="token punctuation">:</span>\data\mydb</code></pre>
</div>
</li>
<li class="listitem">
<p>
Start the MySQL service.
</p>
</li>
</ol>
</div>
<p>
After this, all tables created in the database
<code class="literal">
mydb
</code>
are created in
<code class="filename">
D:\data\mydb
</code>
.
</p>
<p>
Alternatively, on any version of Windows supported by MySQL,
you can create a symbolic link to a MySQL database by creating
a
<code class="filename">
.sym
</code>
file in the data directory that
contains the path to the destination directory. The file
should be named
<code class="filename">
<em class="replaceable">
<code>
db_name
</code>
</em>
.sym
</code>
,
where
<em class="replaceable">
<code>
db_name
</code>
</em>
is the database name.
</p>
<p>
Support for database symbolic links on Windows using
<code class="filename">
.sym
</code>
files is enabled by default. If you
do not need
<code class="filename">
.sym
</code>
file symbolic links, you
can disable support for them by starting
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
with the
<a class="link" href="server-options.html#option_mysqld_symbolic-links">
<code class="option">
--skip-symbolic-links
</code>
</a>
option. To determine whether your system supports
<code class="filename">
.sym
</code>
file symbolic links, check the value
of the
<a class="link" href="server-system-variables.html#sysvar_have_symlink">
<code class="literal">
have_symlink
</code>
</a>
system
variable using this statement:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa34010028"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SHOW</span> <span class="token keyword">VARIABLES</span> <span class="token operator">LIKE</span> <span class="token string">'have_symlink'</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
To create a
<code class="filename">
.sym
</code>
file symlink, use this
procedure:
</p>
<div class="orderedlist">
<ol class="orderedlist" type="1">
<li class="listitem">
<p>
Change location into the data directory:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa6468634"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">C:\></span><span class="token command"> cd</span> <em class="replaceable">\path\to\datadir</em></code></pre>
</div>
</li>
<li class="listitem">
<p>
In the data directory, create a text file named
<code class="filename">
mydb.sym
</code>
that contains this path
name:
<code class="literal">
D:\data\mydb\
</code>
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
The path name to the new database and tables should be
absolute. If you specify a relative path, the location
is relative to the
<code class="filename">
mydb.sym
</code>
file.
</p>
</div>
</li>
</ol>
</div>
<p>
After this, all tables created in the database
<code class="literal">
mydb
</code>
are created in
<code class="filename">
D:\data\mydb
</code>
.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/keyring-system-variables.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="keyring-system-variables">
</a>
8.4.4.16 Keyring System Variables
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045239191424">
</a>
<p>
MySQL Keyring plugins support the following system variables.
Use them to configure keyring plugin operation. These variables
are unavailable unless the appropriate keyring plugin is
installed (see
<a class="xref" href="keyring-plugin-installation.html" title="8.4.4.3 Keyring Plugin Installation">
Section 8.4.4.3, “Keyring Plugin Installation”
</a>
).
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a name="sysvar_keyring_aws_cmk_id">
</a>
<a class="link" href="keyring-system-variables.html#sysvar_keyring_aws_cmk_id">
<code class="literal">
keyring_aws_cmk_id
</code>
</a>
</p>
<a class="indexterm" name="idm46045239186432">
</a>
<a class="indexterm" name="idm46045239185392">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for keyring_aws_cmk_id">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--keyring-aws-cmk-id=value
</code>
</td>
</tr>
<tr>
<th>
System Variable
</th>
<td>
<code class="literal">
<a class="link" href="keyring-system-variables.html#sysvar_keyring_aws_cmk_id">
keyring_aws_cmk_id
</a>
</code>
</td>
</tr>
<tr>
<th>
Scope
</th>
<td>
Global
</td>
</tr>
<tr>
<th>
Dynamic
</th>
<td>
Yes
</td>
</tr>
<tr>
<th>
<a class="link" href="optimizer-hints.html#optimizer-hints-set-var" title="Variable-Setting Hint Syntax">
<code class="literal">
SET_VAR
</code>
</a>
Hint Applies
</th>
<td>
No
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
String
</td>
</tr>
</tbody>
</table>
</div>
<p>
The KMS key ID obtained from the AWS KMS server and used by
the
<code class="literal">
keyring_aws
</code>
plugin. This variable is
unavailable unless that plugin is installed.
</p>
<p>
This variable is mandatory. If not specified,
<code class="literal">
keyring_aws
</code>
initialization fails.
</p>
</li>
<li class="listitem">
<p>
<a name="sysvar_keyring_aws_conf_file">
</a>
<a class="link" href="keyring-system-variables.html#sysvar_keyring_aws_conf_file">
<code class="literal">
keyring_aws_conf_file
</code>
</a>
</p>
<a class="indexterm" name="idm46045239161168">
</a>
<a class="indexterm" name="idm46045239160128">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for keyring_aws_conf_file">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--keyring-aws-conf-file=file_name
</code>
</td>
</tr>
<tr>
<th>
System Variable
</th>
<td>
<code class="literal">
<a class="link" href="keyring-system-variables.html#sysvar_keyring_aws_conf_file">
keyring_aws_conf_file
</a>
</code>
</td>
</tr>
<tr>
<th>
Scope
</th>
<td>
Global
</td>
</tr>
<tr>
<th>
Dynamic
</th>
<td>
No
</td>
</tr>
<tr>
<th>
<a class="link" href="optimizer-hints.html#optimizer-hints-set-var" title="Variable-Setting Hint Syntax">
<code class="literal">
SET_VAR
</code>
</a>
Hint Applies
</th>
<td>
No
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
File name
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
platform specific
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
The location of the configuration file for the
<code class="literal">
keyring_aws
</code>
plugin. This variable is
unavailable unless that plugin is installed.
</p>
<p>
At plugin startup,
<code class="literal">
keyring_aws
</code>
reads the
AWS secret access key ID and key from the configuration
file. For the
<code class="literal">
keyring_aws
</code>
plugin to start
successfully, the configuration file must exist and contain
valid secret access key information, initialized as
described in
<a class="xref" href="keyring-aws-plugin.html" title="8.4.4.7 Using the keyring_aws Amazon Web Services Keyring Plugin">
Section 8.4.4.7, “Using the keyring_aws Amazon Web Services Keyring Plugin”
</a>
.
</p>
<p>
The default file name is
<code class="literal">
keyring_aws_conf
</code>
, located in the default
keyring file directory.
</p>
</li>
<li class="listitem">
<p>
<a name="sysvar_keyring_aws_data_file">
</a>
<a class="link" href="keyring-system-variables.html#sysvar_keyring_aws_data_file">
<code class="literal">
keyring_aws_data_file
</code>
</a>
</p>
<a class="indexterm" name="idm46045239130656">
</a>
<a class="indexterm" name="idm46045239129616">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for keyring_aws_data_file">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--keyring-aws-data-file
</code>
</td>
</tr>
<tr>
<th>
System Variable
</th>
<td>
<code class="literal">
<a class="link" href="keyring-system-variables.html#sysvar_keyring_aws_data_file">
keyring_aws_data_file
</a>
</code>
</td>
</tr>
<tr>
<th>
Scope
</th>
<td>
Global
</td>
</tr>
<tr>
<th>
Dynamic
</th>
<td>
No
</td>
</tr>
<tr>
<th>
<a class="link" href="optimizer-hints.html#optimizer-hints-set-var" title="Variable-Setting Hint Syntax">
<code class="literal">
SET_VAR
</code>
</a>
Hint Applies
</th>
<td>
No
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
File name
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
platform specific
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
The location of the storage file for the
<code class="literal">
keyring_aws
</code>
plugin. This variable is
unavailable unless that plugin is installed.
</p>
<p>
At plugin startup, if the value assigned to
<a class="link" href="keyring-system-variables.html#sysvar_keyring_aws_data_file">
<code class="literal">
keyring_aws_data_file
</code>
</a>
specifies a file that does not exist, the
<code class="literal">
keyring_aws
</code>
plugin attempts to create it
(as well as its parent directory, if necessary). If the file
does exist,
<code class="literal">
keyring_aws
</code>
reads any
encrypted keys contained in the file into its in-memory
cache.
<code class="literal">
keyring_aws
</code>
does not cache
unencrypted keys in memory.
</p>
<p>
The default file name is
<code class="literal">
keyring_aws_data
</code>
, located in the default
keyring file directory.
</p>
</li>
<li class="listitem">
<p>
<a name="sysvar_keyring_aws_region">
</a>
<a class="link" href="keyring-system-variables.html#sysvar_keyring_aws_region">
<code class="literal">
keyring_aws_region
</code>
</a>
</p>
<a class="indexterm" name="idm46045239098800">
</a>
<a class="indexterm" name="idm46045239097760">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for keyring_aws_region">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--keyring-aws-region=value
</code>
</td>
</tr>
<tr>
<th>
System Variable
</th>
<td>
<code class="literal">
<a class="link" href="keyring-system-variables.html#sysvar_keyring_aws_region">
keyring_aws_region
</a>
</code>
</td>
</tr>
<tr>
<th>
Scope
</th>
<td>
Global
</td>
</tr>
<tr>
<th>
Dynamic
</th>
<td>
Yes
</td>
</tr>
<tr>
<th>
<a class="link" href="optimizer-hints.html#optimizer-hints-set-var" title="Variable-Setting Hint Syntax">
<code class="literal">
SET_VAR
</code>
</a>
Hint Applies
</th>
<td>
No
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
Enumeration
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
us-east-1
</code>
</td>
</tr>
<tr>
<th>
Valid Values
</th>
<td>
<p class="valid-value">
<code class="literal">
af-south-1
</code>
</p>
<p class="valid-value">
<code class="literal">
ap-east-1
</code>
</p>
<p class="valid-value">
<code class="literal">
ap-northeast-1
</code>
</p>
<p class="valid-value">
<code class="literal">
ap-northeast-2
</code>
</p>
<p class="valid-value">
<code class="literal">
ap-northeast-3
</code>
</p>
<p class="valid-value">
<code class="literal">
ap-south-1
</code>
</p>
<p class="valid-value">
<code class="literal">
ap-southeast-1
</code>
</p>
<p class="valid-value">
<code class="literal">
ap-southeast-2
</code>
</p>
<p class="valid-value">
<code class="literal">
ca-central-1
</code>
</p>
<p class="valid-value">
<code class="literal">
cn-north-1
</code>
</p>
<p class="valid-value">
<code class="literal">
cn-northwest-1
</code>
</p>
<p class="valid-value">
<code class="literal">
eu-central-1
</code>
</p>
<p class="valid-value">
<code class="literal">
eu-north-1
</code>
</p>
<p class="valid-value">
<code class="literal">
eu-south-1
</code>
</p>
<p class="valid-value">
<code class="literal">
eu-west-1
</code>
</p>
<p class="valid-value">
<code class="literal">
eu-west-2
</code>
</p>
<p class="valid-value">
<code class="literal">
eu-west-3
</code>
</p>
<p class="valid-value">
<code class="literal">
me-south-1
</code>
</p>
<p class="valid-value">
<code class="literal">
sa-east-1
</code>
</p>
<p class="valid-value">
<code class="literal">
us-east-1
</code>
</p>
<p class="valid-value">
<code class="literal">
us-east-2
</code>
</p>
<p class="valid-value">
<code class="literal">
us-gov-east-1
</code>
</p>
<p class="valid-value">
<code class="literal">
us-iso-east-1
</code>
</p>
<p class="valid-value">
<code class="literal">
us-iso-west-1
</code>
</p>
<p class="valid-value">
<code class="literal">
us-isob-east-1
</code>
</p>
<p class="valid-value">
<code class="literal">
us-west-1
</code>
</p>
<p class="valid-value">
<code class="literal">
us-west-2
</code>
</p>
</td>
</tr>
</tbody>
</table>
</div>
<p>
The AWS region for the
<code class="literal">
keyring_aws
</code>
plugin. This variable is unavailable unless that plugin is
installed.
</p>
</li>
<li class="listitem">
<p>
<a name="sysvar_keyring_hashicorp_auth_path">
</a>
<a class="link" href="keyring-system-variables.html#sysvar_keyring_hashicorp_auth_path">
<code class="literal">
keyring_hashicorp_auth_path
</code>
</a>
</p>
<a class="indexterm" name="idm46045239044560">
</a>
<a class="indexterm" name="idm46045239043456">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for keyring_hashicorp_auth_path">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--keyring-hashicorp-auth-path=value
</code>
</td>
</tr>
<tr>
<th>
System Variable
</th>
<td>
<code class="literal">
<a class="link" href="keyring-system-variables.html#sysvar_keyring_hashicorp_auth_path">
keyring_hashicorp_auth_path
</a>
</code>
</td>
</tr>
<tr>
<th>
Scope
</th>
<td>
Global
</td>
</tr>
<tr>
<th>
Dynamic
</th>
<td>
Yes
</td>
</tr>
<tr>
<th>
<a class="link" href="optimizer-hints.html#optimizer-hints-set-var" title="Variable-Setting Hint Syntax">
<code class="literal">
SET_VAR
</code>
</a>
Hint Applies
</th>
<td>
No
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
String
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
/v1/auth/approle/login
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
The authentication path where AppRole authentication is
enabled within the HashiCorp Vault server, for use by the
<code class="literal">
keyring_hashicorp
</code>
plugin. This variable
is unavailable unless that plugin is installed.
</p>
</li>
<li class="listitem">
<p>
<a name="sysvar_keyring_hashicorp_ca_path">
</a>
<a class="link" href="keyring-system-variables.html#sysvar_keyring_hashicorp_ca_path">
<code class="literal">
keyring_hashicorp_ca_path
</code>
</a>
</p>
<a class="indexterm" name="idm46045239017984">
</a>
<a class="indexterm" name="idm46045239016880">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for keyring_hashicorp_ca_path">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--keyring-hashicorp-ca-path=file_name
</code>
</td>
</tr>
<tr>
<th>
System Variable
</th>
<td>
<code class="literal">
<a class="link" href="keyring-system-variables.html#sysvar_keyring_hashicorp_ca_path">
keyring_hashicorp_ca_path
</a>
</code>
</td>
</tr>
<tr>
<th>
Scope
</th>
<td>
Global
</td>
</tr>
<tr>
<th>
Dynamic
</th>
<td>
Yes
</td>
</tr>
<tr>
<th>
<a class="link" href="optimizer-hints.html#optimizer-hints-set-var" title="Variable-Setting Hint Syntax">
<code class="literal">
SET_VAR
</code>
</a>
Hint Applies
</th>
<td>
No
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
File name
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
empty string
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
The absolute path name of a local file accessible to the
MySQL server that contains a properly formatted TLS
certificate authority for use by the
<code class="literal">
keyring_hashicorp
</code>
plugin. This variable
is unavailable unless that plugin is installed.
</p>
<p>
If this variable is not set, the
<code class="literal">
keyring_hashicorp
</code>
plugin opens an HTTPS
connection without using server certificate verification,
and trusts any certificate delivered by the HashiCorp Vault
server. For this to be safe, it must be assumed that the
Vault server is not malicious and that no man-in-the-middle
attack is possible. If those assumptions are invalid, set
<a class="link" href="keyring-system-variables.html#sysvar_keyring_hashicorp_ca_path">
<code class="literal">
keyring_hashicorp_ca_path
</code>
</a>
to the path of a trusted CA certificate. (For example, for
the instructions in
<a class="xref" href="keyring-hashicorp-plugin.html#keyring-hashicorp-certificate-configuration" title="Certificate and Key Preparation">
Certificate and Key Preparation
</a>
,
this is the
<code class="filename">
company.crt
</code>
file.)
</p>
</li>
<li class="listitem">
<p>
<a name="sysvar_keyring_hashicorp_caching">
</a>
<a class="link" href="keyring-system-variables.html#sysvar_keyring_hashicorp_caching">
<code class="literal">
keyring_hashicorp_caching
</code>
</a>
</p>
<a class="indexterm" name="idm46045238986896">
</a>
<a class="indexterm" name="idm46045238985792">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for keyring_hashicorp_caching">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--keyring-hashicorp-caching[={OFF|ON}]
</code>
</td>
</tr>
<tr>
<th>
System Variable
</th>
<td>
<code class="literal">
<a class="link" href="keyring-system-variables.html#sysvar_keyring_hashicorp_caching">
keyring_hashicorp_caching
</a>
</code>
</td>
</tr>
<tr>
<th>
Scope
</th>
<td>
Global
</td>
</tr>
<tr>
<th>
Dynamic
</th>
<td>
Yes
</td>
</tr>
<tr>
<th>
<a class="link" href="optimizer-hints.html#optimizer-hints-set-var" title="Variable-Setting Hint Syntax">
<code class="literal">
SET_VAR
</code>
</a>
Hint Applies
</th>
<td>
No
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
Boolean
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
OFF
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Whether to enable the optional in-memory key cache used by
the
<code class="literal">
keyring_hashicorp
</code>
plugin to cache
keys from the HashiCorp Vault server. This variable is
unavailable unless that plugin is installed. If the cache is
enabled, the plugin populates it during initialization.
Otherwise, the plugin populates only the key list during
initialization.
</p>
<p>
Enabling the cache is a compromise: It improves performance,
but maintains a copy of sensitive key information in memory,
which may be undesirable for security purposes.
</p>
</li>
<li class="listitem">
<p>
<a name="sysvar_keyring_hashicorp_commit_auth_path">
</a>
<a class="link" href="keyring-system-variables.html#sysvar_keyring_hashicorp_commit_auth_path">
<code class="literal">
keyring_hashicorp_commit_auth_path
</code>
</a>
</p>
<a class="indexterm" name="idm46045238959408">
</a>
<a class="indexterm" name="idm46045238958368">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for keyring_hashicorp_commit_auth_path">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
System Variable
</th>
<td>
<code class="literal">
<a class="link" href="keyring-system-variables.html#sysvar_keyring_hashicorp_commit_auth_path">
keyring_hashicorp_commit_auth_path
</a>
</code>
</td>
</tr>
<tr>
<th>
Scope
</th>
<td>
Global
</td>
</tr>
<tr>
<th>
Dynamic
</th>
<td>
No
</td>
</tr>
<tr>
<th>
<a class="link" href="optimizer-hints.html#optimizer-hints-set-var" title="Variable-Setting Hint Syntax">
<code class="literal">
SET_VAR
</code>
</a>
Hint Applies
</th>
<td>
No
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
String
</td>
</tr>
</tbody>
</table>
</div>
<p>
This variable is associated with
<a class="link" href="keyring-system-variables.html#sysvar_keyring_hashicorp_auth_path">
<code class="literal">
keyring_hashicorp_auth_path
</code>
</a>
,
from which it takes its value during
<code class="literal">
keyring_hashicorp
</code>
plugin initialization.
This variable is unavailable unless that plugin is
installed. It reflects the
<span class="quote">
“
<span class="quote">
committed
</span>
”
</span>
value
actually used for plugin operation if initialization
succeeds. For additional information, see
<a class="xref" href="keyring-hashicorp-plugin.html#keyring-hashicorp-plugin-configuration" title="keyring_hashicorp Configuration">
keyring_hashicorp Configuration
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="sysvar_keyring_hashicorp_commit_ca_path">
</a>
<a class="link" href="keyring-system-variables.html#sysvar_keyring_hashicorp_commit_ca_path">
<code class="literal">
keyring_hashicorp_commit_ca_path
</code>
</a>
</p>
<a class="indexterm" name="idm46045238935216">
</a>
<a class="indexterm" name="idm46045238934112">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for keyring_hashicorp_commit_ca_path">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
System Variable
</th>
<td>
<code class="literal">
<a class="link" href="keyring-system-variables.html#sysvar_keyring_hashicorp_commit_ca_path">
keyring_hashicorp_commit_ca_path
</a>
</code>
</td>
</tr>
<tr>
<th>
Scope
</th>
<td>
Global
</td>
</tr>
<tr>
<th>
Dynamic
</th>
<td>
No
</td>
</tr>
<tr>
<th>
<a class="link" href="optimizer-hints.html#optimizer-hints-set-var" title="Variable-Setting Hint Syntax">
<code class="literal">
SET_VAR
</code>
</a>
Hint Applies
</th>
<td>
No
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
String
</td>
</tr>
</tbody>
</table>
</div>
<p>
This variable is associated with
<a class="link" href="keyring-system-variables.html#sysvar_keyring_hashicorp_ca_path">
<code class="literal">
keyring_hashicorp_ca_path
</code>
</a>
,
from which it takes its value during
<code class="literal">
keyring_hashicorp
</code>
plugin initialization.
This variable is unavailable unless that plugin is
installed. It reflects the
<span class="quote">
“
<span class="quote">
committed
</span>
”
</span>
value
actually used for plugin operation if initialization
succeeds. For additional information, see
<a class="xref" href="keyring-hashicorp-plugin.html#keyring-hashicorp-plugin-configuration" title="keyring_hashicorp Configuration">
keyring_hashicorp Configuration
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="sysvar_keyring_hashicorp_commit_caching">
</a>
<a class="link" href="keyring-system-variables.html#sysvar_keyring_hashicorp_commit_caching">
<code class="literal">
keyring_hashicorp_commit_caching
</code>
</a>
</p>
<a class="indexterm" name="idm46045238910992">
</a>
<a class="indexterm" name="idm46045238909888">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for keyring_hashicorp_commit_caching">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
System Variable
</th>
<td>
<code class="literal">
<a class="link" href="keyring-system-variables.html#sysvar_keyring_hashicorp_commit_caching">
keyring_hashicorp_commit_caching
</a>
</code>
</td>
</tr>
<tr>
<th>
Scope
</th>
<td>
Global
</td>
</tr>
<tr>
<th>
Dynamic
</th>
<td>
No
</td>
</tr>
<tr>
<th>
<a class="link" href="optimizer-hints.html#optimizer-hints-set-var" title="Variable-Setting Hint Syntax">
<code class="literal">
SET_VAR
</code>
</a>
Hint Applies
</th>
<td>
No
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
String
</td>
</tr>
</tbody>
</table>
</div>
<p>
This variable is associated with
<a class="link" href="keyring-system-variables.html#sysvar_keyring_hashicorp_caching">
<code class="literal">
keyring_hashicorp_caching
</code>
</a>
,
from which it takes its value during
<code class="literal">
keyring_hashicorp
</code>
plugin initialization.
This variable is unavailable unless that plugin is
installed. It reflects the
<span class="quote">
“
<span class="quote">
committed
</span>
”
</span>
value
actually used for plugin operation if initialization
succeeds. For additional information, see
<a class="xref" href="keyring-hashicorp-plugin.html#keyring-hashicorp-plugin-configuration" title="keyring_hashicorp Configuration">
keyring_hashicorp Configuration
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="sysvar_keyring_hashicorp_commit_role_id">
</a>
<a class="link" href="keyring-system-variables.html#sysvar_keyring_hashicorp_commit_role_id">
<code class="literal">
keyring_hashicorp_commit_role_id
</code>
</a>
</p>
<a class="indexterm" name="idm46045238886768">
</a>
<a class="indexterm" name="idm46045238885664">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for keyring_hashicorp_commit_role_id">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
System Variable
</th>
<td>
<code class="literal">
<a class="link" href="keyring-system-variables.html#sysvar_keyring_hashicorp_commit_role_id">
keyring_hashicorp_commit_role_id
</a>
</code>
</td>
</tr>
<tr>
<th>
Scope
</th>
<td>
Global
</td>
</tr>
<tr>
<th>
Dynamic
</th>
<td>
No
</td>
</tr>
<tr>
<th>
<a class="link" href="optimizer-hints.html#optimizer-hints-set-var" title="Variable-Setting Hint Syntax">
<code class="literal">
SET_VAR
</code>
</a>
Hint Applies
</th>
<td>
No
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
String
</td>
</tr>
</tbody>
</table>
</div>
<p>
This variable is associated with
<a class="link" href="keyring-system-variables.html#sysvar_keyring_hashicorp_role_id">
<code class="literal">
keyring_hashicorp_role_id
</code>
</a>
,
from which it takes its value during
<code class="literal">
keyring_hashicorp
</code>
plugin initialization.
This variable is unavailable unless that plugin is
installed. It reflects the
<span class="quote">
“
<span class="quote">
committed
</span>
”
</span>
value
actually used for plugin operation if initialization
succeeds. For additional information, see
<a class="xref" href="keyring-hashicorp-plugin.html#keyring-hashicorp-plugin-configuration" title="keyring_hashicorp Configuration">
keyring_hashicorp Configuration
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="sysvar_keyring_hashicorp_commit_server_url">
</a>
<a class="link" href="keyring-system-variables.html#sysvar_keyring_hashicorp_commit_server_url">
<code class="literal">
keyring_hashicorp_commit_server_url
</code>
</a>
</p>
<a class="indexterm" name="idm46045238862352">
</a>
<a class="indexterm" name="idm46045238861312">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for keyring_hashicorp_commit_server_url">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
System Variable
</th>
<td>
<code class="literal">
<a class="link" href="keyring-system-variables.html#sysvar_keyring_hashicorp_commit_server_url">
keyring_hashicorp_commit_server_url
</a>
</code>
</td>
</tr>
<tr>
<th>
Scope
</th>
<td>
Global
</td>
</tr>
<tr>
<th>
Dynamic
</th>
<td>
No
</td>
</tr>
<tr>
<th>
<a class="link" href="optimizer-hints.html#optimizer-hints-set-var" title="Variable-Setting Hint Syntax">
<code class="literal">
SET_VAR
</code>
</a>
Hint Applies
</th>
<td>
No
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
String
</td>
</tr>
</tbody>
</table>
</div>
<p>
This variable is associated with
<a class="link" href="keyring-system-variables.html#sysvar_keyring_hashicorp_server_url">
<code class="literal">
keyring_hashicorp_server_url
</code>
</a>
,
from which it takes its value during
<code class="literal">
keyring_hashicorp
</code>
plugin initialization.
This variable is unavailable unless that plugin is
installed. It reflects the
<span class="quote">
“
<span class="quote">
committed
</span>
”
</span>
value
actually used for plugin operation if initialization
succeeds. For additional information, see
<a class="xref" href="keyring-hashicorp-plugin.html#keyring-hashicorp-plugin-configuration" title="keyring_hashicorp Configuration">
keyring_hashicorp Configuration
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="sysvar_keyring_hashicorp_commit_store_path">
</a>
<a class="link" href="keyring-system-variables.html#sysvar_keyring_hashicorp_commit_store_path">
<code class="literal">
keyring_hashicorp_commit_store_path
</code>
</a>
</p>
<a class="indexterm" name="idm46045238837968">
</a>
<a class="indexterm" name="idm46045238836928">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for keyring_hashicorp_commit_store_path">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
System Variable
</th>
<td>
<code class="literal">
<a class="link" href="keyring-system-variables.html#sysvar_keyring_hashicorp_commit_store_path">
keyring_hashicorp_commit_store_path
</a>
</code>
</td>
</tr>
<tr>
<th>
Scope
</th>
<td>
Global
</td>
</tr>
<tr>
<th>
Dynamic
</th>
<td>
No
</td>
</tr>
<tr>
<th>
<a class="link" href="optimizer-hints.html#optimizer-hints-set-var" title="Variable-Setting Hint Syntax">
<code class="literal">
SET_VAR
</code>
</a>
Hint Applies
</th>
<td>
No
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
String
</td>
</tr>
</tbody>
</table>
</div>
<p>
This variable is associated with
<a class="link" href="keyring-system-variables.html#sysvar_keyring_hashicorp_store_path">
<code class="literal">
keyring_hashicorp_store_path
</code>
</a>
,
from which it takes its value during
<code class="literal">
keyring_hashicorp
</code>
plugin initialization.
This variable is unavailable unless that plugin is
installed. It reflects the
<span class="quote">
“
<span class="quote">
committed
</span>
”
</span>
value
actually used for plugin operation if initialization
succeeds. For additional information, see
<a class="xref" href="keyring-hashicorp-plugin.html#keyring-hashicorp-plugin-configuration" title="keyring_hashicorp Configuration">
keyring_hashicorp Configuration
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="sysvar_keyring_hashicorp_role_id">
</a>
<a class="link" href="keyring-system-variables.html#sysvar_keyring_hashicorp_role_id">
<code class="literal">
keyring_hashicorp_role_id
</code>
</a>
</p>
<a class="indexterm" name="idm46045238813712">
</a>
<a class="indexterm" name="idm46045238812608">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for keyring_hashicorp_role_id">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--keyring-hashicorp-role-id=value
</code>
</td>
</tr>
<tr>
<th>
System Variable
</th>
<td>
<code class="literal">
<a class="link" href="keyring-system-variables.html#sysvar_keyring_hashicorp_role_id">
keyring_hashicorp_role_id
</a>
</code>
</td>
</tr>
<tr>
<th>
Scope
</th>
<td>
Global
</td>
</tr>
<tr>
<th>
Dynamic
</th>
<td>
Yes
</td>
</tr>
<tr>
<th>
<a class="link" href="optimizer-hints.html#optimizer-hints-set-var" title="Variable-Setting Hint Syntax">
<code class="literal">
SET_VAR
</code>
</a>
Hint Applies
</th>
<td>
No
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
String
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
empty string
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
The HashiCorp Vault AppRole authentication role ID, for use
by the
<code class="literal">
keyring_hashicorp
</code>
plugin. This
variable is unavailable unless that plugin is installed. The
value must be in UUID format.
</p>
<p>
This variable is mandatory. If not specified,
<code class="literal">
keyring_hashicorp
</code>
initialization fails.
</p>
</li>
<li class="listitem">
<p>
<a name="sysvar_keyring_hashicorp_secret_id">
</a>
<a class="link" href="keyring-system-variables.html#sysvar_keyring_hashicorp_secret_id">
<code class="literal">
keyring_hashicorp_secret_id
</code>
</a>
</p>
<a class="indexterm" name="idm46045238785936">
</a>
<a class="indexterm" name="idm46045238784832">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for keyring_hashicorp_secret_id">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--keyring-hashicorp-secret-id=value
</code>
</td>
</tr>
<tr>
<th>
System Variable
</th>
<td>
<code class="literal">
<a class="link" href="keyring-system-variables.html#sysvar_keyring_hashicorp_secret_id">
keyring_hashicorp_secret_id
</a>
</code>
</td>
</tr>
<tr>
<th>
Scope
</th>
<td>
Global
</td>
</tr>
<tr>
<th>
Dynamic
</th>
<td>
Yes
</td>
</tr>
<tr>
<th>
<a class="link" href="optimizer-hints.html#optimizer-hints-set-var" title="Variable-Setting Hint Syntax">
<code class="literal">
SET_VAR
</code>
</a>
Hint Applies
</th>
<td>
No
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
String
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
empty string
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
The HashiCorp Vault AppRole authentication secret ID, for
use by the
<code class="literal">
keyring_hashicorp
</code>
plugin. This
variable is unavailable unless that plugin is installed. The
value must be in UUID format.
</p>
<p>
This variable is mandatory. If not specified,
<code class="literal">
keyring_hashicorp
</code>
initialization fails.
</p>
<p>
The value of this variable is sensitive, so its value is
masked by
<code class="literal">
*
</code>
characters when displayed.
</p>
</li>
<li class="listitem">
<p>
<a name="sysvar_keyring_hashicorp_server_url">
</a>
<a class="link" href="keyring-system-variables.html#sysvar_keyring_hashicorp_server_url">
<code class="literal">
keyring_hashicorp_server_url
</code>
</a>
</p>
<a class="indexterm" name="idm46045238756960">
</a>
<a class="indexterm" name="idm46045238755856">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for keyring_hashicorp_server_url">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--keyring-hashicorp-server-url=value
</code>
</td>
</tr>
<tr>
<th>
System Variable
</th>
<td>
<code class="literal">
<a class="link" href="keyring-system-variables.html#sysvar_keyring_hashicorp_server_url">
keyring_hashicorp_server_url
</a>
</code>
</td>
</tr>
<tr>
<th>
Scope
</th>
<td>
Global
</td>
</tr>
<tr>
<th>
Dynamic
</th>
<td>
Yes
</td>
</tr>
<tr>
<th>
<a class="link" href="optimizer-hints.html#optimizer-hints-set-var" title="Variable-Setting Hint Syntax">
<code class="literal">
SET_VAR
</code>
</a>
Hint Applies
</th>
<td>
No
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
String
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
https://127.0.0.1:8200
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
The HashiCorp Vault server URL, for use by the
<code class="literal">
keyring_hashicorp
</code>
plugin. This variable
is unavailable unless that plugin is installed. The value
must begin with
<code class="literal">
https://
</code>
.
</p>
</li>
<li class="listitem">
<p>
<a name="sysvar_keyring_hashicorp_store_path">
</a>
<a class="link" href="keyring-system-variables.html#sysvar_keyring_hashicorp_store_path">
<code class="literal">
keyring_hashicorp_store_path
</code>
</a>
</p>
<a class="indexterm" name="idm46045238729632">
</a>
<a class="indexterm" name="idm46045238728528">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for keyring_hashicorp_store_path">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--keyring-hashicorp-store-path=value
</code>
</td>
</tr>
<tr>
<th>
System Variable
</th>
<td>
<code class="literal">
<a class="link" href="keyring-system-variables.html#sysvar_keyring_hashicorp_store_path">
keyring_hashicorp_store_path
</a>
</code>
</td>
</tr>
<tr>
<th>
Scope
</th>
<td>
Global
</td>
</tr>
<tr>
<th>
Dynamic
</th>
<td>
Yes
</td>
</tr>
<tr>
<th>
<a class="link" href="optimizer-hints.html#optimizer-hints-set-var" title="Variable-Setting Hint Syntax">
<code class="literal">
SET_VAR
</code>
</a>
Hint Applies
</th>
<td>
No
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
String
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
empty string
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
A store path within the HashiCorp Vault server that is
writeable when appropriate AppRole credentials are provided
by the
<code class="literal">
keyring_hashicorp
</code>
plugin. This
variable is unavailable unless that plugin is installed. To
specify the credentials, set the
<a class="link" href="keyring-system-variables.html#sysvar_keyring_hashicorp_role_id">
<code class="literal">
keyring_hashicorp_role_id
</code>
</a>
and
<a class="link" href="keyring-system-variables.html#sysvar_keyring_hashicorp_secret_id">
<code class="literal">
keyring_hashicorp_secret_id
</code>
</a>
system variables (for example, as shown in
<a class="xref" href="keyring-hashicorp-plugin.html#keyring-hashicorp-plugin-configuration" title="keyring_hashicorp Configuration">
keyring_hashicorp Configuration
</a>
).
</p>
<p>
This variable is mandatory. If not specified,
<code class="literal">
keyring_hashicorp
</code>
initialization fails.
</p>
</li>
<li class="listitem">
<p>
<a name="sysvar_keyring_okv_conf_dir">
</a>
<a class="link" href="keyring-system-variables.html#sysvar_keyring_okv_conf_dir">
<code class="literal">
keyring_okv_conf_dir
</code>
</a>
</p>
<a class="indexterm" name="idm46045238698368">
</a>
<a class="indexterm" name="idm46045238697328">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for keyring_okv_conf_dir">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--keyring-okv-conf-dir=dir_name
</code>
</td>
</tr>
<tr>
<th>
System Variable
</th>
<td>
<code class="literal">
<a class="link" href="keyring-system-variables.html#sysvar_keyring_okv_conf_dir">
keyring_okv_conf_dir
</a>
</code>
</td>
</tr>
<tr>
<th>
Scope
</th>
<td>
Global
</td>
</tr>
<tr>
<th>
Dynamic
</th>
<td>
Yes
</td>
</tr>
<tr>
<th>
<a class="link" href="optimizer-hints.html#optimizer-hints-set-var" title="Variable-Setting Hint Syntax">
<code class="literal">
SET_VAR
</code>
</a>
Hint Applies
</th>
<td>
No
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
Directory name
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
empty string
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
The path name of the directory that stores configuration
information used by the
<code class="literal">
keyring_okv
</code>
plugin. This variable is unavailable unless that plugin is
installed. The location should be a directory considered for
use only by the
<code class="literal">
keyring_okv
</code>
plugin. For
example, do not locate the directory under the data
directory.
</p>
<p>
The default
<a class="link" href="keyring-system-variables.html#sysvar_keyring_okv_conf_dir">
<code class="literal">
keyring_okv_conf_dir
</code>
</a>
value
is empty. For the
<code class="literal">
keyring_okv
</code>
plugin to
be able to access Oracle Key Vault, the value must be set to
a directory that contains Oracle Key Vault configuration and
SSL materials. For instructions on setting up this
directory, see
<a class="xref" href="keyring-okv-plugin.html" title="8.4.4.6 Using the keyring_okv KMIP Plugin">
Section 8.4.4.6, “Using the keyring_okv KMIP Plugin”
</a>
.
</p>
<p>
The directory should have a restrictive mode and be
accessible only to the account used to run the MySQL server.
For example, on Unix and Unix-like systems, to use the
<code class="filename">
/usr/local/mysql/mysql-keyring-okv
</code>
directory, the following commands (executed as
<code class="literal">
root
</code>
) create the directory and set its
mode and ownership:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa19901120"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal">cd /usr/local/mysql
mkdir mysql-keyring-okv
chmod 750 mysql-keyring-okv
chown mysql mysql-keyring-okv
chgrp mysql mysql-keyring-okv</code></pre>
</div>
<p>
If the value assigned to
<a class="link" href="keyring-system-variables.html#sysvar_keyring_okv_conf_dir">
<code class="literal">
keyring_okv_conf_dir
</code>
</a>
specifies a directory that does not exist, or that does not
contain configuration information that enables a connection
to Oracle Key Vault to be established,
<code class="literal">
keyring_okv
</code>
writes an error message to
the error log. If an attempted runtime assignment to
<a class="link" href="keyring-system-variables.html#sysvar_keyring_okv_conf_dir">
<code class="literal">
keyring_okv_conf_dir
</code>
</a>
results in an error, the variable value and keyring
operation remain unchanged.
</p>
</li>
<li class="listitem">
<p>
<a name="sysvar_keyring_operations">
</a>
<a class="link" href="keyring-system-variables.html#sysvar_keyring_operations">
<code class="literal">
keyring_operations
</code>
</a>
</p>
<a class="indexterm" name="idm46045238660256">
</a>
<a class="indexterm" name="idm46045238659216">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for keyring_operations">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
System Variable
</th>
<td>
<code class="literal">
<a class="link" href="keyring-system-variables.html#sysvar_keyring_operations">
keyring_operations
</a>
</code>
</td>
</tr>
<tr>
<th>
Scope
</th>
<td>
Global
</td>
</tr>
<tr>
<th>
Dynamic
</th>
<td>
Yes
</td>
</tr>
<tr>
<th>
<a class="link" href="optimizer-hints.html#optimizer-hints-set-var" title="Variable-Setting Hint Syntax">
<code class="literal">
SET_VAR
</code>
</a>
Hint Applies
</th>
<td>
No
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
Boolean
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
ON
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Whether keyring operations are enabled. This variable is
used during key migration operations. See
<a class="xref" href="keyring-key-migration.html" title="8.4.4.11 Migrating Keys Between Keyring Keystores">
Section 8.4.4.11, “Migrating Keys Between Keyring Keystores”
</a>
. The privileges
required to modify this variable are
<a class="link" href="privileges-provided.html#priv_encryption-key-admin">
<code class="literal">
ENCRYPTION_KEY_ADMIN
</code>
</a>
in
addition to either
<a class="link" href="privileges-provided.html#priv_system-variables-admin">
<code class="literal">
SYSTEM_VARIABLES_ADMIN
</code>
</a>
or the
deprecated
<a class="link" href="privileges-provided.html#priv_super">
<code class="literal">
SUPER
</code>
</a>
privilege.
</p>
</li>
</ul>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/explain-for-connection.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="explain-for-connection">
</a>
10.8.4 Obtaining Execution Plan Information for a Named Connection
</h3>
</div>
</div>
</div>
<p>
To obtain the execution plan for an explainable statement
executing in a named connection, use this statement:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa45157127"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">EXPLAIN</span> <span class="token punctuation">[</span><span class="token keyword"><em class="replaceable">options</em></span><span class="token punctuation">]</span> <span class="token keyword">FOR</span> <span class="token keyword">CONNECTION</span> <em class="replaceable">connection_id</em><span class="token punctuation">;</span></code></pre>
</div>
<p>
<a class="link" href="explain-for-connection.html" title="10.8.4 Obtaining Execution Plan Information for a Named Connection">
<code class="literal">
EXPLAIN FOR CONNECTION
</code>
</a>
returns
the
<a class="link" href="explain.html" title="15.8.2 EXPLAIN Statement">
<code class="literal">
EXPLAIN
</code>
</a>
information that is
currently being used to execute a query in a given connection.
Because of changes to data (and supporting statistics) it may
produce a different result from running
<a class="link" href="explain.html" title="15.8.2 EXPLAIN Statement">
<code class="literal">
EXPLAIN
</code>
</a>
on the equivalent query
text. This difference in behavior can be useful in diagnosing
more transient performance problems. For example, if you are
running a statement in one session that is taking a long time to
complete, using
<a class="link" href="explain-for-connection.html" title="10.8.4 Obtaining Execution Plan Information for a Named Connection">
<code class="literal">
EXPLAIN FOR
CONNECTION
</code>
</a>
in another session may yield useful
information about the cause of the delay.
</p>
<p>
<em class="replaceable">
<code>
connection_id
</code>
</em>
is the connection
identifier, as obtained from the
<code class="literal">
INFORMATION_SCHEMA
</code>
<a class="link" href="information-schema-processlist-table.html" title="28.3.23 The INFORMATION_SCHEMA PROCESSLIST Table">
<code class="literal">
PROCESSLIST
</code>
</a>
table or the
<a class="link" href="show-processlist.html" title="15.7.7.31 SHOW PROCESSLIST Statement">
<code class="literal">
SHOW PROCESSLIST
</code>
</a>
statement. If
you have the
<a class="link" href="privileges-provided.html#priv_process">
<code class="literal">
PROCESS
</code>
</a>
privilege,
you can specify the identifier for any connection. Otherwise,
you can specify the identifier only for your own connections. In
all cases, you must have sufficient privileges to explain the
query on the specified connection.
</p>
<p>
If the named connection is not executing a statement, the result
is empty. Otherwise,
<code class="literal">
EXPLAIN FOR CONNECTION
</code>
applies only if the statement being executed in the named
connection is explainable. This includes
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
,
<a class="link" href="delete.html" title="15.2.2 DELETE Statement">
<code class="literal">
DELETE
</code>
</a>
,
<a class="link" href="insert.html" title="15.2.7 INSERT Statement">
<code class="literal">
INSERT
</code>
</a>
,
<a class="link" href="replace.html" title="15.2.12 REPLACE Statement">
<code class="literal">
REPLACE
</code>
</a>
, and
<a class="link" href="update.html" title="15.2.17 UPDATE Statement">
<code class="literal">
UPDATE
</code>
</a>
. (However,
<code class="literal">
EXPLAIN FOR CONNECTION
</code>
does not work for
prepared statements, even prepared statements of those types.)
</p>
<p>
If the named connection is executing an explainable statement,
the output is what you would obtain by using
<code class="literal">
EXPLAIN
</code>
on the statement itself.
</p>
<p>
If the named connection is executing a statement that is not
explainable, an error occurs. For example, you cannot name the
connection identifier for your current session because
<code class="literal">
EXPLAIN
</code>
is not explainable:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa24059134"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token function">CONNECTION_ID</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> CONNECTION_ID() <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 373 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">1 row in set (0.00 sec)</span>
<span class="token prompt">mysql></span> <span class="token keyword">EXPLAIN</span> <span class="token keyword">FOR</span> <span class="token keyword">CONNECTION</span> <span class="token number">373</span><span class="token punctuation">;</span>
<span class="token output">ERROR 1889 (HY000)<span class="token punctuation">:</span> EXPLAIN FOR CONNECTION command is supported
only for SELECT/UPDATE/INSERT/DELETE/REPLACE</span></code></pre>
</div>
<p>
The
<code class="literal">
Com_explain_other
</code>
status variable
indicates the number of
<a class="link" href="explain.html" title="15.8.2 EXPLAIN Statement">
<code class="literal">
EXPLAIN FOR
CONNECTION
</code>
</a>
statements executed.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/debugging-server.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="debugging-server">
</a>
7.9.1 Debugging a MySQL Server
</h3>
</div>
</div>
</div>
<div class="toc">
<dl class="toc">
<dt>
<span class="section">
<a href="compiling-for-debugging.html">
7.9.1.1 Compiling MySQL for Debugging
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="making-trace-files.html">
7.9.1.2 Creating Trace Files
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="making-windows-dumps.html">
7.9.1.3 Using WER with PDB to create a Windows crashdump
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="using-gdb-on-mysqld.html">
7.9.1.4 Debugging mysqld under gdb
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="using-stack-trace.html">
7.9.1.5 Using a Stack Trace
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="using-log-files.html">
7.9.1.6 Using Server Logs to Find Causes of Errors in mysqld
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="reproducible-test-case.html">
7.9.1.7 Making a Test Case If You Experience Table Corruption
</a>
</span>
</dt>
</dl>
</div>
<a class="indexterm" name="idm46045253858032">
</a>
<a class="indexterm" name="idm46045253856576">
</a>
<a class="indexterm" name="idm46045253855088">
</a>
<p>
If you are using some functionality that is very new in MySQL, you
can try to run
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
with the
<a class="link" href="server-options.html#option_mysqld_skip-new">
<code class="option">
--skip-new
</code>
</a>
option (which disables
all new, potentially unsafe functionality). See
<a class="xref" href="crashing.html" title="B.3.3.3 What to Do If MySQL Keeps Crashing">
Section B.3.3.3, “What to Do If MySQL Keeps Crashing”
</a>
.
</p>
<p>
If
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
does not want to start, verify that
you have no
<code class="filename">
my.cnf
</code>
files that interfere with
your setup! You can check your
<code class="filename">
my.cnf
</code>
arguments with
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld --print-defaults
</strong>
</span>
</a>
and
avoid using them by starting with
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld --no-defaults
...
</strong>
</span>
</a>
.
</p>
<p>
If
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
starts to eat up CPU or memory or if
it
<span class="quote">
“
<span class="quote">
hangs,
</span>
”
</span>
you can use
<a class="link" href="mysqladmin.html" title="6.5.2 mysqladmin — A MySQL Server Administration Program">
<span class="command">
<strong>
mysqladmin
processlist status
</strong>
</span>
</a>
to find out if someone is executing a
query that takes a long time. It may be a good idea to run
<a class="link" href="mysqladmin.html" title="6.5.2 mysqladmin — A MySQL Server Administration Program">
<span class="command">
<strong>
mysqladmin -i10 processlist status
</strong>
</span>
</a>
in some
window if you are experiencing performance problems or problems
when new clients cannot connect.
</p>
<p>
The command
<a class="link" href="mysqladmin.html" title="6.5.2 mysqladmin — A MySQL Server Administration Program">
<span class="command">
<strong>
mysqladmin debug
</strong>
</span>
</a>
dumps some
information about locks in use, used memory and query usage to the
MySQL log file. This may help solve some problems. This command
also provides some useful information even if you have not
compiled MySQL for debugging!
</p>
<p>
If the problem is that some tables are getting slower and slower
you should try to optimize the table with
<a class="link" href="optimize-table.html" title="15.7.3.4 OPTIMIZE TABLE Statement">
<code class="literal">
OPTIMIZE TABLE
</code>
</a>
or
<a class="link" href="myisamchk.html" title="6.6.4 myisamchk — MyISAM Table-Maintenance Utility">
<span class="command">
<strong>
myisamchk
</strong>
</span>
</a>
. See
<a class="xref" href="server-administration.html" title="Chapter 7 MySQL Server Administration">
Chapter 7,
<i>
MySQL Server Administration
</i>
</a>
. You should also check the
slow queries with
<a class="link" href="explain.html" title="15.8.2 EXPLAIN Statement">
<code class="literal">
EXPLAIN
</code>
</a>
.
</p>
<p>
You should also read the OS-specific section in this manual for
problems that may be unique to your environment. See
<a class="xref" href="general-installation-issues.html" title="2.1 General Installation Guidance">
Section 2.1, “General Installation Guidance”
</a>
.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/mysql-cluster-ndb-innodb-engines.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="mysql-cluster-ndb-innodb-engines">
</a>
25.2.6.1 Differences Between the NDB and InnoDB Storage Engines
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045123877424">
</a>
<a class="indexterm" name="idm46045123876000">
</a>
<a class="indexterm" name="idm46045123874512">
</a>
<a class="indexterm" name="idm46045123873024">
</a>
<p>
The
<a class="link" href="mysql-cluster.html" title="Chapter 25 MySQL NDB Cluster 8.4">
<code class="literal">
NDB
</code>
</a>
storage engine is
implemented using a distributed, shared-nothing architecture,
which causes it to behave differently from
<a class="link" href="innodb-storage-engine.html" title="Chapter 17 The InnoDB Storage Engine">
<code class="literal">
InnoDB
</code>
</a>
in a number of ways. For
those unaccustomed to working with
<a class="link" href="mysql-cluster.html" title="Chapter 25 MySQL NDB Cluster 8.4">
<code class="literal">
NDB
</code>
</a>
, unexpected behaviors can arise
due to its distributed nature with regard to transactions,
foreign keys, table limits, and other characteristics. These are
shown in the following table:
</p>
<div class="table">
<a name="idm46045123867072">
</a>
<p class="title">
<b>
Table 25.1
Differences between InnoDB and NDB storage engines
</b>
</p>
<div class="table-contents">
<table>
<colgroup>
<col style="width: 33%"/>
<col style="width: 34%"/>
<col style="width: 33%"/>
</colgroup>
<thead>
<tr>
<th scope="col">
Feature
</th>
<th scope="col">
<code class="literal">
InnoDB
</code>
(MySQL 8.4)
</th>
<th scope="col">
<code class="literal">
NDB
</code>
8.4
</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">
MySQL Server Version
</th>
<td>
8.4
</td>
<td>
8.4
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="innodb-storage-engine.html" title="Chapter 17 The InnoDB Storage Engine">
<code class="literal">
InnoDB
</code>
</a>
Version
</th>
<td>
<a class="link" href="innodb-storage-engine.html" title="Chapter 17 The InnoDB Storage Engine">
<code class="literal">
InnoDB
</code>
</a>
8.4.3
</td>
<td>
<a class="link" href="innodb-storage-engine.html" title="Chapter 17 The InnoDB Storage Engine">
<code class="literal">
InnoDB
</code>
</a>
8.4.3
</td>
</tr>
<tr>
<th scope="row">
NDB Cluster Version
</th>
<td>
N/A
</td>
<td>
<a class="link" href="mysql-cluster.html" title="Chapter 25 MySQL NDB Cluster 8.4">
<code class="literal">
NDB
</code>
</a>
8.4.0/8.4.0
</td>
</tr>
<tr>
<th scope="row">
Storage Limits
</th>
<td>
64TB
</td>
<td>
128TB
</td>
</tr>
<tr>
<th scope="row">
Foreign Keys
</th>
<td>
Yes
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
Transactions
</th>
<td>
All standard types
</td>
<td>
<a class="link" href="innodb-transaction-isolation-levels.html#isolevel_read-committed">
<code class="literal">
READ COMMITTED
</code>
</a>
</td>
</tr>
<tr>
<th scope="row">
MVCC
</th>
<td>
Yes
</td>
<td>
No
</td>
</tr>
<tr>
<th scope="row">
Data Compression
</th>
<td>
Yes
</td>
<td>
No (NDB checkpoint and backup files can be compressed)
</td>
</tr>
<tr>
<th scope="row">
Large Row Support (> 14K)
</th>
<td>
Supported for
<a class="link" href="binary-varbinary.html" title="13.3.3 The BINARY and VARBINARY Types">
<code class="literal">
VARBINARY
</code>
</a>
,
<a class="link" href="char.html" title="13.3.2 The CHAR and VARCHAR Types">
<code class="literal">
VARCHAR
</code>
</a>
,
<a class="link" href="blob.html" title="13.3.4 The BLOB and TEXT Types">
<code class="literal">
BLOB
</code>
</a>
, and
<a class="link" href="blob.html" title="13.3.4 The BLOB and TEXT Types">
<code class="literal">
TEXT
</code>
</a>
columns
</td>
<td>
Supported for
<a class="link" href="blob.html" title="13.3.4 The BLOB and TEXT Types">
<code class="literal">
BLOB
</code>
</a>
and
<a class="link" href="blob.html" title="13.3.4 The BLOB and TEXT Types">
<code class="literal">
TEXT
</code>
</a>
columns only (Using
these types to store very large amounts of data can lower
NDB performance)
</td>
</tr>
<tr>
<th scope="row">
Replication Support
</th>
<td>
Asynchronous and semisynchronous replication using MySQL Replication;
MySQL
<a class="link" href="group-replication.html" title="Chapter 20 Group Replication">
Group
Replication
</a>
</td>
<td>
Automatic synchronous replication within an NDB Cluster; asynchronous
replication between NDB Clusters, using MySQL Replication
(Semisynchronous replication is not supported)
</td>
</tr>
<tr>
<th scope="row">
Scaleout for Read Operations
</th>
<td>
Yes (MySQL Replication)
</td>
<td>
Yes (Automatic partitioning in NDB Cluster; NDB Cluster Replication)
</td>
</tr>
<tr>
<th scope="row">
Scaleout for Write Operations
</th>
<td>
Requires application-level partitioning (sharding)
</td>
<td>
Yes (Automatic partitioning in NDB Cluster is transparent to
applications)
</td>
</tr>
<tr>
<th scope="row">
High Availability (HA)
</th>
<td>
Built-in, from InnoDB cluster
</td>
<td>
Yes (Designed for 99.999% uptime)
</td>
</tr>
<tr>
<th scope="row">
Node Failure Recovery and Failover
</th>
<td>
From MySQL Group Replication
</td>
<td>
Automatic (Key element in NDB architecture)
</td>
</tr>
<tr>
<th scope="row">
Time for Node Failure Recovery
</th>
<td>
30 seconds or longer
</td>
<td>
Typically < 1 second
</td>
</tr>
<tr>
<th scope="row">
Real-Time Performance
</th>
<td>
No
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
In-Memory Tables
</th>
<td>
No
</td>
<td>
Yes (Some data can optionally be stored on disk; both in-memory and disk
data storage are durable)
</td>
</tr>
<tr>
<th scope="row">
NoSQL Access to Storage Engine
</th>
<td>
Yes
</td>
<td>
Yes (Multiple APIs, including Memcached, Node.js/JavaScript, Java, JPA,
C++, and HTTP/REST)
</td>
</tr>
<tr>
<th scope="row">
Concurrent and Parallel Writes
</th>
<td>
Yes
</td>
<td>
Up to 48 writers, optimized for concurrent writes
</td>
</tr>
<tr>
<th scope="row">
Conflict Detection and Resolution (Multiple Sources)
</th>
<td>
Yes (MySQL Group Replication)
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
Hash Indexes
</th>
<td>
No
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
Online Addition of Nodes
</th>
<td>
Read/write replicas using MySQL Group Replication
</td>
<td>
Yes (all node types)
</td>
</tr>
<tr>
<th scope="row">
Online Upgrades
</th>
<td>
Yes (using replication)
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
Online Schema Modifications
</th>
<td>
Yes, as part of MySQL 8.4
</td>
<td>
Yes
</td>
</tr>
</tbody>
</table>
</div>
<div class="table-contents">
<table cellpadding="0" cellspacing="0" style="position: fixed; top: 0px; display: none; left: 401px; width: 739px;">
<thead>
<tr>
<th scope="col" style="width: 243.531px;">
Feature
</th>
<th scope="col" style="width: 250.906px;">
<code class="literal">
InnoDB
</code>
(MySQL 8.4)
</th>
<th scope="col" style="width: 243.562px;">
<code class="literal">
NDB
</code>
8.4
</th>
</tr>
</thead>
</table>
</div>
</div>
<br class="table-break"/>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/firewall.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="firewall">
</a>
8.4.7 MySQL Enterprise Firewall
</h3>
</div>
</div>
</div>
<div class="toc">
<dl class="toc">
<dt>
<span class="section">
<a href="firewall-elements.html">
8.4.7.1 Elements of MySQL Enterprise Firewall
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="firewall-installation.html">
8.4.7.2 Installing or Uninstalling MySQL Enterprise Firewall
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="firewall-usage.html">
8.4.7.3 Using MySQL Enterprise Firewall
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="firewall-reference.html">
8.4.7.4 MySQL Enterprise Firewall Reference
</a>
</span>
</dt>
</dl>
</div>
<a class="indexterm" name="idm46045234626944">
</a>
<a class="indexterm" name="idm46045234625888">
</a>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
MySQL Enterprise Firewall is an extension included in MySQL Enterprise Edition, a commercial product.
To learn more about commercial products, see
<a class="ulink" href="https://www.mysql.com/products/" target="_blank">
https://www.mysql.com/products/
</a>
.
</p>
</div>
<p>
MySQL Enterprise Edition includes MySQL Enterprise Firewall, an application-level firewall that enables
database administrators to permit or deny SQL statement execution
based on matching against lists of accepted statement patterns.
This helps harden MySQL Server against attacks such as SQL
injection or attempts to exploit applications by using them
outside of their legitimate query workload characteristics.
</p>
<a class="indexterm" name="idm46045234622000">
</a>
<a class="indexterm" name="idm46045234620928">
</a>
<p>
Each MySQL account registered with the firewall has its own
statement allowlist, enabling protection to be tailored per
account. For a given account, the firewall can operate in
recording, protecting, or detecting mode, for training in the
accepted statement patterns, active protection against
unacceptable statements, or passive detection of unacceptable
statements. The diagram illustrates how the firewall processes
incoming statements in each mode.
</p>
<div class="figure">
<a name="firewall-diagram">
</a>
<p class="title">
<b>
Figure 8.1 MySQL Enterprise Firewall Operation
</b>
</p>
<div class="figure-contents">
<div class="mediaobject">
<img alt="Flow chart showing how MySQL Enterprise Firewall processes incoming SQL statements in recording, protecting, and detecting modes." src="images/firewall-diagram-1.png" style="width: 100%; max-width: 632px;"/>
</div>
</div>
</div>
<br class="figure-break"/>
<p>
The following sections describe the elements of MySQL Enterprise Firewall, discuss
how to install and use it, and provide reference information for
its elements.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/hash-joins.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="hash-joins">
</a>
10.2.1.4 Hash Join Optimization
</h4>
</div>
</div>
</div>
<p>
By default, MySQL employs hash joins whenever possible. It is
possible to control whether hash joins are employed using one
of the
<a class="link" href="optimizer-hints.html#optimizer-hints-table-level" title="Table-Level Optimizer Hints">
<code class="literal">
BNL
</code>
</a>
and
<a class="link" href="optimizer-hints.html#optimizer-hints-table-level" title="Table-Level Optimizer Hints">
<code class="literal">
NO_BNL
</code>
</a>
optimizer hints, or
by setting
<a class="link" href="switchable-optimizations.html#optflag_block-nested-loop">
<code class="literal">
block_nested_loop=on
</code>
</a>
or
<code class="literal">
block_nested_loop=off
</code>
as part of the
setting for the optimizer_switch server system variable.
</p>
<p>
MySQL employs a hash join for any query for which each join
has an equi-join condition, and in which there are no indexes
that can be applied to any join conditions, such as this one:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa95488814"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> <span class="token operator">*</span>
<span class="token keyword">FROM</span> t1
<span class="token keyword">JOIN</span> t2
<span class="token keyword">ON</span> t1<span class="token punctuation">.</span>c1<span class="token operator">=</span>t2<span class="token punctuation">.</span>c1<span class="token punctuation">;</span></code></pre>
</div>
<p>
A hash join can also be used when there are one or more
indexes that can be used for single-table predicates.
</p>
<p>
In the example just shown and the remaining examples in this
section, we assume that the three tables
<code class="literal">
t1
</code>
,
<code class="literal">
t2
</code>
, and
<code class="literal">
t3
</code>
have been created using the following
statements:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa16835890"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> t1 <span class="token punctuation">(</span>c1 <span class="token datatype">INT</span><span class="token punctuation">,</span> c2 <span class="token datatype">INT</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> t2 <span class="token punctuation">(</span>c1 <span class="token datatype">INT</span><span class="token punctuation">,</span> c2 <span class="token datatype">INT</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> t3 <span class="token punctuation">(</span>c1 <span class="token datatype">INT</span><span class="token punctuation">,</span> c2 <span class="token datatype">INT</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
You can see that a hash join is being employed by using
<a class="link" href="explain.html" title="15.8.2 EXPLAIN Statement">
<code class="literal">
EXPLAIN
</code>
</a>
,
like this:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa66334182"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">EXPLAIN</span>
<span class="token prompt"> -></span> <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t1
<span class="token prompt"> -></span> <span class="token keyword">JOIN</span> t2 <span class="token keyword">ON</span> t1<span class="token punctuation">.</span>c1<span class="token operator">=</span>t2<span class="token punctuation">.</span>c1\G
<span class="token output"><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span> 1. row <span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span>
id<span class="token punctuation">:</span> 1
select_type<span class="token punctuation">:</span> SIMPLE
table<span class="token punctuation">:</span> t1
partitions<span class="token punctuation">:</span> NULL
type<span class="token punctuation">:</span> ALL
possible_keys<span class="token punctuation">:</span> NULL
key<span class="token punctuation">:</span> NULL
key_len<span class="token punctuation">:</span> NULL
ref<span class="token punctuation">:</span> NULL
rows<span class="token punctuation">:</span> 1
filtered<span class="token punctuation">:</span> 100.00
Extra<span class="token punctuation">:</span> NULL
<span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span> 2. row <span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span>
id<span class="token punctuation">:</span> 1
select_type<span class="token punctuation">:</span> SIMPLE
table<span class="token punctuation">:</span> t2
partitions<span class="token punctuation">:</span> NULL
type<span class="token punctuation">:</span> ALL
possible_keys<span class="token punctuation">:</span> NULL
key<span class="token punctuation">:</span> NULL
key_len<span class="token punctuation">:</span> NULL
ref<span class="token punctuation">:</span> NULL
rows<span class="token punctuation">:</span> 1
filtered<span class="token punctuation">:</span> 100.00
Extra<span class="token punctuation">:</span> Using where; Using join buffer (hash join)</span></code></pre>
</div>
<p>
<a class="link" href="explain.html#explain-analyze" title="Obtaining Information with EXPLAIN ANALYZE">
<code class="literal">
EXPLAIN ANALYZE
</code>
</a>
also displays
information about hash joins used.
</p>
<p>
The hash join is used for queries involving multiple joins as
well, as long as at least one join condition for each pair of
tables is an equi-join, like the query shown here:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa63933684"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t1
<span class="token keyword">JOIN</span> t2 <span class="token keyword">ON</span> <span class="token punctuation">(</span>t1<span class="token punctuation">.</span>c1 <span class="token operator">=</span> t2<span class="token punctuation">.</span>c1 <span class="token operator">AND</span> t1<span class="token punctuation">.</span>c2 <span class="token operator"><</span> t2<span class="token punctuation">.</span>c2<span class="token punctuation">)</span>
<span class="token keyword">JOIN</span> t3 <span class="token keyword">ON</span> <span class="token punctuation">(</span>t2<span class="token punctuation">.</span>c1 <span class="token operator">=</span> t3<span class="token punctuation">.</span>c1<span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
In cases like the one just shown, which makes use of an inner
join, any extra conditions which are not equi-joins are
applied as filters after the join is executed. (For outer
joins, such as left joins, semijoins, and antijoins, they are
printed as part of the join.) This can be seen here in the
output of
<code class="literal">
EXPLAIN
</code>
:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa67070766"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">EXPLAIN</span> <span class="token keyword">FORMAT</span><span class="token operator">=</span><span class="token keyword">TREE</span>
<span class="token prompt"> -></span> <span class="token keyword">SELECT</span> <span class="token operator">*</span>
<span class="token prompt"> -></span> <span class="token keyword">FROM</span> t1
<span class="token prompt"> -></span> <span class="token keyword">JOIN</span> t2
<span class="token prompt"> -></span> <span class="token keyword">ON</span> <span class="token punctuation">(</span>t1<span class="token punctuation">.</span>c1 <span class="token operator">=</span> t2<span class="token punctuation">.</span>c1 <span class="token operator">AND</span> t1<span class="token punctuation">.</span>c2 <span class="token operator"><</span> t2<span class="token punctuation">.</span>c2<span class="token punctuation">)</span>
<span class="token prompt"> -></span> <span class="token keyword">JOIN</span> t3
<span class="token prompt"> -></span> <span class="token keyword">ON</span> <span class="token punctuation">(</span>t2<span class="token punctuation">.</span>c1 <span class="token operator">=</span> t3<span class="token punctuation">.</span>c1<span class="token punctuation">)</span>\G
<span class="token output"><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span> 1. row <span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span>
EXPLAIN<span class="token punctuation">:</span> -> Inner hash join (t3.c1 = t1.c1) (cost=1.05 rows=1)</span>
<span class="token prompt"> -></span> <span class="token keyword">Table</span> scan <span class="token keyword">on</span> t3 <span class="token punctuation">(</span>cost<span class="token operator">=</span><span class="token number">0.35</span> <span class="token keyword">rows</span><span class="token operator">=</span><span class="token number">1</span><span class="token punctuation">)</span>
<span class="token prompt"> -></span> <span class="token keyword">Hash</span>
<span class="token prompt"> -></span> <span class="token keyword">Filter</span>: <span class="token punctuation">(</span>t1<span class="token punctuation">.</span>c2 <span class="token operator"><</span> t2<span class="token punctuation">.</span>c2<span class="token punctuation">)</span> <span class="token punctuation">(</span>cost<span class="token operator">=</span><span class="token number">0.70</span> <span class="token keyword">rows</span><span class="token operator">=</span><span class="token number">1</span><span class="token punctuation">)</span>
<span class="token prompt"> -></span> <span class="token keyword">Inner</span> <span class="token keyword">hash</span> <span class="token keyword">join</span> <span class="token punctuation">(</span>t2<span class="token punctuation">.</span>c1 <span class="token operator">=</span> t1<span class="token punctuation">.</span>c1<span class="token punctuation">)</span> <span class="token punctuation">(</span>cost<span class="token operator">=</span><span class="token number">0.70</span> <span class="token keyword">rows</span><span class="token operator">=</span><span class="token number">1</span><span class="token punctuation">)</span>
<span class="token prompt"> -></span> <span class="token keyword">Table</span> scan <span class="token keyword">on</span> t2 <span class="token punctuation">(</span>cost<span class="token operator">=</span><span class="token number">0.35</span> <span class="token keyword">rows</span><span class="token operator">=</span><span class="token number">1</span><span class="token punctuation">)</span>
<span class="token prompt"> -></span> <span class="token keyword">Hash</span>
<span class="token prompt"> -></span> <span class="token keyword">Table</span> scan <span class="token keyword">on</span> t1 <span class="token punctuation">(</span>cost<span class="token operator">=</span><span class="token number">0.35</span> <span class="token keyword">rows</span><span class="token operator">=</span><span class="token number">1</span><span class="token punctuation">)</span></code></pre>
</div>
<p>
As also can be seen from the output just shown, multiple hash
joins can be (and are) used for joins having multiple
equi-join conditions.
</p>
<p>
A hash join is used even if any pair of joined tables does not
have at least one equi-join condition, as shown here:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa85718368"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">EXPLAIN</span> <span class="token keyword">FORMAT</span><span class="token operator">=</span><span class="token keyword">TREE</span>
<span class="token prompt"> -></span> <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t1
<span class="token prompt"> -></span> <span class="token keyword">JOIN</span> t2 <span class="token keyword">ON</span> <span class="token punctuation">(</span>t1<span class="token punctuation">.</span>c1 <span class="token operator">=</span> t2<span class="token punctuation">.</span>c1<span class="token punctuation">)</span>
<span class="token prompt"> -></span> <span class="token keyword">JOIN</span> t3 <span class="token keyword">ON</span> <span class="token punctuation">(</span>t2<span class="token punctuation">.</span>c1 <span class="token operator"><</span> t3<span class="token punctuation">.</span>c1<span class="token punctuation">)</span>\G
<span class="token output"><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span> 1. row <span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span>
EXPLAIN<span class="token punctuation">:</span> -> Filter<span class="token punctuation">:</span> (t1.c1 < t3.c1) (cost=1.05 rows=1)</span>
<span class="token prompt"> -></span> <span class="token keyword">Inner</span> <span class="token keyword">hash</span> <span class="token keyword">join</span> <span class="token punctuation">(</span><span class="token keyword">no</span> <span class="token keyword">condition</span><span class="token punctuation">)</span> <span class="token punctuation">(</span>cost<span class="token operator">=</span><span class="token number">1.05</span> <span class="token keyword">rows</span><span class="token operator">=</span><span class="token number">1</span><span class="token punctuation">)</span>
<span class="token prompt"> -></span> <span class="token keyword">Table</span> scan <span class="token keyword">on</span> t3 <span class="token punctuation">(</span>cost<span class="token operator">=</span><span class="token number">0.35</span> <span class="token keyword">rows</span><span class="token operator">=</span><span class="token number">1</span><span class="token punctuation">)</span>
<span class="token prompt"> -></span> <span class="token keyword">Hash</span>
<span class="token prompt"> -></span> <span class="token keyword">Inner</span> <span class="token keyword">hash</span> <span class="token keyword">join</span> <span class="token punctuation">(</span>t2<span class="token punctuation">.</span>c1 <span class="token operator">=</span> t1<span class="token punctuation">.</span>c1<span class="token punctuation">)</span> <span class="token punctuation">(</span>cost<span class="token operator">=</span><span class="token number">0.70</span> <span class="token keyword">rows</span><span class="token operator">=</span><span class="token number">1</span><span class="token punctuation">)</span>
<span class="token prompt"> -></span> <span class="token keyword">Table</span> scan <span class="token keyword">on</span> t2 <span class="token punctuation">(</span>cost<span class="token operator">=</span><span class="token number">0.35</span> <span class="token keyword">rows</span><span class="token operator">=</span><span class="token number">1</span><span class="token punctuation">)</span>
<span class="token prompt"> -></span> <span class="token keyword">Hash</span>
<span class="token prompt"> -></span> <span class="token keyword">Table</span> scan <span class="token keyword">on</span> t1 <span class="token punctuation">(</span>cost<span class="token operator">=</span><span class="token number">0.35</span> <span class="token keyword">rows</span><span class="token operator">=</span><span class="token number">1</span><span class="token punctuation">)</span></code></pre>
</div>
<p>
(Additional examples are provided later in this section.)
</p>
<p>
A hash join is also applied for a Cartesian product—that
is, when no join condition is specified, as shown here:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa43151297"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">EXPLAIN</span> <span class="token keyword">FORMAT</span><span class="token operator">=</span><span class="token keyword">TREE</span>
<span class="token prompt"> -></span> <span class="token keyword">SELECT</span> <span class="token operator">*</span>
<span class="token prompt"> -></span> <span class="token keyword">FROM</span> t1
<span class="token prompt"> -></span> <span class="token keyword">JOIN</span> t2
<span class="token prompt"> -></span> <span class="token keyword">WHERE</span> t1<span class="token punctuation">.</span>c2 <span class="token operator">></span> <span class="token number">50</span>\G
<span class="token output"><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span> 1. row <span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span>
EXPLAIN<span class="token punctuation">:</span> -> Inner hash join (cost=0.70 rows=1)</span>
<span class="token prompt"> -></span> <span class="token keyword">Table</span> scan <span class="token keyword">on</span> t2 <span class="token punctuation">(</span>cost<span class="token operator">=</span><span class="token number">0.35</span> <span class="token keyword">rows</span><span class="token operator">=</span><span class="token number">1</span><span class="token punctuation">)</span>
<span class="token prompt"> -></span> <span class="token keyword">Hash</span>
<span class="token prompt"> -></span> <span class="token keyword">Filter</span>: <span class="token punctuation">(</span>t1<span class="token punctuation">.</span>c2 <span class="token operator">></span> <span class="token number">50</span><span class="token punctuation">)</span> <span class="token punctuation">(</span>cost<span class="token operator">=</span><span class="token number">0.35</span> <span class="token keyword">rows</span><span class="token operator">=</span><span class="token number">1</span><span class="token punctuation">)</span>
<span class="token prompt"> -></span> <span class="token keyword">Table</span> scan <span class="token keyword">on</span> t1 <span class="token punctuation">(</span>cost<span class="token operator">=</span><span class="token number">0.35</span> <span class="token keyword">rows</span><span class="token operator">=</span><span class="token number">1</span><span class="token punctuation">)</span></code></pre>
</div>
<p>
It is not necessary for the join to contain at least one
equi-join condition in order for a hash join to be used. This
means that the types of queries which can be optimized using
hash joins include those in the following list (with
examples):
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<span class="emphasis">
<em>
Inner non-equi-join
</em>
</span>
:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa42611919"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">EXPLAIN</span> <span class="token keyword">FORMAT</span><span class="token operator">=</span><span class="token keyword">TREE</span> <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t1 <span class="token keyword">JOIN</span> t2 <span class="token keyword">ON</span> t1<span class="token punctuation">.</span>c1 <span class="token operator"><</span> t2<span class="token punctuation">.</span>c1\G
<span class="token output"><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span> 1. row <span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span>
EXPLAIN<span class="token punctuation">:</span> -> Filter<span class="token punctuation">:</span> (t1.c1 < t2.c1) (cost=4.70 rows=12)</span>
<span class="token prompt"> -></span> <span class="token keyword">Inner</span> <span class="token keyword">hash</span> <span class="token keyword">join</span> <span class="token punctuation">(</span><span class="token keyword">no</span> <span class="token keyword">condition</span><span class="token punctuation">)</span> <span class="token punctuation">(</span>cost<span class="token operator">=</span><span class="token number">4.70</span> <span class="token keyword">rows</span><span class="token operator">=</span><span class="token number">12</span><span class="token punctuation">)</span>
<span class="token prompt"> -></span> <span class="token keyword">Table</span> scan <span class="token keyword">on</span> t2 <span class="token punctuation">(</span>cost<span class="token operator">=</span><span class="token number">0.08</span> <span class="token keyword">rows</span><span class="token operator">=</span><span class="token number">6</span><span class="token punctuation">)</span>
<span class="token prompt"> -></span> <span class="token keyword">Hash</span>
<span class="token prompt"> -></span> <span class="token keyword">Table</span> scan <span class="token keyword">on</span> t1 <span class="token punctuation">(</span>cost<span class="token operator">=</span><span class="token number">0.85</span> <span class="token keyword">rows</span><span class="token operator">=</span><span class="token number">6</span><span class="token punctuation">)</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
<span class="emphasis">
<em>
Semijoin
</em>
</span>
:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa55002136"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">EXPLAIN</span> <span class="token keyword">FORMAT</span><span class="token operator">=</span><span class="token keyword">TREE</span> <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t1
<span class="token prompt"> -></span> <span class="token keyword">WHERE</span> t1<span class="token punctuation">.</span>c1 <span class="token keyword">IN</span> <span class="token punctuation">(</span><span class="token keyword">SELECT</span> t2<span class="token punctuation">.</span>c2 <span class="token keyword">FROM</span> t2<span class="token punctuation">)</span>\G
<span class="token output"><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span> 1. row <span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span>
EXPLAIN<span class="token punctuation">:</span> -> Hash semijoin (t2.c2 = t1.c1) (cost=0.70 rows=1)</span>
<span class="token prompt"> -></span> <span class="token keyword">Table</span> scan <span class="token keyword">on</span> t1 <span class="token punctuation">(</span>cost<span class="token operator">=</span><span class="token number">0.35</span> <span class="token keyword">rows</span><span class="token operator">=</span><span class="token number">1</span><span class="token punctuation">)</span>
<span class="token prompt"> -></span> <span class="token keyword">Hash</span>
<span class="token prompt"> -></span> <span class="token keyword">Table</span> scan <span class="token keyword">on</span> t2 <span class="token punctuation">(</span>cost<span class="token operator">=</span><span class="token number">0.35</span> <span class="token keyword">rows</span><span class="token operator">=</span><span class="token number">1</span><span class="token punctuation">)</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
<span class="emphasis">
<em>
Antijoin
</em>
</span>
:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa16667102"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">EXPLAIN</span> <span class="token keyword">FORMAT</span><span class="token operator">=</span><span class="token keyword">TREE</span> <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t2
<span class="token prompt"> -></span> <span class="token keyword">WHERE</span> <span class="token operator">NOT</span> <span class="token keyword">EXISTS</span> <span class="token punctuation">(</span><span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t1 <span class="token keyword">WHERE</span> t1<span class="token punctuation">.</span>c1 <span class="token operator">=</span> t2<span class="token punctuation">.</span>c1<span class="token punctuation">)</span>\G
<span class="token output"><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span> 1. row <span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span>
EXPLAIN<span class="token punctuation">:</span> -> Hash antijoin (t1.c1 = t2.c1) (cost=0.70 rows=1)</span>
<span class="token prompt"> -></span> <span class="token keyword">Table</span> scan <span class="token keyword">on</span> t2 <span class="token punctuation">(</span>cost<span class="token operator">=</span><span class="token number">0.35</span> <span class="token keyword">rows</span><span class="token operator">=</span><span class="token number">1</span><span class="token punctuation">)</span>
<span class="token prompt"> -></span> <span class="token keyword">Hash</span>
<span class="token prompt"> -></span> <span class="token keyword">Table</span> scan <span class="token keyword">on</span> t1 <span class="token punctuation">(</span>cost<span class="token operator">=</span><span class="token number">0.35</span> <span class="token keyword">rows</span><span class="token operator">=</span><span class="token number">1</span><span class="token punctuation">)</span>
<span class="token output">1 row in set, 1 warning (0.00 sec)</span>
<span class="token prompt">mysql></span> <span class="token keyword">SHOW</span> <span class="token keyword">WARNINGS</span>\G
<span class="token output"><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span> 1. row <span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span>
Level<span class="token punctuation">:</span> Note
Code<span class="token punctuation">:</span> 1276
Message<span class="token punctuation">:</span> Field or reference 't3.t2.c1' of SELECT #2 was resolved in SELECT #1</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
<span class="emphasis">
<em>
Left outer join
</em>
</span>
:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa4308709"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">EXPLAIN</span> <span class="token keyword">FORMAT</span><span class="token operator">=</span><span class="token keyword">TREE</span> <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t1 <span class="token keyword">LEFT</span> <span class="token keyword">JOIN</span> t2 <span class="token keyword">ON</span> t1<span class="token punctuation">.</span>c1 <span class="token operator">=</span> t2<span class="token punctuation">.</span>c1\G
<span class="token output"><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span> 1. row <span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span>
EXPLAIN<span class="token punctuation">:</span> -> Left hash join (t2.c1 = t1.c1) (cost=0.70 rows=1)</span>
<span class="token prompt"> -></span> <span class="token keyword">Table</span> scan <span class="token keyword">on</span> t1 <span class="token punctuation">(</span>cost<span class="token operator">=</span><span class="token number">0.35</span> <span class="token keyword">rows</span><span class="token operator">=</span><span class="token number">1</span><span class="token punctuation">)</span>
<span class="token prompt"> -></span> <span class="token keyword">Hash</span>
<span class="token prompt"> -></span> <span class="token keyword">Table</span> scan <span class="token keyword">on</span> t2 <span class="token punctuation">(</span>cost<span class="token operator">=</span><span class="token number">0.35</span> <span class="token keyword">rows</span><span class="token operator">=</span><span class="token number">1</span><span class="token punctuation">)</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
<span class="emphasis">
<em>
Right outer join
</em>
</span>
(observe that MySQL
rewrites all right outer joins as left outer joins):
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa72200938"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">EXPLAIN</span> <span class="token keyword">FORMAT</span><span class="token operator">=</span><span class="token keyword">TREE</span> <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t1 <span class="token keyword">RIGHT</span> <span class="token keyword">JOIN</span> t2 <span class="token keyword">ON</span> t1<span class="token punctuation">.</span>c1 <span class="token operator">=</span> t2<span class="token punctuation">.</span>c1\G
<span class="token output"><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span> 1. row <span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span>
EXPLAIN<span class="token punctuation">:</span> -> Left hash join (t1.c1 = t2.c1) (cost=0.70 rows=1)</span>
<span class="token prompt"> -></span> <span class="token keyword">Table</span> scan <span class="token keyword">on</span> t2 <span class="token punctuation">(</span>cost<span class="token operator">=</span><span class="token number">0.35</span> <span class="token keyword">rows</span><span class="token operator">=</span><span class="token number">1</span><span class="token punctuation">)</span>
<span class="token prompt"> -></span> <span class="token keyword">Hash</span>
<span class="token prompt"> -></span> <span class="token keyword">Table</span> scan <span class="token keyword">on</span> t1 <span class="token punctuation">(</span>cost<span class="token operator">=</span><span class="token number">0.35</span> <span class="token keyword">rows</span><span class="token operator">=</span><span class="token number">1</span><span class="token punctuation">)</span></code></pre>
</div>
</li>
</ul>
</div>
<p>
By default, MySQL employs hash joins whenever possible. It is
possible to control whether hash joins are employed using one
of the
<a class="link" href="optimizer-hints.html#optimizer-hints-table-level" title="Table-Level Optimizer Hints">
<code class="literal">
BNL
</code>
</a>
and
<code class="literal">
NO_BNL
</code>
optimizer hints.
</p>
<p>
Memory usage by hash joins can be controlled using the
<a class="link" href="server-system-variables.html#sysvar_join_buffer_size">
<code class="literal">
join_buffer_size
</code>
</a>
system
variable; a hash join cannot use more memory than this amount.
When the memory required for a hash join exceeds the amount
available, MySQL handles this by using files on disk. If this
happens, you should be aware that the join may not succeed if
a hash join cannot fit into memory and it creates more files
than set for
<a class="link" href="server-system-variables.html#sysvar_open_files_limit">
<code class="literal">
open_files_limit
</code>
</a>
. To avoid
such problems, make either of the following changes:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Increase
<code class="literal">
join_buffer_size
</code>
so that the
hash join does not spill over to disk.
</p>
</li>
<li class="listitem">
<p>
Increase
<code class="literal">
open_files_limit
</code>
.
</p>
</li>
</ul>
</div>
<p>
Join buffers for hash joins are allocated incrementally; thus,
you can set
<a class="link" href="server-system-variables.html#sysvar_join_buffer_size">
<code class="literal">
join_buffer_size
</code>
</a>
higher without small queries allocating very large amounts of
RAM, but outer joins allocate the entire buffer. Hash joins
are used for outer joins (including antijoins and semijoins)
as well, so this is no longer an issue.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/performance-schema-wait-summary-tables.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="performance-schema-wait-summary-tables">
</a>
29.12.20.1 Wait Event Summary Tables
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045069146480">
</a>
<a class="indexterm" name="idm46045069144960">
</a>
<a class="indexterm" name="idm46045069143440">
</a>
<a class="indexterm" name="idm46045069141920">
</a>
<a class="indexterm" name="idm46045069140400">
</a>
<a class="indexterm" name="idm46045069138896">
</a>
<a class="indexterm" name="idm46045069137392">
</a>
<a class="indexterm" name="idm46045069135872">
</a>
<a class="indexterm" name="idm46045069134352">
</a>
<a class="indexterm" name="idm46045069132832">
</a>
<a class="indexterm" name="idm46045069131312">
</a>
<a class="indexterm" name="idm46045069129792">
</a>
<p>
The Performance Schema maintains tables for collecting current
and recent wait events, and aggregates that information in
summary tables.
<a class="xref" href="performance-schema-wait-tables.html" title="29.12.4 Performance Schema Wait Event Tables">
Section 29.12.4, “Performance Schema Wait Event Tables”
</a>
describes the
events on which wait summaries are based. See that discussion
for information about the content of wait events, the current
and recent wait event tables, and how to control wait event
collection, which is disabled by default.
</p>
<p>
Example wait event summary information:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa35857897"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token operator">*</span>
<span class="token keyword">FROM</span> performance_schema<span class="token punctuation">.</span>events_waits_summary_global_by_event_name\G
<span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
<span class="token output"><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span> 6. row <span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span>
EVENT_NAME<span class="token punctuation">:</span> wait/synch/mutex/sql/BINARY_LOG<span class="token punctuation">:</span><span class="token punctuation">:</span>LOCK_index
COUNT_STAR<span class="token punctuation">:</span> 8
SUM_TIMER_WAIT<span class="token punctuation">:</span> 2119302
MIN_TIMER_WAIT<span class="token punctuation">:</span> 196092
AVG_TIMER_WAIT<span class="token punctuation">:</span> 264912
MAX_TIMER_WAIT<span class="token punctuation">:</span> 569421
...
<span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span> 9. row <span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span>
EVENT_NAME<span class="token punctuation">:</span> wait/synch/mutex/sql/hash_filo<span class="token punctuation">:</span><span class="token punctuation">:</span>lock
COUNT_STAR<span class="token punctuation">:</span> 69
SUM_TIMER_WAIT<span class="token punctuation">:</span> 16848828
MIN_TIMER_WAIT<span class="token punctuation">:</span> 0
AVG_TIMER_WAIT<span class="token punctuation">:</span> 244185
MAX_TIMER_WAIT<span class="token punctuation">:</span> 735345
...</span></code></pre>
</div>
<p>
Each wait event summary table has one or more grouping columns
to indicate how the table aggregates events. Event names refer
to names of event instruments in the
<a class="link" href="performance-schema-setup-instruments-table.html" title="29.12.2.3 The setup_instruments Table">
<code class="literal">
setup_instruments
</code>
</a>
table:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="link" href="performance-schema-stage-summary-tables.html" title="29.12.20.2 Stage Summary Tables">
<code class="literal">
events_waits_summary_by_account_by_event_name
</code>
</a>
has
<code class="literal">
EVENT_NAME
</code>
,
<code class="literal">
USER
</code>
, and
<code class="literal">
HOST
</code>
columns. Each row summarizes events for a given account
(user and host combination) and event name.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="performance-schema-stage-summary-tables.html" title="29.12.20.2 Stage Summary Tables">
<code class="literal">
events_waits_summary_by_host_by_event_name
</code>
</a>
has
<code class="literal">
EVENT_NAME
</code>
and
<code class="literal">
HOST
</code>
columns. Each row summarizes
events for a given host and event name.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="performance-schema-wait-summary-tables.html" title="29.12.20.1 Wait Event Summary Tables">
<code class="literal">
events_waits_summary_by_instance
</code>
</a>
has
<code class="literal">
EVENT_NAME
</code>
and
<code class="literal">
OBJECT_INSTANCE_BEGIN
</code>
columns. Each row
summarizes events for a given event name and object. If an
instrument is used to create multiple instances, each
instance has a unique
<code class="literal">
OBJECT_INSTANCE_BEGIN
</code>
value and is
summarized separately in this table.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="performance-schema-wait-summary-tables.html" title="29.12.20.1 Wait Event Summary Tables">
<code class="literal">
events_waits_summary_by_thread_by_event_name
</code>
</a>
has
<code class="literal">
THREAD_ID
</code>
and
<code class="literal">
EVENT_NAME
</code>
columns. Each row summarizes
events for a given thread and event name.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="performance-schema-stage-summary-tables.html" title="29.12.20.2 Stage Summary Tables">
<code class="literal">
events_waits_summary_by_user_by_event_name
</code>
</a>
has
<code class="literal">
EVENT_NAME
</code>
and
<code class="literal">
USER
</code>
columns. Each row summarizes
events for a given user and event name.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="performance-schema-wait-summary-tables.html" title="29.12.20.1 Wait Event Summary Tables">
<code class="literal">
events_waits_summary_global_by_event_name
</code>
</a>
has an
<code class="literal">
EVENT_NAME
</code>
column. Each row
summarizes events for a given event name. An instrument
might be used to create multiple instances of the
instrumented object. For example, if there is an
instrument for a mutex that is created for each
connection, there are as many instances as there are
connections. The summary row for the instrument summarizes
over all these instances.
</p>
</li>
</ul>
</div>
<p>
Each wait event summary table has these summary columns
containing aggregated values:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
COUNT_STAR
</code>
</p>
<p>
The number of summarized events. This value includes all
events, whether timed or nontimed.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SUM_TIMER_WAIT
</code>
</p>
<p>
The total wait time of the summarized timed events. This
value is calculated only for timed events because nontimed
events have a wait time of
<code class="literal">
NULL
</code>
. The
same is true for the other
<code class="literal">
<em class="replaceable">
<code>
xxx
</code>
</em>
_TIMER_WAIT
</code>
values.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MIN_TIMER_WAIT
</code>
</p>
<p>
The minimum wait time of the summarized timed events.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
AVG_TIMER_WAIT
</code>
</p>
<p>
The average wait time of the summarized timed events.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MAX_TIMER_WAIT
</code>
</p>
<p>
The maximum wait time of the summarized timed events.
</p>
</li>
</ul>
</div>
<p>
The wait event summary tables have these indexes:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="link" href="performance-schema-stage-summary-tables.html" title="29.12.20.2 Stage Summary Tables">
<code class="literal">
events_waits_summary_by_account_by_event_name
</code>
</a>
:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
Primary key on (
<code class="literal">
USER
</code>
,
<code class="literal">
HOST
</code>
,
<code class="literal">
EVENT_NAME
</code>
)
</p>
</li>
</ul>
</div>
</li>
<li class="listitem">
<p>
<a class="link" href="performance-schema-stage-summary-tables.html" title="29.12.20.2 Stage Summary Tables">
<code class="literal">
events_waits_summary_by_host_by_event_name
</code>
</a>
:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
Primary key on (
<code class="literal">
HOST
</code>
,
<code class="literal">
EVENT_NAME
</code>
)
</p>
</li>
</ul>
</div>
</li>
<li class="listitem">
<p>
<a class="link" href="performance-schema-wait-summary-tables.html" title="29.12.20.1 Wait Event Summary Tables">
<code class="literal">
events_waits_summary_by_instance
</code>
</a>
:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
Primary key on
(
<code class="literal">
OBJECT_INSTANCE_BEGIN
</code>
)
</p>
</li>
<li class="listitem">
<p>
Index on (
<code class="literal">
EVENT_NAME
</code>
)
</p>
</li>
</ul>
</div>
</li>
<li class="listitem">
<p>
<a class="link" href="performance-schema-wait-summary-tables.html" title="29.12.20.1 Wait Event Summary Tables">
<code class="literal">
events_waits_summary_by_thread_by_event_name
</code>
</a>
:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
Primary key on (
<code class="literal">
THREAD_ID
</code>
,
<code class="literal">
EVENT_NAME
</code>
)
</p>
</li>
</ul>
</div>
</li>
<li class="listitem">
<p>
<a class="link" href="performance-schema-stage-summary-tables.html" title="29.12.20.2 Stage Summary Tables">
<code class="literal">
events_waits_summary_by_user_by_event_name
</code>
</a>
:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
Primary key on (
<code class="literal">
USER
</code>
,
<code class="literal">
EVENT_NAME
</code>
)
</p>
</li>
</ul>
</div>
</li>
<li class="listitem">
<p>
<a class="link" href="performance-schema-wait-summary-tables.html" title="29.12.20.1 Wait Event Summary Tables">
<code class="literal">
events_waits_summary_global_by_event_name
</code>
</a>
:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
Primary key on (
<code class="literal">
EVENT_NAME
</code>
)
</p>
</li>
</ul>
</div>
</li>
</ul>
</div>
<p>
<a class="link" href="truncate-table.html" title="15.1.37 TRUNCATE TABLE Statement">
<code class="literal">
TRUNCATE TABLE
</code>
</a>
is permitted for
wait summary tables. It has these effects:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
For summary tables not aggregated by account, host, or
user, truncation resets the summary columns to zero rather
than removing rows.
</p>
</li>
<li class="listitem">
<p>
For summary tables aggregated by account, host, or user,
truncation removes rows for accounts, hosts, or users with
no connections, and resets the summary columns to zero for
the remaining rows.
</p>
</li>
</ul>
</div>
<p>
In addition, each wait summary table that is aggregated by
account, host, user, or thread is implicitly truncated by
truncation of the connection table on which it depends, or
truncation of
<a class="link" href="performance-schema-wait-summary-tables.html" title="29.12.20.1 Wait Event Summary Tables">
<code class="literal">
events_waits_summary_global_by_event_name
</code>
</a>
.
For details, see
<a class="xref" href="performance-schema-connection-tables.html" title="29.12.8 Performance Schema Connection Tables">
Section 29.12.8, “Performance Schema Connection Tables”
</a>
.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/innodb-fulltext-index.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="innodb-fulltext-index">
</a>
17.6.2.4 InnoDB Full-Text Indexes
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045165777968">
</a>
<a class="indexterm" name="idm46045165776512">
</a>
<p>
Full-text indexes are created on text-based columns
(
<a class="link" href="char.html" title="13.3.2 The CHAR and VARCHAR Types">
<code class="literal">
CHAR
</code>
</a>
,
<a class="link" href="char.html" title="13.3.2 The CHAR and VARCHAR Types">
<code class="literal">
VARCHAR
</code>
</a>
, or
<a class="link" href="blob.html" title="13.3.4 The BLOB and TEXT Types">
<code class="literal">
TEXT
</code>
</a>
columns) to speed up queries
and DML operations on data contained within those columns.
</p>
<p>
A full-text index is defined as part of a
<a class="link" href="create-table.html" title="15.1.20 CREATE TABLE Statement">
<code class="literal">
CREATE TABLE
</code>
</a>
statement or added to
an existing table using
<a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
<code class="literal">
ALTER TABLE
</code>
</a>
or
<a class="link" href="create-index.html" title="15.1.15 CREATE INDEX Statement">
<code class="literal">
CREATE INDEX
</code>
</a>
.
</p>
<p>
Full-text search is performed using
<a class="link" href="fulltext-search.html#function_match">
<code class="literal">
MATCH()
... AGAINST
</code>
</a>
syntax. For usage information, see
<a class="xref" href="fulltext-search.html" title="14.9 Full-Text Search Functions">
Section 14.9, “Full-Text Search Functions”
</a>
.
</p>
<p>
<code class="literal">
InnoDB
</code>
full-text indexes are described under
the following topics in this section:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="xref" href="innodb-fulltext-index.html#innodb-fulltext-index-design" title="InnoDB Full-Text Index Design">
InnoDB Full-Text Index Design
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="innodb-fulltext-index.html#innodb-fulltext-index-tables" title="InnoDB Full-Text Index Tables">
InnoDB Full-Text Index Tables
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="innodb-fulltext-index.html#innodb-fulltext-index-cache" title="InnoDB Full-Text Index Cache">
InnoDB Full-Text Index Cache
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="innodb-fulltext-index.html#innodb-fulltext-index-docid" title="InnoDB Full-Text Index DOC_ID and FTS_DOC_ID Column">
InnoDB Full-Text Index DOC_ID and FTS_DOC_ID Column
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="innodb-fulltext-index.html#innodb-fulltext-index-deletion" title="InnoDB Full-Text Index Deletion Handling">
InnoDB Full-Text Index Deletion Handling
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="innodb-fulltext-index.html#innodb-fulltext-index-transaction" title="InnoDB Full-Text Index Transaction Handling">
InnoDB Full-Text Index Transaction Handling
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="innodb-fulltext-index.html#innodb-fulltext-index-monitoring" title="Monitoring InnoDB Full-Text Indexes">
Monitoring InnoDB Full-Text Indexes
</a>
</p>
</li>
</ul>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="innodb-fulltext-index-design">
</a>
InnoDB Full-Text Index Design
</h5>
</div>
</div>
</div>
<p>
<code class="literal">
InnoDB
</code>
full-text indexes have an inverted
index design. Inverted indexes store a list of words, and for
each word, a list of documents that the word appears in. To
support proximity search, position information for each word is
also stored, as a byte offset.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="innodb-fulltext-index-tables">
</a>
InnoDB Full-Text Index Tables
</h5>
</div>
</div>
</div>
<p>
When an
<code class="literal">
InnoDB
</code>
full-text index is created, a
set of index tables is created, as shown in the following
example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa67228080"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> opening_lines <span class="token punctuation">(</span>
id <span class="token datatype">INT</span> <span class="token keyword">UNSIGNED</span> <span class="token keyword">AUTO_INCREMENT</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span> <span class="token keyword">PRIMARY</span> <span class="token keyword">KEY</span><span class="token punctuation">,</span>
opening_line <span class="token datatype">TEXT</span><span class="token punctuation">(</span><span class="token number">500</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
author <span class="token datatype">VARCHAR</span><span class="token punctuation">(</span><span class="token number">200</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
title <span class="token datatype">VARCHAR</span><span class="token punctuation">(</span><span class="token number">200</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token keyword">FULLTEXT</span> idx <span class="token punctuation">(</span>opening_line<span class="token punctuation">)</span>
<span class="token punctuation">)</span> <span class="token keyword">ENGINE</span><span class="token operator">=</span>InnoDB<span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> table_id<span class="token punctuation">,</span> <span class="token keyword">name</span><span class="token punctuation">,</span> space <span class="token keyword">from</span> INFORMATION_SCHEMA<span class="token punctuation">.</span>INNODB_TABLES
<span class="token keyword">WHERE</span> <span class="token keyword">name</span> <span class="token operator">LIKE</span> <span class="token string">'test/%'</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> table_id <span class="token punctuation">|</span> name <span class="token punctuation">|</span> space <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 333 <span class="token punctuation">|</span> test/fts_0000000000000147_00000000000001c9_index_1 <span class="token punctuation">|</span> 289 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 334 <span class="token punctuation">|</span> test/fts_0000000000000147_00000000000001c9_index_2 <span class="token punctuation">|</span> 290 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 335 <span class="token punctuation">|</span> test/fts_0000000000000147_00000000000001c9_index_3 <span class="token punctuation">|</span> 291 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 336 <span class="token punctuation">|</span> test/fts_0000000000000147_00000000000001c9_index_4 <span class="token punctuation">|</span> 292 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 337 <span class="token punctuation">|</span> test/fts_0000000000000147_00000000000001c9_index_5 <span class="token punctuation">|</span> 293 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 338 <span class="token punctuation">|</span> test/fts_0000000000000147_00000000000001c9_index_6 <span class="token punctuation">|</span> 294 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 330 <span class="token punctuation">|</span> test/fts_0000000000000147_being_deleted <span class="token punctuation">|</span> 286 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 331 <span class="token punctuation">|</span> test/fts_0000000000000147_being_deleted_cache <span class="token punctuation">|</span> 287 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 332 <span class="token punctuation">|</span> test/fts_0000000000000147_config <span class="token punctuation">|</span> 288 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 328 <span class="token punctuation">|</span> test/fts_0000000000000147_deleted <span class="token punctuation">|</span> 284 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 329 <span class="token punctuation">|</span> test/fts_0000000000000147_deleted_cache <span class="token punctuation">|</span> 285 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 327 <span class="token punctuation">|</span> test/opening_lines <span class="token punctuation">|</span> 283 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
<p>
The first six index tables comprise the inverted index and are
referred to as auxiliary index tables. When incoming documents
are tokenized, the individual words (also referred to as
<span class="quote">
“
<span class="quote">
tokens
</span>
”
</span>
) are inserted into the index tables along
with position information and an associated
<code class="literal">
DOC_ID
</code>
. The words are fully sorted and
partitioned among the six index tables based on the character
set sort weight of the word's first character.
</p>
<p>
The inverted index is partitioned into six auxiliary index
tables to support parallel index creation. By default, two
threads tokenize, sort, and insert words and associated data
into the index tables. The number of threads that perform this
work is configurable using the
<a class="link" href="innodb-parameters.html#sysvar_innodb_ft_sort_pll_degree">
<code class="literal">
innodb_ft_sort_pll_degree
</code>
</a>
variable. Consider increasing the number of threads when
creating full-text indexes on large tables.
</p>
<p>
Auxiliary index table names are prefixed with
<code class="literal">
fts_
</code>
and postfixed with
<code class="literal">
index_
<em class="replaceable">
<code>
#
</code>
</em>
</code>
. Each
auxiliary index table is associated with the indexed table by a
hex value in the auxiliary index table name that matches the
<code class="literal">
table_id
</code>
of the indexed table. For example,
the
<code class="literal">
table_id
</code>
of the
<code class="literal">
test/opening_lines
</code>
table is
<code class="literal">
327
</code>
, for which the hex value is 0x147. As
shown in the preceding example, the
<span class="quote">
“
<span class="quote">
147
</span>
”
</span>
hex value
appears in the names of auxiliary index tables that are
associated with the
<code class="literal">
test/opening_lines
</code>
table.
</p>
<p>
A hex value representing the
<code class="literal">
index_id
</code>
of the
full-text index also appears in auxiliary index table names. For
example, in the auxiliary table name
<code class="literal">
test/fts_0000000000000147_00000000000001c9_index_1
</code>
,
the hex value
<code class="literal">
1c9
</code>
has a decimal value of 457.
The index defined on the
<code class="literal">
opening_lines
</code>
table
(
<code class="literal">
idx
</code>
) can be identified by querying the
Information Schema
<a class="link" href="information-schema-innodb-indexes-table.html" title="28.4.20 The INFORMATION_SCHEMA INNODB_INDEXES Table">
<code class="literal">
INNODB_INDEXES
</code>
</a>
table for this value (457).
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa56881970"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> index_id<span class="token punctuation">,</span> <span class="token keyword">name</span><span class="token punctuation">,</span> table_id<span class="token punctuation">,</span> space <span class="token keyword">from</span> INFORMATION_SCHEMA<span class="token punctuation">.</span>INNODB_INDEXES
<span class="token keyword">WHERE</span> index_id<span class="token operator">=</span><span class="token number">457</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> index_id <span class="token punctuation">|</span> name <span class="token punctuation">|</span> table_id <span class="token punctuation">|</span> space <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 457 <span class="token punctuation">|</span> idx <span class="token punctuation">|</span> 327 <span class="token punctuation">|</span> 283 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
<p>
Index tables are stored in their own tablespace if the primary
table is created in a
<a class="link" href="glossary.html#glos_file_per_table" title="file-per-table">
file-per-table
</a>
tablespace. Otherwise, index tables are stored in the tablespace
where the indexed table resides.
</p>
<p>
The other index tables shown in the preceding example are
referred to as common index tables and are used for deletion
handling and storing the internal state of full-text indexes.
Unlike the inverted index tables, which are created for each
full-text index, this set of tables is common to all full-text
indexes created on a particular table.
</p>
<p>
Common index tables are retained even if full-text indexes are
dropped. When a full-text index is dropped, the
<code class="literal">
FTS_DOC_ID
</code>
column that was created for the
index is retained, as removing the
<code class="literal">
FTS_DOC_ID
</code>
column would require rebuilding the previously indexed table.
Common index tables are required to manage the
<code class="literal">
FTS_DOC_ID
</code>
column.
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
fts_*_deleted
</code>
and
<code class="literal">
fts_*_deleted_cache
</code>
</p>
<p>
Contain the document IDs (DOC_ID) for documents that are
deleted but whose data is not yet removed from the full-text
index. The
<code class="literal">
fts_*_deleted_cache
</code>
is the
in-memory version of the
<code class="literal">
fts_*_deleted
</code>
table.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
fts_*_being_deleted
</code>
and
<code class="literal">
fts_*_being_deleted_cache
</code>
</p>
<p>
Contain the document IDs (DOC_ID) for documents that are
deleted and whose data is currently in the process of being
removed from the full-text index. The
<code class="literal">
fts_*_being_deleted_cache
</code>
table is the
in-memory version of the
<code class="literal">
fts_*_being_deleted
</code>
table.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
fts_*_config
</code>
</p>
<p>
Stores information about the internal state of the full-text
index. Most importantly, it stores the
<code class="literal">
FTS_SYNCED_DOC_ID
</code>
, which identifies
documents that have been parsed and flushed to disk. In case
of crash recovery,
<code class="literal">
FTS_SYNCED_DOC_ID
</code>
values are used to identify documents that have not been
flushed to disk so that the documents can be re-parsed and
added back to the full-text index cache. To view the data in
this table, query the Information Schema
<a class="link" href="information-schema-innodb-ft-config-table.html" title="28.4.15 The INFORMATION_SCHEMA INNODB_FT_CONFIG Table">
<code class="literal">
INNODB_FT_CONFIG
</code>
</a>
table.
</p>
</li>
</ul>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="innodb-fulltext-index-cache">
</a>
InnoDB Full-Text Index Cache
</h5>
</div>
</div>
</div>
<p>
When a document is inserted, it is tokenized, and the individual
words and associated data are inserted into the full-text index.
This process, even for small documents, can result in numerous
small insertions into the auxiliary index tables, making
concurrent access to these tables a point of contention. To
avoid this problem,
<code class="literal">
InnoDB
</code>
uses a full-text
index cache to temporarily cache index table insertions for
recently inserted rows. This in-memory cache structure holds
insertions until the cache is full and then batch flushes them
to disk (to the auxiliary index tables). You can query the
Information Schema
<a class="link" href="information-schema-innodb-ft-index-cache-table.html" title="28.4.18 The INFORMATION_SCHEMA INNODB_FT_INDEX_CACHE Table">
<code class="literal">
INNODB_FT_INDEX_CACHE
</code>
</a>
table to view
tokenized data for recently inserted rows.
</p>
<p>
The caching and batch flushing behavior avoids frequent updates
to auxiliary index tables, which could result in concurrent
access issues during busy insert and update times. The batching
technique also avoids multiple insertions for the same word, and
minimizes duplicate entries. Instead of flushing each word
individually, insertions for the same word are merged and
flushed to disk as a single entry, improving insertion
efficiency while keeping auxiliary index tables as small as
possible.
</p>
<p>
The
<a class="link" href="innodb-parameters.html#sysvar_innodb_ft_cache_size">
<code class="literal">
innodb_ft_cache_size
</code>
</a>
variable is used to configure the full-text index cache size (on
a per-table basis), which affects how often the full-text index
cache is flushed. You can also define a global full-text index
cache size limit for all tables in a given instance using the
<a class="link" href="innodb-parameters.html#sysvar_innodb_ft_total_cache_size">
<code class="literal">
innodb_ft_total_cache_size
</code>
</a>
variable.
</p>
<p>
The full-text index cache stores the same information as
auxiliary index tables. However, the full-text index cache only
caches tokenized data for recently inserted rows. The data that
is already flushed to disk (to the auxiliary index tables) is
not brought back into the full-text index cache when queried.
The data in auxiliary index tables is queried directly, and
results from the auxiliary index tables are merged with results
from the full-text index cache before being returned.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="innodb-fulltext-index-docid">
</a>
InnoDB Full-Text Index DOC_ID and FTS_DOC_ID Column
</h5>
</div>
</div>
</div>
<p>
<code class="literal">
InnoDB
</code>
uses a unique document identifier
referred to as the
<code class="literal">
DOC_ID
</code>
to map words in the
full-text index to document records where the word appears. The
mapping requires an
<code class="literal">
FTS_DOC_ID
</code>
column on the
indexed table. If an
<code class="literal">
FTS_DOC_ID
</code>
column is not
defined,
<code class="literal">
InnoDB
</code>
automatically adds a hidden
<code class="literal">
FTS_DOC_ID
</code>
column when the full-text index is
created. The following example demonstrates this behavior.
</p>
<p>
The following table definition does not include an
<code class="literal">
FTS_DOC_ID
</code>
column:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa78274334"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> opening_lines <span class="token punctuation">(</span>
id <span class="token datatype">INT</span> <span class="token keyword">UNSIGNED</span> <span class="token keyword">AUTO_INCREMENT</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span> <span class="token keyword">PRIMARY</span> <span class="token keyword">KEY</span><span class="token punctuation">,</span>
opening_line <span class="token datatype">TEXT</span><span class="token punctuation">(</span><span class="token number">500</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
author <span class="token datatype">VARCHAR</span><span class="token punctuation">(</span><span class="token number">200</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
title <span class="token datatype">VARCHAR</span><span class="token punctuation">(</span><span class="token number">200</span><span class="token punctuation">)</span>
<span class="token punctuation">)</span> <span class="token keyword">ENGINE</span><span class="token operator">=</span>InnoDB<span class="token punctuation">;</span></code></pre>
</div>
<p>
When you create a full-text index on the table using
<code class="literal">
CREATE FULLTEXT INDEX
</code>
syntax, a warning is
returned which reports that
<code class="literal">
InnoDB
</code>
is
rebuilding the table to add the
<code class="literal">
FTS_DOC_ID
</code>
column.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa80651267"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">CREATE</span> <span class="token keyword">FULLTEXT</span> <span class="token keyword">INDEX</span> idx <span class="token keyword">ON</span> opening_lines<span class="token punctuation">(</span>opening_line<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected, 1 warning (0.19 sec)</span>
<span class="token output">Records: 0 Duplicates: 0 Warnings: 1</span>
<span class="token prompt">mysql></span> <span class="token keyword">SHOW</span> <span class="token keyword">WARNINGS</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> Level <span class="token punctuation">|</span> Code <span class="token punctuation">|</span> Message <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> Warning <span class="token punctuation">|</span> 124 <span class="token punctuation">|</span> InnoDB rebuilding table to add column FTS_DOC_ID <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
<p>
The same warning is returned when using
<a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
<code class="literal">
ALTER TABLE
</code>
</a>
to add a full-text
index to a table that does not have an
<code class="literal">
FTS_DOC_ID
</code>
column. If you create a full-text
index at
<a class="link" href="create-table.html" title="15.1.20 CREATE TABLE Statement">
<code class="literal">
CREATE TABLE
</code>
</a>
time and do
not specify an
<code class="literal">
FTS_DOC_ID
</code>
column,
<code class="literal">
InnoDB
</code>
adds a hidden
<code class="literal">
FTS_DOC_ID
</code>
column, without warning.
</p>
<p>
Defining an
<code class="literal">
FTS_DOC_ID
</code>
column at
<a class="link" href="create-table.html" title="15.1.20 CREATE TABLE Statement">
<code class="literal">
CREATE TABLE
</code>
</a>
time is less
expensive than creating a full-text index on a table that is
already loaded with data. If an
<code class="literal">
FTS_DOC_ID
</code>
column is defined on a table prior to loading data, the table
and its indexes do not have to be rebuilt to add the new column.
If you are not concerned with
<code class="literal">
CREATE FULLTEXT
INDEX
</code>
performance, leave out the
<code class="literal">
FTS_DOC_ID
</code>
column to have
<code class="literal">
InnoDB
</code>
create it for you.
<code class="literal">
InnoDB
</code>
creates a hidden
<code class="literal">
FTS_DOC_ID
</code>
column along with a unique index
(
<code class="literal">
FTS_DOC_ID_INDEX
</code>
) on the
<code class="literal">
FTS_DOC_ID
</code>
column. If you want to create your
own
<code class="literal">
FTS_DOC_ID
</code>
column, the column must be
defined as
<code class="literal">
BIGINT UNSIGNED NOT NULL
</code>
and named
<code class="literal">
FTS_DOC_ID
</code>
(all uppercase), as in the
following example:
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
The
<code class="literal">
FTS_DOC_ID
</code>
column does not need to be
defined as an
<code class="literal">
AUTO_INCREMENT
</code>
column, but
doing so could make loading data easier.
</p>
</div>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa20273545"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> opening_lines <span class="token punctuation">(</span>
FTS_DOC_ID <span class="token datatype">BIGINT</span> <span class="token keyword">UNSIGNED</span> <span class="token keyword">AUTO_INCREMENT</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span> <span class="token keyword">PRIMARY</span> <span class="token keyword">KEY</span><span class="token punctuation">,</span>
opening_line <span class="token datatype">TEXT</span><span class="token punctuation">(</span><span class="token number">500</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
author <span class="token datatype">VARCHAR</span><span class="token punctuation">(</span><span class="token number">200</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
title <span class="token datatype">VARCHAR</span><span class="token punctuation">(</span><span class="token number">200</span><span class="token punctuation">)</span>
<span class="token punctuation">)</span> <span class="token keyword">ENGINE</span><span class="token operator">=</span>InnoDB<span class="token punctuation">;</span></code></pre>
</div>
<p>
If you choose to define the
<code class="literal">
FTS_DOC_ID
</code>
column
yourself, you are responsible for managing the column to avoid
empty or duplicate values.
<code class="literal">
FTS_DOC_ID
</code>
values
cannot be reused, which means
<code class="literal">
FTS_DOC_ID
</code>
values must be ever increasing.
</p>
<p>
Optionally, you can create the required unique
<code class="literal">
FTS_DOC_ID_INDEX
</code>
(all uppercase) on the
<code class="literal">
FTS_DOC_ID
</code>
column.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa8561766"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">CREATE</span> <span class="token keyword">UNIQUE</span> <span class="token keyword">INDEX</span> FTS_DOC_ID_INDEX <span class="token keyword">on</span> opening_lines<span class="token punctuation">(</span>FTS_DOC_ID<span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
If you do not create the
<code class="literal">
FTS_DOC_ID_INDEX
</code>
,
<code class="literal">
InnoDB
</code>
creates it automatically.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
<code class="literal">
FTS_DOC_ID_INDEX
</code>
cannot be defined as a
descending index because the
<code class="literal">
InnoDB
</code>
SQL
parser does not use descending indexes.
</p>
</div>
<p>
The permitted gap between the largest used
<code class="literal">
FTS_DOC_ID
</code>
value and new
<code class="literal">
FTS_DOC_ID
</code>
value is 65535.
</p>
<p>
To avoid rebuilding the table, the
<code class="literal">
FTS_DOC_ID
</code>
column is retained when dropping a full-text index.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="innodb-fulltext-index-deletion">
</a>
InnoDB Full-Text Index Deletion Handling
</h5>
</div>
</div>
</div>
<p>
Deleting a record that has a full-text index column could result
in numerous small deletions in the auxiliary index tables,
making concurrent access to these tables a point of contention.
To avoid this problem, the
<code class="literal">
DOC_ID
</code>
of a
deleted document is logged in a special
<code class="literal">
FTS_*_DELETED
</code>
table whenever a record is
deleted from an indexed table, and the indexed record remains in
the full-text index. Before returning query results, information
in the
<code class="literal">
FTS_*_DELETED
</code>
table is used to filter
out deleted
<code class="literal">
DOC_ID
</code>
s. The benefit of this
design is that deletions are fast and inexpensive. The drawback
is that the size of the index is not immediately reduced after
deleting records. To remove full-text index entries for deleted
records, run
<code class="literal">
OPTIMIZE TABLE
</code>
on the indexed
table with
<a class="link" href="innodb-parameters.html#sysvar_innodb_optimize_fulltext_only">
<code class="literal">
innodb_optimize_fulltext_only=ON
</code>
</a>
to rebuild the full-text index. For more information, see
<a class="xref" href="fulltext-fine-tuning.html#fulltext-optimize" title="Optimizing InnoDB Full-Text Indexes">
Optimizing InnoDB Full-Text Indexes
</a>
.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="innodb-fulltext-index-transaction">
</a>
InnoDB Full-Text Index Transaction Handling
</h5>
</div>
</div>
</div>
<p>
<code class="literal">
InnoDB
</code>
full-text indexes have special
transaction handling characteristics due its caching and batch
processing behavior. Specifically, updates and insertions on a
full-text index are processed at transaction commit time, which
means that a full-text search can only see committed data. The
following example demonstrates this behavior. The full-text
search only returns a result after the inserted lines are
committed.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa12278775"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> opening_lines <span class="token punctuation">(</span>
id <span class="token datatype">INT</span> <span class="token keyword">UNSIGNED</span> <span class="token keyword">AUTO_INCREMENT</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span> <span class="token keyword">PRIMARY</span> <span class="token keyword">KEY</span><span class="token punctuation">,</span>
opening_line <span class="token datatype">TEXT</span><span class="token punctuation">(</span><span class="token number">500</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
author <span class="token datatype">VARCHAR</span><span class="token punctuation">(</span><span class="token number">200</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
title <span class="token datatype">VARCHAR</span><span class="token punctuation">(</span><span class="token number">200</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token keyword">FULLTEXT</span> idx <span class="token punctuation">(</span>opening_line<span class="token punctuation">)</span>
<span class="token punctuation">)</span> <span class="token keyword">ENGINE</span><span class="token operator">=</span>InnoDB<span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">BEGIN</span><span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">INSERT</span> <span class="token keyword">INTO</span> opening_lines<span class="token punctuation">(</span>opening_line<span class="token punctuation">,</span>author<span class="token punctuation">,</span>title<span class="token punctuation">)</span> <span class="token keyword">VALUES</span>
<span class="token punctuation">(</span><span class="token string">'Call me Ishmael.'</span><span class="token punctuation">,</span><span class="token string">'Herman Melville'</span><span class="token punctuation">,</span><span class="token string">'Moby-Dick'</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token punctuation">(</span><span class="token string">'A screaming comes across the sky.'</span><span class="token punctuation">,</span><span class="token string">'Thomas Pynchon'</span><span class="token punctuation">,</span><span class="token string">'Gravity\'s Rainbow'</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token punctuation">(</span><span class="token string">'I am an invisible man.'</span><span class="token punctuation">,</span><span class="token string">'Ralph Ellison'</span><span class="token punctuation">,</span><span class="token string">'Invisible Man'</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token punctuation">(</span><span class="token string">'Where now? Who now? When now?'</span><span class="token punctuation">,</span><span class="token string">'Samuel Beckett'</span><span class="token punctuation">,</span><span class="token string">'The Unnamable'</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token punctuation">(</span><span class="token string">'It was love at first sight.'</span><span class="token punctuation">,</span><span class="token string">'Joseph Heller'</span><span class="token punctuation">,</span><span class="token string">'Catch-22'</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token punctuation">(</span><span class="token string">'All this happened, more or less.'</span><span class="token punctuation">,</span><span class="token string">'Kurt Vonnegut'</span><span class="token punctuation">,</span><span class="token string">'Slaughterhouse-Five'</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token punctuation">(</span><span class="token string">'Mrs. Dalloway said she would buy the flowers herself.'</span><span class="token punctuation">,</span><span class="token string">'Virginia Woolf'</span><span class="token punctuation">,</span><span class="token string">'Mrs. Dalloway'</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token punctuation">(</span><span class="token string">'It was a pleasure to burn.'</span><span class="token punctuation">,</span><span class="token string">'Ray Bradbury'</span><span class="token punctuation">,</span><span class="token string">'Fahrenheit 451'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token function">COUNT</span><span class="token punctuation">(</span><span class="token operator">*</span><span class="token punctuation">)</span> <span class="token keyword">FROM</span> opening_lines <span class="token keyword">WHERE</span> <span class="token operator">MATCH</span><span class="token punctuation">(</span>opening_line<span class="token punctuation">)</span> <span class="token keyword">AGAINST</span><span class="token punctuation">(</span><span class="token string">'Ishmael'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> COUNT(*) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 0 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token prompt">mysql></span> <span class="token keyword">COMMIT</span><span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token function">COUNT</span><span class="token punctuation">(</span><span class="token operator">*</span><span class="token punctuation">)</span> <span class="token keyword">FROM</span> opening_lines
<span class="token prompt"> -></span> <span class="token keyword">WHERE</span> <span class="token operator">MATCH</span><span class="token punctuation">(</span>opening_line<span class="token punctuation">)</span> <span class="token keyword">AGAINST</span><span class="token punctuation">(</span><span class="token string">'Ishmael'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> COUNT(*) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 1 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="innodb-fulltext-index-monitoring">
</a>
Monitoring InnoDB Full-Text Indexes
</h5>
</div>
</div>
</div>
<a class="indexterm" name="idm46045165607728">
</a>
<a class="indexterm" name="idm46045165606240">
</a>
<p>
You can monitor and examine the special text-processing aspects
of
<code class="literal">
InnoDB
</code>
full-text indexes by querying the
following
<code class="literal">
INFORMATION_SCHEMA
</code>
tables:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="link" href="information-schema-innodb-ft-config-table.html" title="28.4.15 The INFORMATION_SCHEMA INNODB_FT_CONFIG Table">
<code class="literal">
INNODB_FT_CONFIG
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="information-schema-innodb-ft-index-table-table.html" title="28.4.19 The INFORMATION_SCHEMA INNODB_FT_INDEX_TABLE Table">
<code class="literal">
INNODB_FT_INDEX_TABLE
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="information-schema-innodb-ft-index-cache-table.html" title="28.4.18 The INFORMATION_SCHEMA INNODB_FT_INDEX_CACHE Table">
<code class="literal">
INNODB_FT_INDEX_CACHE
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="information-schema-innodb-ft-default-stopword-table.html" title="28.4.16 The INFORMATION_SCHEMA INNODB_FT_DEFAULT_STOPWORD Table">
<code class="literal">
INNODB_FT_DEFAULT_STOPWORD
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="information-schema-innodb-ft-deleted-table.html" title="28.4.17 The INFORMATION_SCHEMA INNODB_FT_DELETED Table">
<code class="literal">
INNODB_FT_DELETED
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="information-schema-innodb-ft-being-deleted-table.html" title="28.4.14 The INFORMATION_SCHEMA INNODB_FT_BEING_DELETED Table">
<code class="literal">
INNODB_FT_BEING_DELETED
</code>
</a>
</p>
</li>
</ul>
</div>
<p>
You can also view basic information for full-text indexes and
tables by querying
<a class="link" href="information-schema-innodb-indexes-table.html" title="28.4.20 The INFORMATION_SCHEMA INNODB_INDEXES Table">
<code class="literal">
INNODB_INDEXES
</code>
</a>
and
<a class="link" href="information-schema-innodb-tables-table.html" title="28.4.23 The INFORMATION_SCHEMA INNODB_TABLES Table">
<code class="literal">
INNODB_TABLES
</code>
</a>
.
</p>
<p>
For more information, see
<a class="xref" href="innodb-information-schema-fulltext_index-tables.html" title="17.15.4 InnoDB INFORMATION_SCHEMA FULLTEXT Index Tables">
Section 17.15.4, “InnoDB INFORMATION_SCHEMA FULLTEXT Index Tables”
</a>
.
</p>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/mysql-shell-tutorial-python-documents-collections.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="mysql-shell-tutorial-python-documents-collections">
</a>
22.4.3 Documents and Collections
</h3>
</div>
</div>
</div>
<div class="toc">
<dl class="toc">
<dt>
<span class="section">
<a href="mysql-shell-tutorial-python-collections-operations.html">
22.4.3.1 Create, List, and Drop Collections
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="mysql-shell-tutorial-python-documents-add.html">
22.4.3.2 Working with Collections
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="mysql-shell-tutorial-python-documents-find.html">
22.4.3.3 Find Documents
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="mysql-shell-tutorial-python-documents-modify.html">
22.4.3.4 Modify Documents
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="mysql-shell-tutorial-python-documents-remove.html">
22.4.3.5 Remove Documents
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="mysql-shell-tutorial-python-documents-index.html">
22.4.3.6 Create and Drop Indexes
</a>
</span>
</dt>
</dl>
</div>
<a class="indexterm" name="idm46045127308976">
</a>
<p>
When you are using MySQL as a Document Store, collections are
containers within a schema that you can create, list, and drop.
Collections contain JSON documents that you can add, find, update,
and remove.
</p>
<p>
The examples in this section use the
<code class="literal">
countryinfo
</code>
collection in the
<code class="literal">
world_x
</code>
schema. For instructions on setting up
the
<code class="literal">
world_x
</code>
schema, see
<a class="xref" href="mysql-shell-tutorial-python-download.html" title="22.4.2 Download and Import world_x Database">
Section 22.4.2, “Download and Import world_x Database”
</a>
.
</p>
<h4>
<a name="mysql-shell-tutorial-python-documents">
</a>
Documents
</h4>
<p>
In MySQL, documents are represented as JSON objects. Internally,
they are stored in an efficient binary format that enables fast
lookups and updates.
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Simple document format for Python:
</p>
<pre class="screen">{"field1": "value", "field2" : 10, "field 3": null}
</pre>
</li>
</ul>
</div>
<p>
An array of documents consists of a set of documents separated by
commas and enclosed within
<code class="literal">
[
</code>
and
<code class="literal">
]
</code>
characters.
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Simple array of documents for Python:
</p>
<pre class="screen">[{"Name": "Aruba", "Code:": "ABW"}, {"Name": "Angola", "Code:": "AGO"}]
</pre>
</li>
</ul>
</div>
<p>
MySQL supports the following Python value types in JSON documents:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
numbers (integer and floating point)
</p>
</li>
<li class="listitem">
<p>
strings
</p>
</li>
<li class="listitem">
<p>
boolean (False and True)
</p>
</li>
<li class="listitem">
<p>
None
</p>
</li>
<li class="listitem">
<p>
arrays of more JSON values
</p>
</li>
<li class="listitem">
<p>
nested (or embedded) objects of more JSON values
</p>
</li>
</ul>
</div>
<h4>
<a name="mysql-shell-tutorial-python-collections">
</a>
Collections
</h4>
<p>
Collections are containers for documents that share a purpose and
possibly share one or more indexes. Each collection has a unique
name and exists within a single schema.
</p>
<p>
The term schema is equivalent to a database, which means a group
of database objects as opposed to a relational schema, used to
enforce structure and constraints over data. A schema does not
enforce conformity on the documents in a collection.
</p>
<p>
In this quick-start guide:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Basic objects include:
</p>
<div class="informaltable">
<table summary="Objects to use interactively in MySQL Shell">
<colgroup>
<col style="width: 40%"/>
<col style="width: 60%"/>
</colgroup>
<thead>
<tr>
<th>
Object form
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<code class="literal">
db
</code>
</td>
<td>
<code class="literal">
db
</code>
is a global variable assigned to the current
active schema. When you want to run operations against
the schema, for example to retrieve a collection, you
use methods available for the
<code class="literal">
db
</code>
variable.
</td>
</tr>
<tr>
<td>
<code class="literal">
db.get_collections()
</code>
</td>
<td>
<a class="link" href="mysql-shell-tutorial-python-collections-operations.html#mysql-shell-tutorial-python-collections-get" title="List Collections">
db.get_collections()
</a>
returns a list of collections in the schema. Use the
list to get references to collection objects, iterate
over them, and so on.
</td>
</tr>
</tbody>
</table>
</div>
</li>
<li class="listitem">
<p>
Basic operations scoped by collections include:
</p>
<div class="informaltable">
<table summary="CRUD operations available in X DevAPI">
<colgroup>
<col style="width: 40%"/>
<col style="width: 60%"/>
</colgroup>
<thead>
<tr>
<th>
Operation form
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<code class="literal">
db.
<em class="replaceable">
<code>
name
</code>
</em>
.add()
</code>
</td>
<td>
The
<a class="link" href="mysql-shell-tutorial-python-documents-add.html" title="22.4.3.2 Working with Collections">
add()
</a>
method inserts one document or a list of documents into
the named collection.
</td>
</tr>
<tr>
<td>
<code class="literal">
db.
<em class="replaceable">
<code>
name
</code>
</em>
.find()
</code>
</td>
<td>
The
<a class="link" href="mysql-shell-tutorial-python-documents-find.html" title="22.4.3.3 Find Documents">
find()
</a>
method returns some or all documents in the named
collection.
</td>
</tr>
<tr>
<td>
<code class="literal">
db.
<em class="replaceable">
<code>
name
</code>
</em>
.modify()
</code>
</td>
<td>
The
<a class="link" href="mysql-shell-tutorial-python-documents-modify.html" title="22.4.3.4 Modify Documents">
modify()
</a>
method updates documents in the named collection.
</td>
</tr>
<tr>
<td>
<code class="literal">
db.
<em class="replaceable">
<code>
name
</code>
</em>
.remove()
</code>
</td>
<td>
The
<a class="link" href="mysql-shell-tutorial-python-documents-remove.html" title="22.4.3.5 Remove Documents">
remove()
</a>
method deletes one document or a list of documents from
the named collection.
</td>
</tr>
</tbody>
</table>
</div>
</li>
</ul>
</div>
<h4>
<a name="idm46045127250768">
</a>
Related Information
</h4>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
See
<a class="ulink" href="/doc/x-devapi-userguide/en/devapi-users-working-with-collections.html" target="_top">
Working with Collections
</a>
for a general overview.
</p>
</li>
<li class="listitem">
<p>
<a class="ulink" href="/doc/x-devapi-userguide/en/mysql-x-crud-ebnf-definitions.html" target="_top">
CRUD EBNF Definitions
</a>
provides a
complete list of operations.
</p>
</li>
</ul>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/external-locking.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="external-locking">
</a>
10.11.5 External Locking
</h3>
</div>
</div>
</div>
<a class="indexterm" name="idm46045222584576">
</a>
<a class="indexterm" name="idm46045222583504">
</a>
<p>
External locking is the use of file system locking to manage
contention for
<a class="link" href="myisam-storage-engine.html" title="18.2 The MyISAM Storage Engine">
<code class="literal">
MyISAM
</code>
</a>
database
tables by multiple processes. External locking is used in
situations where a single process such as the MySQL server
cannot be assumed to be the only process that requires access to
tables. Here are some examples:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
If you run multiple servers that use the same database
directory (not recommended), each server must have external
locking enabled.
</p>
</li>
<li class="listitem">
<p>
If you use
<a class="link" href="myisamchk.html" title="6.6.4 myisamchk — MyISAM Table-Maintenance Utility">
<span class="command">
<strong>
myisamchk
</strong>
</span>
</a>
to perform table
maintenance operations on
<a class="link" href="myisam-storage-engine.html" title="18.2 The MyISAM Storage Engine">
<code class="literal">
MyISAM
</code>
</a>
tables, you must either
ensure that the server is not running, or that the server
has external locking enabled so that it locks table files as
necessary to coordinate with
<a class="link" href="myisamchk.html" title="6.6.4 myisamchk — MyISAM Table-Maintenance Utility">
<span class="command">
<strong>
myisamchk
</strong>
</span>
</a>
for access to the tables. The same is true for use of
<a class="link" href="myisampack.html" title="6.6.6 myisampack — Generate Compressed, Read-Only MyISAM Tables">
<span class="command">
<strong>
myisampack
</strong>
</span>
</a>
to pack
<a class="link" href="myisam-storage-engine.html" title="18.2 The MyISAM Storage Engine">
<code class="literal">
MyISAM
</code>
</a>
tables.
</p>
<p>
If the server is run with external locking enabled, you can
use
<a class="link" href="myisamchk.html" title="6.6.4 myisamchk — MyISAM Table-Maintenance Utility">
<span class="command">
<strong>
myisamchk
</strong>
</span>
</a>
at any time for read
operations such a checking tables. In this case, if the
server tries to update a table that
<a class="link" href="myisamchk.html" title="6.6.4 myisamchk — MyISAM Table-Maintenance Utility">
<span class="command">
<strong>
myisamchk
</strong>
</span>
</a>
is using, the server waits for
<a class="link" href="myisamchk.html" title="6.6.4 myisamchk — MyISAM Table-Maintenance Utility">
<span class="command">
<strong>
myisamchk
</strong>
</span>
</a>
to finish before it continues.
</p>
<p>
If you use
<a class="link" href="myisamchk.html" title="6.6.4 myisamchk — MyISAM Table-Maintenance Utility">
<span class="command">
<strong>
myisamchk
</strong>
</span>
</a>
for write operations
such as repairing or optimizing tables, or if you use
<a class="link" href="myisampack.html" title="6.6.6 myisampack — Generate Compressed, Read-Only MyISAM Tables">
<span class="command">
<strong>
myisampack
</strong>
</span>
</a>
to pack tables, you
<span class="emphasis">
<em>
must
</em>
</span>
always ensure that the
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
server is not using the table. If
you do not stop
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
, at least do a
<a class="link" href="mysqladmin.html" title="6.5.2 mysqladmin — A MySQL Server Administration Program">
<span class="command">
<strong>
mysqladmin flush-tables
</strong>
</span>
</a>
before you run
<a class="link" href="myisamchk.html" title="6.6.4 myisamchk — MyISAM Table-Maintenance Utility">
<span class="command">
<strong>
myisamchk
</strong>
</span>
</a>
. Your tables
<span class="emphasis">
<em>
may
become corrupted
</em>
</span>
if the server and
<a class="link" href="myisamchk.html" title="6.6.4 myisamchk — MyISAM Table-Maintenance Utility">
<span class="command">
<strong>
myisamchk
</strong>
</span>
</a>
access the tables
simultaneously.
</p>
</li>
</ul>
</div>
<p>
With external locking in effect, each process that requires
access to a table acquires a file system lock for the table
files before proceeding to access the table. If all necessary
locks cannot be acquired, the process is blocked from accessing
the table until the locks can be obtained (after the process
that currently holds the locks releases them).
</p>
<p>
External locking affects server performance because the server
must sometimes wait for other processes before it can access
tables.
</p>
<p>
External locking is unnecessary if you run a single server to
access a given data directory (which is the usual case) and if
no other programs such as
<a class="link" href="myisamchk.html" title="6.6.4 myisamchk — MyISAM Table-Maintenance Utility">
<span class="command">
<strong>
myisamchk
</strong>
</span>
</a>
need to
modify tables while the server is running. If you only
<span class="emphasis">
<em>
read
</em>
</span>
tables with other programs, external
locking is not required, although
<a class="link" href="myisamchk.html" title="6.6.4 myisamchk — MyISAM Table-Maintenance Utility">
<span class="command">
<strong>
myisamchk
</strong>
</span>
</a>
might report warnings if the server changes tables while
<a class="link" href="myisamchk.html" title="6.6.4 myisamchk — MyISAM Table-Maintenance Utility">
<span class="command">
<strong>
myisamchk
</strong>
</span>
</a>
is reading them.
</p>
<p>
With external locking disabled, to use
<a class="link" href="myisamchk.html" title="6.6.4 myisamchk — MyISAM Table-Maintenance Utility">
<span class="command">
<strong>
myisamchk
</strong>
</span>
</a>
, you must either stop the server
while
<a class="link" href="myisamchk.html" title="6.6.4 myisamchk — MyISAM Table-Maintenance Utility">
<span class="command">
<strong>
myisamchk
</strong>
</span>
</a>
executes or else lock and
flush the tables before running
<a class="link" href="myisamchk.html" title="6.6.4 myisamchk — MyISAM Table-Maintenance Utility">
<span class="command">
<strong>
myisamchk
</strong>
</span>
</a>
. To
avoid this requirement, use the
<a class="link" href="check-table.html" title="15.7.3.2 CHECK TABLE Statement">
<code class="literal">
CHECK
TABLE
</code>
</a>
and
<a class="link" href="repair-table.html" title="15.7.3.5 REPAIR TABLE Statement">
<code class="literal">
REPAIR TABLE
</code>
</a>
statements to check and repair
<a class="link" href="myisam-storage-engine.html" title="18.2 The MyISAM Storage Engine">
<code class="literal">
MyISAM
</code>
</a>
tables.
</p>
<p>
For
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
, external locking is controlled by
the value of the
<a class="link" href="server-system-variables.html#sysvar_skip_external_locking">
<code class="literal">
skip_external_locking
</code>
</a>
system
variable. When this variable is enabled, external locking is
disabled, and vice versa. External locking is disabled by
default.
</p>
<p>
Use of external locking can be controlled at server startup by
using the
<a class="link" href="server-options.html#option_mysqld_external-locking">
<code class="option">
--external-locking
</code>
</a>
or
<a class="link" href="server-options.html#option_mysqld_external-locking">
<code class="option">
--skip-external-locking
</code>
</a>
option.
</p>
<p>
If you do use external locking option to enable updates to
<a class="link" href="myisam-storage-engine.html" title="18.2 The MyISAM Storage Engine">
<code class="literal">
MyISAM
</code>
</a>
tables from many MySQL
processes, do not start the server with the
<a class="link" href="server-system-variables.html#sysvar_delay_key_write">
<code class="literal">
delay_key_write
</code>
</a>
system variable
set to
<code class="literal">
ALL
</code>
or use the
<code class="literal">
DELAY_KEY_WRITE=1
</code>
table option for any shared
tables. Otherwise, index corruption can occur.
</p>
<p>
The easiest way to satisfy this condition is to always use
<a class="link" href="server-options.html#option_mysqld_external-locking">
<code class="option">
--external-locking
</code>
</a>
together with
<a class="link" href="server-system-variables.html#sysvar_delay_key_write">
<code class="option">
--delay-key-write=OFF
</code>
</a>
. (This is
not done by default because in many setups it is useful to have
a mixture of the preceding options.)
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/federated-create.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="federated-create">
</a>
18.8.2 How to Create FEDERATED Tables
</h3>
</div>
</div>
</div>
<div class="toc">
<dl class="toc">
<dt>
<span class="section">
<a href="federated-create-connection.html">
18.8.2.1 Creating a FEDERATED Table Using CONNECTION
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="federated-create-server.html">
18.8.2.2 Creating a FEDERATED Table Using CREATE SERVER
</a>
</span>
</dt>
</dl>
</div>
<p>
To create a
<code class="literal">
FEDERATED
</code>
table you should follow
these steps:
</p>
<div class="orderedlist">
<ol class="orderedlist" type="1">
<li class="listitem">
<p>
Create the table on the remote server. Alternatively, make a
note of the table definition of an existing table, perhaps
using the
<a class="link" href="show-create-table.html" title="15.7.7.11 SHOW CREATE TABLE Statement">
<code class="literal">
SHOW CREATE TABLE
</code>
</a>
statement.
</p>
</li>
<li class="listitem">
<p>
Create the table on the local server with an identical table
definition, but adding the connection information that links
the local table to the remote table.
</p>
</li>
</ol>
</div>
<p>
For example, you could create the following table on the remote
server:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa1427744"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> test_table <span class="token punctuation">(</span>
id <span class="token datatype">INT</span><span class="token punctuation">(</span><span class="token number">20</span><span class="token punctuation">)</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span> <span class="token keyword">AUTO_INCREMENT</span><span class="token punctuation">,</span>
<span class="token keyword">name</span> <span class="token datatype">VARCHAR</span><span class="token punctuation">(</span><span class="token number">32</span><span class="token punctuation">)</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span> <span class="token keyword">DEFAULT</span> <span class="token string">''</span><span class="token punctuation">,</span>
other <span class="token datatype">INT</span><span class="token punctuation">(</span><span class="token number">20</span><span class="token punctuation">)</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span> <span class="token keyword">DEFAULT</span> <span class="token string">'0'</span><span class="token punctuation">,</span>
<span class="token keyword">PRIMARY</span> <span class="token keyword">KEY</span> <span class="token punctuation">(</span>id<span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token keyword">INDEX</span> <span class="token keyword">name</span> <span class="token punctuation">(</span><span class="token keyword">name</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token keyword">INDEX</span> other_key <span class="token punctuation">(</span>other<span class="token punctuation">)</span>
<span class="token punctuation">)</span>
<span class="token keyword">ENGINE</span><span class="token operator">=</span>MyISAM
<span class="token keyword">DEFAULT</span> <span class="token keyword">CHARSET</span><span class="token operator">=</span>utf8mb4<span class="token punctuation">;</span></code></pre>
</div>
<p>
To create the local table that is federated to the remote table,
there are two options available. You can either create the local
table and specify the connection string (containing the server
name, login, password) to be used to connect to the remote table
using the
<code class="literal">
CONNECTION
</code>
, or you can use an
existing connection that you have previously created using the
<a class="link" href="create-server.html" title="15.1.18 CREATE SERVER Statement">
<code class="literal">
CREATE SERVER
</code>
</a>
statement.
</p>
<div class="important" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Important
</div>
<p>
When you create the local table it
<span class="emphasis">
<em>
must
</em>
</span>
have an identical field definition to the remote table.
</p>
</div>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
You can improve the performance of a
<code class="literal">
FEDERATED
</code>
table by adding indexes to the
table on the host. The optimization occurs because the query
sent to the remote server includes the contents of the
<code class="literal">
WHERE
</code>
clause and is sent to the remote server
and subsequently executed locally. This reduces the network
traffic that would otherwise request the entire table from the
server for local processing.
</p>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/select-into.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="select-into">
</a>
15.2.13.1 SELECT ... INTO Statement
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045180693408">
</a>
<a class="indexterm" name="idm46045180691952">
</a>
<p>
The
<a class="link" href="select-into.html" title="15.2.13.1 SELECT ... INTO Statement">
<code class="literal">
SELECT ...
INTO
</code>
</a>
form of
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
enables a query result to be stored in variables or written to a
file:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
SELECT ... INTO
<em class="replaceable">
<code>
var_list
</code>
</em>
</code>
selects column
values and stores them into variables.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SELECT ... INTO OUTFILE
</code>
writes the
selected rows to a file. Column and line terminators can be
specified to produce a specific output format.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SELECT ... INTO DUMPFILE
</code>
writes a single
row to a file without any formatting.
</p>
</li>
</ul>
</div>
<p>
A given
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
statement can
contain at most one
<code class="literal">
INTO
</code>
clause, although as
shown by the
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
syntax
description (see
<a class="xref" href="select.html" title="15.2.13 SELECT Statement">
Section 15.2.13, “SELECT Statement”
</a>
), the
<code class="literal">
INTO
</code>
can appear in different positions:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Before
<code class="literal">
FROM
</code>
. Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa60742057"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">INTO</span> <span class="token variable">@myvar</span> <span class="token keyword">FROM</span> t1<span class="token punctuation">;</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
Before a trailing locking clause. Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa7355401"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t1 <span class="token keyword">INTO</span> <span class="token variable">@myvar</span> <span class="token keyword">FOR</span> <span class="token keyword">UPDATE</span><span class="token punctuation">;</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
At the end of the
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
.
Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa60378267"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t1 <span class="token keyword">FOR</span> <span class="token keyword">UPDATE</span> <span class="token keyword">INTO</span> <span class="token variable">@myvar</span><span class="token punctuation">;</span></code></pre>
</div>
</li>
</ul>
</div>
<p>
The
<code class="literal">
INTO
</code>
position at the end of the statement
is the preferred position. The position before a locking clause
is deprecated; expect support for it to be removed in a future
version of MySQL. In other words,
<code class="literal">
INTO
</code>
after
<code class="literal">
FROM
</code>
but not at the end of the
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
produces a warning.
</p>
<p>
An
<code class="literal">
INTO
</code>
clause should not be used in a nested
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
because such a
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
must return its result to
the outer context. There are also constraints on the use of
<code class="literal">
INTO
</code>
within
<a class="link" href="union.html" title="15.2.18 UNION Clause">
<code class="literal">
UNION
</code>
</a>
statements; see
<a class="xref" href="union.html" title="15.2.18 UNION Clause">
Section 15.2.18, “UNION Clause”
</a>
.
</p>
<p>
For the
<code class="literal">
INTO
<em class="replaceable">
<code>
var_list
</code>
</em>
</code>
variant:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<em class="replaceable">
<code>
var_list
</code>
</em>
names a list of one or
more variables, each of which can be a user-defined
variable, stored procedure or function parameter, or stored
program local variable. (Within a prepared
<code class="literal">
SELECT
... INTO
<em class="replaceable">
<code>
var_list
</code>
</em>
</code>
statement, only user-defined variables are permitted; see
<a class="xref" href="local-variable-scope.html" title="15.6.4.2 Local Variable Scope and Resolution">
Section 15.6.4.2, “Local Variable Scope and Resolution”
</a>
.)
</p>
</li>
<li class="listitem">
<p>
The selected values are assigned to the variables. The
number of variables must match the number of columns. The
query should return a single row. If the query returns no
rows, a warning with error code 1329 occurs (
<code class="literal">
No
data
</code>
), and the variable values remain unchanged.
If the query returns multiple rows, error 1172 occurs
(
<code class="literal">
Result consisted of more than one row
</code>
).
If it is possible that the statement may retrieve multiple
rows, you can use
<code class="literal">
LIMIT 1
</code>
to limit the
result set to a single row.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa21860490"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> id<span class="token punctuation">,</span> <span class="token keyword">data</span> <span class="token keyword">INTO</span> <span class="token variable">@x</span><span class="token punctuation">,</span> <span class="token variable">@y</span> <span class="token keyword">FROM</span> test<span class="token punctuation">.</span>t1 <span class="token keyword">LIMIT</span> <span class="token number">1</span><span class="token punctuation">;</span></code></pre>
</div>
</li>
</ul>
</div>
<a class="indexterm" name="idm46045180649264">
</a>
<a class="indexterm" name="idm46045180647776">
</a>
<p>
<code class="literal">
INTO
<em class="replaceable">
<code>
var_list
</code>
</em>
</code>
can
also be used with a
<a class="link" href="table.html" title="15.2.16 TABLE Statement">
<code class="literal">
TABLE
</code>
</a>
statement, subject to these restrictions:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
The number of variables must match the number of columns in
the table.
</p>
</li>
<li class="listitem">
<p>
If the table contains more than one row, you must use
<code class="literal">
LIMIT 1
</code>
to limit the result set to a
single row.
<code class="literal">
LIMIT 1
</code>
must precede the
<code class="literal">
INTO
</code>
keyword.
</p>
</li>
</ul>
</div>
<p>
An example of such a statement is shown here:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa74939026"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">TABLE</span> employees <span class="token keyword">ORDER</span> <span class="token keyword">BY</span> lname <span class="token keyword">DESC</span> <span class="token keyword">LIMIT</span> <span class="token number">1</span>
<span class="token keyword">INTO</span> <span class="token variable">@id</span><span class="token punctuation">,</span> <span class="token variable">@fname</span><span class="token punctuation">,</span> <span class="token variable">@lname</span><span class="token punctuation">,</span> <span class="token variable">@hired</span><span class="token punctuation">,</span> <span class="token variable">@separated</span><span class="token punctuation">,</span> <span class="token variable">@job_code</span><span class="token punctuation">,</span> <span class="token variable">@store_id</span><span class="token punctuation">;</span></code></pre>
</div>
<a class="indexterm" name="idm46045180637760">
</a>
<a class="indexterm" name="idm46045180636272">
</a>
<p>
You can also select values from a
<a class="link" href="values.html" title="15.2.19 VALUES Statement">
<code class="literal">
VALUES
</code>
</a>
statement that generates a
single row into a set of user variables. In this case, you must
employ a table alias, and you must assign each value from the
value list to a variable. Each of the two statements shown here
is equivalent to
<a class="link" href="set-variable.html" title="15.7.6.1 SET Syntax for Variable Assignment">
<code class="literal">
SET @x=2, @y=4,
@z=8
</code>
</a>
:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa19051156"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> <span class="token punctuation">(</span><span class="token keyword">VALUES</span> <span class="token keyword">ROW</span><span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">,</span><span class="token number">4</span><span class="token punctuation">,</span><span class="token number">8</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token keyword">AS</span> t <span class="token keyword">INTO</span> <span class="token variable">@x</span><span class="token punctuation">,</span><span class="token variable">@y</span><span class="token punctuation">,</span><span class="token variable">@z</span><span class="token punctuation">;</span>
<span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> <span class="token punctuation">(</span><span class="token keyword">VALUES</span> <span class="token keyword">ROW</span><span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">,</span><span class="token number">4</span><span class="token punctuation">,</span><span class="token number">8</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token keyword">AS</span> t<span class="token punctuation">(</span>a<span class="token punctuation">,</span>b<span class="token punctuation">,</span>c<span class="token punctuation">)</span> <span class="token keyword">INTO</span> <span class="token variable">@x</span><span class="token punctuation">,</span><span class="token variable">@y</span><span class="token punctuation">,</span><span class="token variable">@z</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
User variable names are not case-sensitive. See
<a class="xref" href="user-variables.html" title="11.4 User-Defined Variables">
Section 11.4, “User-Defined Variables”
</a>
.
</p>
<a class="indexterm" name="idm46045180629440">
</a>
<a class="indexterm" name="idm46045180628368">
</a>
<p>
The
<a class="link" href="select-into.html" title="15.2.13.1 SELECT ... INTO Statement">
<code class="literal">
SELECT ... INTO
OUTFILE '
<em class="replaceable">
<code>
file_name
</code>
</em>
'
</code>
</a>
form of
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
writes the selected rows
to a file. The file is created on the server host, so you must
have the
<a class="link" href="privileges-provided.html#priv_file">
<code class="literal">
FILE
</code>
</a>
privilege to use
this syntax.
<em class="replaceable">
<code>
file_name
</code>
</em>
cannot be an
existing file, which among other things prevents files such as
<code class="filename">
/etc/passwd
</code>
and database tables from being
modified. The
<a class="link" href="server-system-variables.html#sysvar_character_set_filesystem">
<code class="literal">
character_set_filesystem
</code>
</a>
system
variable controls the interpretation of the file name.
</p>
<p>
The
<a class="link" href="select-into.html" title="15.2.13.1 SELECT ... INTO Statement">
<code class="literal">
SELECT ... INTO
OUTFILE
</code>
</a>
statement is intended to enable dumping a
table to a text file on the server host. To create the resulting
file on some other host,
<a class="link" href="select-into.html" title="15.2.13.1 SELECT ... INTO Statement">
<code class="literal">
SELECT ... INTO
OUTFILE
</code>
</a>
normally is unsuitable because there is no way
to write a path to the file relative to the server host file
system, unless the location of the file on the remote host can
be accessed using a network-mapped path on the server host file
system.
</p>
<p>
Alternatively, if the MySQL client software is installed on the
remote host, you can use a client command such as
<code class="literal">
mysql
-e "SELECT ..." >
<em class="replaceable">
<code>
file_name
</code>
</em>
</code>
to generate the
file on that host.
</p>
<p>
<a class="link" href="select-into.html" title="15.2.13.1 SELECT ... INTO Statement">
<code class="literal">
SELECT ... INTO
OUTFILE
</code>
</a>
is the complement of
<a class="link" href="load-data.html" title="15.2.9 LOAD DATA Statement">
<code class="literal">
LOAD
DATA
</code>
</a>
. Column values are written converted to the
character set specified in the
<code class="literal">
CHARACTER SET
</code>
clause. If no such clause is present, values are dumped using
the
<code class="literal">
binary
</code>
character set. In effect, there is
no character set conversion. If a result set contains columns in
several character sets, so is the output data file, and it may
not be possible to reload the file correctly.
</p>
<p>
The syntax for the
<em class="replaceable">
<code>
export_options
</code>
</em>
part of the statement consists of the same
<code class="literal">
FIELDS
</code>
and
<code class="literal">
LINES
</code>
clauses
that are used with the
<a class="link" href="load-data.html" title="15.2.9 LOAD DATA Statement">
<code class="literal">
LOAD DATA
</code>
</a>
statement. For information about the
<code class="literal">
FIELDS
</code>
and
<code class="literal">
LINES
</code>
clauses, including their default
values and permissible values, see
<a class="xref" href="load-data.html" title="15.2.9 LOAD DATA Statement">
Section 15.2.9, “LOAD DATA Statement”
</a>
.
</p>
<p>
<code class="literal">
FIELDS ESCAPED BY
</code>
controls how to write
special characters. If the
<code class="literal">
FIELDS ESCAPED BY
</code>
character is not empty, it is used when necessary to avoid
ambiguity as a prefix that precedes following characters on
output:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
The
<code class="literal">
FIELDS ESCAPED BY
</code>
character
</p>
</li>
<li class="listitem">
<p>
The
<code class="literal">
FIELDS [OPTIONALLY] ENCLOSED BY
</code>
character
</p>
</li>
<li class="listitem">
<p>
The first character of the
<code class="literal">
FIELDS TERMINATED
BY
</code>
and
<code class="literal">
LINES TERMINATED BY
</code>
values
</p>
</li>
<li class="listitem">
<p>
ASCII
<code class="literal">
NUL
</code>
(the zero-valued byte; what is
actually written following the escape character is ASCII
<code class="literal">
0
</code>
, not a zero-valued byte)
</p>
</li>
</ul>
</div>
<p>
The
<code class="literal">
FIELDS TERMINATED BY
</code>
,
<code class="literal">
ENCLOSED
BY
</code>
,
<code class="literal">
ESCAPED BY
</code>
, or
<code class="literal">
LINES
TERMINATED BY
</code>
characters
<span class="emphasis">
<em>
must
</em>
</span>
be
escaped so that you can read the file back in reliably. ASCII
<code class="literal">
NUL
</code>
is escaped to make it easier to view with
some pagers.
</p>
<p>
The resulting file need not conform to SQL syntax, so nothing
else need be escaped.
</p>
<p>
If the
<code class="literal">
FIELDS ESCAPED BY
</code>
character is empty,
no characters are escaped and
<code class="literal">
NULL
</code>
is output
as
<code class="literal">
NULL
</code>
, not
<code class="literal">
\N
</code>
. It is
probably not a good idea to specify an empty escape character,
particularly if field values in your data contain any of the
characters in the list just given.
</p>
<a class="indexterm" name="idm46045180586000">
</a>
<p>
<code class="literal">
INTO OUTFILE
</code>
can also be used with a
<a class="link" href="table.html" title="15.2.16 TABLE Statement">
<code class="literal">
TABLE
</code>
</a>
statement when you want to
dump all columns of a table into a text file. In this case, the
ordering and number of rows can be controlled using
<code class="literal">
ORDER BY
</code>
and
<code class="literal">
LIMIT
</code>
; these
clauses must precede
<code class="literal">
INTO OUTFILE
</code>
.
<code class="literal">
TABLE ... INTO OUTFILE
</code>
supports the same
<em class="replaceable">
<code>
export_options
</code>
</em>
as does
<code class="literal">
SELECT ... INTO OUTFILE
</code>
, and it is subject to
the same restrictions on writing to the file system. An example
of such a statement is shown here:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa10031898"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">TABLE</span> employees <span class="token keyword">ORDER</span> <span class="token keyword">BY</span> lname <span class="token keyword">LIMIT</span> <span class="token number">1000</span>
<span class="token keyword">INTO</span> <span class="token keyword">OUTFILE</span> <span class="token string">'/tmp/employee_data_1.txt'</span>
<span class="token keyword">FIELDS</span> <span class="token keyword">TERMINATED</span> <span class="token keyword">BY</span> <span class="token string">','</span> <span class="token keyword">OPTIONALLY</span> <span class="token keyword">ENCLOSED</span> <span class="token keyword">BY</span> <span class="token string">'"'</span><span class="token punctuation">,</span> <span class="token keyword">ESCAPED</span> <span class="token keyword">BY</span> <span class="token string">'\'
LINES TERMINATED BY '</span>\n'<span class="token punctuation">;</span></code></pre>
</div>
<p>
You can also use
<code class="literal">
SELECT ... INTO OUTFILE
</code>
with
a
<a class="link" href="values.html" title="15.2.19 VALUES Statement">
<code class="literal">
VALUES
</code>
</a>
statement to write
values directly into a file. An example is shown here:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa37421590"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> <span class="token punctuation">(</span><span class="token keyword">VALUES</span> <span class="token keyword">ROW</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">,</span><span class="token number">2</span><span class="token punctuation">,</span><span class="token number">3</span><span class="token punctuation">)</span><span class="token punctuation">,</span><span class="token keyword">ROW</span><span class="token punctuation">(</span><span class="token number">4</span><span class="token punctuation">,</span><span class="token number">5</span><span class="token punctuation">,</span><span class="token number">6</span><span class="token punctuation">)</span><span class="token punctuation">,</span><span class="token keyword">ROW</span><span class="token punctuation">(</span><span class="token number">7</span><span class="token punctuation">,</span><span class="token number">8</span><span class="token punctuation">,</span><span class="token number">9</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token keyword">AS</span> t
<span class="token keyword">INTO</span> <span class="token keyword">OUTFILE</span> <span class="token string">'/tmp/select-values.txt'</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
You must use a table alias; column aliases are also supported,
and can optionally be used to write values only from desired
columns. You can also use any or all of the export options
supported by
<code class="literal">
SELECT ... INTO OUTFILE
</code>
to
format the output to the file.
</p>
<a class="indexterm" name="idm46045180571824">
</a>
<a class="indexterm" name="idm46045180570752">
</a>
<p>
Here is an example that produces a file in the comma-separated
values (CSV) format used by many programs:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa87469967"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> a<span class="token punctuation">,</span>b<span class="token punctuation">,</span>a<span class="token operator">+</span>b <span class="token keyword">INTO</span> <span class="token keyword">OUTFILE</span> <span class="token string">'/tmp/result.txt'</span>
<span class="token keyword">FIELDS</span> <span class="token keyword">TERMINATED</span> <span class="token keyword">BY</span> <span class="token string">','</span> <span class="token keyword">OPTIONALLY</span> <span class="token keyword">ENCLOSED</span> <span class="token keyword">BY</span> <span class="token string">'"'</span>
<span class="token keyword">LINES</span> <span class="token keyword">TERMINATED</span> <span class="token keyword">BY</span> <span class="token string">'\n'</span>
<span class="token keyword">FROM</span> test_table<span class="token punctuation">;</span></code></pre>
</div>
<a class="indexterm" name="idm46045180568080">
</a>
<p>
If you use
<code class="literal">
INTO DUMPFILE
</code>
instead of
<code class="literal">
INTO OUTFILE
</code>
, MySQL writes only one row into
the file, without any column or line termination and without
performing any escape processing. This is useful for selecting a
<a class="link" href="blob.html" title="13.3.4 The BLOB and TEXT Types">
<code class="literal">
BLOB
</code>
</a>
value and storing it in a
file.
</p>
<p>
<a class="link" href="table.html" title="15.2.16 TABLE Statement">
<code class="literal">
TABLE
</code>
</a>
also supports
<code class="literal">
INTO
DUMPFILE
</code>
. If the table contains more than one row, you
must also use
<code class="literal">
LIMIT 1
</code>
to limit the output to
a single row.
<code class="literal">
INTO DUMPFILE
</code>
can also be used
with
<code class="literal">
SELECT * FROM (VALUES ROW()[, ...]) AS
<em class="replaceable">
<code>
table_alias
</code>
</em>
[LIMIT 1]
</code>
. See
<a class="xref" href="values.html" title="15.2.19 VALUES Statement">
Section 15.2.19, “VALUES Statement”
</a>
.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
Any file created by
<code class="literal">
INTO OUTFILE
</code>
or
<code class="literal">
INTO DUMPFILE
</code>
is owned by the operating
system user under whose account
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
runs. (You should
<span class="emphasis">
<em>
never
</em>
</span>
run
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
as
<code class="literal">
root
</code>
for this
and other reasons.) The umask for file creation is 0640; you
must have sufficient access privileges to manipulate the file
contents.
</p>
<p>
If the
<a class="link" href="server-system-variables.html#sysvar_secure_file_priv">
<code class="literal">
secure_file_priv
</code>
</a>
system variable is set to a nonempty directory name, the file
to be written must be located in that directory.
</p>
</div>
<p>
In the context of
<a class="link" href="select-into.html" title="15.2.13.1 SELECT ... INTO Statement">
<code class="literal">
SELECT ...
INTO
</code>
</a>
statements that occur as part of events executed
by the Event Scheduler, diagnostics messages (not only errors,
but also warnings) are written to the error log, and, on
Windows, to the application event log. For additional
information, see
<a class="xref" href="events-status-info.html" title="27.4.5 Event Scheduler Status">
Section 27.4.5, “Event Scheduler Status”
</a>
.
</p>
<p>
Support is provided for periodic synchronization of output files
written to by
<code class="literal">
SELECT INTO OUTFILE
</code>
and
<code class="literal">
SELECT INTO DUMPFILE
</code>
, enabled by setting the
<a class="link" href="server-system-variables.html#sysvar_select_into_disk_sync">
<code class="literal">
select_into_disk_sync
</code>
</a>
server
system variable introduced in that version. Output buffer size
and optional delay can be set using, respectively,
<a class="link" href="server-system-variables.html#sysvar_select_into_buffer_size">
<code class="literal">
select_into_buffer_size
</code>
</a>
and
<a class="link" href="server-system-variables.html#sysvar_select_into_disk_sync_delay">
<code class="literal">
select_into_disk_sync_delay
</code>
</a>
.
For more information, see the descriptions of these system
variables.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/group-by-functional-dependence.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="group-by-functional-dependence">
</a>
14.19.4 Detection of Functional Dependence
</h3>
</div>
</div>
</div>
<a class="indexterm" name="idm46045192451712">
</a>
<p>
The following discussion provides several examples of the ways
in which MySQL detects functional dependencies. The examples use
this notation:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa5064259"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql">{<em class="replaceable">X</em>} <span class="token operator">-</span><span class="token operator">></span> {<em class="replaceable">Y</em>}</code></pre>
</div>
<p>
Understand this as
<span class="quote">
“
<span class="quote">
<em class="replaceable">
<code>
X
</code>
</em>
uniquely
determines
<em class="replaceable">
<code>
Y
</code>
</em>
,
</span>
”
</span>
which also
means that
<em class="replaceable">
<code>
Y
</code>
</em>
is functionally
dependent on
<em class="replaceable">
<code>
X
</code>
</em>
.
</p>
<p>
The examples use the
<code class="literal">
world
</code>
database, which
can be downloaded from
<a class="ulink" href="/doc/index-other.html" target="_top">
https://dev.mysql.com/doc/index-other.html
</a>
. You can find details
on how to install the database on the same page.
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="xref" href="group-by-functional-dependence.html#functional-dependence-keys" title="Functional Dependencies Derived from Keys">
Functional Dependencies Derived from Keys
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="group-by-functional-dependence.html#functional-dependence-multiple-column-keys" title="Functional Dependencies Derived from Multiple-Column Keys and from Equalities">
Functional Dependencies Derived from Multiple-Column Keys and from
Equalities
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="group-by-functional-dependence.html#functional-dependence-special-cases" title="Functional Dependency Special Cases">
Functional Dependency Special Cases
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="group-by-functional-dependence.html#functional-dependence-views" title="Functional Dependencies and Views">
Functional Dependencies and Views
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="group-by-functional-dependence.html#functional-dependence-combinations" title="Combinations of Functional Dependencies">
Combinations of Functional Dependencies
</a>
</p>
</li>
</ul>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h4 class="title">
<a name="functional-dependence-keys">
</a>
Functional Dependencies Derived from Keys
</h4>
</div>
</div>
</div>
<p>
The following query selects, for each country, a count of
spoken languages:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa56682869"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> co<span class="token punctuation">.</span><span class="token keyword">Name</span><span class="token punctuation">,</span> <span class="token function">COUNT</span><span class="token punctuation">(</span><span class="token operator">*</span><span class="token punctuation">)</span>
<span class="token keyword">FROM</span> countrylanguage cl<span class="token punctuation">,</span> country co
<span class="token keyword">WHERE</span> cl<span class="token punctuation">.</span>CountryCode <span class="token operator">=</span> co<span class="token punctuation">.</span><span class="token keyword">Code</span>
<span class="token keyword">GROUP</span> <span class="token keyword">BY</span> co<span class="token punctuation">.</span><span class="token keyword">Code</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
<code class="literal">
co.Code
</code>
is a primary key of
<code class="literal">
co
</code>
, so all columns of
<code class="literal">
co
</code>
are functionally dependent on it, as expressed using this
notation:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa97717171"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql">{co<span class="token punctuation">.</span><span class="token keyword">Code</span>} <span class="token operator">-</span><span class="token operator">></span> {co<span class="token punctuation">.</span><span class="token operator">*</span>}</code></pre>
</div>
<p>
Thus,
<code class="literal">
co.name
</code>
is functionally dependent on
<code class="literal">
GROUP BY
</code>
columns and the query is valid.
</p>
<p>
A
<code class="literal">
UNIQUE
</code>
index over a
<code class="literal">
NOT
NULL
</code>
column could be used instead of a primary key
and the same functional dependence would apply. (This is not
true for a
<code class="literal">
UNIQUE
</code>
index that permits
<code class="literal">
NULL
</code>
values because it permits multiple
<code class="literal">
NULL
</code>
values and in that case uniqueness is
lost.)
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h4 class="title">
<a name="functional-dependence-multiple-column-keys">
</a>
Functional Dependencies Derived from Multiple-Column Keys and from
Equalities
</h4>
</div>
</div>
</div>
<p>
This query selects, for each country, a list of all spoken
languages and how many people speak them:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa24628477"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> co<span class="token punctuation">.</span><span class="token keyword">Name</span><span class="token punctuation">,</span> cl<span class="token punctuation">.</span><span class="token keyword">Language</span><span class="token punctuation">,</span>
cl<span class="token punctuation">.</span>Percentage <span class="token operator">*</span> co<span class="token punctuation">.</span>Population <span class="token operator">/</span> <span class="token number">100.0</span> <span class="token keyword">AS</span> SpokenBy
<span class="token keyword">FROM</span> countrylanguage cl<span class="token punctuation">,</span> country co
<span class="token keyword">WHERE</span> cl<span class="token punctuation">.</span>CountryCode <span class="token operator">=</span> co<span class="token punctuation">.</span><span class="token keyword">Code</span>
<span class="token keyword">GROUP</span> <span class="token keyword">BY</span> cl<span class="token punctuation">.</span>CountryCode<span class="token punctuation">,</span> cl<span class="token punctuation">.</span><span class="token keyword">Language</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
The pair (
<code class="literal">
cl.CountryCode
</code>
,
<code class="literal">
cl.Language
</code>
) is a two-column composite
primary key of
<code class="literal">
cl
</code>
, so that column pair
uniquely determines all columns of
<code class="literal">
cl
</code>
:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa42940828"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql">{cl<span class="token punctuation">.</span>CountryCode<span class="token punctuation">,</span> cl<span class="token punctuation">.</span><span class="token keyword">Language</span>} <span class="token operator">-</span><span class="token operator">></span> {cl<span class="token punctuation">.</span><span class="token operator">*</span>}</code></pre>
</div>
<p>
Moreover, because of the equality in the
<code class="literal">
WHERE
</code>
clause:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa99383589"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql">{cl<span class="token punctuation">.</span>CountryCode} <span class="token operator">-</span><span class="token operator">></span> {co<span class="token punctuation">.</span><span class="token keyword">Code</span>}</code></pre>
</div>
<p>
And, because
<code class="literal">
co.Code
</code>
is primary key of
<code class="literal">
co
</code>
:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa81299785"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql">{co<span class="token punctuation">.</span><span class="token keyword">Code</span>} <span class="token operator">-</span><span class="token operator">></span> {co<span class="token punctuation">.</span><span class="token operator">*</span>}</code></pre>
</div>
<p>
<span class="quote">
“
<span class="quote">
Uniquely determines
</span>
”
</span>
relationships are
transitive, therefore:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa61324045"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql">{cl<span class="token punctuation">.</span>CountryCode<span class="token punctuation">,</span> cl<span class="token punctuation">.</span><span class="token keyword">Language</span>} <span class="token operator">-</span><span class="token operator">></span> {cl<span class="token punctuation">.</span><span class="token operator">*</span><span class="token punctuation">,</span>co<span class="token punctuation">.</span><span class="token operator">*</span>}</code></pre>
</div>
<p>
As a result, the query is valid.
</p>
<p>
As with the previous example, a
<code class="literal">
UNIQUE
</code>
key
over
<code class="literal">
NOT NULL
</code>
columns could be used instead
of a primary key.
</p>
<p>
An
<code class="literal">
INNER JOIN
</code>
condition can be used instead
of
<code class="literal">
WHERE
</code>
. The same functional dependencies
apply:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa73833728"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> co<span class="token punctuation">.</span><span class="token keyword">Name</span><span class="token punctuation">,</span> cl<span class="token punctuation">.</span><span class="token keyword">Language</span><span class="token punctuation">,</span>
cl<span class="token punctuation">.</span>Percentage <span class="token operator">*</span> co<span class="token punctuation">.</span>Population<span class="token operator">/</span><span class="token number">100.0</span> <span class="token keyword">AS</span> SpokenBy
<span class="token keyword">FROM</span> countrylanguage cl <span class="token keyword">INNER</span> <span class="token keyword">JOIN</span> country co
<span class="token keyword">ON</span> cl<span class="token punctuation">.</span>CountryCode <span class="token operator">=</span> co<span class="token punctuation">.</span><span class="token keyword">Code</span>
<span class="token keyword">GROUP</span> <span class="token keyword">BY</span> cl<span class="token punctuation">.</span>CountryCode<span class="token punctuation">,</span> cl<span class="token punctuation">.</span><span class="token keyword">Language</span><span class="token punctuation">;</span></code></pre>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h4 class="title">
<a name="functional-dependence-special-cases">
</a>
Functional Dependency Special Cases
</h4>
</div>
</div>
</div>
<p>
Whereas an equality test in a
<code class="literal">
WHERE
</code>
condition or
<code class="literal">
INNER JOIN
</code>
condition is
symmetric, an equality test in an outer join condition is not,
because tables play different roles.
</p>
<p>
Assume that referential integrity has been accidentally broken
and there exists a row of
<code class="literal">
countrylanguage
</code>
without a corresponding row in
<code class="literal">
country
</code>
.
Consider the same query as in the previous example, but with a
<code class="literal">
LEFT JOIN
</code>
:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa59909186"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> co<span class="token punctuation">.</span><span class="token keyword">Name</span><span class="token punctuation">,</span> cl<span class="token punctuation">.</span><span class="token keyword">Language</span><span class="token punctuation">,</span>
cl<span class="token punctuation">.</span>Percentage <span class="token operator">*</span> co<span class="token punctuation">.</span>Population<span class="token operator">/</span><span class="token number">100.0</span> <span class="token keyword">AS</span> SpokenBy
<span class="token keyword">FROM</span> countrylanguage cl <span class="token keyword">LEFT</span> <span class="token keyword">JOIN</span> country co
<span class="token keyword">ON</span> cl<span class="token punctuation">.</span>CountryCode <span class="token operator">=</span> co<span class="token punctuation">.</span><span class="token keyword">Code</span>
<span class="token keyword">GROUP</span> <span class="token keyword">BY</span> cl<span class="token punctuation">.</span>CountryCode<span class="token punctuation">,</span> cl<span class="token punctuation">.</span><span class="token keyword">Language</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
For a given value of
<code class="literal">
cl.CountryCode
</code>
, the
value of
<code class="literal">
co.Code
</code>
in the join result is
either found in a matching row (determined by
<code class="literal">
cl.CountryCode
</code>
) or is
<code class="literal">
NULL
</code>
-complemented if there is no match
(also determined by
<code class="literal">
cl.CountryCode
</code>
). In
each case, this relationship applies:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa77391123"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql">{cl<span class="token punctuation">.</span>CountryCode} <span class="token operator">-</span><span class="token operator">></span> {co<span class="token punctuation">.</span><span class="token keyword">Code</span>}</code></pre>
</div>
<p>
<code class="literal">
cl.CountryCode
</code>
is itself functionally
dependent on {
<code class="literal">
cl.CountryCode
</code>
,
<code class="literal">
cl.Language
</code>
} which is a primary key.
</p>
<p>
If in the join result
<code class="literal">
co.Code
</code>
is
<code class="literal">
NULL
</code>
-complemented,
<code class="literal">
co.Name
</code>
is as well. If
<code class="literal">
co.Code
</code>
is not
<code class="literal">
NULL
</code>
-complemented, then because
<code class="literal">
co.Code
</code>
is a primary key, it determines
<code class="literal">
co.Name
</code>
. Therefore, in all cases:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa83864994"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql">{co<span class="token punctuation">.</span><span class="token keyword">Code</span>} <span class="token operator">-</span><span class="token operator">></span> {co<span class="token punctuation">.</span><span class="token keyword">Name</span>}</code></pre>
</div>
<p>
Which yields:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa47932821"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql">{cl<span class="token punctuation">.</span>CountryCode<span class="token punctuation">,</span> cl<span class="token punctuation">.</span><span class="token keyword">Language</span>} <span class="token operator">-</span><span class="token operator">></span> {cl<span class="token punctuation">.</span><span class="token operator">*</span><span class="token punctuation">,</span>co<span class="token punctuation">.</span><span class="token operator">*</span>}</code></pre>
</div>
<p>
As a result, the query is valid.
</p>
<p>
However, suppose that the tables are swapped, as in this
query:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa2232322"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> co<span class="token punctuation">.</span><span class="token keyword">Name</span><span class="token punctuation">,</span> cl<span class="token punctuation">.</span><span class="token keyword">Language</span><span class="token punctuation">,</span>
cl<span class="token punctuation">.</span>Percentage <span class="token operator">*</span> co<span class="token punctuation">.</span>Population<span class="token operator">/</span><span class="token number">100.0</span> <span class="token keyword">AS</span> SpokenBy
<span class="token keyword">FROM</span> country co <span class="token keyword">LEFT</span> <span class="token keyword">JOIN</span> countrylanguage cl
<span class="token keyword">ON</span> cl<span class="token punctuation">.</span>CountryCode <span class="token operator">=</span> co<span class="token punctuation">.</span><span class="token keyword">Code</span>
<span class="token keyword">GROUP</span> <span class="token keyword">BY</span> cl<span class="token punctuation">.</span>CountryCode<span class="token punctuation">,</span> cl<span class="token punctuation">.</span><span class="token keyword">Language</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
Now this relationship does
<span class="emphasis">
<em>
not
</em>
</span>
apply:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa38481070"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql">{cl<span class="token punctuation">.</span>CountryCode<span class="token punctuation">,</span> cl<span class="token punctuation">.</span><span class="token keyword">Language</span>} <span class="token operator">-</span><span class="token operator">></span> {cl<span class="token punctuation">.</span><span class="token operator">*</span><span class="token punctuation">,</span>co<span class="token punctuation">.</span><span class="token operator">*</span>}</code></pre>
</div>
<p>
Indeed, all
<code class="literal">
NULL
</code>
-complemented rows made for
<code class="literal">
cl
</code>
is put into a single group (they have
both
<code class="literal">
GROUP BY
</code>
columns equal to
<code class="literal">
NULL
</code>
), and inside this group the value of
<code class="literal">
co.Name
</code>
can vary. The query is invalid and
MySQL rejects it.
</p>
<p>
Functional dependence in outer joins is thus linked to whether
determinant columns belong to the left or right side of the
<code class="literal">
LEFT JOIN
</code>
. Determination of functional
dependence becomes more complex if there are nested outer
joins or the join condition does not consist entirely of
equality comparisons.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h4 class="title">
<a name="functional-dependence-views">
</a>
Functional Dependencies and Views
</h4>
</div>
</div>
</div>
<p>
Suppose that a view on countries produces their code, their
name in uppercase, and how many different official languages
they have:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa31449917"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">CREATE</span> <span class="token keyword">VIEW</span> country2 <span class="token keyword">AS</span>
<span class="token keyword">SELECT</span> co<span class="token punctuation">.</span><span class="token keyword">Code</span><span class="token punctuation">,</span> <span class="token function">UPPER</span><span class="token punctuation">(</span>co<span class="token punctuation">.</span><span class="token keyword">Name</span><span class="token punctuation">)</span> <span class="token keyword">AS</span> UpperName<span class="token punctuation">,</span>
<span class="token function">COUNT</span><span class="token punctuation">(</span>cl<span class="token punctuation">.</span><span class="token keyword">Language</span><span class="token punctuation">)</span> <span class="token keyword">AS</span> OfficialLanguages
<span class="token keyword">FROM</span> country <span class="token keyword">AS</span> co <span class="token keyword">JOIN</span> countrylanguage <span class="token keyword">AS</span> cl
<span class="token keyword">ON</span> cl<span class="token punctuation">.</span>CountryCode <span class="token operator">=</span> co<span class="token punctuation">.</span><span class="token keyword">Code</span>
<span class="token keyword">WHERE</span> cl<span class="token punctuation">.</span>isOfficial <span class="token operator">=</span> <span class="token string">'T'</span>
<span class="token keyword">GROUP</span> <span class="token keyword">BY</span> co<span class="token punctuation">.</span><span class="token keyword">Code</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
This definition is valid because:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa62135800"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql">{co<span class="token punctuation">.</span><span class="token keyword">Code</span>} <span class="token operator">-</span><span class="token operator">></span> {co<span class="token punctuation">.</span><span class="token operator">*</span>}</code></pre>
</div>
<p>
In the view result, the first selected column is
<code class="literal">
co.Code
</code>
, which is also the group column and
thus determines all other selected expressions:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa53970221"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql">{country2<span class="token punctuation">.</span><span class="token keyword">Code</span>} <span class="token operator">-</span><span class="token operator">></span> {country2<span class="token punctuation">.</span><span class="token operator">*</span>}</code></pre>
</div>
<p>
MySQL understands this and uses this information, as described
following.
</p>
<p>
This query displays countries, how many different official
languages they have, and how many cities they have, by joining
the view with the
<code class="literal">
city
</code>
table:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa74832865"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> co2<span class="token punctuation">.</span><span class="token keyword">Code</span><span class="token punctuation">,</span> co2<span class="token punctuation">.</span>UpperName<span class="token punctuation">,</span> co2<span class="token punctuation">.</span>OfficialLanguages<span class="token punctuation">,</span>
<span class="token function">COUNT</span><span class="token punctuation">(</span><span class="token operator">*</span><span class="token punctuation">)</span> <span class="token keyword">AS</span> Cities
<span class="token keyword">FROM</span> country2 <span class="token keyword">AS</span> co2 <span class="token keyword">JOIN</span> city ci
<span class="token keyword">ON</span> ci<span class="token punctuation">.</span>CountryCode <span class="token operator">=</span> co2<span class="token punctuation">.</span><span class="token keyword">Code</span>
<span class="token keyword">GROUP</span> <span class="token keyword">BY</span> co2<span class="token punctuation">.</span><span class="token keyword">Code</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
This query is valid because, as seen previously:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa38746040"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql">{co2<span class="token punctuation">.</span><span class="token keyword">Code</span>} <span class="token operator">-</span><span class="token operator">></span> {co2<span class="token punctuation">.</span><span class="token operator">*</span>}</code></pre>
</div>
<p>
MySQL is able to discover a functional dependency in the
result of a view and use that to validate a query which uses
the view. The same would be true if
<code class="literal">
country2
</code>
were a derived table (or common
table expression), as in:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa29194112"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> co2<span class="token punctuation">.</span><span class="token keyword">Code</span><span class="token punctuation">,</span> co2<span class="token punctuation">.</span>UpperName<span class="token punctuation">,</span> co2<span class="token punctuation">.</span>OfficialLanguages<span class="token punctuation">,</span>
<span class="token function">COUNT</span><span class="token punctuation">(</span><span class="token operator">*</span><span class="token punctuation">)</span> <span class="token keyword">AS</span> Cities
<span class="token keyword">FROM</span>
<span class="token punctuation">(</span>
<span class="token keyword">SELECT</span> co<span class="token punctuation">.</span><span class="token keyword">Code</span><span class="token punctuation">,</span> <span class="token function">UPPER</span><span class="token punctuation">(</span>co<span class="token punctuation">.</span><span class="token keyword">Name</span><span class="token punctuation">)</span> <span class="token keyword">AS</span> UpperName<span class="token punctuation">,</span>
<span class="token function">COUNT</span><span class="token punctuation">(</span>cl<span class="token punctuation">.</span><span class="token keyword">Language</span><span class="token punctuation">)</span> <span class="token keyword">AS</span> OfficialLanguages
<span class="token keyword">FROM</span> country <span class="token keyword">AS</span> co <span class="token keyword">JOIN</span> countrylanguage <span class="token keyword">AS</span> cl
<span class="token keyword">ON</span> cl<span class="token punctuation">.</span>CountryCode<span class="token operator">=</span>co<span class="token punctuation">.</span><span class="token keyword">Code</span>
<span class="token keyword">WHERE</span> cl<span class="token punctuation">.</span>isOfficial<span class="token operator">=</span><span class="token string">'T'</span>
<span class="token keyword">GROUP</span> <span class="token keyword">BY</span> co<span class="token punctuation">.</span><span class="token keyword">Code</span>
<span class="token punctuation">)</span> <span class="token keyword">AS</span> co2
<span class="token keyword">JOIN</span> city ci <span class="token keyword">ON</span> ci<span class="token punctuation">.</span>CountryCode <span class="token operator">=</span> co2<span class="token punctuation">.</span><span class="token keyword">Code</span>
<span class="token keyword">GROUP</span> <span class="token keyword">BY</span> co2<span class="token punctuation">.</span><span class="token keyword">Code</span><span class="token punctuation">;</span></code></pre>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h4 class="title">
<a name="functional-dependence-combinations">
</a>
Combinations of Functional Dependencies
</h4>
</div>
</div>
</div>
<p>
MySQL is able to combine all of the preceding types of
functional dependencies (key based, equality based, view
based) to validate more complex queries.
</p>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/group-replication-group-write-consensus.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="group-replication-group-write-consensus">
</a>
20.5.1.3 Using Group Replication Group Write Consensus
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045133538528">
</a>
<a class="indexterm" name="idm46045133537040">
</a>
<p>
This section explains how to inspect and configure the maximum
number of consensus instances at any time for a group. This
maximum is referred to as the event horizon for a group, and is
the maximum number of consensus instances that the group can
execute in parallel. This enables you to fine tune the
performance of your Group Replication deployment. For example,
the default value of 10 is suitable for a group running on a
LAN, but for groups operating over a slower network such as a
WAN, increase this number to improve performance.
</p>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="group-replication-inspect-write-concurrency">
</a>
Inspecting a Group's Write Concurrency
</h5>
</div>
</div>
</div>
<a class="indexterm" name="idm46045133533760">
</a>
<a class="indexterm" name="idm46045133532256">
</a>
<a class="indexterm" name="idm46045133531216">
</a>
<a class="indexterm" name="idm46045133529728">
</a>
<p>
Use the
<a class="link" href="group-replication-functions-for-maximum-consensus.html#function_group-replication-get-write-concurrency">
<code class="literal">
group_replication_get_write_concurrency()
</code>
</a>
function to inspect a group's event horizon value at runtime
by issuing:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa55983886"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> group_replication_get_write_concurrency<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="group-replication-configure-write-concurrency">
</a>
Configuring a Group's Write Concurrency
</h5>
</div>
</div>
</div>
<a class="indexterm" name="idm46045133523520">
</a>
<a class="indexterm" name="idm46045133522016">
</a>
<a class="indexterm" name="idm46045133520976">
</a>
<a class="indexterm" name="idm46045133519488">
</a>
<p>
Use the
<a class="link" href="group-replication-functions-for-maximum-consensus.html#function_group-replication-set-write-concurrency">
<code class="literal">
group_replication_set_write_concurrency()
</code>
</a>
function to set the maximum number of consensus instances that
the system can execute in parallel by issuing:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa49686299"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> group_replication_set_write_concurrency<span class="token punctuation">(</span><em class="replaceable">instances</em><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
where
<em class="replaceable">
<code>
instances
</code>
</em>
is the new maximum
number of consensus instances. The
<a class="link" href="privileges-provided.html#priv_group-replication-admin">
<code class="literal">
GROUP_REPLICATION_ADMIN
</code>
</a>
privilege is required to use this function.
</p>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/date-and-time-literals.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="date-and-time-literals">
</a>
11.1.3 Date and Time Literals
</h3>
</div>
</div>
</div>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="xref" href="date-and-time-literals.html#date-and-time-standard-sql-literals" title="Standard SQL and ODBC Date and Time Literals">
Standard SQL and ODBC Date and Time Literals
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="date-and-time-literals.html#date-and-time-string-numeric-literals" title="String and Numeric Literals in Date and Time Context">
String and Numeric Literals in Date and Time Context
</a>
</p>
</li>
</ul>
</div>
<a class="indexterm" name="idm46045220420224">
</a>
<a class="indexterm" name="idm46045220418736">
</a>
<a class="indexterm" name="idm46045220417248">
</a>
<a class="indexterm" name="idm46045220416176">
</a>
<p>
Date and time values can be represented in several formats, such
as quoted strings or as numbers, depending on the exact type of
the value and other factors. For example, in contexts where
MySQL expects a date, it interprets any of
<code class="literal">
'2015-07-21'
</code>
,
<code class="literal">
'20150721'
</code>
,
and
<code class="literal">
20150721
</code>
as a date.
</p>
<p>
This section describes the acceptable formats for date and time
literals. For more information about the temporal data types,
such as the range of permitted values, see
<a class="xref" href="date-and-time-types.html" title="13.2 Date and Time Data Types">
Section 13.2, “Date and Time Data Types”
</a>
.
</p>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h4 class="title">
<a name="date-and-time-standard-sql-literals">
</a>
Standard SQL and ODBC Date and Time Literals
</h4>
</div>
</div>
</div>
<p>
Standard SQL requires temporal literals to be specified using
a type keyword and a string. The space between the keyword and
string is optional.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa23130090"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token datatype">DATE</span> <span class="token string">'<em class="replaceable">str</em>'</span>
<span class="token datatype">TIME</span> <span class="token string">'<em class="replaceable">str</em>'</span>
<span class="token datatype">TIMESTAMP</span> <span class="token string">'<em class="replaceable">str</em>'</span></code></pre>
</div>
<p>
MySQL recognizes but, unlike standard SQL, does not require
the type keyword. Applications that are to be
standard-compliant should include the type keyword for
temporal literals.
</p>
<p>
MySQL also recognizes the ODBC syntax corresponding to the
standard SQL syntax:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-clike"><div class="docs-select-all right" id="sa32623545"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-clike"><span class="token punctuation">{</span> d <span class="token string">'<em class="replaceable">str</em>'</span> <span class="token punctuation">}</span>
<span class="token punctuation">{</span> t <span class="token string">'<em class="replaceable">str</em>'</span> <span class="token punctuation">}</span>
<span class="token punctuation">{</span> ts <span class="token string">'<em class="replaceable">str</em>'</span> <span class="token punctuation">}</span></code></pre>
</div>
<p>
MySQL uses the type keywords and the ODBC constructions to
produce
<a class="link" href="datetime.html" title="13.2.2 The DATE, DATETIME, and TIMESTAMP Types">
<code class="literal">
DATE
</code>
</a>
,
<a class="link" href="time.html" title="13.2.3 The TIME Type">
<code class="literal">
TIME
</code>
</a>
, and
<a class="link" href="datetime.html" title="13.2.2 The DATE, DATETIME, and TIMESTAMP Types">
<code class="literal">
DATETIME
</code>
</a>
values, respectively,
including a trailing fractional seconds part if specified. The
<a class="link" href="datetime.html" title="13.2.2 The DATE, DATETIME, and TIMESTAMP Types">
<code class="literal">
TIMESTAMP
</code>
</a>
syntax produces a
<a class="link" href="datetime.html" title="13.2.2 The DATE, DATETIME, and TIMESTAMP Types">
<code class="literal">
DATETIME
</code>
</a>
value in MySQL because
<a class="link" href="datetime.html" title="13.2.2 The DATE, DATETIME, and TIMESTAMP Types">
<code class="literal">
DATETIME
</code>
</a>
has a range that more
closely corresponds to the standard SQL
<a class="link" href="datetime.html" title="13.2.2 The DATE, DATETIME, and TIMESTAMP Types">
<code class="literal">
TIMESTAMP
</code>
</a>
type, which has a
year range from
<code class="literal">
0001
</code>
to
<code class="literal">
9999
</code>
. (The MySQL
<a class="link" href="datetime.html" title="13.2.2 The DATE, DATETIME, and TIMESTAMP Types">
<code class="literal">
TIMESTAMP
</code>
</a>
year range is
<code class="literal">
1970
</code>
to
<code class="literal">
2038
</code>
.)
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h4 class="title">
<a name="date-and-time-string-numeric-literals">
</a>
String and Numeric Literals in Date and Time Context
</h4>
</div>
</div>
</div>
<p>
MySQL recognizes
<a class="link" href="datetime.html" title="13.2.2 The DATE, DATETIME, and TIMESTAMP Types">
<code class="literal">
DATE
</code>
</a>
values in
these formats:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
As a string in either
<code class="literal">
'
<em class="replaceable">
<code>
YYYY-MM-DD
</code>
</em>
'
</code>
or
<code class="literal">
'
<em class="replaceable">
<code>
YY-MM-DD
</code>
</em>
'
</code>
format. A
<span class="quote">
“
<span class="quote">
relaxed
</span>
”
</span>
syntax is permitted, but
is deprecated: Any punctuation character may be used as
the delimiter between date parts. For example,
<code class="literal">
'2012-12-31'
</code>
,
<code class="literal">
'2012/12/31'
</code>
,
<code class="literal">
'2012^12^31'
</code>
, and
<code class="literal">
'2012@12@31'
</code>
are equivalent. Using any
character other than the dash (
<code class="literal">
-
</code>
) as
the delimiter raises a warning, as shown here:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa92783362"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token datatype">DATE</span><span class="token string">'2012@12@31'</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> DATE'2012@12@31' <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 2012<span class="token punctuation">-</span>12<span class="token punctuation">-</span>31 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">1 row in set, 1 warning (0.00 sec)</span>
<span class="token prompt">mysql></span> <span class="token keyword">SHOW</span> <span class="token keyword">WARNINGS</span>\G
<span class="token output"><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span> 1. row <span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span>
Level<span class="token punctuation">:</span> Warning
Code<span class="token punctuation">:</span> 4095
Message<span class="token punctuation">:</span> Delimiter '@' in position 4 in datetime value '2012@12@31' at row 1 is
deprecated. Prefer the standard '-'.
</span><span class="token output">1 row in set (0.00 sec)</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
As a string with no delimiters in either
<code class="literal">
'
<em class="replaceable">
<code>
YYYYMMDD
</code>
</em>
'
</code>
or
<code class="literal">
'
<em class="replaceable">
<code>
YYMMDD
</code>
</em>
'
</code>
format, provided that the string makes sense as a date.
For example,
<code class="literal">
'20070523'
</code>
and
<code class="literal">
'070523'
</code>
are interpreted as
<code class="literal">
'2007-05-23'
</code>
, but
<code class="literal">
'071332'
</code>
is illegal (it has nonsensical
month and day parts) and becomes
<code class="literal">
'0000-00-00'
</code>
.
</p>
</li>
<li class="listitem">
<p>
As a number in either
<em class="replaceable">
<code>
YYYYMMDD
</code>
</em>
or
<em class="replaceable">
<code>
YYMMDD
</code>
</em>
format, provided that
the number makes sense as a date. For example,
<code class="literal">
19830905
</code>
and
<code class="literal">
830905
</code>
are interpreted as
<code class="literal">
'1983-09-05'
</code>
.
</p>
</li>
</ul>
</div>
<p>
MySQL recognizes
<a class="link" href="datetime.html" title="13.2.2 The DATE, DATETIME, and TIMESTAMP Types">
<code class="literal">
DATETIME
</code>
</a>
and
<a class="link" href="datetime.html" title="13.2.2 The DATE, DATETIME, and TIMESTAMP Types">
<code class="literal">
TIMESTAMP
</code>
</a>
values in these
formats:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
As a string in either
<code class="literal">
'
<em class="replaceable">
<code>
YYYY-MM-DD
hh:mm:ss
</code>
</em>
'
</code>
or
<code class="literal">
'
<em class="replaceable">
<code>
YY-MM-DD
hh:mm:ss
</code>
</em>
'
</code>
format. MySQL also
permits a
<span class="quote">
“
<span class="quote">
relaxed
</span>
”
</span>
syntax here, although
this is deprecated: Any punctuation character may be used
as the delimiter between date parts or time parts. For
example,
<code class="literal">
'2012-12-31 11:30:45'
</code>
,
<code class="literal">
'2012^12^31 11+30+45'
</code>
,
<code class="literal">
'2012/12/31 11*30*45'
</code>
, and
<code class="literal">
'2012@12@31 11^30^45'
</code>
are equivalent.
Use of any characters as delimiters in such values, other
than the dash (
<code class="literal">
-
</code>
) for the date part and
the colon (
<code class="literal">
:
</code>
) for the time part, raises
a warning, as shown here:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa82301229"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token datatype">TIMESTAMP</span><span class="token string">'2012^12^31 11*30*45'</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> TIMESTAMP'2012^12^31 11*30*45' <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 2012<span class="token punctuation">-</span>12<span class="token punctuation">-</span>31 11:30:45 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">1 row in set, 1 warning (0.00 sec)</span>
<span class="token prompt">mysql></span> <span class="token keyword">SHOW</span> <span class="token keyword">WARNINGS</span>\G
<span class="token output"><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span> 1. row <span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span>
Level<span class="token punctuation">:</span> Warning
Code<span class="token punctuation">:</span> 4095
Message<span class="token punctuation">:</span> Delimiter '^' in position 4 in datetime value '2012^12^31 11<span class="token punctuation">*</span>30<span class="token punctuation">*</span>45' at
row 1 is deprecated. Prefer the standard '-'.
</span><span class="token output">1 row in set (0.00 sec)</span></code></pre>
</div>
<p>
The only delimiter recognized between a date and time part
and a fractional seconds part is the decimal point.
</p>
<p>
The date and time parts can be separated by
<code class="literal">
T
</code>
rather than a space. For example,
<code class="literal">
'2012-12-31 11:30:45'
</code>
<code class="literal">
'2012-12-31T11:30:45'
</code>
are equivalent.
</p>
<p>
Previously, MySQL supported arbitrary numbers of leading
and trailing whitespace characters in date and time
values, as well as between the date and time parts of
<code class="literal">
DATETIME
</code>
and
<code class="literal">
TIMESTAMP
</code>
values. In MySQL
8.4, this behavior is deprecated, and the
presence of excess whitespace characters triggers a
warning, as shown here:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa13851156"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token datatype">TIMESTAMP</span><span class="token string">'2012-12-31 11-30-45'</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> TIMESTAMP'2012<span class="token punctuation">-</span>12<span class="token punctuation">-</span>31 11<span class="token punctuation">-</span>30<span class="token punctuation">-</span>45' <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 2012<span class="token punctuation">-</span>12<span class="token punctuation">-</span>31 11:30:45 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">1 row in set, 1 warning (0.00 sec)</span>
<span class="token prompt">mysql></span> <span class="token keyword">SHOW</span> <span class="token keyword">WARNINGS</span>\G
<span class="token output"><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span> 1. row <span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span>
Level<span class="token punctuation">:</span> Warning
Code<span class="token punctuation">:</span> 4096
Message<span class="token punctuation">:</span> Delimiter ' ' in position 11 in datetime value '2012-12-31 11-30-45'
at row 1 is superfluous and is deprecated. Please remove.
</span><span class="token output">1 row in set (0.00 sec)</span></code></pre>
</div>
<p>
A warning is also raised when whitespace characters other
than the space character is used, like this:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa1825821"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token datatype">TIMESTAMP</span><span class="token string">'2021-06-06
'</span><span class="token operator">></span> <span class="token number">11</span>:<span class="token number">15</span>:<span class="token number">25</span><span class="token string">';
+--------------------------------+
| TIMESTAMP'</span><span class="token number">2021</span><span class="token operator">-</span><span class="token number">06</span><span class="token operator">-</span><span class="token number">06</span>
<span class="token number">11</span>:<span class="token number">15</span>:<span class="token number">25</span><span class="token string">' |
+--------------------------------+
| 2021-06-06 11:15:25 |
+--------------------------------+
1 row in set, 1 warning (0.00 sec)
mysql> SHOW WARNINGS\G
*************************** 1. row ***************************
Level: Warning
Code: 4095
Message: Delimiter '</span>\n<span class="token string">' in position 10 in datetime value '</span><span class="token number">2021</span><span class="token operator">-</span><span class="token number">06</span><span class="token operator">-</span><span class="token number">06</span>
<span class="token number">11</span>:<span class="token number">15</span>:<span class="token number">25</span><span class="token string">' at row 1 is deprecated. Prefer the standard '</span> '<span class="token punctuation">.</span>
<span class="token output">1 row in set (0.00 sec)</span></code></pre>
</div>
<p>
Only one such warning is raised per temporal value, even
though multiple issues may exist with delimiters,
whitespace, or both, as shown in the following series of
statements:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa1582851"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token datatype">TIMESTAMP</span><span class="token string">'2012!-12-31 11:30:45'</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> TIMESTAMP'2012!<span class="token punctuation">-</span>12<span class="token punctuation">-</span>31 11:30:45' <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 2012<span class="token punctuation">-</span>12<span class="token punctuation">-</span>31 11:30:45 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">1 row in set, 1 warning (0.00 sec)</span>
<span class="token prompt">mysql></span> <span class="token keyword">SHOW</span> <span class="token keyword">WARNINGS</span>\G
<span class="token output"><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span> 1. row <span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span>
Level<span class="token punctuation">:</span> Warning
Code<span class="token punctuation">:</span> 4095
Message<span class="token punctuation">:</span> Delimiter '!' in position 4 in datetime value '2012!-12-31 11<span class="token punctuation">:</span>30<span class="token punctuation">:</span>45'
at row 1 is deprecated. Prefer the standard '-'.
</span><span class="token output">1 row in set (0.00 sec)</span>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token datatype">TIMESTAMP</span><span class="token string">'2012-12-31 11:30:45'</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> TIMESTAMP'2012<span class="token punctuation">-</span>12<span class="token punctuation">-</span>31 11:30:45' <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 2012<span class="token punctuation">-</span>12<span class="token punctuation">-</span>31 11:30:45 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">1 row in set, 1 warning (0.00 sec)</span>
<span class="token prompt">mysql></span> <span class="token keyword">SHOW</span> <span class="token keyword">WARNINGS</span>\G
<span class="token output"><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span> 1. row <span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span>
Level<span class="token punctuation">:</span> Warning
Code<span class="token punctuation">:</span> 4096
Message<span class="token punctuation">:</span> Delimiter ' ' in position 11 in datetime value '2012-12-31 11<span class="token punctuation">:</span>30<span class="token punctuation">:</span>45'
at row 1 is superfluous and is deprecated. Please remove.
</span><span class="token output">1 row in set (0.00 sec)</span>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token datatype">TIMESTAMP</span><span class="token string">'2012-12-31 11:30:45'</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> TIMESTAMP'2012<span class="token punctuation">-</span>12<span class="token punctuation">-</span>31 11:30:45' <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 2012<span class="token punctuation">-</span>12<span class="token punctuation">-</span>31 11:30:45 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">1 row in set (0.00 sec)</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
As a string with no delimiters in either
<code class="literal">
'
<em class="replaceable">
<code>
YYYYMMDDhhmmss
</code>
</em>
'
</code>
or
<code class="literal">
'
<em class="replaceable">
<code>
YYMMDDhhmmss
</code>
</em>
'
</code>
format, provided that the string makes sense as a date.
For example,
<code class="literal">
'20070523091528'
</code>
and
<code class="literal">
'070523091528'
</code>
are interpreted as
<code class="literal">
'2007-05-23 09:15:28'
</code>
, but
<code class="literal">
'071122129015'
</code>
is illegal (it has a
nonsensical minute part) and becomes
<code class="literal">
'0000-00-00
00:00:00'
</code>
.
</p>
</li>
<li class="listitem">
<p>
As a number in either
<em class="replaceable">
<code>
YYYYMMDDhhmmss
</code>
</em>
or
<em class="replaceable">
<code>
YYMMDDhhmmss
</code>
</em>
format, provided
that the number makes sense as a date. For example,
<code class="literal">
19830905132800
</code>
and
<code class="literal">
830905132800
</code>
are interpreted as
<code class="literal">
'1983-09-05 13:28:00'
</code>
.
</p>
</li>
</ul>
</div>
<p>
A
<a class="link" href="datetime.html" title="13.2.2 The DATE, DATETIME, and TIMESTAMP Types">
<code class="literal">
DATETIME
</code>
</a>
or
<a class="link" href="datetime.html" title="13.2.2 The DATE, DATETIME, and TIMESTAMP Types">
<code class="literal">
TIMESTAMP
</code>
</a>
value can include a
trailing fractional seconds part in up to microseconds (6
digits) precision. The fractional part should always be
separated from the rest of the time by a decimal point; no
other fractional seconds delimiter is recognized. For
information about fractional seconds support in MySQL, see
<a class="xref" href="fractional-seconds.html" title="13.2.6 Fractional Seconds in Time Values">
Section 13.2.6, “Fractional Seconds in Time Values”
</a>
.
</p>
<p>
Dates containing two-digit year values are ambiguous because
the century is unknown. MySQL interprets two-digit year values
using these rules:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Year values in the range
<code class="literal">
70-99
</code>
become
<code class="literal">
1970-1999
</code>
.
</p>
</li>
<li class="listitem">
<p>
Year values in the range
<code class="literal">
00-69
</code>
become
<code class="literal">
2000-2069
</code>
.
</p>
</li>
</ul>
</div>
<p>
See also
<a class="xref" href="two-digit-years.html" title="13.2.9 2-Digit Years in Dates">
Section 13.2.9, “2-Digit Years in Dates”
</a>
.
</p>
<p>
For values specified as strings that include date part
delimiters, it is unnecessary to specify two digits for month
or day values that are less than
<code class="literal">
10
</code>
.
<code class="literal">
'2015-6-9'
</code>
is the same as
<code class="literal">
'2015-06-09'
</code>
. Similarly, for values
specified as strings that include time part delimiters, it is
unnecessary to specify two digits for hour, minute, or second
values that are less than
<code class="literal">
10
</code>
.
<code class="literal">
'2015-10-30 1:2:3'
</code>
is the same as
<code class="literal">
'2015-10-30 01:02:03'
</code>
.
</p>
<p>
Values specified as numbers should be 6, 8, 12, or 14 digits
long. If a number is 8 or 14 digits long, it is assumed to be
in
<em class="replaceable">
<code>
YYYYMMDD
</code>
</em>
or
<em class="replaceable">
<code>
YYYYMMDDhhmmss
</code>
</em>
format and that the
year is given by the first 4 digits. If the number is 6 or 12
digits long, it is assumed to be in
<em class="replaceable">
<code>
YYMMDD
</code>
</em>
or
<em class="replaceable">
<code>
YYMMDDhhmmss
</code>
</em>
format and that the
year is given by the first 2 digits. Numbers that are not one
of these lengths are interpreted as though padded with leading
zeros to the closest length.
</p>
<a class="indexterm" name="idm46045220301904">
</a>
<a class="indexterm" name="idm46045220300832">
</a>
<p>
Values specified as nondelimited strings are interpreted
according their length. For a string 8 or 14 characters long,
the year is assumed to be given by the first 4 characters.
Otherwise, the year is assumed to be given by the first 2
characters. The string is interpreted from left to right to
find year, month, day, hour, minute, and second values, for as
many parts as are present in the string. This means you should
not use strings that have fewer than 6 characters. For
example, if you specify
<code class="literal">
'9903'
</code>
, thinking
that represents March, 1999, MySQL converts it to the
<span class="quote">
“
<span class="quote">
zero
</span>
”
</span>
date value. This occurs because the year
and month values are
<code class="literal">
99
</code>
and
<code class="literal">
03
</code>
, but the day part is completely missing.
However, you can explicitly specify a value of zero to
represent missing month or day parts. For example, to insert
the value
<code class="literal">
'1999-03-00'
</code>
, use
<code class="literal">
'990300'
</code>
.
</p>
<p>
MySQL recognizes
<a class="link" href="time.html" title="13.2.3 The TIME Type">
<code class="literal">
TIME
</code>
</a>
values in
these formats:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
As a string in
<em class="replaceable">
<code>
'D hh:mm:ss'
</code>
</em>
format. You can also use one of the following
<span class="quote">
“
<span class="quote">
relaxed
</span>
”
</span>
syntaxes:
<em class="replaceable">
<code>
'hh:mm:ss'
</code>
</em>
,
<em class="replaceable">
<code>
'hh:mm'
</code>
</em>
,
<em class="replaceable">
<code>
'D
hh:mm'
</code>
</em>
,
<em class="replaceable">
<code>
'D hh'
</code>
</em>
,
or
<em class="replaceable">
<code>
'ss'
</code>
</em>
. Here
<em class="replaceable">
<code>
D
</code>
</em>
represents days and can have
a value from 0 to 34.
</p>
</li>
<li class="listitem">
<p>
As a string with no delimiters in
<em class="replaceable">
<code>
'hhmmss'
</code>
</em>
format, provided that
it makes sense as a time. For example,
<code class="literal">
'101112'
</code>
is understood as
<code class="literal">
'10:11:12'
</code>
, but
<code class="literal">
'109712'
</code>
is illegal (it has a
nonsensical minute part) and becomes
<code class="literal">
'00:00:00'
</code>
.
</p>
</li>
<li class="listitem">
<p>
As a number in
<em class="replaceable">
<code>
hhmmss
</code>
</em>
format,
provided that it makes sense as a time. For example,
<code class="literal">
101112
</code>
is understood as
<code class="literal">
'10:11:12'
</code>
. The following alternative
formats are also understood:
<em class="replaceable">
<code>
ss
</code>
</em>
,
<em class="replaceable">
<code>
mmss
</code>
</em>
, or
<em class="replaceable">
<code>
hhmmss
</code>
</em>
.
</p>
</li>
</ul>
</div>
<p>
A trailing fractional seconds part is recognized in the
<em class="replaceable">
<code>
'D hh:mm:ss.fraction'
</code>
</em>
,
<em class="replaceable">
<code>
'hh:mm:ss.fraction'
</code>
</em>
,
<em class="replaceable">
<code>
'hhmmss.fraction'
</code>
</em>
, and
<em class="replaceable">
<code>
hhmmss.fraction
</code>
</em>
time formats, where
<code class="literal">
fraction
</code>
is the fractional part in up to
microseconds (6 digits) precision. The fractional part should
always be separated from the rest of the time by a decimal
point; no other fractional seconds delimiter is recognized.
For information about fractional seconds support in MySQL, see
<a class="xref" href="fractional-seconds.html" title="13.2.6 Fractional Seconds in Time Values">
Section 13.2.6, “Fractional Seconds in Time Values”
</a>
.
</p>
<p>
For
<a class="link" href="time.html" title="13.2.3 The TIME Type">
<code class="literal">
TIME
</code>
</a>
values specified as
strings that include a time part delimiter, it is unnecessary
to specify two digits for hours, minutes, or seconds values
that are less than
<code class="literal">
10
</code>
.
<code class="literal">
'8:3:2'
</code>
is the same as
<code class="literal">
'08:03:02'
</code>
.
</p>
<p>
You can specify a time zone offset when inserting
<code class="literal">
TIMESTAMP
</code>
and
<code class="literal">
DATETIME
</code>
values into a table. The offset is appended to the time part
of a datetime literal, with no intravening spaces, and uses
the same format used for setting the
<a class="link" href="server-system-variables.html#sysvar_time_zone">
<code class="literal">
time_zone
</code>
</a>
system variable,
with the following exceptions:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
For hour values less than 10, a leading zero is required.
</p>
</li>
<li class="listitem">
<p>
The value
<code class="literal">
'-00:00'
</code>
is rejected.
</p>
</li>
<li class="listitem">
<p>
Time zone names such as
<code class="literal">
'EET'
</code>
and
<code class="literal">
'Asia/Shanghai'
</code>
cannot be used;
<code class="literal">
'SYSTEM'
</code>
also cannot be used in this
context.
</p>
</li>
</ul>
</div>
<p>
The value inserted must not have a zero for the month part,
the day part, or both parts. This is enforced regardless of
the server SQL mode setting.
</p>
<p>
This example illustrates inserting datetime values with time
zone offsets into
<code class="literal">
TIMESTAMP
</code>
and
<code class="literal">
DATETIME
</code>
columns using different
<a class="link" href="server-system-variables.html#sysvar_time_zone">
<code class="literal">
time_zone
</code>
</a>
settings, and then
retrieving them:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa77123652"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> ts <span class="token punctuation">(</span>
<span class="token prompt"> -></span> id <span class="token datatype">INTEGER</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span> <span class="token keyword">AUTO_INCREMENT</span> <span class="token keyword">PRIMARY</span> <span class="token keyword">KEY</span><span class="token punctuation">,</span>
<span class="token prompt"> -></span> col <span class="token datatype">TIMESTAMP</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span>
<span class="token prompt"> -></span> <span class="token punctuation">)</span> <span class="token keyword">AUTO_INCREMENT</span> <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> dt <span class="token punctuation">(</span>
<span class="token prompt"> -></span> id <span class="token datatype">INT</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span> <span class="token keyword">AUTO_INCREMENT</span> <span class="token keyword">PRIMARY</span> <span class="token keyword">KEY</span><span class="token punctuation">,</span>
<span class="token prompt"> -></span> col <span class="token datatype">DATETIME</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span>
<span class="token prompt"> -></span> <span class="token punctuation">)</span> <span class="token keyword">AUTO_INCREMENT</span> <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">SET</span> <span class="token variable">@@time_zone</span> <span class="token operator">=</span> <span class="token string">'SYSTEM'</span><span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">INSERT</span> <span class="token keyword">INTO</span> ts <span class="token punctuation">(</span>col<span class="token punctuation">)</span> <span class="token keyword">VALUES</span> <span class="token punctuation">(</span><span class="token string">'2020-01-01 10:10:10'</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token prompt"> -></span> <span class="token punctuation">(</span><span class="token string">'2020-01-01 10:10:10+05:30'</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token punctuation">(</span><span class="token string">'2020-01-01 10:10:10-08:00'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">SET</span> <span class="token variable">@@time_zone</span> <span class="token operator">=</span> <span class="token string">'+00:00'</span><span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">INSERT</span> <span class="token keyword">INTO</span> ts <span class="token punctuation">(</span>col<span class="token punctuation">)</span> <span class="token keyword">VALUES</span> <span class="token punctuation">(</span><span class="token string">'2020-01-01 10:10:10'</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token prompt"> -></span> <span class="token punctuation">(</span><span class="token string">'2020-01-01 10:10:10+05:30'</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token punctuation">(</span><span class="token string">'2020-01-01 10:10:10-08:00'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">SET</span> <span class="token variable">@@time_zone</span> <span class="token operator">=</span> <span class="token string">'SYSTEM'</span><span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">INSERT</span> <span class="token keyword">INTO</span> dt <span class="token punctuation">(</span>col<span class="token punctuation">)</span> <span class="token keyword">VALUES</span> <span class="token punctuation">(</span><span class="token string">'2020-01-01 10:10:10'</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token prompt"> -></span> <span class="token punctuation">(</span><span class="token string">'2020-01-01 10:10:10+05:30'</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token punctuation">(</span><span class="token string">'2020-01-01 10:10:10-08:00'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">SET</span> <span class="token variable">@@time_zone</span> <span class="token operator">=</span> <span class="token string">'+00:00'</span><span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">INSERT</span> <span class="token keyword">INTO</span> dt <span class="token punctuation">(</span>col<span class="token punctuation">)</span> <span class="token keyword">VALUES</span> <span class="token punctuation">(</span><span class="token string">'2020-01-01 10:10:10'</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token prompt"> -></span> <span class="token punctuation">(</span><span class="token string">'2020-01-01 10:10:10+05:30'</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token punctuation">(</span><span class="token string">'2020-01-01 10:10:10-08:00'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">SET</span> <span class="token variable">@@time_zone</span> <span class="token operator">=</span> <span class="token string">'SYSTEM'</span><span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token variable">@@system_time_zone</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> @@system_time_zone <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> EST <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> col<span class="token punctuation">,</span> <span class="token function">UNIX_TIMESTAMP</span><span class="token punctuation">(</span>col<span class="token punctuation">)</span> <span class="token keyword">FROM</span> dt <span class="token keyword">ORDER</span> <span class="token keyword">BY</span> id<span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> col <span class="token punctuation">|</span> UNIX_TIMESTAMP(col) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 2020<span class="token punctuation">-</span>01<span class="token punctuation">-</span>01 10:10:10 <span class="token punctuation">|</span> 1577891410 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 2019<span class="token punctuation">-</span>12<span class="token punctuation">-</span>31 23:40:10 <span class="token punctuation">|</span> 1577853610 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 2020<span class="token punctuation">-</span>01<span class="token punctuation">-</span>01 13:10:10 <span class="token punctuation">|</span> 1577902210 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 2020<span class="token punctuation">-</span>01<span class="token punctuation">-</span>01 10:10:10 <span class="token punctuation">|</span> 1577891410 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 2020<span class="token punctuation">-</span>01<span class="token punctuation">-</span>01 04:40:10 <span class="token punctuation">|</span> 1577871610 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 2020<span class="token punctuation">-</span>01<span class="token punctuation">-</span>01 18:10:10 <span class="token punctuation">|</span> 1577920210 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> col<span class="token punctuation">,</span> <span class="token function">UNIX_TIMESTAMP</span><span class="token punctuation">(</span>col<span class="token punctuation">)</span> <span class="token keyword">FROM</span> ts <span class="token keyword">ORDER</span> <span class="token keyword">BY</span> id<span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> col <span class="token punctuation">|</span> UNIX_TIMESTAMP(col) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 2020<span class="token punctuation">-</span>01<span class="token punctuation">-</span>01 10:10:10 <span class="token punctuation">|</span> 1577891410 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 2019<span class="token punctuation">-</span>12<span class="token punctuation">-</span>31 23:40:10 <span class="token punctuation">|</span> 1577853610 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 2020<span class="token punctuation">-</span>01<span class="token punctuation">-</span>01 13:10:10 <span class="token punctuation">|</span> 1577902210 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 2020<span class="token punctuation">-</span>01<span class="token punctuation">-</span>01 05:10:10 <span class="token punctuation">|</span> 1577873410 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 2019<span class="token punctuation">-</span>12<span class="token punctuation">-</span>31 23:40:10 <span class="token punctuation">|</span> 1577853610 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 2020<span class="token punctuation">-</span>01<span class="token punctuation">-</span>01 13:10:10 <span class="token punctuation">|</span> 1577902210 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
<p>
The offset is not displayed when selecting a datetime value,
even if one was used when inserting it.
</p>
<p>
The range of supported offset values is
<code class="literal">
-13:59
</code>
to
<code class="literal">
+14:00
</code>
,
inclusive.
</p>
<p>
Datetime literals that include time zone offsets are accepted
as parameter values by prepared statements.
</p>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/mysql-cluster-overview-requirements.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="mysql-cluster-overview-requirements">
</a>
25.2.3 NDB Cluster Hardware, Software, and Networking Requirements
</h3>
</div>
</div>
</div>
<a class="indexterm" name="idm46045124115008">
</a>
<a class="indexterm" name="idm46045124113520">
</a>
<p>
One of the strengths of NDB Cluster is that it can be run on
commodity hardware and has no unusual requirements in this regard,
other than for large amounts of RAM, due to the fact that all live
data storage is done in memory. (It is possible to reduce this
requirement using Disk Data tables—see
<a class="xref" href="mysql-cluster-disk-data.html" title="25.6.11 NDB Cluster Disk Data Tables">
Section 25.6.11, “NDB Cluster Disk Data Tables”
</a>
, for more information
about these.) You can obtain information about memory usage by
data nodes by viewing the
<a class="link" href="mysql-cluster-ndbinfo-memoryusage.html" title="25.6.17.46 The ndbinfo memoryusage Table">
<code class="literal">
ndbinfo.memoryusage
</code>
</a>
table, or
the output of the
<a class="link" href="mysql-cluster-mgm-client-commands.html#ndbclient-report">
<code class="literal">
REPORT
MemoryUsage
</code>
</a>
command in the
<a class="link" href="mysql-cluster-programs-ndb-mgm.html" title="25.5.5 ndb_mgm — The NDB Cluster Management Client">
<span class="command">
<strong>
ndb_mgm
</strong>
</span>
</a>
client. For information about memory used by
<code class="literal">
NDB
</code>
tables, you can query the
<a class="link" href="mysql-cluster-ndbinfo-memory-per-fragment.html" title="25.6.17.47 The ndbinfo memory_per_fragment Table">
<code class="literal">
ndbinfo.memory_per_fragment
</code>
</a>
table.
</p>
<p>
Increasing the number of CPUs, using faster CPUs, or both, on the
computers hosting data nodes can generally be expected to enhance
the performance of NDB Cluster. Memory requirements for cluster
processes other than the data nodes are relatively small.
</p>
<p>
The software requirements for NDB Cluster are also modest. Host
operating systems do not require any unusual modules, services,
applications, or configuration to support NDB Cluster. For
supported operating systems, a standard installation should be
sufficient. The MySQL software requirements are simple: all that
is needed is a production release of NDB Cluster. It is not
strictly necessary to compile MySQL yourself merely to be able to
use NDB Cluster. We assume that you are using the binaries
appropriate to your platform, available from the NDB Cluster
software downloads page at
<a class="ulink" href="https://dev.mysql.com/downloads/cluster/" target="_top">
https://dev.mysql.com/downloads/cluster/
</a>
.
</p>
<p>
For communication between nodes, NDB Cluster supports TCP/IP
networking in any standard topology, and the minimum expected for
each host is a standard 100 Mbps Ethernet card, plus a switch,
hub, or router to provide network connectivity for the cluster as
a whole. We strongly recommend that an NDB Cluster be run on its
own subnet which is not shared with machines not forming part of
the cluster for the following reasons:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<b>
Security.
</b>
Communications between NDB Cluster nodes are not encrypted
or shielded in any way. The only means of protecting
transmissions within an NDB Cluster is to run your NDB
Cluster on a protected network. If you intend to use NDB
Cluster for Web applications, the cluster should definitely
reside behind your firewall and not in your network's
De-Militarized Zone
(
<a class="ulink" href="http://compnetworking.about.com/cs/networksecurity/g/bldef_dmz.htm" target="_blank">
DMZ
</a>
)
or elsewhere.
</p>
<p>
See
<a class="xref" href="mysql-cluster-security-networking-issues.html" title="25.6.21.1 NDB Cluster Security and Networking Issues">
Section 25.6.21.1, “NDB Cluster Security and Networking Issues”
</a>
,
for more information.
</p>
</li>
<li class="listitem">
<p>
<b>
Efficiency.
</b>
Setting up an NDB Cluster on a private or protected network
enables the cluster to make exclusive use of bandwidth
between cluster hosts. Using a separate switch for your NDB
Cluster not only helps protect against unauthorized access
to NDB Cluster data, it also ensures that NDB Cluster nodes
are shielded from interference caused by transmissions
between other computers on the network. For enhanced
reliability, you can use dual switches and dual cards to
remove the network as a single point of failure; many device
drivers support failover for such communication links.
</p>
</li>
</ul>
</div>
<p>
<a name="mysql-cluster-network-latency-issues">
</a>
<b>
Network communication and latency.
</b>
NDB Cluster requires communication between data nodes and API
nodes (including SQL nodes), as well as between data nodes and
other data nodes, to execute queries and updates. Communication
latency between these processes can directly affect the observed
performance and latency of user queries. In addition, to
maintain consistency and service despite the silent failure of
nodes, NDB Cluster uses heartbeating and timeout mechanisms
which treat an extended loss of communication from a node as
node failure. This can lead to reduced redundancy. Recall that,
to maintain data consistency, an NDB Cluster shuts down when the
last node in a node group fails. Thus, to avoid increasing the
risk of a forced shutdown, breaks in communication between nodes
should be avoided wherever possible.
</p>
<p>
The failure of a data or API node results in the abort of all
uncommitted transactions involving the failed node. Data node
recovery requires synchronization of the failed node's data
from a surviving data node, and re-establishment of disk-based
redo and checkpoint logs, before the data node returns to service.
This recovery can take some time, during which the Cluster
operates with reduced redundancy.
</p>
<p>
Heartbeating relies on timely generation of heartbeat signals by
all nodes. This may not be possible if the node is overloaded, has
insufficient machine CPU due to sharing with other programs, or is
experiencing delays due to swapping. If heartbeat generation is
sufficiently delayed, other nodes treat the node that is slow to
respond as failed.
</p>
<p>
This treatment of a slow node as a failed one may or may not be
desirable in some circumstances, depending on the impact of the
node's slowed operation on the rest of the cluster. When
setting timeout values such as
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-heartbeatintervaldbdb">
<code class="literal">
HeartbeatIntervalDbDb
</code>
</a>
and
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-heartbeatintervaldbapi">
<code class="literal">
HeartbeatIntervalDbApi
</code>
</a>
for
NDB Cluster, care must be taken care to achieve quick detection,
failover, and return to service, while avoiding potentially
expensive false positives.
</p>
<p>
Where communication latencies between data nodes are expected to
be higher than would be expected in a LAN environment (on the
order of 100 µs), timeout parameters must be increased to
ensure that any allowed periods of latency periods are well within
configured timeouts. Increasing timeouts in this way has a
corresponding effect on the worst-case time to detect failure and
therefore time to service recovery.
</p>
<p>
LAN environments can typically be configured with stable low
latency, and such that they can provide redundancy with fast
failover. Individual link failures can be recovered from with
minimal and controlled latency visible at the TCP level (where NDB
Cluster normally operates). WAN environments may offer a range of
latencies, as well as redundancy with slower failover times.
Individual link failures may require route changes to propagate
before end-to-end connectivity is restored. At the TCP level this
can appear as large latencies on individual channels. The
worst-case observed TCP latency in these scenarios is related to
the worst-case time for the IP layer to reroute around the
failures.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/replication-functions-synchronization.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="replication-functions-synchronization">
</a>
14.18.4 Position-Based Synchronization Functions
</h3>
</div>
</div>
</div>
<p>
The functions listed in this section are used for controlling
position-based synchronization of source and replica servers in
MySQL Replication.
</p>
<div class="table">
<a name="idm46045193458912">
</a>
<p class="title">
<b>
Table 14.28 Positional Synchronization Functions
</b>
</p>
<div class="table-contents">
<table frame="box" rules="all" summary="A reference that lists functions used with position-based synchronization of replication source and replica servers.">
<colgroup>
<col style="width: 25%"/>
<col style="width: 62%"/>
<col style="width: 12%"/>
</colgroup>
<thead>
<tr>
<th>
Name
</th>
<th>
Description
</th>
<th>
Deprecated
</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">
<a class="link" href="replication-functions-synchronization.html#function_master-pos-wait">
<code class="literal">
MASTER_POS_WAIT()
</code>
</a>
</th>
<td>
Block until the replica has read and applied all updates up to the
specified position
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="replication-functions-synchronization.html#function_source-pos-wait">
<code class="literal">
SOURCE_POS_WAIT()
</code>
</a>
</th>
<td>
Block until the replica has read and applied all updates up to the
specified position
</td>
<td>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<br class="table-break"/>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<a name="function_master-pos-wait">
</a>
<p>
<a class="link" href="replication-functions-synchronization.html#function_master-pos-wait">
<code class="literal">
MASTER_POS_WAIT(
<em class="replaceable">
<code>
log_name
</code>
</em>
,
<em class="replaceable">
<code>
log_pos
</code>
</em>
[,
<em class="replaceable">
<code>
timeout
</code>
</em>
][,
<em class="replaceable">
<code>
channel
</code>
</em>
])
</code>
</a>
</p>
<a class="indexterm" name="idm46045193436720">
</a>
<p>
Deprecated alias for
<a class="link" href="replication-functions-synchronization.html#function_source-pos-wait">
<code class="literal">
SOURCE_POS_WAIT()
</code>
</a>
.
</p>
</li>
<li class="listitem">
<a name="function_source-pos-wait">
</a>
<p>
<a class="link" href="replication-functions-synchronization.html#function_source-pos-wait">
<code class="literal">
SOURCE_POS_WAIT(
<em class="replaceable">
<code>
log_name
</code>
</em>
,
<em class="replaceable">
<code>
log_pos
</code>
</em>
[,
<em class="replaceable">
<code>
timeout
</code>
</em>
][,
<em class="replaceable">
<code>
channel
</code>
</em>
])
</code>
</a>
</p>
<a class="indexterm" name="idm46045193426192">
</a>
<p>
This function is for control of source-replica
synchronization. It blocks until the replica has read and
applied all updates up to the specified position in the
source's binary log.
</p>
<p>
The return value is the number of log events the replica had
to wait for to advance to the specified position. The
function returns
<code class="literal">
NULL
</code>
if the replication
SQL thread is not started, the replica's source information
is not initialized, the arguments are incorrect, or an error
occurs. It returns
<code class="literal">
-1
</code>
if the timeout has
been exceeded. If the replication SQL thread stops while
<a class="link" href="replication-functions-synchronization.html#function_source-pos-wait">
<code class="literal">
SOURCE_POS_WAIT()
</code>
</a>
is waiting,
the function returns
<code class="literal">
NULL
</code>
. If the replica
is past the specified position, the function returns
immediately.
</p>
<p>
If the binary log file position has been marked as invalid,
the function waits until a valid file position is known. The
binary log file position can be marked as invalid when the
<a class="link" href="change-replication-source-to.html" title="15.4.2.2 CHANGE REPLICATION SOURCE TO Statement">
<code class="literal">
CHANGE REPLICATION SOURCE TO
</code>
</a>
option
<code class="literal">
GTID_ONLY
</code>
is set for the
replication channel, and the server is restarted or
replication is stopped. The file position becomes valid
after a transaction is successfully applied past the given
file position. If the applier does not reach the stated
position, the function waits until the timeout. Use a
<a class="link" href="show-replica-status.html" title="15.7.7.35 SHOW REPLICA STATUS Statement">
<code class="literal">
SHOW REPLICA STATUS
</code>
</a>
statement
to check if the binary log file position has been marked as
invalid.
</p>
<p>
On a multithreaded replica, the function waits until expiry
of the limit set by the
<a class="link" href="replication-options-replica.html#sysvar_replica_checkpoint_group">
<code class="literal">
replica_checkpoint_group
</code>
</a>
or
<a class="link" href="replication-options-replica.html#sysvar_replica_checkpoint_period">
<code class="literal">
replica_checkpoint_period
</code>
</a>
system variable, when the checkpoint operation is called to
update the status of the replica. Depending on the setting
for the system variables, the function might therefore
return some time after the specified position was reached.
</p>
<p>
If binary log transaction compression is in use and the
transaction payload at the specified position is compressed
(as a
<code class="literal">
Transaction_payload_event
</code>
), the
function waits until the whole transaction has been read and
applied, and the positions have updated.
</p>
<p>
If a
<em class="replaceable">
<code>
timeout
</code>
</em>
value is specified,
<a class="link" href="replication-functions-synchronization.html#function_source-pos-wait">
<code class="literal">
SOURCE_POS_WAIT()
</code>
</a>
stops
waiting when
<em class="replaceable">
<code>
timeout
</code>
</em>
seconds have
elapsed.
<em class="replaceable">
<code>
timeout
</code>
</em>
must be greater
than or equal to 0. (When the server is running in strict
SQL mode, a negative
<em class="replaceable">
<code>
timeout
</code>
</em>
value is immediately rejected with
<a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html#error_er_wrong_arguments" target="_top">
<code class="literal">
ER_WRONG_ARGUMENTS
</code>
</a>
;
otherwise the function returns
<code class="literal">
NULL
</code>
, and
raises a warning.)
</p>
<p>
The optional
<em class="replaceable">
<code>
channel
</code>
</em>
value
enables you to name which replication channel the function
applies to. See
<a class="xref" href="replication-channels.html" title="19.2.2 Replication Channels">
Section 19.2.2, “Replication Channels”
</a>
for
more information.
</p>
<p>
This function is unsafe for statement-based replication. A
warning is logged if you use this function when
<a class="link" href="replication-options-binary-log.html#sysvar_binlog_format">
<code class="literal">
binlog_format
</code>
</a>
is set to
<code class="literal">
STATEMENT
</code>
.
</p>
</li>
</ul>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/window-functions-frames.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="window-functions-frames">
</a>
14.20.3 Window Function Frame Specification
</h3>
</div>
</div>
</div>
<a class="indexterm" name="idm46045191912704">
</a>
<p>
The definition of a window used with a window function can
include a frame clause. A frame is a subset of the current
partition and the frame clause specifies how to define the
subset.
</p>
<p>
Frames are determined with respect to the current row, which
enables a frame to move within a partition depending on the
location of the current row within its partition. Examples:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
By defining a frame to be all rows from the partition start
to the current row, you can compute running totals for each
row.
</p>
</li>
<li class="listitem">
<p>
By defining a frame as extending
<em class="replaceable">
<code>
N
</code>
</em>
rows on either side of the
current row, you can compute rolling averages.
</p>
</li>
</ul>
</div>
<p>
The following query demonstrates the use of moving frames to
compute running totals within each group of time-ordered
<code class="literal">
level
</code>
values, as well as rolling averages
computed from the current row and the rows that immediately
precede and follow it:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa48095713"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span>
<span class="token datatype">time</span><span class="token punctuation">,</span> <span class="token keyword">subject</span><span class="token punctuation">,</span> val<span class="token punctuation">,</span>
<span class="token function">SUM</span><span class="token punctuation">(</span>val<span class="token punctuation">)</span> <span class="token keyword">OVER</span> <span class="token punctuation">(</span><span class="token keyword">PARTITION</span> <span class="token keyword">BY</span> <span class="token keyword">subject</span> <span class="token keyword">ORDER</span> <span class="token keyword">BY</span> <span class="token datatype">time</span>
<span class="token keyword">ROWS</span> <span class="token keyword">UNBOUNDED</span> <span class="token keyword">PRECEDING</span><span class="token punctuation">)</span>
<span class="token keyword">AS</span> running_total<span class="token punctuation">,</span>
<span class="token function">AVG</span><span class="token punctuation">(</span>val<span class="token punctuation">)</span> <span class="token keyword">OVER</span> <span class="token punctuation">(</span><span class="token keyword">PARTITION</span> <span class="token keyword">BY</span> <span class="token keyword">subject</span> <span class="token keyword">ORDER</span> <span class="token keyword">BY</span> <span class="token datatype">time</span>
<span class="token keyword">ROWS</span> <span class="token operator">BETWEEN</span> <span class="token number">1</span> <span class="token keyword">PRECEDING</span> <span class="token operator">AND</span> <span class="token number">1</span> <span class="token keyword">FOLLOWING</span><span class="token punctuation">)</span>
<span class="token keyword">AS</span> running_average
<span class="token keyword">FROM</span> observations<span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> time <span class="token punctuation">|</span> subject <span class="token punctuation">|</span> val <span class="token punctuation">|</span> running_total <span class="token punctuation">|</span> running_average <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 07:00:00 <span class="token punctuation">|</span> st113 <span class="token punctuation">|</span> 10 <span class="token punctuation">|</span> 10 <span class="token punctuation">|</span> 9.5000 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 07:15:00 <span class="token punctuation">|</span> st113 <span class="token punctuation">|</span> 9 <span class="token punctuation">|</span> 19 <span class="token punctuation">|</span> 14.6667 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 07:30:00 <span class="token punctuation">|</span> st113 <span class="token punctuation">|</span> 25 <span class="token punctuation">|</span> 44 <span class="token punctuation">|</span> 18.0000 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 07:45:00 <span class="token punctuation">|</span> st113 <span class="token punctuation">|</span> 20 <span class="token punctuation">|</span> 64 <span class="token punctuation">|</span> 22.5000 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 07:00:00 <span class="token punctuation">|</span> xh458 <span class="token punctuation">|</span> 0 <span class="token punctuation">|</span> 0 <span class="token punctuation">|</span> 5.0000 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 07:15:00 <span class="token punctuation">|</span> xh458 <span class="token punctuation">|</span> 10 <span class="token punctuation">|</span> 10 <span class="token punctuation">|</span> 5.0000 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 07:30:00 <span class="token punctuation">|</span> xh458 <span class="token punctuation">|</span> 5 <span class="token punctuation">|</span> 15 <span class="token punctuation">|</span> 15.0000 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 07:45:00 <span class="token punctuation">|</span> xh458 <span class="token punctuation">|</span> 30 <span class="token punctuation">|</span> 45 <span class="token punctuation">|</span> 20.0000 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 08:00:00 <span class="token punctuation">|</span> xh458 <span class="token punctuation">|</span> 25 <span class="token punctuation">|</span> 70 <span class="token punctuation">|</span> 27.5000 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
<p>
For the
<code class="literal">
running_average
</code>
column, there is no
frame row preceding the first one or following the last. In
these cases,
<a class="link" href="aggregate-functions.html#function_avg">
<code class="literal">
AVG()
</code>
</a>
computes the
average of the rows that are available.
</p>
<p>
Aggregate functions used as window functions operate on rows in
the current row frame, as do these nonaggregate window
functions:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa33816518"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token function">FIRST_VALUE</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
<span class="token function">LAST_VALUE</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
<span class="token function">NTH_VALUE</span><span class="token punctuation">(</span><span class="token punctuation">)</span></code></pre>
</div>
<p>
Standard SQL specifies that window functions that operate on the
entire partition should have no frame clause. MySQL permits a
frame clause for such functions but ignores it. These functions
use the entire partition even if a frame is specified:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa99005626"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token function">CUME_DIST</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
<span class="token function">DENSE_RANK</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
<span class="token function">LAG</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
<span class="token function">LEAD</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
<span class="token function">NTILE</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
<span class="token function">PERCENT_RANK</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
<span class="token function">RANK</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
<span class="token function">ROW_NUMBER</span><span class="token punctuation">(</span><span class="token punctuation">)</span></code></pre>
</div>
<p>
The frame clause, if given, has this syntax:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa3368279"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><em class="replaceable">frame_clause</em>:
<em class="replaceable">frame_units</em> <em class="replaceable">frame_extent</em>
<em class="replaceable">frame_units</em>:
{<span class="token keyword">ROWS</span> <span class="token operator">|</span> <span class="token keyword">RANGE</span>}</code></pre>
</div>
<p>
In the absence of a frame clause, the default frame depends on
whether an
<code class="literal">
ORDER BY
</code>
clause is present, as
described later in this section.
</p>
<p>
The
<em class="replaceable">
<code>
frame_units
</code>
</em>
value indicates the
type of relationship between the current row and frame rows:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
ROWS
</code>
: The frame is defined by beginning
and ending row positions. Offsets are differences in row
numbers from the current row number.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
RANGE
</code>
: The frame is defined by rows
within a value range. Offsets are differences in row values
from the current row value.
</p>
</li>
</ul>
</div>
<p>
The
<em class="replaceable">
<code>
frame_extent
</code>
</em>
value indicates the
start and end points of the frame. You can specify just the
start of the frame (in which case the current row is implicitly
the end) or use
<code class="literal">
BETWEEN
</code>
to specify both frame
endpoints:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa90545286"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><em class="replaceable">frame_extent</em>:
{<em class="replaceable">frame_start</em> <span class="token operator">|</span> <em class="replaceable">frame_between</em>}
<em class="replaceable">frame_between</em>:
<span class="token operator">BETWEEN</span> <em class="replaceable">frame_start</em> <span class="token operator">AND</span> <em class="replaceable">frame_end</em>
<em class="replaceable">frame_start</em><span class="token punctuation">,</span> <em class="replaceable">frame_end</em>: {
<span class="token keyword">CURRENT</span> <span class="token keyword">ROW</span>
<span class="token operator">|</span> <span class="token keyword">UNBOUNDED</span> <span class="token keyword">PRECEDING</span>
<span class="token operator">|</span> <span class="token keyword">UNBOUNDED</span> <span class="token keyword">FOLLOWING</span>
<span class="token operator">|</span> <em class="replaceable">expr</em> <span class="token keyword">PRECEDING</span>
<span class="token operator">|</span> <em class="replaceable">expr</em> <span class="token keyword">FOLLOWING</span>
}</code></pre>
</div>
<p>
With
<code class="literal">
BETWEEN
</code>
syntax,
<em class="replaceable">
<code>
frame_start
</code>
</em>
must not occur later than
<em class="replaceable">
<code>
frame_end
</code>
</em>
.
</p>
<p>
The permitted
<em class="replaceable">
<code>
frame_start
</code>
</em>
and
<em class="replaceable">
<code>
frame_end
</code>
</em>
values have these meanings:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
CURRENT ROW
</code>
: For
<code class="literal">
ROWS
</code>
,
the bound is the current row. For
<code class="literal">
RANGE
</code>
,
the bound is the peers of the current row.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
UNBOUNDED PRECEDING
</code>
: The bound is the
first partition row.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
UNBOUNDED FOLLOWING
</code>
: The bound is the
last partition row.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<em class="replaceable">
<code>
expr
</code>
</em>
PRECEDING
</code>
: For
<code class="literal">
ROWS
</code>
, the bound
is
<em class="replaceable">
<code>
expr
</code>
</em>
rows before the current
row. For
<code class="literal">
RANGE
</code>
, the bound is the rows
with values equal to the current row value minus
<em class="replaceable">
<code>
expr
</code>
</em>
; if the current row value is
<code class="literal">
NULL
</code>
, the bound is the peers of the row.
</p>
<p>
For
<code class="literal">
<em class="replaceable">
<code>
expr
</code>
</em>
PRECEDING
</code>
(and
<code class="literal">
<em class="replaceable">
<code>
expr
</code>
</em>
FOLLOWING
</code>
),
<em class="replaceable">
<code>
expr
</code>
</em>
can be
a
<code class="literal">
?
</code>
parameter marker (for use in a
prepared statement), a nonnegative numeric literal, or a
temporal interval of the form
<code class="literal">
INTERVAL
<em class="replaceable">
<code>
val
</code>
</em>
<em class="replaceable">
<code>
unit
</code>
</em>
</code>
. For
<code class="literal">
INTERVAL
</code>
expressions,
<em class="replaceable">
<code>
val
</code>
</em>
specifies nonnegative
interval value, and
<em class="replaceable">
<code>
unit
</code>
</em>
is a
keyword indicating the units in which the value should be
interpreted. (For details about the permitted
<em class="replaceable">
<code>
units
</code>
</em>
specifiers, see the
description of the
<a class="link" href="date-and-time-functions.html#function_date-add">
<code class="literal">
DATE_ADD()
</code>
</a>
function in
<a class="xref" href="date-and-time-functions.html" title="14.7 Date and Time Functions">
Section 14.7, “Date and Time Functions”
</a>
.)
</p>
<p>
<code class="literal">
RANGE
</code>
on a numeric or temporal
<em class="replaceable">
<code>
expr
</code>
</em>
requires
<code class="literal">
ORDER
BY
</code>
on a numeric or temporal expression,
respectively.
</p>
<p>
Examples of valid
<code class="literal">
<em class="replaceable">
<code>
expr
</code>
</em>
PRECEDING
</code>
and
<code class="literal">
<em class="replaceable">
<code>
expr
</code>
</em>
FOLLOWING
</code>
indicators:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa2726447"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token number">10</span> <span class="token keyword">PRECEDING</span>
<span class="token keyword">INTERVAL</span> <span class="token number">5</span> <span class="token keyword">DAY</span> <span class="token keyword">PRECEDING</span>
<span class="token number">5</span> <span class="token keyword">FOLLOWING</span>
<span class="token keyword">INTERVAL</span> <span class="token string">'2:30'</span> <span class="token keyword">MINUTE_SECOND</span> <span class="token keyword">FOLLOWING</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
<code class="literal">
<em class="replaceable">
<code>
expr
</code>
</em>
FOLLOWING
</code>
: For
<code class="literal">
ROWS
</code>
, the bound
is
<em class="replaceable">
<code>
expr
</code>
</em>
rows after the current
row. For
<code class="literal">
RANGE
</code>
, the bound is the rows
with values equal to the current row value plus
<em class="replaceable">
<code>
expr
</code>
</em>
; if the current row value is
<code class="literal">
NULL
</code>
, the bound is the peers of the row.
</p>
<p>
For permitted values of
<em class="replaceable">
<code>
expr
</code>
</em>
, see
the description of
<code class="literal">
<em class="replaceable">
<code>
expr
</code>
</em>
PRECEDING
</code>
.
</p>
</li>
</ul>
</div>
<p>
The following query demonstrates
<a class="link" href="window-function-descriptions.html#function_first-value">
<code class="literal">
FIRST_VALUE()
</code>
</a>
,
<a class="link" href="window-function-descriptions.html#function_last-value">
<code class="literal">
LAST_VALUE()
</code>
</a>
, and two instances
of
<a class="link" href="window-function-descriptions.html#function_nth-value">
<code class="literal">
NTH_VALUE()
</code>
</a>
:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa76527300"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span>
<span class="token datatype">time</span><span class="token punctuation">,</span> <span class="token keyword">subject</span><span class="token punctuation">,</span> val<span class="token punctuation">,</span>
<span class="token function">FIRST_VALUE</span><span class="token punctuation">(</span>val<span class="token punctuation">)</span> <span class="token keyword">OVER</span> w <span class="token keyword">AS</span> <span class="token string">'first'</span><span class="token punctuation">,</span>
<span class="token function">LAST_VALUE</span><span class="token punctuation">(</span>val<span class="token punctuation">)</span> <span class="token keyword">OVER</span> w <span class="token keyword">AS</span> <span class="token string">'last'</span><span class="token punctuation">,</span>
<span class="token function">NTH_VALUE</span><span class="token punctuation">(</span>val<span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">)</span> <span class="token keyword">OVER</span> w <span class="token keyword">AS</span> <span class="token string">'second'</span><span class="token punctuation">,</span>
<span class="token function">NTH_VALUE</span><span class="token punctuation">(</span>val<span class="token punctuation">,</span> <span class="token number">4</span><span class="token punctuation">)</span> <span class="token keyword">OVER</span> w <span class="token keyword">AS</span> <span class="token string">'fourth'</span>
<span class="token keyword">FROM</span> observations
<span class="token keyword">WINDOW</span> w <span class="token keyword">AS</span> <span class="token punctuation">(</span><span class="token keyword">PARTITION</span> <span class="token keyword">BY</span> <span class="token keyword">subject</span> <span class="token keyword">ORDER</span> <span class="token keyword">BY</span> <span class="token datatype">time</span>
<span class="token keyword">ROWS</span> <span class="token keyword">UNBOUNDED</span> <span class="token keyword">PRECEDING</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> time <span class="token punctuation">|</span> subject <span class="token punctuation">|</span> val <span class="token punctuation">|</span> first <span class="token punctuation">|</span> last <span class="token punctuation">|</span> second <span class="token punctuation">|</span> fourth <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 07:00:00 <span class="token punctuation">|</span> st113 <span class="token punctuation">|</span> 10 <span class="token punctuation">|</span> 10 <span class="token punctuation">|</span> 10 <span class="token punctuation">|</span> NULL <span class="token punctuation">|</span> NULL <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 07:15:00 <span class="token punctuation">|</span> st113 <span class="token punctuation">|</span> 9 <span class="token punctuation">|</span> 10 <span class="token punctuation">|</span> 9 <span class="token punctuation">|</span> 9 <span class="token punctuation">|</span> NULL <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 07:30:00 <span class="token punctuation">|</span> st113 <span class="token punctuation">|</span> 25 <span class="token punctuation">|</span> 10 <span class="token punctuation">|</span> 25 <span class="token punctuation">|</span> 9 <span class="token punctuation">|</span> NULL <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 07:45:00 <span class="token punctuation">|</span> st113 <span class="token punctuation">|</span> 20 <span class="token punctuation">|</span> 10 <span class="token punctuation">|</span> 20 <span class="token punctuation">|</span> 9 <span class="token punctuation">|</span> 20 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 07:00:00 <span class="token punctuation">|</span> xh458 <span class="token punctuation">|</span> 0 <span class="token punctuation">|</span> 0 <span class="token punctuation">|</span> 0 <span class="token punctuation">|</span> NULL <span class="token punctuation">|</span> NULL <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 07:15:00 <span class="token punctuation">|</span> xh458 <span class="token punctuation">|</span> 10 <span class="token punctuation">|</span> 0 <span class="token punctuation">|</span> 10 <span class="token punctuation">|</span> 10 <span class="token punctuation">|</span> NULL <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 07:30:00 <span class="token punctuation">|</span> xh458 <span class="token punctuation">|</span> 5 <span class="token punctuation">|</span> 0 <span class="token punctuation">|</span> 5 <span class="token punctuation">|</span> 10 <span class="token punctuation">|</span> NULL <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 07:45:00 <span class="token punctuation">|</span> xh458 <span class="token punctuation">|</span> 30 <span class="token punctuation">|</span> 0 <span class="token punctuation">|</span> 30 <span class="token punctuation">|</span> 10 <span class="token punctuation">|</span> 30 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 08:00:00 <span class="token punctuation">|</span> xh458 <span class="token punctuation">|</span> 25 <span class="token punctuation">|</span> 0 <span class="token punctuation">|</span> 25 <span class="token punctuation">|</span> 10 <span class="token punctuation">|</span> 30 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
<p>
Each function uses the rows in the current frame, which, per the
window definition shown, extends from the first partition row to
the current row. For the
<a class="link" href="window-function-descriptions.html#function_nth-value">
<code class="literal">
NTH_VALUE()
</code>
</a>
calls, the current
frame does not always include the requested row; in such cases,
the return value is
<code class="literal">
NULL
</code>
.
</p>
<p>
In the absence of a frame clause, the default frame depends on
whether an
<code class="literal">
ORDER BY
</code>
clause is present:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
With
<code class="literal">
ORDER BY
</code>
: The default frame includes
rows from the partition start through the current row,
including all peers of the current row (rows equal to the
current row according to the
<code class="literal">
ORDER BY
</code>
clause). The default is equivalent to this frame
specification:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa33025844"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">RANGE</span> <span class="token operator">BETWEEN</span> <span class="token keyword">UNBOUNDED</span> <span class="token keyword">PRECEDING</span> <span class="token operator">AND</span> <span class="token keyword">CURRENT</span> <span class="token keyword">ROW</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
Without
<code class="literal">
ORDER BY
</code>
: The default frame
includes all partition rows (because, without
<code class="literal">
ORDER
BY
</code>
, all partition rows are peers). The default is
equivalent to this frame specification:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa20547863"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">RANGE</span> <span class="token operator">BETWEEN</span> <span class="token keyword">UNBOUNDED</span> <span class="token keyword">PRECEDING</span> <span class="token operator">AND</span> <span class="token keyword">UNBOUNDED</span> <span class="token keyword">FOLLOWING</span></code></pre>
</div>
</li>
</ul>
</div>
<p>
Because the default frame differs depending on presence or
absence of
<code class="literal">
ORDER BY
</code>
, adding
<code class="literal">
ORDER
BY
</code>
to a query to get deterministic results may change
the results. (For example, the values produced by
<a class="link" href="aggregate-functions.html#function_sum">
<code class="literal">
SUM()
</code>
</a>
might change.) To obtain
the same results but ordered per
<code class="literal">
ORDER BY
</code>
,
provide an explicit frame specification to be used regardless of
whether
<code class="literal">
ORDER BY
</code>
is present.
</p>
<p>
The meaning of a frame specification can be nonobvious when the
current row value is
<code class="literal">
NULL
</code>
. Assuming that to
be the case, these examples illustrate how various frame
specifications apply:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
ORDER BY X ASC RANGE BETWEEN 10 FOLLOWING AND 15
FOLLOWING
</code>
</p>
<p>
The frame starts at
<code class="literal">
NULL
</code>
and stops at
<code class="literal">
NULL
</code>
, thus includes only rows with value
<code class="literal">
NULL
</code>
.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ORDER BY X ASC RANGE BETWEEN 10 FOLLOWING AND
UNBOUNDED FOLLOWING
</code>
</p>
<p>
The frame starts at
<code class="literal">
NULL
</code>
and stops at the
end of the partition. Because an
<code class="literal">
ASC
</code>
sort
puts
<code class="literal">
NULL
</code>
values first, the frame is the
entire partition.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ORDER BY X DESC RANGE BETWEEN 10 FOLLOWING AND
UNBOUNDED FOLLOWING
</code>
</p>
<p>
The frame starts at
<code class="literal">
NULL
</code>
and stops at the
end of the partition. Because a
<code class="literal">
DESC
</code>
sort
puts
<code class="literal">
NULL
</code>
values last, the frame is only
the
<code class="literal">
NULL
</code>
values.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ORDER BY X ASC RANGE BETWEEN 10 PRECEDING AND
UNBOUNDED FOLLOWING
</code>
</p>
<p>
The frame starts at
<code class="literal">
NULL
</code>
and stops at the
end of the partition. Because an
<code class="literal">
ASC
</code>
sort
puts
<code class="literal">
NULL
</code>
values first, the frame is the
entire partition.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ORDER BY X ASC RANGE BETWEEN 10 PRECEDING AND 10
FOLLOWING
</code>
</p>
<p>
The frame starts at
<code class="literal">
NULL
</code>
and stops at
<code class="literal">
NULL
</code>
, thus includes only rows with value
<code class="literal">
NULL
</code>
.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ORDER BY X ASC RANGE BETWEEN 10 PRECEDING AND 1
PRECEDING
</code>
</p>
<p>
The frame starts at
<code class="literal">
NULL
</code>
and stops at
<code class="literal">
NULL
</code>
, thus includes only rows with value
<code class="literal">
NULL
</code>
.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ORDER BY X ASC RANGE BETWEEN UNBOUNDED PRECEDING
AND 10 FOLLOWING
</code>
</p>
<p>
The frame starts at the beginning of the partition and stops
at rows with value
<code class="literal">
NULL
</code>
. Because an
<code class="literal">
ASC
</code>
sort puts
<code class="literal">
NULL
</code>
values first, the frame is only the
<code class="literal">
NULL
</code>
values.
</p>
</li>
</ul>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/crashing.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="crashing">
</a>
B.3.3.3 What to Do If MySQL Keeps Crashing
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045053952688">
</a>
<p>
Each MySQL version is tested on many platforms before it is
released. This does not mean that there are no bugs in MySQL,
but if there are bugs, they should be very few and can be hard
to find. If you have a problem, it always helps if you try to
find out exactly what crashes your system, because you have a
much better chance of getting the problem fixed quickly.
</p>
<p>
First, you should try to find out whether the problem is that
the
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
server dies or whether your
problem has to do with your client. You can check how long
your
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
server has been up by executing
<a class="link" href="mysqladmin.html" title="6.5.2 mysqladmin — A MySQL Server Administration Program">
<span class="command">
<strong>
mysqladmin version
</strong>
</span>
</a>
. If
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
has died and restarted, you may find
the reason by looking in the server's error log. See
<a class="xref" href="error-log.html" title="7.4.2 The Error Log">
Section 7.4.2, “The Error Log”
</a>
.
</p>
<p>
On some systems, you can find in the error log a stack trace
of where
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
died. Note that the
variable values written in the error log may not always be
100% correct.
</p>
<p>
If you find that
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
fails at startup
during
<code class="literal">
InnoDB
</code>
recovery, refer to
<a class="xref" href="innodb-troubleshooting-recovery.html" title="17.20.2 Troubleshooting Recovery Failures">
Section 17.20.2, “Troubleshooting Recovery Failures”
</a>
.
</p>
<p>
Many unexpected server exits are caused by corrupted data
files or index files. MySQL updates the files on disk with the
<code class="literal">
write()
</code>
system call after every SQL
statement and before the client is notified about the result.
(This is not true if you are running with the
<a class="link" href="server-system-variables.html#sysvar_delay_key_write">
<code class="literal">
delay_key_write
</code>
</a>
system
variable enabled, in which case data files are written but not
index files.) This means that data file contents are safe even
if
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
crashes, because the operating
system ensures that the unflushed data is written to disk. You
can force MySQL to flush everything to disk after every SQL
statement by starting
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
with the
<a class="link" href="server-options.html#option_mysqld_flush">
<code class="option">
--flush
</code>
</a>
option.
</p>
<p>
The preceding means that normally you should not get corrupted
tables unless one of the following happens:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
The MySQL server or the server host was killed in the
middle of an update.
</p>
</li>
<li class="listitem">
<p>
You have found a bug in
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
that
caused it to die in the middle of an update.
</p>
</li>
<li class="listitem">
<p>
Some external program is manipulating data files or index
files at the same time as
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
without locking the table properly.
</p>
</li>
<li class="listitem">
<p>
You are running many
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
servers
using the same data directory on a system that does not
support good file system locks (normally handled by the
<code class="literal">
lockd
</code>
lock manager), or you are running
multiple servers with external locking disabled.
</p>
</li>
<li class="listitem">
<p>
You have a crashed data file or index file that contains
very corrupt data that confused
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
.
</p>
</li>
<li class="listitem">
<p>
You have found a bug in the data storage code. This is not
likely, but it is at least possible. In this case, you can
try to change the storage engine to another engine by
using
<a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
<code class="literal">
ALTER TABLE
</code>
</a>
on a
repaired copy of the table.
</p>
</li>
</ul>
</div>
<p>
Because it is very difficult to know why something is
crashing, first try to check whether things that work for
others result in an unexpected exit for you. Try the following
things:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Stop the
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
server with
<a class="link" href="mysqladmin.html" title="6.5.2 mysqladmin — A MySQL Server Administration Program">
<span class="command">
<strong>
mysqladmin shutdown
</strong>
</span>
</a>
, run
<a class="link" href="myisamchk.html" title="6.6.4 myisamchk — MyISAM Table-Maintenance Utility">
<span class="command">
<strong>
myisamchk --silent --force */*.MYI
</strong>
</span>
</a>
from
the data directory to check all
<code class="literal">
MyISAM
</code>
tables, and restart
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
. This
ensures that you are running from a clean state. See
<a class="xref" href="server-administration.html" title="Chapter 7 MySQL Server Administration">
Chapter 7,
<i>
MySQL Server Administration
</i>
</a>
.
</p>
</li>
<li class="listitem">
<p>
Start
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
with the general query log
enabled (see
<a class="xref" href="query-log.html" title="7.4.3 The General Query Log">
Section 7.4.3, “The General Query Log”
</a>
). Then try to
determine from the information written to the log whether
some specific query kills the server. About 95% of all
bugs are related to a particular query. Normally, this is
one of the last queries in the log file just before the
server restarts. See
<a class="xref" href="query-log.html" title="7.4.3 The General Query Log">
Section 7.4.3, “The General Query Log”
</a>
. If you
can repeatedly kill MySQL with a specific query, even when
you have checked all tables just before issuing it, then
you have isolated the bug and should submit a bug report
for it. See
<a class="xref" href="bug-reports.html" title="1.6 How to Report Bugs or Problems">
Section 1.6, “How to Report Bugs or Problems”
</a>
.
</p>
</li>
<li class="listitem">
<p>
Try to make a test case that we can use to repeat the
problem. See
<a class="xref" href="debugging-mysql.html" title="7.9 Debugging MySQL">
Section 7.9, “Debugging MySQL”
</a>
.
</p>
</li>
<li class="listitem">
<p>
Try the
<code class="literal">
fork_big.pl
</code>
script. (It is
located in the
<code class="filename">
tests
</code>
directory of
source distributions.)
</p>
</li>
<li class="listitem">
<p>
Configuring MySQL for debugging makes it much easier to
gather information about possible errors if something goes
wrong. Reconfigure MySQL with the
<a class="link" href="source-configuration-options.html#option_cmake_with_debug">
<code class="option">
-DWITH_DEBUG=1
</code>
</a>
option to
<span class="command">
<strong>
CMake
</strong>
</span>
and then recompile. See
<a class="xref" href="debugging-mysql.html" title="7.9 Debugging MySQL">
Section 7.9, “Debugging MySQL”
</a>
.
</p>
</li>
<li class="listitem">
<p>
Make sure that you have applied the latest patches for
your operating system.
</p>
</li>
<li class="listitem">
<p>
Use the
<a class="link" href="server-options.html#option_mysqld_external-locking">
<code class="option">
--skip-external-locking
</code>
</a>
option to
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
. On some systems, the
<code class="literal">
lockd
</code>
lock manager does not work
properly; the
<a class="link" href="server-options.html#option_mysqld_external-locking">
<code class="option">
--skip-external-locking
</code>
</a>
option tells
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
not to use external
locking. (This means that you cannot run two
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
servers on the same data
directory and that you must be careful if you use
<a class="link" href="myisamchk.html" title="6.6.4 myisamchk — MyISAM Table-Maintenance Utility">
<span class="command">
<strong>
myisamchk
</strong>
</span>
</a>
. Nevertheless, it may be
instructive to try the option as a test.)
</p>
</li>
<li class="listitem">
<p>
If
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
appears to be running but not
responding, try
<a class="link" href="mysqladmin.html" title="6.5.2 mysqladmin — A MySQL Server Administration Program">
<span class="command">
<strong>
mysqladmin -u root
processlist
</strong>
</span>
</a>
. Sometimes
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
is not hung even though it seems unresponsive. The problem
may be that all connections are in use, or there may be
some internal lock problem.
<a class="link" href="mysqladmin.html" title="6.5.2 mysqladmin — A MySQL Server Administration Program">
<span class="command">
<strong>
mysqladmin -u root
processlist
</strong>
</span>
</a>
usually is able to make a connection
even in these cases, and can provide useful information
about the current number of connections and their status.
</p>
</li>
<li class="listitem">
<p>
Run the command
<a class="link" href="mysqladmin.html" title="6.5.2 mysqladmin — A MySQL Server Administration Program">
<span class="command">
<strong>
mysqladmin -i 5 status
</strong>
</span>
</a>
or
<a class="link" href="mysqladmin.html" title="6.5.2 mysqladmin — A MySQL Server Administration Program">
<span class="command">
<strong>
mysqladmin -i 5 -r status
</strong>
</span>
</a>
in a
separate window to produce statistics while running other
queries.
</p>
</li>
<li class="listitem">
<p>
Try the following:
</p>
<div class="orderedlist">
<ol class="orderedlist" type="1">
<li class="listitem">
<p>
Start
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
from
<span class="command">
<strong>
gdb
</strong>
</span>
(or another debugger). See
<a class="xref" href="debugging-mysql.html" title="7.9 Debugging MySQL">
Section 7.9, “Debugging MySQL”
</a>
.
</p>
</li>
<li class="listitem">
<p>
Run your test scripts.
</p>
</li>
<li class="listitem">
<p>
Print the backtrace and the local variables at the
three lowest levels. In
<span class="command">
<strong>
gdb
</strong>
</span>
, you
can do this with the following commands when
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
has crashed inside
<span class="command">
<strong>
gdb
</strong>
</span>
:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-none"><div class="docs-select-all right" id="sa95747073"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-none">backtrace
info local
up
info local
up
info local</code></pre>
</div>
<p>
With
<span class="command">
<strong>
gdb
</strong>
</span>
, you can also examine
which threads exist with
<code class="literal">
info
threads
</code>
and switch to a specific thread with
<code class="literal">
thread
<em class="replaceable">
<code>
N
</code>
</em>
</code>
, where
<em class="replaceable">
<code>
N
</code>
</em>
is the thread ID.
</p>
</li>
</ol>
</div>
</li>
<li class="listitem">
<p>
Try to simulate your application with a Perl script to
force MySQL to exit or misbehave.
</p>
</li>
<li class="listitem">
<p>
Send a normal bug report. See
<a class="xref" href="bug-reports.html" title="1.6 How to Report Bugs or Problems">
Section 1.6, “How to Report Bugs or Problems”
</a>
. Be even more detailed than
usual. Because MySQL works for many people, the crash
might result from something that exists only on your
computer (for example, an error that is related to your
particular system libraries).
</p>
</li>
<li class="listitem">
<p>
If you have a problem with tables containing
dynamic-length rows and you are using only
<a class="link" href="char.html" title="13.3.2 The CHAR and VARCHAR Types">
<code class="literal">
VARCHAR
</code>
</a>
columns (not
<a class="link" href="blob.html" title="13.3.4 The BLOB and TEXT Types">
<code class="literal">
BLOB
</code>
</a>
or
<a class="link" href="blob.html" title="13.3.4 The BLOB and TEXT Types">
<code class="literal">
TEXT
</code>
</a>
columns), you can try
to change all
<a class="link" href="char.html" title="13.3.2 The CHAR and VARCHAR Types">
<code class="literal">
VARCHAR
</code>
</a>
to
<a class="link" href="char.html" title="13.3.2 The CHAR and VARCHAR Types">
<code class="literal">
CHAR
</code>
</a>
with
<a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
<code class="literal">
ALTER TABLE
</code>
</a>
. This forces
MySQL to use fixed-size rows. Fixed-size rows take a
little extra space, but are much more tolerant to
corruption.
</p>
<p>
The current dynamic row code has been in use for several
years with very few problems, but dynamic-length rows are
by nature more prone to errors, so it may be a good idea
to try this strategy to see whether it helps.
</p>
</li>
<li class="listitem">
<p>
Consider the possibility of hardware faults when
diagnosing problems. Defective hardware can be the cause
of data corruption. Pay particular attention to your
memory and disk subsystems when troubleshooting hardware.
</p>
</li>
</ul>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/mysql-cluster-online-add-node-example.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="mysql-cluster-online-add-node-example">
</a>
25.6.7.3 Adding NDB Cluster Data Nodes Online: Detailed Example
</h4>
</div>
</div>
</div>
<p>
In this section we provide a detailed example illustrating how
to add new NDB Cluster data nodes online, starting with an NDB
Cluster having 2 data nodes in a single node group and
concluding with a cluster having 4 data nodes in 2 node groups.
</p>
<p>
<b>
Starting configuration.
</b>
For purposes of illustration, we assume a minimal
configuration, and that the cluster uses a
<code class="filename">
config.ini
</code>
file containing only the
following information:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-ini"><div class="docs-select-all right" id="sa13456092"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-ini"><span class="token selector">[ndbd default]</span>
<span class="token constant">DataMemory</span> <span class="token attr-value"><span class="token punctuation">=</span> 100M</span>
<span class="token constant">IndexMemory</span> <span class="token attr-value"><span class="token punctuation">=</span> 100M</span>
<span class="token constant">NoOfReplicas</span> <span class="token attr-value"><span class="token punctuation">=</span> 2</span>
<span class="token constant">DataDir</span> <span class="token attr-value"><span class="token punctuation">=</span> /usr/local/mysql/var/mysql-cluster</span>
<span class="token selector">[ndbd]</span>
<span class="token constant">Id</span> <span class="token attr-value"><span class="token punctuation">=</span> 1</span>
<span class="token constant">HostName</span> <span class="token attr-value"><span class="token punctuation">=</span> 198.51.100.1</span>
<span class="token selector">[ndbd]</span>
<span class="token constant">Id</span> <span class="token attr-value"><span class="token punctuation">=</span> 2</span>
<span class="token constant">HostName</span> <span class="token attr-value"><span class="token punctuation">=</span> 198.51.100.2</span>
<span class="token selector">[mgm]</span>
<span class="token constant">HostName</span> <span class="token attr-value"><span class="token punctuation">=</span> 198.51.100.10</span>
<span class="token constant">Id</span> <span class="token attr-value"><span class="token punctuation">=</span> 10</span>
<span class="token selector">[api]</span>
<span class="token constant">Id</span><span class="token attr-value"><span class="token punctuation">=</span>20</span>
<span class="token constant">HostName</span> <span class="token attr-value"><span class="token punctuation">=</span> 198.51.100.20</span>
<span class="token selector">[api]</span>
<span class="token constant">Id</span><span class="token attr-value"><span class="token punctuation">=</span>21</span>
<span class="token constant">HostName</span> <span class="token attr-value"><span class="token punctuation">=</span> 198.51.100.21</span></code></pre>
</div>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
We have left a gap in the sequence between data node IDs and
other nodes. This make it easier later to assign node IDs that
are not already in use to data nodes which are newly added.
</p>
</div>
<p>
We also assume that you have already started the cluster using
the appropriate command line or
<code class="filename">
my.cnf
</code>
options, and that running
<a class="link" href="mysql-cluster-mgm-client-commands.html#ndbclient-show">
<code class="literal">
SHOW
</code>
</a>
in the management
client produces output similar to what is shown here:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-ndbmgm"><div class="docs-select-all right" id="sa62819682"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-ndbmgm"><span class="token operator">--</span> NDB Cluster <span class="token operator">--</span> Management Client <span class="token operator">--</span>
<span class="token prompt">ndb_mgm></span> <span class="token keyword">SHOW</span>
Connected to Management Server at<span class="token operator">:</span> 198<span class="token punctuation">.</span>51<span class="token punctuation">.</span>100<span class="token punctuation">.</span>10<span class="token operator">:</span>1186 <span class="token punctuation">(</span>using cleartext<span class="token punctuation">)</span>
Cluster Configuration
<span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">-</span>
<span class="token selector">[ndbd(NDB)]</span> 2 node<span class="token punctuation">(</span>s<span class="token punctuation">)</span>
id<span class="token operator">=</span>1 @198<span class="token punctuation">.</span>51<span class="token punctuation">.</span>100<span class="token punctuation">.</span>1 <span class="token punctuation">(</span>8<span class="token punctuation">.</span>4<span class="token punctuation">.</span>0<span class="token operator">-</span>ndb<span class="token operator">-</span>8<span class="token punctuation">.</span>4<span class="token punctuation">.</span>0<span class="token punctuation">,</span> Nodegroup<span class="token operator">:</span> 0<span class="token punctuation">,</span> <span class="token operator">*</span><span class="token punctuation">)</span>
id<span class="token operator">=</span>2 @198<span class="token punctuation">.</span>51<span class="token punctuation">.</span>100<span class="token punctuation">.</span>2 <span class="token punctuation">(</span>8<span class="token punctuation">.</span>4<span class="token punctuation">.</span>0<span class="token operator">-</span>ndb<span class="token operator">-</span>8<span class="token punctuation">.</span>4<span class="token punctuation">.</span>0<span class="token punctuation">,</span> Nodegroup<span class="token operator">:</span> 0<span class="token punctuation">)</span>
<span class="token selector">[ndb_mgmd(MGM)]</span> 1 node<span class="token punctuation">(</span>s<span class="token punctuation">)</span>
id<span class="token operator">=</span>10 @198<span class="token punctuation">.</span>51<span class="token punctuation">.</span>100<span class="token punctuation">.</span>10 <span class="token punctuation">(</span>8<span class="token punctuation">.</span>4<span class="token punctuation">.</span>0<span class="token operator">-</span>ndb<span class="token operator">-</span>8<span class="token punctuation">.</span>4<span class="token punctuation">.</span>0<span class="token punctuation">)</span>
<span class="token selector">[mysqld(API)]</span> 2 node<span class="token punctuation">(</span>s<span class="token punctuation">)</span>
id<span class="token operator">=</span>20 @198<span class="token punctuation">.</span>51<span class="token punctuation">.</span>100<span class="token punctuation">.</span>20 <span class="token punctuation">(</span>8<span class="token punctuation">.</span>4<span class="token punctuation">.</span>0<span class="token operator">-</span>ndb<span class="token operator">-</span>8<span class="token punctuation">.</span>4<span class="token punctuation">.</span>0<span class="token punctuation">)</span>
id<span class="token operator">=</span>21 @198<span class="token punctuation">.</span>51<span class="token punctuation">.</span>100<span class="token punctuation">.</span>21 <span class="token punctuation">(</span>8<span class="token punctuation">.</span>4<span class="token punctuation">.</span>0<span class="token operator">-</span>ndb<span class="token operator">-</span>8<span class="token punctuation">.</span>4<span class="token punctuation">.</span>0<span class="token punctuation">)</span></code></pre>
</div>
<p>
Finally, we assume that the cluster contains a single
<a class="link" href="mysql-cluster.html" title="Chapter 25 MySQL NDB Cluster 8.4">
<code class="literal">
NDBCLUSTER
</code>
</a>
table created as shown
here:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa19068166"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">USE</span> n<span class="token punctuation">;</span>
<span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> ips <span class="token punctuation">(</span>
id <span class="token datatype">BIGINT</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span> <span class="token keyword">AUTO_INCREMENT</span> <span class="token keyword">PRIMARY</span> <span class="token keyword">KEY</span><span class="token punctuation">,</span>
country_code <span class="token datatype">CHAR</span><span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">)</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span><span class="token punctuation">,</span>
<span class="token keyword">type</span> <span class="token datatype">CHAR</span><span class="token punctuation">(</span><span class="token number">4</span><span class="token punctuation">)</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span><span class="token punctuation">,</span>
ip_address <span class="token datatype">VARCHAR</span><span class="token punctuation">(</span><span class="token number">15</span><span class="token punctuation">)</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span><span class="token punctuation">,</span>
addresses <span class="token datatype">BIGINT</span> <span class="token keyword">UNSIGNED</span> <span class="token keyword">DEFAULT</span> <span class="token boolean">NULL</span><span class="token punctuation">,</span>
<span class="token datatype">date</span> <span class="token datatype">BIGINT</span> <span class="token keyword">UNSIGNED</span> <span class="token keyword">DEFAULT</span> <span class="token boolean">NULL</span>
<span class="token punctuation">)</span> <span class="token keyword">ENGINE</span> <span class="token keyword">NDBCLUSTER</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
The memory usage and related information shown later in this
section was generated after inserting approximately 50000 rows
into this table.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
In this example, we show the single-threaded
<a class="link" href="mysql-cluster-programs-ndbd.html" title="25.5.1 ndbd — The NDB Cluster Data Node Daemon">
<span class="command">
<strong>
ndbd
</strong>
</span>
</a>
being used for the data node
processes. You can also apply this example, if you are using
the multithreaded
<a class="link" href="mysql-cluster-programs-ndbmtd.html" title="25.5.3 ndbmtd — The NDB Cluster Data Node Daemon (Multi-Threaded)">
<span class="command">
<strong>
ndbmtd
</strong>
</span>
</a>
by substituting
<a class="link" href="mysql-cluster-programs-ndbmtd.html" title="25.5.3 ndbmtd — The NDB Cluster Data Node Daemon (Multi-Threaded)">
<span class="command">
<strong>
ndbmtd
</strong>
</span>
</a>
for
<a class="link" href="mysql-cluster-programs-ndbd.html" title="25.5.1 ndbd — The NDB Cluster Data Node Daemon">
<span class="command">
<strong>
ndbd
</strong>
</span>
</a>
wherever
it appears in the steps that follow.
</p>
</div>
<p>
<b>
Step 1: Update configuration file.
</b>
Open the cluster global configuration file in a text editor
and add
<code class="literal">
[ndbd]
</code>
sections corresponding to
the 2 new data nodes. (We give these data nodes IDs 3 and 4,
and assume that they are to be run on host machines at
addresses 198.51.100.3 and 198.51.100.4, respectively.) After
you have added the new sections, the contents of the
<code class="filename">
config.ini
</code>
file should look like what is
shown here, where the additions to the file are shown in bold
type:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-ini"><div class="docs-select-all right" id="sa23915192"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-ini"><span class="token selector">[ndbd default]</span>
<span class="token constant">DataMemory</span> <span class="token attr-value"><span class="token punctuation">=</span> 100M</span>
<span class="token constant">IndexMemory</span> <span class="token attr-value"><span class="token punctuation">=</span> 100M</span>
<span class="token constant">NoOfReplicas</span> <span class="token attr-value"><span class="token punctuation">=</span> 2</span>
<span class="token constant">DataDir</span> <span class="token attr-value"><span class="token punctuation">=</span> /usr/local/mysql/var/mysql-cluster</span>
<span class="token selector">[ndbd]</span>
<span class="token constant">Id</span> <span class="token attr-value"><span class="token punctuation">=</span> 1</span>
<span class="token constant">HostName</span> <span class="token attr-value"><span class="token punctuation">=</span> 198.51.100.1</span>
<span class="token selector">[ndbd]</span>
<span class="token constant">Id</span> <span class="token attr-value"><span class="token punctuation">=</span> 2</span>
<span class="token constant">HostName</span> <span class="token attr-value"><span class="token punctuation">=</span> 198.51.100.2</span>
<span class="token selector">[ndbd]</span>
<span class="token constant">Id</span> <span class="token attr-value"><span class="token punctuation">=</span> 3</span>
<span class="token constant">HostName</span> <span class="token attr-value"><span class="token punctuation">=</span> 198.51.100.3</span>
<span class="token selector">[ndbd]</span>
<span class="token constant">Id</span> <span class="token attr-value"><span class="token punctuation">=</span> 4</span>
<span class="token constant">HostName</span> <span class="token attr-value"><span class="token punctuation">=</span> 198.51.100.4</span>
<span class="token selector">[mgm]</span>
<span class="token constant">HostName</span> <span class="token attr-value"><span class="token punctuation">=</span> 198.51.100.10</span>
<span class="token constant">Id</span> <span class="token attr-value"><span class="token punctuation">=</span> 10</span>
<span class="token selector">[api]</span>
<span class="token constant">Id</span><span class="token attr-value"><span class="token punctuation">=</span>20</span>
<span class="token constant">HostName</span> <span class="token attr-value"><span class="token punctuation">=</span> 198.51.100.20</span>
<span class="token selector">[api]</span>
<span class="token constant">Id</span><span class="token attr-value"><span class="token punctuation">=</span>21</span>
<span class="token constant">HostName</span> <span class="token attr-value"><span class="token punctuation">=</span> 198.51.100.21</span></code></pre>
</div>
<p>
Once you have made the necessary changes, save the file.
</p>
<p>
<b>
Step 2: Restart the management server.
</b>
Restarting the cluster management server requires that you
issue separate commands to stop the management server and then
to start it again, as follows:
</p>
<div class="orderedlist">
<ol class="orderedlist" type="1">
<li class="listitem">
<p>
Stop the management server using the management client
<a class="link" href="mysql-cluster-mgm-client-commands.html#ndbclient-stop">
<code class="literal">
STOP
</code>
</a>
command, as shown
here:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-ndbmgm"><div class="docs-select-all right" id="sa87708342"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-ndbmgm"><span class="token prompt">ndb_mgm></span> 10 <span class="token keyword">STOP</span>
<span class="token selector">Node 10</span> has shut down<span class="token punctuation">.</span>
Disconnecting to allow Management Server to shutdown
$<span class="token operator">></span></code></pre>
</div>
</li>
<li class="listitem">
<p>
Because shutting down the management server causes the
management client to terminate, you must start the
management server from the system shell. For simplicity, we
assume that
<code class="filename">
config.ini
</code>
is in the same
directory as the management server binary, but in practice,
you must supply the correct path to the configuration file.
You must also supply the
<a class="link" href="mysql-cluster-programs-ndb-mgmd.html#option_ndb_mgmd_reload">
<code class="option">
--reload
</code>
</a>
or
<a class="link" href="mysql-cluster-programs-ndb-mgmd.html#option_ndb_mgmd_initial">
<code class="option">
--initial
</code>
</a>
option so that
the management server reads the new configuration from the
file rather than its configuration cache. If your
shell's current directory is also the same as the
directory where the management server binary is located,
then you can invoke the management server as shown here:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa23635339"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$> </span><span class="token command">ndb_mgmd</span> <span class="token property">-f</span> config<span class="token punctuation">.</span>ini <span class="token property">--reload</span>
2008-12-08 17<span class="token punctuation">:</span>29<span class="token punctuation">:</span>23 <span class="token punctuation">[</span>MgmSrvr<span class="token punctuation">]</span> INFO <span class="token property">--</span> NDB Cluster Management Server<span class="token punctuation">.</span> 8<span class="token punctuation">.</span>4<span class="token punctuation">.</span>0-ndb-8<span class="token punctuation">.</span>4<span class="token punctuation">.</span>0
2008-12-08 17<span class="token punctuation">:</span>29<span class="token punctuation">:</span>23 <span class="token punctuation">[</span>MgmSrvr<span class="token punctuation">]</span> INFO <span class="token property">--</span> Reading cluster configuration from <span class="token atrule">'config.ini'</span></code></pre>
</div>
</li>
</ol>
</div>
<p>
If you check the output of
<a class="link" href="mysql-cluster-mgm-client-commands.html#ndbclient-show">
<code class="literal">
SHOW
</code>
</a>
in the management
client after restarting the
<a class="link" href="mysql-cluster-programs-ndb-mgm.html" title="25.5.5 ndb_mgm — The NDB Cluster Management Client">
<span class="command">
<strong>
ndb_mgm
</strong>
</span>
</a>
process,
you should now see something like this:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-ndbmgm"><div class="docs-select-all right" id="sa57440547"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-ndbmgm"><span class="token operator">--</span> NDB Cluster <span class="token operator">--</span> Management Client <span class="token operator">--</span>
<span class="token prompt">ndb_mgm></span> <span class="token keyword">SHOW</span>
Connected to Management Server at<span class="token operator">:</span> 198<span class="token punctuation">.</span>51<span class="token punctuation">.</span>100<span class="token punctuation">.</span>10<span class="token operator">:</span>1186 <span class="token punctuation">(</span>using cleartext<span class="token punctuation">)</span>
Cluster Configuration
<span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">-</span>
<span class="token selector">[ndbd(NDB)]</span> 2 node<span class="token punctuation">(</span>s<span class="token punctuation">)</span>
id<span class="token operator">=</span>1 @198<span class="token punctuation">.</span>51<span class="token punctuation">.</span>100<span class="token punctuation">.</span>1 <span class="token punctuation">(</span>8<span class="token punctuation">.</span>4<span class="token punctuation">.</span>0<span class="token operator">-</span>ndb<span class="token operator">-</span>8<span class="token punctuation">.</span>4<span class="token punctuation">.</span>0<span class="token punctuation">,</span> Nodegroup<span class="token operator">:</span> 0<span class="token punctuation">,</span> <span class="token operator">*</span><span class="token punctuation">)</span>
id<span class="token operator">=</span>2 @198<span class="token punctuation">.</span>51<span class="token punctuation">.</span>100<span class="token punctuation">.</span>2 <span class="token punctuation">(</span>8<span class="token punctuation">.</span>4<span class="token punctuation">.</span>0<span class="token operator">-</span>ndb<span class="token operator">-</span>8<span class="token punctuation">.</span>4<span class="token punctuation">.</span>0<span class="token punctuation">,</span> Nodegroup<span class="token operator">:</span> 0<span class="token punctuation">)</span>
id<span class="token operator">=</span>3 <span class="token punctuation">(</span>not connected<span class="token punctuation">,</span> accepting connect from 198<span class="token punctuation">.</span>51<span class="token punctuation">.</span>100<span class="token punctuation">.</span>3<span class="token punctuation">)</span>
id<span class="token operator">=</span>4 <span class="token punctuation">(</span>not connected<span class="token punctuation">,</span> accepting connect from 198<span class="token punctuation">.</span>51<span class="token punctuation">.</span>100<span class="token punctuation">.</span>4<span class="token punctuation">)</span>
<span class="token selector">[ndb_mgmd(MGM)]</span> 1 node<span class="token punctuation">(</span>s<span class="token punctuation">)</span>
id<span class="token operator">=</span>10 @198<span class="token punctuation">.</span>51<span class="token punctuation">.</span>100<span class="token punctuation">.</span>10 <span class="token punctuation">(</span>8<span class="token punctuation">.</span>4<span class="token punctuation">.</span>0<span class="token operator">-</span>ndb<span class="token operator">-</span>8<span class="token punctuation">.</span>4<span class="token punctuation">.</span>0<span class="token punctuation">)</span>
<span class="token selector">[mysqld(API)]</span> 2 node<span class="token punctuation">(</span>s<span class="token punctuation">)</span>
id<span class="token operator">=</span>20 @198<span class="token punctuation">.</span>51<span class="token punctuation">.</span>100<span class="token punctuation">.</span>20 <span class="token punctuation">(</span>8<span class="token punctuation">.</span>4<span class="token punctuation">.</span>0<span class="token operator">-</span>ndb<span class="token operator">-</span>8<span class="token punctuation">.</span>4<span class="token punctuation">.</span>0<span class="token punctuation">)</span>
id<span class="token operator">=</span>21 @198<span class="token punctuation">.</span>51<span class="token punctuation">.</span>100<span class="token punctuation">.</span>21 <span class="token punctuation">(</span>8<span class="token punctuation">.</span>4<span class="token punctuation">.</span>0<span class="token operator">-</span>ndb<span class="token operator">-</span>8<span class="token punctuation">.</span>4<span class="token punctuation">.</span>0<span class="token punctuation">)</span></code></pre>
</div>
<p>
<b>
Step 3: Perform a rolling restart of the existing data nodes.
</b>
This step can be accomplished entirely within the cluster
management client using the
<a class="link" href="mysql-cluster-mgm-client-commands.html#ndbclient-restart">
<code class="literal">
RESTART
</code>
</a>
command, as shown
here:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-ndbmgm"><div class="docs-select-all right" id="sa40323017"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-ndbmgm"><span class="token prompt">ndb_mgm></span> 1 <span class="token keyword">RESTART</span>
<span class="token selector">Node 1:</span> Node shutdown initiated
<span class="token selector">Node 1:</span> Node shutdown completed<span class="token punctuation">,</span> restarting<span class="token punctuation">,</span> no start<span class="token punctuation">.</span>
<span class="token selector">Node 1</span> is being restarted
<span class="token prompt">ndb_mgm></span><span class="token selector"> Node 1:</span> Start initiated <span class="token punctuation">(</span>version 8<span class="token punctuation">.</span>4<span class="token punctuation">.</span>0<span class="token punctuation">)</span>
<span class="token selector">Node 1:</span> Started <span class="token punctuation">(</span>version 8<span class="token punctuation">.</span>4<span class="token punctuation">.</span>0<span class="token punctuation">)</span>
<span class="token prompt">ndb_mgm></span> 2 <span class="token keyword">RESTART</span>
<span class="token selector">Node 2:</span> Node shutdown initiated
<span class="token selector">Node 2:</span> Node shutdown completed<span class="token punctuation">,</span> restarting<span class="token punctuation">,</span> no start<span class="token punctuation">.</span>
<span class="token selector">Node 2</span> is being restarted
<span class="token prompt">ndb_mgm></span><span class="token selector"> Node 2:</span> Start initiated <span class="token punctuation">(</span>version 8<span class="token punctuation">.</span>4<span class="token punctuation">.</span>0<span class="token punctuation">)</span>
<span class="token prompt">ndb_mgm></span><span class="token selector"> Node 2:</span> Started <span class="token punctuation">(</span>version 8<span class="token punctuation">.</span>4<span class="token punctuation">.</span>0<span class="token punctuation">)</span></code></pre>
</div>
<div class="important" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Important
</div>
<p>
After issuing each
<code class="literal">
<em class="replaceable">
<code>
X
</code>
</em>
RESTART
</code>
command, wait until the management client
reports
<code class="literal">
Node
<em class="replaceable">
<code>
X
</code>
</em>
: Started
(version ...)
</code>
<span class="emphasis">
<em>
before
</em>
</span>
proceeding
any further.
</p>
</div>
<p>
You can verify that all existing data nodes were restarted using
the updated configuration by checking the
<a class="link" href="mysql-cluster-ndbinfo-nodes.html" title="25.6.17.48 The ndbinfo nodes Table">
<code class="literal">
ndbinfo.nodes
</code>
</a>
table in the
<a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
<span class="command">
<strong>
mysql
</strong>
</span>
</a>
client.
</p>
<p>
<b>
Step 4: Perform a rolling restart of all cluster API nodes.
</b>
Shut down and restart each MySQL server acting as an SQL node
in the cluster using
<a class="link" href="mysqladmin.html" title="6.5.2 mysqladmin — A MySQL Server Administration Program">
<span class="command">
<strong>
mysqladmin shutdown
</strong>
</span>
</a>
followed by
<a class="link" href="mysqld-safe.html" title="6.3.2 mysqld_safe — MySQL Server Startup Script">
<span class="command">
<strong>
mysqld_safe
</strong>
</span>
</a>
(or another startup
script). This should be similar to what is shown here, where
<em class="replaceable">
<code>
password
</code>
</em>
is the MySQL
<code class="literal">
root
</code>
password for a given MySQL server
instance:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa41621347"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$> </span><span class="token command">mysqladmin</span> <span class="token property">-uroot</span> <span class="token property">-p<em class="replaceable">password</em></span> shutdown
081208 20<span class="token punctuation">:</span>19<span class="token punctuation">:</span>56 mysqld_safe mysqld from pid file
/usr/local/mysql/var/tonfisk<span class="token punctuation">.</span>pid ended
<span class="token prompt">$> </span><span class="token command">mysqld_safe</span> <span class="token property">--ndbcluster</span> <span class="token constant">--ndb-connectstring</span><span class="token attr-value"><span class="token punctuation">=</span>198.51.100.10</span> &
081208 20<span class="token punctuation">:</span>20<span class="token punctuation">:</span>06 mysqld_safe Logging to <span class="token atrule">'/usr/local/mysql/var/tonfisk.err'</span><span class="token punctuation">.</span>
081208 20<span class="token punctuation">:</span>20<span class="token punctuation">:</span>06 mysqld_safe Starting mysqld daemon with databases
from /usr/local/mysql/var</code></pre>
</div>
<p>
Of course, the exact input and output depend on how and where
MySQL is installed on the system, as well as which options you
choose to start it (and whether or not some or all of these
options are specified in a
<code class="filename">
my.cnf
</code>
file).
</p>
<p>
<b>
Step 5: Perform an initial start of the new data nodes.
</b>
From a system shell on each of the hosts for the new data
nodes, start the data nodes as shown here, using the
<a class="link" href="mysql-cluster-programs-ndbd.html#option_ndbd_initial">
<code class="option">
--initial
</code>
</a>
option:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa49294466"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$> </span><span class="token command">ndbd</span> <span class="token property">-c</span> 198<span class="token punctuation">.</span>51<span class="token punctuation">.</span>100<span class="token punctuation">.</span>10 <span class="token property">--initial</span></code></pre>
</div>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
Unlike the case with restarting the existing data nodes, you
can start the new data nodes concurrently; you do not need to
wait for one to finish starting before starting the other.
</p>
</div>
<p>
<span class="emphasis">
<em>
Wait until both of the new data nodes have started
before proceeding with the next step
</em>
</span>
. Once the new
data nodes have started, you can see in the output of the
management client
<a class="link" href="mysql-cluster-mgm-client-commands.html#ndbclient-show">
<code class="literal">
SHOW
</code>
</a>
command that they do not yet belong to any node group (as
indicated with bold type here):
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-ndbmgm"><div class="docs-select-all right" id="sa1058055"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-ndbmgm"><span class="token prompt">ndb_mgm></span> <span class="token keyword">SHOW</span>
Connected to Management Server at<span class="token operator">:</span> 198<span class="token punctuation">.</span>51<span class="token punctuation">.</span>100<span class="token punctuation">.</span>10<span class="token operator">:</span>1186 <span class="token punctuation">(</span>using cleartext<span class="token punctuation">)</span>
Cluster Configuration
<span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">-</span>
<span class="token selector">[ndbd(NDB)]</span> 2 node<span class="token punctuation">(</span>s<span class="token punctuation">)</span>
id<span class="token operator">=</span>1 @198<span class="token punctuation">.</span>51<span class="token punctuation">.</span>100<span class="token punctuation">.</span>1 <span class="token punctuation">(</span>8<span class="token punctuation">.</span>4<span class="token punctuation">.</span>0<span class="token operator">-</span>ndb<span class="token operator">-</span>8<span class="token punctuation">.</span>4<span class="token punctuation">.</span>0<span class="token punctuation">,</span> Nodegroup<span class="token operator">:</span> 0<span class="token punctuation">,</span> <span class="token operator">*</span><span class="token punctuation">)</span>
id<span class="token operator">=</span>2 @198<span class="token punctuation">.</span>51<span class="token punctuation">.</span>100<span class="token punctuation">.</span>2 <span class="token punctuation">(</span>8<span class="token punctuation">.</span>4<span class="token punctuation">.</span>0<span class="token operator">-</span>ndb<span class="token operator">-</span>8<span class="token punctuation">.</span>4<span class="token punctuation">.</span>0<span class="token punctuation">,</span> Nodegroup<span class="token operator">:</span> 0<span class="token punctuation">)</span>
id<span class="token operator">=</span>3 @198<span class="token punctuation">.</span>51<span class="token punctuation">.</span>100<span class="token punctuation">.</span>3 <span class="token punctuation">(</span>8<span class="token punctuation">.</span>4<span class="token punctuation">.</span>0<span class="token operator">-</span>ndb<span class="token operator">-</span>8<span class="token punctuation">.</span>4<span class="token punctuation">.</span>0<span class="token punctuation">,</span> no nodegroup<span class="token punctuation">)</span>
id<span class="token operator">=</span>4 @198<span class="token punctuation">.</span>51<span class="token punctuation">.</span>100<span class="token punctuation">.</span>4 <span class="token punctuation">(</span>8<span class="token punctuation">.</span>4<span class="token punctuation">.</span>0<span class="token operator">-</span>ndb<span class="token operator">-</span>8<span class="token punctuation">.</span>4<span class="token punctuation">.</span>0<span class="token punctuation">,</span> no nodegroup<span class="token punctuation">)</span>
<span class="token selector">[ndb_mgmd(MGM)]</span> 1 node<span class="token punctuation">(</span>s<span class="token punctuation">)</span>
id<span class="token operator">=</span>10 @198<span class="token punctuation">.</span>51<span class="token punctuation">.</span>100<span class="token punctuation">.</span>10 <span class="token punctuation">(</span>8<span class="token punctuation">.</span>4<span class="token punctuation">.</span>0<span class="token operator">-</span>ndb<span class="token operator">-</span>8<span class="token punctuation">.</span>4<span class="token punctuation">.</span>0<span class="token punctuation">)</span>
<span class="token selector">[mysqld(API)]</span> 2 node<span class="token punctuation">(</span>s<span class="token punctuation">)</span>
id<span class="token operator">=</span>20 @198<span class="token punctuation">.</span>51<span class="token punctuation">.</span>100<span class="token punctuation">.</span>20 <span class="token punctuation">(</span>8<span class="token punctuation">.</span>4<span class="token punctuation">.</span>0<span class="token operator">-</span>ndb<span class="token operator">-</span>8<span class="token punctuation">.</span>4<span class="token punctuation">.</span>0<span class="token punctuation">)</span>
id<span class="token operator">=</span>21 @198<span class="token punctuation">.</span>51<span class="token punctuation">.</span>100<span class="token punctuation">.</span>21 <span class="token punctuation">(</span>8<span class="token punctuation">.</span>4<span class="token punctuation">.</span>0<span class="token operator">-</span>ndb<span class="token operator">-</span>8<span class="token punctuation">.</span>4<span class="token punctuation">.</span>0<span class="token punctuation">)</span></code></pre>
</div>
<p>
<b>
Step 6: Create a new node group.
</b>
You can do this by issuing a
<a class="link" href="mysql-cluster-mgm-client-commands.html#ndbclient-create-nodegroup">
<code class="literal">
CREATE
NODEGROUP
</code>
</a>
command in the cluster management client.
This command takes as its argument a comma-separated list of
the node IDs of the data nodes to be included in the new node
group, as shown here:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-ndbmgm"><div class="docs-select-all right" id="sa11950999"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-ndbmgm"><span class="token prompt">ndb_mgm></span> <span class="token keyword">CREATE NODEGROUP</span> 3<span class="token punctuation">,</span>4
Nodegroup 1 created</code></pre>
</div>
<p>
By issuing
<a class="link" href="mysql-cluster-mgm-client-commands.html#ndbclient-show">
<code class="literal">
SHOW
</code>
</a>
again, you
can verify that data nodes 3 and 4 have joined the new node
group (again indicated in bold type):
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-ndbmgm"><div class="docs-select-all right" id="sa95877635"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-ndbmgm"><span class="token prompt">ndb_mgm></span> <span class="token keyword">SHOW</span>
Connected to Management Server at<span class="token operator">:</span> 198<span class="token punctuation">.</span>51<span class="token punctuation">.</span>100<span class="token punctuation">.</span>10<span class="token operator">:</span>1186 <span class="token punctuation">(</span>using cleartext<span class="token punctuation">)</span>
Cluster Configuration
<span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">-</span>
<span class="token selector">[ndbd(NDB)]</span> 2 node<span class="token punctuation">(</span>s<span class="token punctuation">)</span>
id<span class="token operator">=</span>1 @198<span class="token punctuation">.</span>51<span class="token punctuation">.</span>100<span class="token punctuation">.</span>1 <span class="token punctuation">(</span>8<span class="token punctuation">.</span>4<span class="token punctuation">.</span>0<span class="token operator">-</span>ndb<span class="token operator">-</span>8<span class="token punctuation">.</span>4<span class="token punctuation">.</span>0<span class="token punctuation">,</span> Nodegroup<span class="token operator">:</span> 0<span class="token punctuation">,</span> <span class="token operator">*</span><span class="token punctuation">)</span>
id<span class="token operator">=</span>2 @198<span class="token punctuation">.</span>51<span class="token punctuation">.</span>100<span class="token punctuation">.</span>2 <span class="token punctuation">(</span>8<span class="token punctuation">.</span>4<span class="token punctuation">.</span>0<span class="token operator">-</span>ndb<span class="token operator">-</span>8<span class="token punctuation">.</span>4<span class="token punctuation">.</span>0<span class="token punctuation">,</span> Nodegroup<span class="token operator">:</span> 0<span class="token punctuation">)</span>
id<span class="token operator">=</span>3 @198<span class="token punctuation">.</span>51<span class="token punctuation">.</span>100<span class="token punctuation">.</span>3 <span class="token punctuation">(</span>8<span class="token punctuation">.</span>4<span class="token punctuation">.</span>0<span class="token operator">-</span>ndb<span class="token operator">-</span>8<span class="token punctuation">.</span>4<span class="token punctuation">.</span>0<span class="token punctuation">,</span> Nodegroup<span class="token operator">:</span> 1<span class="token punctuation">)</span>
id<span class="token operator">=</span>4 @198<span class="token punctuation">.</span>51<span class="token punctuation">.</span>100<span class="token punctuation">.</span>4 <span class="token punctuation">(</span>8<span class="token punctuation">.</span>4<span class="token punctuation">.</span>0<span class="token operator">-</span>ndb<span class="token operator">-</span>8<span class="token punctuation">.</span>4<span class="token punctuation">.</span>0<span class="token punctuation">,</span> Nodegroup<span class="token operator">:</span> 1<span class="token punctuation">)</span>
<span class="token selector">[ndb_mgmd(MGM)]</span> 1 node<span class="token punctuation">(</span>s<span class="token punctuation">)</span>
id<span class="token operator">=</span>10 @198<span class="token punctuation">.</span>51<span class="token punctuation">.</span>100<span class="token punctuation">.</span>10 <span class="token punctuation">(</span>8<span class="token punctuation">.</span>4<span class="token punctuation">.</span>0<span class="token operator">-</span>ndb<span class="token operator">-</span>8<span class="token punctuation">.</span>4<span class="token punctuation">.</span>0<span class="token punctuation">)</span>
<span class="token selector">[mysqld(API)]</span> 2 node<span class="token punctuation">(</span>s<span class="token punctuation">)</span>
id<span class="token operator">=</span>20 @198<span class="token punctuation">.</span>51<span class="token punctuation">.</span>100<span class="token punctuation">.</span>20 <span class="token punctuation">(</span>8<span class="token punctuation">.</span>4<span class="token punctuation">.</span>0<span class="token operator">-</span>ndb<span class="token operator">-</span>8<span class="token punctuation">.</span>4<span class="token punctuation">.</span>0<span class="token punctuation">)</span>
id<span class="token operator">=</span>21 @198<span class="token punctuation">.</span>51<span class="token punctuation">.</span>100<span class="token punctuation">.</span>21 <span class="token punctuation">(</span>8<span class="token punctuation">.</span>4<span class="token punctuation">.</span>0<span class="token operator">-</span>ndb<span class="token operator">-</span>8<span class="token punctuation">.</span>4<span class="token punctuation">.</span>0<span class="token punctuation">)</span></code></pre>
</div>
<p>
<b>
Step 7: Redistribute cluster data.
</b>
When a node group is created, existing data and indexes are
not automatically distributed to the new node group's
data nodes, as you can see by issuing the appropriate
<a class="link" href="mysql-cluster-mgm-client-commands.html#ndbclient-report">
<code class="literal">
REPORT
</code>
</a>
command in the
management client:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-ndbmgm"><div class="docs-select-all right" id="sa18829082"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-ndbmgm"><span class="token prompt">ndb_mgm></span> <span class="token keyword">ALL</span> <span class="token keyword">REPORT</span> <span class="token keyword">MEMORY</span>
<span class="token selector">Node 1:</span> Data usage is 5<span class="token operator">%</span><span class="token punctuation">(</span>177 32K pages of total 3200<span class="token punctuation">)</span>
<span class="token selector">Node 1:</span> Index usage is 0<span class="token operator">%</span><span class="token punctuation">(</span>108 8K pages of total 12832<span class="token punctuation">)</span>
<span class="token selector">Node 2:</span> Data usage is 5<span class="token operator">%</span><span class="token punctuation">(</span>177 32K pages of total 3200<span class="token punctuation">)</span>
<span class="token selector">Node 2:</span> Index usage is 0<span class="token operator">%</span><span class="token punctuation">(</span>108 8K pages of total 12832<span class="token punctuation">)</span>
<span class="token selector">Node 3:</span> Data usage is 0<span class="token operator">%</span><span class="token punctuation">(</span>0 32K pages of total 3200<span class="token punctuation">)</span>
<span class="token selector">Node 3:</span> Index usage is 0<span class="token operator">%</span><span class="token punctuation">(</span>0 8K pages of total 12832<span class="token punctuation">)</span>
<span class="token selector">Node 4:</span> Data usage is 0<span class="token operator">%</span><span class="token punctuation">(</span>0 32K pages of total 3200<span class="token punctuation">)</span>
<span class="token selector">Node 4:</span> Index usage is 0<span class="token operator">%</span><span class="token punctuation">(</span>0 8K pages of total 12832<span class="token punctuation">)</span></code></pre>
</div>
<p>
By using
<a class="link" href="mysql-cluster-programs-ndb-desc.html" title="25.5.9 ndb_desc — Describe NDB Tables">
<span class="command">
<strong>
ndb_desc
</strong>
</span>
</a>
with the
<code class="option">
-p
</code>
option, which causes the output to include
partitioning information, you can see that the table still uses
only 2 partitions (in the
<code class="literal">
Per partition info
</code>
section of the output, shown here in bold text):
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa52094105"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$> </span><span class="token command">ndb_desc</span> <span class="token property">-c</span> 198<span class="token punctuation">.</span>51<span class="token punctuation">.</span>100<span class="token punctuation">.</span>10 <span class="token property">-d</span> n ips <span class="token property">-p</span>
<span class="token property">--</span> ips <span class="token property">--</span>
Version<span class="token punctuation">:</span> 1
Fragment type<span class="token punctuation">:</span> 9
K Value<span class="token punctuation">:</span> 6
Min load factor<span class="token punctuation">:</span> 78
Max load factor<span class="token punctuation">:</span> 80
Temporary table<span class="token punctuation">:</span> no
Number of attributes<span class="token punctuation">:</span> 6
Number of primary keys<span class="token punctuation">:</span> 1
Length of frm data<span class="token punctuation">:</span> 340
Row Checksum<span class="token punctuation">:</span> 1
Row GCI<span class="token punctuation">:</span> 1
SingleUserMode<span class="token punctuation">:</span> 0
ForceVarPart<span class="token punctuation">:</span> 1
FragmentCount<span class="token punctuation">:</span> 2
TableStatus<span class="token punctuation">:</span> Retrieved
<span class="token property">--</span> Attributes <span class="token property">--</span>
id Bigint PRIMARY KEY DISTRIBUTION KEY AT<span class="token attr-value"><span class="token punctuation">=</span>FIXED</span> ST<span class="token attr-value"><span class="token punctuation">=</span>MEMORY</span> AUTO_INCR
country_code Char<span class="token punctuation">(</span>2<span class="token punctuation">;</span>latin1_swedish_ci<span class="token punctuation">)</span> NOT NULL AT<span class="token attr-value"><span class="token punctuation">=</span>FIXED</span> ST<span class="token attr-value"><span class="token punctuation">=</span>MEMORY</span>
type Char<span class="token punctuation">(</span>4<span class="token punctuation">;</span>latin1_swedish_ci<span class="token punctuation">)</span> NOT NULL AT<span class="token attr-value"><span class="token punctuation">=</span>FIXED</span> ST<span class="token attr-value"><span class="token punctuation">=</span>MEMORY</span>
ip_address Varchar<span class="token punctuation">(</span>15<span class="token punctuation">;</span>latin1_swedish_ci<span class="token punctuation">)</span> NOT NULL AT<span class="token attr-value"><span class="token punctuation">=</span>SHORT_VAR</span> ST<span class="token attr-value"><span class="token punctuation">=</span>MEMORY</span>
addresses Bigunsigned NULL AT<span class="token attr-value"><span class="token punctuation">=</span>FIXED</span> ST<span class="token attr-value"><span class="token punctuation">=</span>MEMORY</span>
date Bigunsigned NULL AT<span class="token attr-value"><span class="token punctuation">=</span>FIXED</span> ST<span class="token attr-value"><span class="token punctuation">=</span>MEMORY</span>
<span class="token property">--</span> Indexes <span class="token property">--</span>
PRIMARY KEY<span class="token punctuation">(</span>id<span class="token punctuation">)</span> - UniqueHashIndex
PRIMARY<span class="token punctuation">(</span>id<span class="token punctuation">)</span> - OrderedIndex
<span class="token property">--</span> Per partition info <span class="token property">--</span>
Partition Row count Commit count Frag fixed memory Frag varsized memory
0 26086 26086 1572864 557056
1 26329 26329 1605632 557056</code></pre>
</div>
<p>
You can cause the data to be redistributed among all of the data
nodes by performing, for each
<a class="link" href="mysql-cluster.html" title="Chapter 25 MySQL NDB Cluster 8.4">
<code class="literal">
NDB
</code>
</a>
table, an
<a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
<code class="literal">
ALTER
TABLE ... ALGORITHM=INPLACE, REORGANIZE PARTITION
</code>
</a>
statement in the
<a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
<span class="command">
<strong>
mysql
</strong>
</span>
</a>
client.
</p>
<div class="important" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Important
</div>
<p>
<code class="literal">
ALTER TABLE ... ALGORITHM=INPLACE, REORGANIZE
PARTITION
</code>
does not work on tables that were created
with the
<code class="literal">
MAX_ROWS
</code>
option. Instead, use
<code class="literal">
ALTER TABLE ... ALGORITHM=INPLACE,
MAX_ROWS=...
</code>
to reorganize such tables.
</p>
<p>
Keep in mind that using
<code class="literal">
MAX_ROWS
</code>
to set the
number of partitions per table is deprecated, and you should
use
<code class="literal">
PARTITION_BALANCE
</code>
instead; see
<a class="xref" href="create-table-ndb-comment-options.html" title="15.1.20.12 Setting NDB Comment Options">
Section 15.1.20.12, “Setting NDB Comment Options”
</a>
, for more
information.
</p>
</div>
<p>
After issuing the statement
<code class="literal">
ALTER TABLE ips
ALGORITHM=INPLACE, REORGANIZE PARTITION
</code>
, you can see
using
<a class="link" href="mysql-cluster-programs-ndb-desc.html" title="25.5.9 ndb_desc — Describe NDB Tables">
<span class="command">
<strong>
ndb_desc
</strong>
</span>
</a>
that the data for this table
is now stored using 4 partitions, as shown here (with the
relevant portions of the output in bold type):
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa59578409"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$> </span><span class="token command">ndb_desc</span> <span class="token property">-c</span> 198<span class="token punctuation">.</span>51<span class="token punctuation">.</span>100<span class="token punctuation">.</span>10 <span class="token property">-d</span> n ips <span class="token property">-p</span>
<span class="token property">--</span> ips <span class="token property">--</span>
Version<span class="token punctuation">:</span> 16777217
Fragment type<span class="token punctuation">:</span> 9
K Value<span class="token punctuation">:</span> 6
Min load factor<span class="token punctuation">:</span> 78
Max load factor<span class="token punctuation">:</span> 80
Temporary table<span class="token punctuation">:</span> no
Number of attributes<span class="token punctuation">:</span> 6
Number of primary keys<span class="token punctuation">:</span> 1
Length of frm data<span class="token punctuation">:</span> 341
Row Checksum<span class="token punctuation">:</span> 1
Row GCI<span class="token punctuation">:</span> 1
SingleUserMode<span class="token punctuation">:</span> 0
ForceVarPart<span class="token punctuation">:</span> 1
FragmentCount<span class="token punctuation">:</span> 4
TableStatus<span class="token punctuation">:</span> Retrieved
<span class="token property">--</span> Attributes <span class="token property">--</span>
id Bigint PRIMARY KEY DISTRIBUTION KEY AT<span class="token attr-value"><span class="token punctuation">=</span>FIXED</span> ST<span class="token attr-value"><span class="token punctuation">=</span>MEMORY</span> AUTO_INCR
country_code Char<span class="token punctuation">(</span>2<span class="token punctuation">;</span>latin1_swedish_ci<span class="token punctuation">)</span> NOT NULL AT<span class="token attr-value"><span class="token punctuation">=</span>FIXED</span> ST<span class="token attr-value"><span class="token punctuation">=</span>MEMORY</span>
type Char<span class="token punctuation">(</span>4<span class="token punctuation">;</span>latin1_swedish_ci<span class="token punctuation">)</span> NOT NULL AT<span class="token attr-value"><span class="token punctuation">=</span>FIXED</span> ST<span class="token attr-value"><span class="token punctuation">=</span>MEMORY</span>
ip_address Varchar<span class="token punctuation">(</span>15<span class="token punctuation">;</span>latin1_swedish_ci<span class="token punctuation">)</span> NOT NULL AT<span class="token attr-value"><span class="token punctuation">=</span>SHORT_VAR</span> ST<span class="token attr-value"><span class="token punctuation">=</span>MEMORY</span>
addresses Bigunsigned NULL AT<span class="token attr-value"><span class="token punctuation">=</span>FIXED</span> ST<span class="token attr-value"><span class="token punctuation">=</span>MEMORY</span>
date Bigunsigned NULL AT<span class="token attr-value"><span class="token punctuation">=</span>FIXED</span> ST<span class="token attr-value"><span class="token punctuation">=</span>MEMORY</span>
<span class="token property">--</span> Indexes <span class="token property">--</span>
PRIMARY KEY<span class="token punctuation">(</span>id<span class="token punctuation">)</span> - UniqueHashIndex
PRIMARY<span class="token punctuation">(</span>id<span class="token punctuation">)</span> - OrderedIndex
<span class="token property">--</span> Per partition info <span class="token property">--</span>
Partition Row count Commit count Frag fixed memory Frag varsized memory
0 12981 52296 1572864 557056
1 13236 52515 1605632 557056
2 13105 13105 819200 294912
3 13093 13093 819200 294912</code></pre>
</div>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
Normally,
<a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
<code class="literal">
ALTER
TABLE
<em class="replaceable">
<code>
table_name
</code>
</em>
[ALGORITHM=INPLACE,] REORGANIZE PARTITION
</code>
</a>
is used
with a list of partition identifiers and a set of partition
definitions to create a new partitioning scheme for a table
that has already been explicitly partitioned. Its use here to
redistribute data onto a new NDB Cluster node group is an
exception in this regard; when used in this way, no other
keywords or identifiers follow
<code class="literal">
REORGANIZE
PARTITION
</code>
.
</p>
<p>
For more information, see
<a class="xref" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
Section 15.1.9, “ALTER TABLE Statement”
</a>
.
</p>
</div>
<p>
In addition, for each table, the
<a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
<code class="literal">
ALTER
TABLE
</code>
</a>
statement should be followed by an
<a class="link" href="optimize-table.html" title="15.7.3.4 OPTIMIZE TABLE Statement">
<code class="literal">
OPTIMIZE TABLE
</code>
</a>
to reclaim wasted
space. You can obtain a list of all
<a class="link" href="mysql-cluster.html" title="Chapter 25 MySQL NDB Cluster 8.4">
<code class="literal">
NDBCLUSTER
</code>
</a>
tables using the
following query against the Information Schema
<a class="link" href="information-schema-tables-table.html" title="28.3.38 The INFORMATION_SCHEMA TABLES Table">
<code class="literal">
TABLES
</code>
</a>
table:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa1152625"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> TABLE_SCHEMA<span class="token punctuation">,</span> <span class="token keyword">TABLE_NAME</span>
<span class="token keyword">FROM</span> INFORMATION_SCHEMA<span class="token punctuation">.</span><span class="token keyword">TABLES</span>
<span class="token keyword">WHERE</span> <span class="token keyword">ENGINE</span> <span class="token operator">=</span> <span class="token string">'NDBCLUSTER'</span><span class="token punctuation">;</span></code></pre>
</div>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
The
<code class="literal">
INFORMATION_SCHEMA.TABLES.ENGINE
</code>
value
for an NDB Cluster table is always
<a class="link" href="mysql-cluster.html" title="Chapter 25 MySQL NDB Cluster 8.4">
<code class="literal">
NDBCLUSTER
</code>
</a>
, regardless of whether
the
<code class="literal">
CREATE TABLE
</code>
statement used to create
the table (or
<a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
<code class="literal">
ALTER TABLE
</code>
</a>
statement used to convert an existing table from a different
storage engine) used
<a class="link" href="mysql-cluster.html" title="Chapter 25 MySQL NDB Cluster 8.4">
<code class="literal">
NDB
</code>
</a>
or
<a class="link" href="mysql-cluster.html" title="Chapter 25 MySQL NDB Cluster 8.4">
<code class="literal">
NDBCLUSTER
</code>
</a>
in its
<code class="literal">
ENGINE
</code>
option.
</p>
</div>
<p>
You can see after performing these statements in the output of
<a class="link" href="mysql-cluster-mgm-client-commands.html#ndbclient-report">
<code class="literal">
ALL REPORT MEMORY
</code>
</a>
that the
data and indexes are now redistributed between all cluster data
nodes, as shown here:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-ndbmgm"><div class="docs-select-all right" id="sa24158856"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-ndbmgm"><span class="token prompt">ndb_mgm></span> <span class="token keyword">ALL</span> <span class="token keyword">REPORT</span> <span class="token keyword">MEMORY</span>
<span class="token selector">Node 1:</span> Data usage is 5<span class="token operator">%</span><span class="token punctuation">(</span>176 32K pages of total 3200<span class="token punctuation">)</span>
<span class="token selector">Node 1:</span> Index usage is 0<span class="token operator">%</span><span class="token punctuation">(</span>76 8K pages of total 12832<span class="token punctuation">)</span>
<span class="token selector">Node 2:</span> Data usage is 5<span class="token operator">%</span><span class="token punctuation">(</span>176 32K pages of total 3200<span class="token punctuation">)</span>
<span class="token selector">Node 2:</span> Index usage is 0<span class="token operator">%</span><span class="token punctuation">(</span>76 8K pages of total 12832<span class="token punctuation">)</span>
<span class="token selector">Node 3:</span> Data usage is 2<span class="token operator">%</span><span class="token punctuation">(</span>80 32K pages of total 3200<span class="token punctuation">)</span>
<span class="token selector">Node 3:</span> Index usage is 0<span class="token operator">%</span><span class="token punctuation">(</span>51 8K pages of total 12832<span class="token punctuation">)</span>
<span class="token selector">Node 4:</span> Data usage is 2<span class="token operator">%</span><span class="token punctuation">(</span>80 32K pages of total 3200<span class="token punctuation">)</span>
<span class="token selector">Node 4:</span> Index usage is 0<span class="token operator">%</span><span class="token punctuation">(</span>50 8K pages of total 12832<span class="token punctuation">)</span></code></pre>
</div>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
Since only one DDL operation on
<a class="link" href="mysql-cluster.html" title="Chapter 25 MySQL NDB Cluster 8.4">
<code class="literal">
NDBCLUSTER
</code>
</a>
tables can be executed
at a time, you must wait for each
<a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
<code class="literal">
ALTER TABLE ...
REORGANIZE PARTITION
</code>
</a>
statement to finish before
issuing the next one.
</p>
</div>
<p>
It is not necessary to issue
<a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
<code class="literal">
ALTER TABLE ...
REORGANIZE PARTITION
</code>
</a>
statements for
<a class="link" href="mysql-cluster.html" title="Chapter 25 MySQL NDB Cluster 8.4">
<code class="literal">
NDBCLUSTER
</code>
</a>
tables created
<span class="emphasis">
<em>
after
</em>
</span>
the new data nodes have been added;
data added to such tables is distributed among all data nodes
automatically. However, in
<a class="link" href="mysql-cluster.html" title="Chapter 25 MySQL NDB Cluster 8.4">
<code class="literal">
NDBCLUSTER
</code>
</a>
tables that existed
<span class="emphasis">
<em>
prior to
</em>
</span>
the addition of the new nodes,
neither existing nor new data is distributed using the new nodes
until these tables have been reorganized using
<a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
<code class="literal">
ALTER TABLE ...
REORGANIZE PARTITION
</code>
</a>
.
</p>
<p>
<b>
Alternative procedure, without rolling restart.
</b>
It is possible to avoid the need for a rolling restart by
configuring the extra data nodes, but not starting them, when
first starting the cluster. We assume, as before, that you
wish to start with two data nodes—nodes 1 and 2—in
one node group and later to expand the cluster to four data
nodes, by adding a second node group consisting of nodes 3 and
4:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-ini"><div class="docs-select-all right" id="sa82398557"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-ini"><span class="token selector">[ndbd default]</span>
<span class="token constant">DataMemory</span> <span class="token attr-value"><span class="token punctuation">=</span> 100M</span>
<span class="token constant">IndexMemory</span> <span class="token attr-value"><span class="token punctuation">=</span> 100M</span>
<span class="token constant">NoOfReplicas</span> <span class="token attr-value"><span class="token punctuation">=</span> 2</span>
<span class="token constant">DataDir</span> <span class="token attr-value"><span class="token punctuation">=</span> /usr/local/mysql/var/mysql-cluster</span>
<span class="token selector">[ndbd]</span>
<span class="token constant">Id</span> <span class="token attr-value"><span class="token punctuation">=</span> 1</span>
<span class="token constant">HostName</span> <span class="token attr-value"><span class="token punctuation">=</span> 198.51.100.1</span>
<span class="token selector">[ndbd]</span>
<span class="token constant">Id</span> <span class="token attr-value"><span class="token punctuation">=</span> 2</span>
<span class="token constant">HostName</span> <span class="token attr-value"><span class="token punctuation">=</span> 198.51.100.2</span>
<span class="token selector">[ndbd]</span>
<span class="token constant">Id</span> <span class="token attr-value"><span class="token punctuation">=</span> 3</span>
<span class="token constant">HostName</span> <span class="token attr-value"><span class="token punctuation">=</span> 198.51.100.3</span>
<span class="token constant">Nodegroup</span> <span class="token attr-value"><span class="token punctuation">=</span> 65536</span>
<span class="token selector">[ndbd]</span>
<span class="token constant">Id</span> <span class="token attr-value"><span class="token punctuation">=</span> 4</span>
<span class="token constant">HostName</span> <span class="token attr-value"><span class="token punctuation">=</span> 198.51.100.4</span>
<span class="token constant">Nodegroup</span> <span class="token attr-value"><span class="token punctuation">=</span> 65536</span>
<span class="token selector">[mgm]</span>
<span class="token constant">HostName</span> <span class="token attr-value"><span class="token punctuation">=</span> 198.51.100.10</span>
<span class="token constant">Id</span> <span class="token attr-value"><span class="token punctuation">=</span> 10</span>
<span class="token selector">[api]</span>
<span class="token constant">Id</span><span class="token attr-value"><span class="token punctuation">=</span>20</span>
<span class="token constant">HostName</span> <span class="token attr-value"><span class="token punctuation">=</span> 198.51.100.20</span>
<span class="token selector">[api]</span>
<span class="token constant">Id</span><span class="token attr-value"><span class="token punctuation">=</span>21</span>
<span class="token constant">HostName</span> <span class="token attr-value"><span class="token punctuation">=</span> 198.51.100.21</span></code></pre>
</div>
<p>
The data nodes to be brought online at a later time (nodes 3 and
4) can be configured with
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-nodegroup">
<code class="literal">
NodeGroup = 65536
</code>
</a>
, in
which case nodes 1 and 2 can each be started as shown here:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa8213902"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$> </span><span class="token command">ndbd</span> <span class="token property">-c</span> 198<span class="token punctuation">.</span>51<span class="token punctuation">.</span>100<span class="token punctuation">.</span>10 <span class="token property">--initial</span></code></pre>
</div>
<p>
The data nodes configured with
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-nodegroup">
<code class="literal">
NodeGroup = 65536
</code>
</a>
are
treated by the management server as though you had started nodes
1 and 2 using
<a class="link" href="mysql-cluster-programs-ndbd.html#option_ndbd_nowait-nodes">
<code class="option">
--nowait-nodes=3,4
</code>
</a>
after waiting for a period of time determined by the setting for
the
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-startnonodegrouptimeout">
<code class="literal">
StartNoNodeGroupTimeout
</code>
</a>
data node configuration parameter. By default, this is 15
seconds (15000 milliseconds).
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-startnonodegrouptimeout">
<code class="literal">
StartNoNodegroupTimeout
</code>
</a>
must be the same for all data nodes in the cluster; for this
reason, you should always set it in the
<code class="literal">
[ndbd
default]
</code>
section of the
<code class="filename">
config.ini
</code>
file, rather than for
individual data nodes.
</p>
</div>
<p>
When you are ready to add the second node group, you need only
perform the following additional steps:
</p>
<div class="orderedlist">
<ol class="orderedlist" type="1">
<li class="listitem">
<p>
Start data nodes 3 and 4, invoking the data node process
once for each new node:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa236962"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$> </span><span class="token command">ndbd</span> <span class="token property">-c</span> 198<span class="token punctuation">.</span>51<span class="token punctuation">.</span>100<span class="token punctuation">.</span>10 <span class="token property">--initial</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
Issue the appropriate
<a class="link" href="mysql-cluster-mgm-client-commands.html#ndbclient-create-nodegroup">
<code class="literal">
CREATE
NODEGROUP
</code>
</a>
command in the management client:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-ndbmgm"><div class="docs-select-all right" id="sa86732323"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-ndbmgm"><span class="token prompt">ndb_mgm></span> <span class="token keyword">CREATE NODEGROUP</span> 3<span class="token punctuation">,</span>4</code></pre>
</div>
</li>
<li class="listitem">
<p>
In the
<a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
<span class="command">
<strong>
mysql
</strong>
</span>
</a>
client, issue
<a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
<code class="literal">
ALTER TABLE ...
REORGANIZE PARTITION
</code>
</a>
and
<a class="link" href="optimize-table.html" title="15.7.3.4 OPTIMIZE TABLE Statement">
<code class="literal">
OPTIMIZE TABLE
</code>
</a>
statements for
each existing
<a class="link" href="mysql-cluster.html" title="Chapter 25 MySQL NDB Cluster 8.4">
<code class="literal">
NDBCLUSTER
</code>
</a>
table.
(As noted elsewhere in this section, existing NDB Cluster
tables cannot use the new nodes for data distribution until
this has been done.)
</p>
</li>
</ol>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/faqs.html | <div id="docs-body">
<div class="appendix">
<div class="titlepage">
<div>
<div>
<h1 class="title">
<a name="faqs">
</a>
Appendix A MySQL 8.4 Frequently Asked Questions
</h1>
</div>
</div>
</div>
<div class="toc">
<p>
<b>
Table of Contents
</b>
</p>
<dl class="toc">
<dt>
<span class="section">
<a href="faqs-general.html">
A.1 MySQL 8.4 FAQ: General
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="faqs-storage-engines.html">
A.2 MySQL 8.4 FAQ: Storage Engines
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="faqs-sql-modes.html">
A.3 MySQL 8.4 FAQ: Server SQL Mode
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="faqs-stored-procs.html">
A.4 MySQL 8.4 FAQ: Stored Procedures and Functions
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="faqs-triggers.html">
A.5 MySQL 8.4 FAQ: Triggers
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="faqs-views.html">
A.6 MySQL 8.4 FAQ: Views
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="faqs-information-schema.html">
A.7 MySQL 8.4 FAQ: INFORMATION_SCHEMA
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="faqs-migration.html">
A.8 MySQL 8.4 FAQ: Migration
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="faqs-security.html">
A.9 MySQL 8.4 FAQ: Security
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="faqs-mysql-cluster.html">
A.10 MySQL 8.4 FAQ: NDB Cluster
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="faqs-cjk.html">
A.11 MySQL 8.4 FAQ: MySQL Chinese, Japanese, and Korean
Character Sets
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="faqs-connectors-apis.html">
A.12 MySQL 8.4 FAQ: Connectors & APIs
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="faqs-c-api.html">
A.13 MySQL 8.4 FAQ: C API, libmysql
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="faqs-replication.html">
A.14 MySQL 8.4 FAQ: Replication
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="faqs-thread-pool.html">
A.15 MySQL 8.4 FAQ: MySQL Enterprise Thread Pool
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="faqs-innodb-change-buffer.html">
A.16 MySQL 8.4 FAQ: InnoDB Change Buffer
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="faqs-tablespace-encryption.html">
A.17 MySQL 8.4 FAQ: InnoDB Data-at-Rest Encryption
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="faqs-virtualization.html">
A.18 MySQL 8.4 FAQ: Virtualization Support
</a>
</span>
</dt>
</dl>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/mysql-cluster-overview.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h2 class="title">
<a name="mysql-cluster-overview">
</a>
25.2 NDB Cluster Overview
</h2>
</div>
</div>
</div>
<div class="toc">
<dl class="toc">
<dt>
<span class="section">
<a href="mysql-cluster-basics.html">
25.2.1 NDB Cluster Core Concepts
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="mysql-cluster-nodes-groups.html">
25.2.2 NDB Cluster Nodes, Node Groups, Fragment Replicas, and Partitions
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="mysql-cluster-overview-requirements.html">
25.2.3 NDB Cluster Hardware, Software, and Networking Requirements
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="mysql-cluster-what-is-new.html">
25.2.4 What is New in MySQL NDB Cluster 8.4
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="mysql-cluster-added-deprecated-removed.html">
25.2.5 Options, Variables, and Parameters Added, Deprecated or Removed in NDB
8.4
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="mysql-cluster-compared.html">
25.2.6 MySQL Server Using InnoDB Compared with NDB Cluster
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="mysql-cluster-limitations.html">
25.2.7 Known Limitations of NDB Cluster
</a>
</span>
</dt>
</dl>
</div>
<a class="indexterm" name="idm46045124382240">
</a>
<p>
<span class="firstterm">
NDB Cluster
</span>
is a technology
that enables clustering of in-memory databases in a shared-nothing
system. The shared-nothing architecture enables the system to work
with very inexpensive hardware, and with a minimum of specific
requirements for hardware or software.
</p>
<p>
NDB Cluster is designed not to have any single point of failure. In
a shared-nothing system, each component is expected to have its own
memory and disk, and the use of shared storage mechanisms such as
network shares, network file systems, and SANs is not recommended or
supported.
</p>
<p>
NDB Cluster integrates the standard MySQL server with an in-memory
clustered storage engine called
<a class="link" href="mysql-cluster.html" title="Chapter 25 MySQL NDB Cluster 8.4">
<code class="literal">
NDB
</code>
</a>
(which stands for
<span class="quote">
“
<span class="quote">
<span class="emphasis">
<em>
N
</em>
</span>
etwork
<span class="emphasis">
<em>
D
</em>
</span>
ata
<span class="emphasis">
<em>
B
</em>
</span>
ase
</span>
”
</span>
). In our
documentation, the term
<a class="link" href="mysql-cluster.html" title="Chapter 25 MySQL NDB Cluster 8.4">
<code class="literal">
NDB
</code>
</a>
refers to
the part of the setup that is specific to the storage engine,
whereas
<span class="quote">
“
<span class="quote">
MySQL NDB Cluster
</span>
”
</span>
refers to the combination
of one or more MySQL servers with the
<a class="link" href="mysql-cluster.html" title="Chapter 25 MySQL NDB Cluster 8.4">
<code class="literal">
NDB
</code>
</a>
storage engine.
</p>
<p>
An NDB Cluster consists of a set of computers, known as
<span class="firstterm">
hosts
</span>
, each running one or
more processes. These processes, known as
<span class="firstterm">
nodes
</span>
, may include MySQL
servers (for access to NDB data), data nodes (for storage of the
data), one or more management servers, and possibly other
specialized data access programs. The relationship of these
components in an NDB Cluster is shown here:
</p>
<div class="figure">
<a name="fig-mysql-cluster-components">
</a>
<p class="title">
<b>
Figure 25.1 NDB Cluster Components
</b>
</p>
<div class="figure-contents">
<div class="mediaobject">
<img alt="In this cluster, three MySQL servers (mysqld program) are SQL nodes that provide access to four data nodes (ndbd program) that store data. The SQL nodes and data nodes are under the control of an NDB management server (ndb_mgmd program). Various clients and APIs can interact with the SQL nodes - the mysql client, the MySQL C API, PHP, Connector/J, and Connector/NET. Custom clients can also be created using the NDB API to interact with the data nodes or the NDB management server. The NDB management client (ndb_mgm program) interacts with the NDB management server." src="images/cluster-components-1.png" style="width: 100%; max-width: 750px;"/>
</div>
</div>
</div>
<br class="figure-break"/>
<p>
All these programs work together to form an NDB Cluster (see
<a class="xref" href="mysql-cluster-programs.html" title="25.5 NDB Cluster Programs">
Section 25.5, “NDB Cluster Programs”
</a>
. When data is stored by the
<a class="link" href="mysql-cluster.html" title="Chapter 25 MySQL NDB Cluster 8.4">
<code class="literal">
NDB
</code>
</a>
storage engine, the tables (and
table data) are stored in the data nodes. Such tables are directly
accessible from all other MySQL servers (SQL nodes) in the cluster.
Thus, in a payroll application storing data in a cluster, if one
application updates the salary of an employee, all other MySQL
servers that query this data can see this change immediately.
</p>
<p>
An NDB Cluster 8.4 SQL node uses the
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
server daemon, which is the same as the
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
supplied with MySQL Server
8.4 distributions. You should keep in mind that
<span class="emphasis">
<em>
an instance of
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
, regardless of
version, that is not connected to an NDB Cluster cannot use the
<a class="link" href="mysql-cluster.html" title="Chapter 25 MySQL NDB Cluster 8.4">
<code class="literal">
NDB
</code>
</a>
storage engine and cannot access
any NDB Cluster data
</em>
</span>
.
</p>
<p>
The data stored in the data nodes for NDB Cluster can be mirrored;
the cluster can handle failures of individual data nodes with no
other impact than that a small number of transactions are aborted
due to losing the transaction state. Because transactional
applications are expected to handle transaction failure, this should
not be a source of problems.
</p>
<p>
Individual nodes can be stopped and restarted, and can then rejoin
the system (cluster). Rolling restarts (in which all nodes are
restarted in turn) are used in making configuration changes and
software upgrades (see
<a class="xref" href="mysql-cluster-rolling-restart.html" title="25.6.5 Performing a Rolling Restart of an NDB Cluster">
Section 25.6.5, “Performing a Rolling Restart of an NDB Cluster”
</a>
). Rolling restarts
are also used as part of the process of adding new data nodes online
(see
<a class="xref" href="mysql-cluster-online-add-node.html" title="25.6.7 Adding NDB Cluster Data Nodes Online">
Section 25.6.7, “Adding NDB Cluster Data Nodes Online”
</a>
). For more
information about data nodes, how they are organized in an NDB
Cluster, and how they handle and store NDB Cluster data, see
<a class="xref" href="mysql-cluster-nodes-groups.html" title="25.2.2 NDB Cluster Nodes, Node Groups, Fragment Replicas, and Partitions">
Section 25.2.2, “NDB Cluster Nodes, Node Groups, Fragment Replicas, and Partitions”
</a>
.
</p>
<p>
Backing up and restoring NDB Cluster databases can be done using the
<code class="literal">
NDB
</code>
-native functionality found in the NDB Cluster
management client and the
<a class="link" href="mysql-cluster-programs-ndb-restore.html" title="25.5.23 ndb_restore — Restore an NDB Cluster Backup">
<span class="command">
<strong>
ndb_restore
</strong>
</span>
</a>
program
included in the NDB Cluster distribution. For more information, see
<a class="xref" href="mysql-cluster-backup.html" title="25.6.8 Online Backup of NDB Cluster">
Section 25.6.8, “Online Backup of NDB Cluster”
</a>
, and
<a class="xref" href="mysql-cluster-programs-ndb-restore.html" title="25.5.23 ndb_restore — Restore an NDB Cluster Backup">
Section 25.5.23, “ndb_restore — Restore an NDB Cluster Backup”
</a>
. You can also
use the standard MySQL functionality provided for this purpose in
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
and the MySQL server. See
<a class="xref" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
Section 6.5.4, “mysqldump — A Database Backup Program”
</a>
, for more information.
</p>
<p>
NDB Cluster nodes can employ different transport mechanisms for
inter-node communications; TCP/IP over standard 100 Mbps or faster
Ethernet hardware is used in most real-world deployments.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/pluggable-authentication.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="pluggable-authentication">
</a>
8.2.17 Pluggable Authentication
</h3>
</div>
</div>
</div>
<p>
When a client connects to the MySQL server, the server uses the
user name provided by the client and the client host to select the
appropriate account row from the
<code class="literal">
mysql.user
</code>
system table. The server then authenticates the client,
determining from the account row which authentication plugin
applies to the client:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
If the server cannot find the plugin, an error occurs and the
connection attempt is rejected.
</p>
</li>
<li class="listitem">
<p>
Otherwise, the server invokes that plugin to authenticate the
user, and the plugin returns a status to the server indicating
whether the user provided the correct password and is
permitted to connect.
</p>
</li>
</ul>
</div>
<p>
Pluggable authentication enables these important capabilities:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<b>
Choice of authentication methods.
</b>
Pluggable authentication makes it easy for DBAs to choose
and change the authentication method used for individual
MySQL accounts.
</p>
</li>
<li class="listitem">
<p>
<b>
External authentication.
</b>
Pluggable authentication makes it possible for clients to
connect to the MySQL server with credentials appropriate for
authentication methods that store credentials elsewhere than
in the
<code class="literal">
mysql.user
</code>
system table. For
example, plugins can be created to use external
authentication methods such as PAM, Windows login IDs, LDAP,
or Kerberos.
</p>
</li>
<li class="listitem">
<p>
<b>
Proxy users:
</b>
If a user is permitted to connect, an authentication plugin
can return to the server a user name different from the name
of the connecting user, to indicate that the connecting user
is a proxy for another user (the proxied user). While the
connection lasts, the proxy user is treated, for purposes of
access control, as having the privileges of the proxied
user. In effect, one user impersonates another. For more
information, see
<a class="xref" href="proxy-users.html" title="8.2.19 Proxy Users">
Section 8.2.19, “Proxy Users”
</a>
.
</p>
</li>
</ul>
</div>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
If you start the server with the
<a class="link" href="server-options.html#option_mysqld_skip-grant-tables">
<code class="option">
--skip-grant-tables
</code>
</a>
option,
authentication plugins are not used even if loaded because the
server performs no client authentication and permits any client
to connect. Because this is insecure, if the server is started
with the
<a class="link" href="server-options.html#option_mysqld_skip-grant-tables">
<code class="option">
--skip-grant-tables
</code>
</a>
option, it also disables remote connections by enabling
<a class="link" href="server-system-variables.html#sysvar_skip_networking">
<code class="literal">
skip_networking
</code>
</a>
.
</p>
</div>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="xref" href="pluggable-authentication.html#pluggable-authentication-available-plugins" title="Available Authentication Plugins">
Available Authentication Plugins
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="pluggable-authentication.html#pluggable-authentication-default-plugin" title="The Default Authentication Plugin">
The Default Authentication Plugin
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="pluggable-authentication.html#pluggable-authentication-usage" title="Authentication Plugin Usage">
Authentication Plugin Usage
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="pluggable-authentication.html#pluggable-authentication-compatibility" title="Authentication Plugin Client/Server Compatibility">
Authentication Plugin Client/Server Compatibility
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="pluggable-authentication.html#pluggable-authentication-connector-writing" title="Authentication Plugin Connector-Writing Considerations">
Authentication Plugin Connector-Writing Considerations
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="pluggable-authentication.html#pluggable-authentication-restrictions" title="Restrictions on Pluggable Authentication">
Restrictions on Pluggable Authentication
</a>
</p>
</li>
</ul>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h4 class="title">
<a name="pluggable-authentication-available-plugins">
</a>
Available Authentication Plugins
</h4>
</div>
</div>
</div>
<p>
MySQL 8.4 provides these authentication plugins:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
A plugin that performs native authentication; that is,
authentication based on the password hashing method in use
from before the introduction of pluggable authentication in
MySQL. The
<code class="literal">
mysql_native_password
</code>
plugin
implements authentication based on this native password
hashing method. See
<a class="xref" href="native-pluggable-authentication.html" title="8.4.1.1 Native Pluggable Authentication">
Section 8.4.1.1, “Native Pluggable Authentication”
</a>
.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
The
<code class="literal">
mysql_native_password
</code>
authentication plugin is deprecated and subject to removal
in a future version of MySQL.
</p>
</div>
</li>
<li class="listitem">
<p>
Plugins that perform authentication using SHA-256 password
hashing. This is stronger encryption than that available
with native authentication. See
<a class="xref" href="caching-sha2-pluggable-authentication.html" title="8.4.1.2 Caching SHA-2 Pluggable Authentication">
Section 8.4.1.2, “Caching SHA-2 Pluggable Authentication”
</a>
, and
<a class="xref" href="sha256-pluggable-authentication.html" title="8.4.1.3 SHA-256 Pluggable Authentication">
Section 8.4.1.3, “SHA-256 Pluggable Authentication”
</a>
.
</p>
</li>
<li class="listitem">
<p>
A client-side plugin that sends the password to the server
without hashing or encryption. This plugin is used in
conjunction with server-side plugins that require access to
the password exactly as provided by the client user. See
<a class="xref" href="cleartext-pluggable-authentication.html" title="8.4.1.4 Client-Side Cleartext Pluggable Authentication">
Section 8.4.1.4, “Client-Side Cleartext Pluggable Authentication”
</a>
.
</p>
</li>
<li class="listitem">
<p>
A plugin that performs external authentication using PAM
(Pluggable Authentication Modules), enabling MySQL Server to
use PAM to authenticate MySQL users. This plugin supports
proxy users as well. See
<a class="xref" href="pam-pluggable-authentication.html" title="8.4.1.5 PAM Pluggable Authentication">
Section 8.4.1.5, “PAM Pluggable Authentication”
</a>
.
</p>
</li>
<li class="listitem">
<p>
A plugin that performs external authentication on Windows,
enabling MySQL Server to use native Windows services to
authenticate client connections. Users who have logged in to
Windows can connect from MySQL client programs to the server
based on the information in their environment without
specifying an additional password. This plugin supports
proxy users as well. See
<a class="xref" href="windows-pluggable-authentication.html" title="8.4.1.6 Windows Pluggable Authentication">
Section 8.4.1.6, “Windows Pluggable Authentication”
</a>
.
</p>
</li>
<li class="listitem">
<p>
Plugins that perform authentication using LDAP (Lightweight
Directory Access Protocol) to authenticate MySQL users by
accessing directory services such as X.500. These plugins
support proxy users as well. See
<a class="xref" href="ldap-pluggable-authentication.html" title="8.4.1.7 LDAP Pluggable Authentication">
Section 8.4.1.7, “LDAP Pluggable Authentication”
</a>
.
</p>
</li>
<li class="listitem">
<p>
A plugin that performs authentication using Kerberos to
authenticate MySQL users that correspond to Kerberos
principals. See
<a class="xref" href="kerberos-pluggable-authentication.html" title="8.4.1.8 Kerberos Pluggable Authentication">
Section 8.4.1.8, “Kerberos Pluggable Authentication”
</a>
.
</p>
</li>
<li class="listitem">
<p>
A plugin that prevents all client connections to any account
that uses it. Use cases for this plugin include proxied
accounts that should never permit direct login but are
accessed only through proxy accounts and accounts that must
be able to execute stored programs and views with elevated
privileges without exposing those privileges to ordinary
users. See
<a class="xref" href="no-login-pluggable-authentication.html" title="8.4.1.9 No-Login Pluggable Authentication">
Section 8.4.1.9, “No-Login Pluggable Authentication”
</a>
.
</p>
</li>
<li class="listitem">
<p>
A plugin that authenticates clients that connect from the
local host through the Unix socket file. See
<a class="xref" href="socket-pluggable-authentication.html" title="8.4.1.10 Socket Peer-Credential Pluggable Authentication">
Section 8.4.1.10, “Socket Peer-Credential Pluggable Authentication”
</a>
.
</p>
</li>
<li class="listitem">
<p>
A plugin that authenticates users to MySQL Server using
WebAuthn format with a FIDO/FIDO2 device. See
<a class="xref" href="webauthn-pluggable-authentication.html" title="8.4.1.11 WebAuthn Pluggable Authentication">
Section 8.4.1.11, “WebAuthn Pluggable Authentication”
</a>
.
</p>
</li>
<li class="listitem">
<p>
A test plugin that checks account credentials and logs
success or failure to the server error log. This plugin is
intended for testing and development purposes, and as an
example of how to write an authentication plugin. See
<a class="xref" href="test-pluggable-authentication.html" title="8.4.1.12 Test Pluggable Authentication">
Section 8.4.1.12, “Test Pluggable Authentication”
</a>
.
</p>
</li>
</ul>
</div>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
For information about current restrictions on the use of
pluggable authentication, including which connectors support
which plugins, see
<a class="xref" href="pluggable-authentication.html#pluggable-authentication-restrictions" title="Restrictions on Pluggable Authentication">
Restrictions on Pluggable Authentication
</a>
.
</p>
<p>
Third-party connector developers should read that section to
determine the extent to which a connector can take advantage
of pluggable authentication capabilities and what steps to
take to become more compliant.
</p>
</div>
<p>
If you are interested in writing your own authentication
plugins, see
<a class="ulink" href="/doc/extending-mysql/8.4/en/writing-authentication-plugins.html" target="_top">
Writing Authentication Plugins
</a>
.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h4 class="title">
<a name="pluggable-authentication-default-plugin">
</a>
The Default Authentication Plugin
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045248174672">
</a>
<a class="indexterm" name="idm46045248173184">
</a>
<a class="indexterm" name="idm46045248172096">
</a>
<a class="indexterm" name="idm46045248171008">
</a>
<a class="indexterm" name="idm46045248169520">
</a>
<a class="indexterm" name="idm46045248168416">
</a>
<p>
The
<a class="link" href="create-user.html" title="15.7.1.3 CREATE USER Statement">
<code class="literal">
CREATE USER
</code>
</a>
and
<a class="link" href="alter-user.html" title="15.7.1.1 ALTER USER Statement">
<code class="literal">
ALTER USER
</code>
</a>
statements have syntax
for specifying how an account authenticates. Some forms of this
syntax do not explicitly name an authentication plugin (there is
no
<code class="literal">
IDENTIFIED WITH
</code>
clause). For example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa79372298"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">CREATE</span> <span class="token keyword">USER</span> <span class="token string">'jeffrey'</span>@<span class="token string">'localhost'</span> <span class="token keyword">IDENTIFIED</span> <span class="token keyword">BY</span> <span class="token string">'<em class="replaceable">password</em>'</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
In such cases, the server assigns the default authentication
plugin to the account. MySQL 8.4 supports
multifactor authentication and up to three clauses that specify
how an account authenticates. The rules that determine the
default authentication plugin for authentication methods that
name no plugin are factor-specific:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Factor 1: If
<a class="link" href="server-system-variables.html#sysvar_authentication_policy">
<code class="literal">
authentication_policy
</code>
</a>
element 1 names an authentication plugin, that plugin is the
default. If
<a class="link" href="server-system-variables.html#sysvar_authentication_policy">
<code class="literal">
authentication_policy
</code>
</a>
element 1 is
<code class="literal">
*
</code>
,
<code class="literal">
caching_sha2_password
</code>
is the default.
</p>
<p>
Given the rules above, the following statement creates a
two-factor authentication account, with the first factor
authentication method determined by
<a class="link" href="server-system-variables.html#sysvar_authentication_policy">
<code class="literal">
authentication_policy
</code>
</a>
, as
shown here:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa20175065"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">CREATE</span> <span class="token keyword">USER</span> <span class="token string">'wei'</span>@<span class="token string">'localhost'</span> <span class="token keyword">IDENTIFIED</span> <span class="token keyword">BY</span> <span class="token string">'<em class="replaceable">password</em>'</span>
<span class="token operator">AND</span> <span class="token keyword">IDENTIFIED</span> <span class="token keyword">WITH</span> authentication_ldap_simple<span class="token punctuation">;</span></code></pre>
</div>
<p>
In the same way, this example creates a three-factor
authentication account:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa15802906"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">CREATE</span> <span class="token keyword">USER</span> <span class="token string">'mateo'</span>@<span class="token string">'localhost'</span> <span class="token keyword">IDENTIFIED</span> <span class="token keyword">BY</span> <span class="token string">'<em class="replaceable">password</em>'</span>
<span class="token operator">AND</span> <span class="token keyword">IDENTIFIED</span> <span class="token keyword">WITH</span> authentication_ldap_simple
<span class="token operator">AND</span> <span class="token keyword">IDENTIFIED</span> <span class="token keyword">WITH</span> authentication_fido<span class="token punctuation">;</span></code></pre>
</div>
<p>
You can use
<a class="link" href="show-create-user.html" title="15.7.7.13 SHOW CREATE USER Statement">
<code class="literal">
SHOW CREATE USER
</code>
</a>
to view the applied authentication methods.
</p>
</li>
<li class="listitem">
<p>
Factor 2 or 3: If the corresponding
<a class="link" href="server-system-variables.html#sysvar_authentication_policy">
<code class="literal">
authentication_policy
</code>
</a>
element names an authentication plugin, that plugin is the
default. If the
<a class="link" href="server-system-variables.html#sysvar_authentication_policy">
<code class="literal">
authentication_policy
</code>
</a>
element is
<code class="literal">
*
</code>
or empty, there is no
default; attempting to define an account authentication
method for the factor without naming a plugin is an error,
as in the following examples:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa92243934"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">CREATE</span> <span class="token keyword">USER</span> <span class="token string">'sofia'</span>@<span class="token string">'localhost'</span> <span class="token keyword">IDENTIFIED</span> <span class="token keyword">WITH</span> authentication_ldap_simple
<span class="token operator">AND</span> <span class="token keyword">IDENTIFIED</span> <span class="token keyword">BY</span> <span class="token string">'abc'</span><span class="token punctuation">;</span>
<span class="token output">ERROR 1524 (HY000)<span class="token punctuation">:</span> Plugin '' is not loaded
</span>
<span class="token prompt">mysql></span> <span class="token keyword">CREATE</span> <span class="token keyword">USER</span> <span class="token string">'sofia'</span>@<span class="token string">'localhost'</span> <span class="token keyword">IDENTIFIED</span> <span class="token keyword">WITH</span> authentication_ldap_simple
<span class="token operator">AND</span> <span class="token keyword">IDENTIFIED</span> <span class="token keyword">BY</span> <span class="token string">'abc'</span><span class="token punctuation">;</span>
<span class="token output">ERROR 1524 (HY000)<span class="token punctuation">:</span> Plugin '<span class="token punctuation">*</span>' is not loaded</span></code></pre>
</div>
</li>
</ul>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h4 class="title">
<a name="pluggable-authentication-usage">
</a>
Authentication Plugin Usage
</h4>
</div>
</div>
</div>
<p>
This section provides general instructions for installing and
using authentication plugins. For instructions specific to a
given plugin, see the section that describes that plugin under
<a class="xref" href="authentication-plugins.html" title="8.4.1 Authentication Plugins">
Section 8.4.1, “Authentication Plugins”
</a>
.
</p>
<p>
In general, pluggable authentication uses a pair of
corresponding plugins on the server and client sides, so you use
a given authentication method like this:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
If necessary, install the plugin library or libraries
containing the appropriate plugins. On the server host,
install the library containing the server-side plugin, so
that the server can use it to authenticate client
connections. Similarly, on each client host, install the
library containing the client-side plugin for use by client
programs. Authentication plugins that are built in need not
be installed.
</p>
</li>
<li class="listitem">
<p>
For each MySQL account that you create, specify the
appropriate server-side plugin to use for authentication. If
the account is to use the default authentication plugin, the
account-creation statement need not specify the plugin
explicitly. The server assigns the default authentication
plugin, determined as described in
<a class="xref" href="pluggable-authentication.html#pluggable-authentication-default-plugin" title="The Default Authentication Plugin">
The Default Authentication Plugin
</a>
.
</p>
</li>
<li class="listitem">
<p>
When a client connects, the server-side plugin tells the
client program which client-side plugin to use for
authentication.
</p>
</li>
</ul>
</div>
<p>
In the case that an account uses an authentication method that
is the default for both the server and the client program, the
server need not communicate to the client which client-side
plugin to use, and a round trip in client/server negotiation can
be avoided.
</p>
<p>
For standard MySQL clients such as
<a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
<span class="command">
<strong>
mysql
</strong>
</span>
</a>
and
<a class="link" href="mysqladmin.html" title="6.5.2 mysqladmin — A MySQL Server Administration Program">
<span class="command">
<strong>
mysqladmin
</strong>
</span>
</a>
, the
<a class="link" href="mysql-command-options.html#option_mysql_default-auth">
<code class="option">
--default-auth=
<em class="replaceable">
<code>
plugin_name
</code>
</em>
</code>
</a>
option can be specified on the command line as a hint about
which client-side plugin the program can expect to use, although
the server overrides this if the server-side plugin associated
with the user account requires a different client-side plugin.
</p>
<p>
If the client program does not find the client-side plugin
library file, specify a
<a class="link" href="mysql-command-options.html#option_mysql_plugin-dir">
<code class="option">
--plugin-dir=
<em class="replaceable">
<code>
dir_name
</code>
</em>
</code>
</a>
option to indicate the plugin library directory location.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h4 class="title">
<a name="pluggable-authentication-compatibility">
</a>
Authentication Plugin Client/Server Compatibility
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045248123952">
</a>
<p>
Pluggable authentication enables flexibility in the choice of
authentication methods for MySQL accounts, but in some cases
client connections cannot be established due to authentication
plugin incompatibility between the client and server.
</p>
<p>
The general compatibility principle for a successful client
connection to a given account on a given server is that the
client and server both must support the authentication
<span class="emphasis">
<em>
method
</em>
</span>
required by the account. Because
authentication methods are implemented by authentication
plugins, the client and server both must support the
authentication
<span class="emphasis">
<em>
plugin
</em>
</span>
required by the
account.
</p>
<p>
Authentication plugin incompatibilities can arise in various
ways. Examples:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Connect using a MySQL 5.7 client from 5.7.22 or lower to a
MySQL 8.4 server account that authenticates
with
<code class="literal">
caching_sha2_password
</code>
. This fails
because the 5.7 client does not recognize the plugin. (This
issue is addressed in MySQL 5.7 as of 5.7.23, when
<code class="literal">
caching_sha2_password
</code>
client-side support
was added to the MySQL client library and client programs.)
</p>
</li>
<li class="listitem">
<p>
Connect using a MySQL 5.7 client to a pre-5.7 server account
that authenticates with
<code class="literal">
mysql_old_password
</code>
. This fails for
multiple reasons. First, such a connection requires
<code class="option">
--secure-auth=0
</code>
, which is no longer a
supported option. Even were it supported, the 5.7 client
does not recognize the plugin because it was removed in
MySQL 5.7.
</p>
</li>
<li class="listitem">
<p>
Connect using a MySQL 5.7 client from a Community
distribution to a MySQL 5.7 Enterprise server account that
authenticates using one of the Enterprise-only LDAP
authentication plugins. This fails because the Community
client does not have access to the Enterprise plugin.
</p>
</li>
</ul>
</div>
<p>
In general, these compatibility issues do not arise when
connections are made between a client and server from the same
MySQL distribution. When connections are made between a client
and server from different MySQL series, issues can arise. These
issues are inherent in the development process when MySQL
introduces new authentication plugins or removes old ones. To
minimize the potential for incompatibilities, regularly upgrade
the server, clients, and connectors on a timely basis.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h4 class="title">
<a name="pluggable-authentication-connector-writing">
</a>
Authentication Plugin Connector-Writing Considerations
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045248110976">
</a>
<p>
Various implementations of the MySQL client/server protocol
exist. The
<code class="literal">
libmysqlclient
</code>
C API client
library is one implementation. Some MySQL connectors (typically
those not written in C) provide their own implementation.
However, not all protocol implementations handle plugin
authentication the same way. This section describes an
authentication issue that protocol implementors should take into
account.
</p>
<p>
In the client/server protocol, the server tells connecting
clients which authentication plugin it considers the default. If
the protocol implementation used by the client tries to load the
default plugin and that plugin does not exist on the client
side, the load operation fails. This is an unnecessary failure
if the default plugin is not the plugin actually required by the
account to which the client is trying to connect.
</p>
<p>
If a client/server protocol implementation does not have its own
notion of default authentication plugin and always tries to load
the default plugin specified by the server, it fails with an
error if that plugin is not available.
</p>
<p>
To avoid this problem, the protocol implementation used by the
client should have its own default plugin and should use it as
its first choice (or, alternatively, fall back to this default
in case of failure to load the default plugin specified by the
server). Example:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
In MySQL 5.7,
<code class="literal">
libmysqlclient
</code>
uses as its
default choice either
<code class="literal">
mysql_native_password
</code>
or the plugin
specified through the
<code class="literal">
MYSQL_DEFAULT_AUTH
</code>
option for
<a class="ulink" href="/doc/c-api/8.4/en/mysql-options.html" target="_top">
<code class="literal">
mysql_options()
</code>
</a>
.
</p>
</li>
<li class="listitem">
<p>
When a 5.7 client tries to connect to an 8.4
server, the server specifies
<code class="literal">
caching_sha2_password
</code>
as its default
authentication plugin, but the client still sends credential
details per either
<code class="literal">
mysql_native_password
</code>
or whatever is specified through
<code class="literal">
MYSQL_DEFAULT_AUTH
</code>
.
</p>
</li>
<li class="listitem">
<p>
The only time the client loads the plugin specified by the
server is for a change-plugin request, but in that case it
can be any plugin depending on the user account. In this
case, the client must try to load the plugin, and if that
plugin is not available, an error is not optional.
</p>
</li>
</ul>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h4 class="title">
<a name="pluggable-authentication-restrictions">
</a>
Restrictions on Pluggable Authentication
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045248094320">
</a>
<a class="indexterm" name="idm46045248092864">
</a>
<p>
The first part of this section describes general restrictions on
the applicability of the pluggable authentication framework
described at
<a class="xref" href="pluggable-authentication.html" title="8.2.17 Pluggable Authentication">
Section 8.2.17, “Pluggable Authentication”
</a>
. The
second part describes how third-party connector developers can
determine the extent to which a connector can take advantage of
pluggable authentication capabilities and what steps to take to
become more compliant.
</p>
<p>
The term
<span class="quote">
“
<span class="quote">
native authentication
</span>
”
</span>
used here refers
to authentication against passwords stored in the
<code class="literal">
mysql.user
</code>
system table. This is the same
authentication method provided by older MySQL servers, before
pluggable authentication was implemented.
<span class="quote">
“
<span class="quote">
Windows native
authentication
</span>
”
</span>
refers to authentication using the
credentials of a user who has already logged in to Windows, as
implemented by the Windows Native Authentication plugin
(
<span class="quote">
“
<span class="quote">
Windows plugin
</span>
”
</span>
for short).
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="xref" href="pluggable-authentication.html#pluggable-authentication-restrictions-general" title="General Pluggable Authentication Restrictions">
General Pluggable Authentication Restrictions
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="pluggable-authentication.html#pluggable-authentication-restrictions-third-party-connectors" title="Pluggable Authentication and Third-Party Connectors">
Pluggable Authentication and Third-Party Connectors
</a>
</p>
</li>
</ul>
</div>
<h5>
<a name="pluggable-authentication-restrictions-general">
</a>
General Pluggable Authentication Restrictions
</h5>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<span class="bold">
<strong>
Connector/C++:
</strong>
</span>
Clients that
use this connector can connect to the server only through
accounts that use native authentication.
</p>
<p>
Exception: A connector supports pluggable authentication if
it was built to link to
<code class="literal">
libmysqlclient
</code>
dynamically (rather than statically) and it loads the
current version of
<code class="literal">
libmysqlclient
</code>
if that
version is installed, or if the connector is recompiled from
source to link against the current
<code class="literal">
libmysqlclient
</code>
.
</p>
<p>
For information about writing connectors to handle
information from the server about the default server-side
authentication plugin, see
<a class="xref" href="pluggable-authentication.html#pluggable-authentication-connector-writing" title="Authentication Plugin Connector-Writing Considerations">
Authentication Plugin Connector-Writing Considerations
</a>
.
</p>
</li>
<li class="listitem">
<p>
<span class="bold">
<strong>
Connector/NET:
</strong>
</span>
Clients that use
Connector/NET can connect to the server through accounts that use
native authentication or Windows native authentication.
</p>
</li>
<li class="listitem">
<p>
<span class="bold">
<strong>
Connector/PHP:
</strong>
</span>
Clients that
use this connector can connect to the server only through
accounts that use native authentication, when compiled using
the MySQL native driver for PHP
(
<code class="literal">
mysqlnd
</code>
).
</p>
</li>
<li class="listitem">
<p>
<span class="bold">
<strong>
Windows native
authentication:
</strong>
</span>
Connecting through an account
that uses the Windows plugin requires Windows Domain setup.
Without it, NTLM authentication is used and then only local
connections are possible; that is, the client and server
must run on the same computer.
</p>
</li>
<li class="listitem">
<p>
<span class="bold">
<strong>
Proxy users:
</strong>
</span>
Proxy user
support is available to the extent that clients can connect
through accounts authenticated with plugins that implement
proxy user capability (that is, plugins that can return a
user name different from that of the connecting user). For
example, the PAM and Windows plugins support proxy users.
The
<code class="literal">
mysql_native_password
</code>
(deprecated)
and
<code class="literal">
sha256_password
</code>
(deprecated)
authentication plugins do not support proxy users by
default, but can be configured to do so; see
<a class="xref" href="proxy-users.html#proxy-users-server-user-mapping" title="Server Support for Proxy User Mapping">
Server Support for Proxy User Mapping
</a>
.
</p>
</li>
<li class="listitem">
<p>
<span class="bold">
<strong>
Replication
</strong>
</span>
: Replicas can
not only employ replication user accounts using native
authentication, but can also connect through replication
user accounts that use nonnative authentication if the
required client-side plugin is available. If the plugin is
built into
<code class="literal">
libmysqlclient
</code>
, it is
available by default. Otherwise, the plugin must be
installed on the replica side in the directory named by the
replica's
<a class="link" href="server-system-variables.html#sysvar_plugin_dir">
<code class="literal">
plugin_dir
</code>
</a>
system
variable.
</p>
</li>
<li class="listitem">
<p>
<span class="bold">
<strong>
<a class="link" href="federated-storage-engine.html" title="18.8 The FEDERATED Storage Engine">
<code class="literal">
FEDERATED
</code>
</a>
tables:
</strong>
</span>
A
<a class="link" href="federated-storage-engine.html" title="18.8 The FEDERATED Storage Engine">
<code class="literal">
FEDERATED
</code>
</a>
table can access the remote table only through accounts on
the remote server that use native authentication.
</p>
</li>
</ul>
</div>
<h5>
<a name="pluggable-authentication-restrictions-third-party-connectors">
</a>
Pluggable Authentication and Third-Party Connectors
</h5>
<p>
Third-party connector developers can use the following
guidelines to determine readiness of a connector to take
advantage of pluggable authentication capabilities and what
steps to take to become more compliant:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
An existing connector to which no changes have been made
uses native authentication and clients that use the
connector can connect to the server only through accounts
that use native authentication.
<span class="emphasis">
<em>
However, you
should test the connector against a recent version of the
server to verify that such connections still work without
problem.
</em>
</span>
</p>
<p>
Exception: A connector might work with pluggable
authentication without any changes if it links to
<code class="literal">
libmysqlclient
</code>
dynamically (rather than
statically) and it loads the current version of
<code class="literal">
libmysqlclient
</code>
if that version is
installed.
</p>
</li>
<li class="listitem">
<p>
To take advantage of pluggable authentication capabilities,
a connector that is
<code class="literal">
libmysqlclient
</code>
-based
should be relinked against the current version of
<code class="literal">
libmysqlclient
</code>
. This enables the
connector to support connections though accounts that
require client-side plugins now built into
<code class="literal">
libmysqlclient
</code>
(such as the cleartext
plugin needed for PAM authentication and the Windows plugin
needed for Windows native authentication). Linking with a
current
<code class="literal">
libmysqlclient
</code>
also enables the
connector to access client-side plugins installed in the
default MySQL plugin directory (typically the directory
named by the default value of the local server's
<a class="link" href="server-system-variables.html#sysvar_plugin_dir">
<code class="literal">
plugin_dir
</code>
</a>
system
variable).
</p>
<p>
If a connector links to
<code class="literal">
libmysqlclient
</code>
dynamically, it must be ensured that the newer version of
<code class="literal">
libmysqlclient
</code>
is installed on the client
host and that the connector loads it at runtime.
</p>
</li>
<li class="listitem">
<p>
Another way for a connector to support a given
authentication method is to implement it directly in the
client/server protocol. Connector/NET uses this approach to provide
support for Windows native authentication.
</p>
</li>
<li class="listitem">
<p>
If a connector should be able to load client-side plugins
from a directory different from the default plugin
directory, it must implement some means for client users to
specify the directory. Possibilities for this include a
command-line option or environment variable from which the
connector can obtain the directory name. Standard MySQL
client programs such as
<a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
<span class="command">
<strong>
mysql
</strong>
</span>
</a>
and
<a class="link" href="mysqladmin.html" title="6.5.2 mysqladmin — A MySQL Server Administration Program">
<span class="command">
<strong>
mysqladmin
</strong>
</span>
</a>
implement a
<code class="option">
--plugin-dir
</code>
option. See also
<a class="ulink" href="/doc/c-api/8.4/en/c-api-plugin-interface.html" target="_top">
C API Client Plugin Interface
</a>
.
</p>
</li>
<li class="listitem">
<p>
Proxy user support by a connector depends, as described
earlier in this section, on whether the authentication
methods that it supports permit proxy users.
</p>
</li>
</ul>
</div>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/pluggable-storage.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="pluggable-storage">
</a>
18.11.1 Pluggable Storage Engine Architecture
</h3>
</div>
</div>
</div>
<p>
MySQL Server uses a pluggable storage engine architecture that
enables storage engines to be loaded into and unloaded from a
running MySQL server.
</p>
<p>
<span class="bold">
<strong>
Plugging in a Storage Engine
</strong>
</span>
</p>
<p>
Before a storage engine can be used, the storage engine plugin
shared library must be loaded into MySQL using the
<a class="link" href="install-plugin.html" title="15.7.4.4 INSTALL PLUGIN Statement">
<code class="literal">
INSTALL PLUGIN
</code>
</a>
statement. For
example, if the
<code class="literal">
EXAMPLE
</code>
engine plugin is
named
<code class="literal">
example
</code>
and the shared library is named
<code class="filename">
ha_example.so
</code>
, you load it with the
following statement:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa59092605"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">INSTALL</span> <span class="token keyword">PLUGIN</span> example <span class="token keyword">SONAME</span> <span class="token string">'ha_example.so'</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
To install a pluggable storage engine, the plugin file must be
located in the MySQL plugin directory, and the user issuing the
<a class="link" href="install-plugin.html" title="15.7.4.4 INSTALL PLUGIN Statement">
<code class="literal">
INSTALL PLUGIN
</code>
</a>
statement must
have
<a class="link" href="privileges-provided.html#priv_insert">
<code class="literal">
INSERT
</code>
</a>
privilege for the
<code class="literal">
mysql.plugin
</code>
table.
</p>
<p>
The shared library must be located in the MySQL server plugin
directory, the location of which is given by the
<a class="link" href="server-system-variables.html#sysvar_plugin_dir">
<code class="literal">
plugin_dir
</code>
</a>
system variable.
</p>
<p>
<span class="bold">
<strong>
Unplugging a Storage Engine
</strong>
</span>
</p>
<p>
To unplug a storage engine, use the
<a class="link" href="uninstall-plugin.html" title="15.7.4.6 UNINSTALL PLUGIN Statement">
<code class="literal">
UNINSTALL PLUGIN
</code>
</a>
statement:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa98893361"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">UNINSTALL</span> <span class="token keyword">PLUGIN</span> example<span class="token punctuation">;</span></code></pre>
</div>
<p>
If you unplug a storage engine that is needed by existing
tables, those tables become inaccessible, but are still present
on disk (where applicable). Ensure that there are no tables
using a storage engine before you unplug the storage engine.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/partitioning-management-exchange.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="partitioning-management-exchange">
</a>
26.3.3 Exchanging Partitions and Subpartitions with Tables
</h3>
</div>
</div>
</div>
<p>
In MySQL 8.4, it is possible to exchange a table
partition or subpartition with a table using
<code class="literal">
ALTER
TABLE
<em class="replaceable">
<code>
pt
</code>
</em>
EXCHANGE PARTITION
<em class="replaceable">
<code>
p
</code>
</em>
WITH TABLE
<em class="replaceable">
<code>
nt
</code>
</em>
</code>
, where
<em class="replaceable">
<code>
pt
</code>
</em>
is the partitioned table and
<em class="replaceable">
<code>
p
</code>
</em>
is the partition or subpartition of
<em class="replaceable">
<code>
pt
</code>
</em>
to be exchanged with unpartitioned
table
<em class="replaceable">
<code>
nt
</code>
</em>
, provided that the following
statements are true:
</p>
<div class="orderedlist">
<ol class="orderedlist" type="1">
<li class="listitem">
<p>
Table
<em class="replaceable">
<code>
nt
</code>
</em>
is not itself
partitioned.
</p>
</li>
<li class="listitem">
<p>
Table
<em class="replaceable">
<code>
nt
</code>
</em>
is not a temporary
table.
</p>
</li>
<li class="listitem">
<p>
The structures of tables
<em class="replaceable">
<code>
pt
</code>
</em>
and
<em class="replaceable">
<code>
nt
</code>
</em>
are otherwise identical.
</p>
</li>
<li class="listitem">
<p>
Table
<code class="literal">
nt
</code>
contains no foreign key
references, and no other table has any foreign keys that
refer to
<code class="literal">
nt
</code>
.
</p>
</li>
<li class="listitem">
<p>
There are no rows in
<em class="replaceable">
<code>
nt
</code>
</em>
that lie
outside the boundaries of the partition definition for
<em class="replaceable">
<code>
p
</code>
</em>
. This condition does not apply
if
<code class="literal">
WITHOUT VALIDATION
</code>
is used.
</p>
</li>
<li class="listitem">
<p>
Both tables must use the same character set and collation.
</p>
</li>
<li class="listitem">
<p>
For
<code class="literal">
InnoDB
</code>
tables, both tables must use
the same row format. To determine the row format of an
<code class="literal">
InnoDB
</code>
table, query
<a class="link" href="information-schema-innodb-tables-table.html" title="28.4.23 The INFORMATION_SCHEMA INNODB_TABLES Table">
<code class="literal">
INFORMATION_SCHEMA.INNODB_TABLES
</code>
</a>
.
</p>
</li>
<li class="listitem">
<p>
Any partition-level
<code class="literal">
MAX_ROWS
</code>
setting for
<code class="literal">
p
</code>
must be the same as the table-level
<code class="literal">
MAX_ROWS
</code>
value set for
<code class="literal">
nt
</code>
. The setting for any partition-level
<code class="literal">
MIN_ROWS
</code>
setting for
<code class="literal">
p
</code>
must also be the same any table-level
<code class="literal">
MIN_ROWS
</code>
value set for
<code class="literal">
nt
</code>
.
</p>
<p>
This is true in either case whether not
<code class="literal">
pt
</code>
has an explicit table-level
<code class="literal">
MAX_ROWS
</code>
or
<code class="literal">
MIN_ROWS
</code>
option in effect.
</p>
</li>
<li class="listitem">
<p>
The
<code class="literal">
AVG_ROW_LENGTH
</code>
cannot differ between
the two tables
<code class="literal">
pt
</code>
and
<code class="literal">
nt
</code>
.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
INDEX DIRECTORY
</code>
cannot differ between the
table and the partition to be exchanged with it.
</p>
</li>
<li class="listitem">
<p>
No table or partition
<code class="literal">
TABLESPACE
</code>
options
can be used in either of the tables.
</p>
</li>
</ol>
</div>
<p>
In addition to the
<a class="link" href="privileges-provided.html#priv_alter">
<code class="literal">
ALTER
</code>
</a>
,
<a class="link" href="privileges-provided.html#priv_insert">
<code class="literal">
INSERT
</code>
</a>
, and
<a class="link" href="privileges-provided.html#priv_create">
<code class="literal">
CREATE
</code>
</a>
privileges usually
required for
<a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
<code class="literal">
ALTER TABLE
</code>
</a>
statements, you must have the
<a class="link" href="privileges-provided.html#priv_drop">
<code class="literal">
DROP
</code>
</a>
privilege to perform
<a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
<code class="literal">
ALTER TABLE ...
EXCHANGE PARTITION
</code>
</a>
.
</p>
<p>
You should also be aware of the following effects of
<a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
<code class="literal">
ALTER TABLE ...
EXCHANGE PARTITION
</code>
</a>
:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Executing
<a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
<code class="literal">
ALTER
TABLE ... EXCHANGE PARTITION
</code>
</a>
does not invoke any
triggers on either the partitioned table or the table to be
exchanged.
</p>
</li>
<li class="listitem">
<p>
Any
<code class="literal">
AUTO_INCREMENT
</code>
columns in the
exchanged table are reset.
</p>
</li>
<li class="listitem">
<p>
The
<code class="literal">
IGNORE
</code>
keyword has no effect when
used with
<code class="literal">
ALTER TABLE ... EXCHANGE
PARTITION
</code>
.
</p>
</li>
</ul>
</div>
<p>
The syntax for
<a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
<code class="literal">
ALTER TABLE ...
EXCHANGE PARTITION
</code>
</a>
is shown here, where
<em class="replaceable">
<code>
pt
</code>
</em>
is the partitioned table,
<em class="replaceable">
<code>
p
</code>
</em>
is the partition (or subpartition)
to be exchanged, and
<em class="replaceable">
<code>
nt
</code>
</em>
is the
nonpartitioned table to be exchanged with
<em class="replaceable">
<code>
p
</code>
</em>
:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa96494875"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">ALTER</span> <span class="token keyword">TABLE</span> <em class="replaceable">pt</em>
<span class="token keyword">EXCHANGE</span> <span class="token keyword">PARTITION</span> <em class="replaceable">p</em>
<span class="token keyword">WITH</span> <span class="token keyword">TABLE</span> <em class="replaceable">nt</em><span class="token punctuation">;</span></code></pre>
</div>
<p>
Optionally, you can append
<code class="literal">
WITH VALIDATION
</code>
or
<code class="literal">
WITHOUT VALIDATION
</code>
. When
<code class="literal">
WITHOUT
VALIDATION
</code>
is specified, the
<a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
<code class="literal">
ALTER TABLE ...
EXCHANGE PARTITION
</code>
</a>
operation does not perform any
row-by-row validation when exchanging a partition a
nonpartitioned table, allowing database administrators to assume
responsibility for ensuring that rows are within the boundaries
of the partition definition.
<code class="literal">
WITH VALIDATION
</code>
is the default.
</p>
<p>
One and only one partition or subpartition may be exchanged with
one and only one nonpartitioned table in a single
<a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
<code class="literal">
ALTER TABLE
EXCHANGE PARTITION
</code>
</a>
statement. To exchange multiple
partitions or subpartitions, use multiple
<a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
<code class="literal">
ALTER TABLE
EXCHANGE PARTITION
</code>
</a>
statements.
<code class="literal">
EXCHANGE
PARTITION
</code>
may not be combined with other
<a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
<code class="literal">
ALTER TABLE
</code>
</a>
options. The
partitioning and (if applicable) subpartitioning used by the
partitioned table may be of any type or types supported in MySQL
8.4.
</p>
<h4>
<a name="idm46045083630256">
</a>
Exchanging a Partition with a Nonpartitioned Table
</h4>
<p>
Suppose that a partitioned table
<code class="literal">
e
</code>
has been
created and populated using the following SQL statements:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa73585392"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> e <span class="token punctuation">(</span>
id <span class="token datatype">INT</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span><span class="token punctuation">,</span>
fname <span class="token datatype">VARCHAR</span><span class="token punctuation">(</span><span class="token number">30</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
lname <span class="token datatype">VARCHAR</span><span class="token punctuation">(</span><span class="token number">30</span><span class="token punctuation">)</span>
<span class="token punctuation">)</span>
<span class="token keyword">PARTITION</span> <span class="token keyword">BY</span> <span class="token keyword">RANGE</span> <span class="token punctuation">(</span>id<span class="token punctuation">)</span> <span class="token punctuation">(</span>
<span class="token keyword">PARTITION</span> p0 <span class="token keyword">VALUES</span> <span class="token keyword">LESS</span> <span class="token keyword">THAN</span> <span class="token punctuation">(</span><span class="token number">50</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token keyword">PARTITION</span> p1 <span class="token keyword">VALUES</span> <span class="token keyword">LESS</span> <span class="token keyword">THAN</span> <span class="token punctuation">(</span><span class="token number">100</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token keyword">PARTITION</span> p2 <span class="token keyword">VALUES</span> <span class="token keyword">LESS</span> <span class="token keyword">THAN</span> <span class="token punctuation">(</span><span class="token number">150</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token keyword">PARTITION</span> p3 <span class="token keyword">VALUES</span> <span class="token keyword">LESS</span> <span class="token keyword">THAN</span> <span class="token punctuation">(</span><span class="token keyword">MAXVALUE</span><span class="token punctuation">)</span>
<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">INSERT</span> <span class="token keyword">INTO</span> e <span class="token keyword">VALUES</span>
<span class="token punctuation">(</span><span class="token number">1669</span><span class="token punctuation">,</span> <span class="token string">"Jim"</span><span class="token punctuation">,</span> <span class="token string">"Smith"</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token punctuation">(</span><span class="token number">337</span><span class="token punctuation">,</span> <span class="token string">"Mary"</span><span class="token punctuation">,</span> <span class="token string">"Jones"</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token punctuation">(</span><span class="token number">16</span><span class="token punctuation">,</span> <span class="token string">"Frank"</span><span class="token punctuation">,</span> <span class="token string">"White"</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token punctuation">(</span><span class="token number">2005</span><span class="token punctuation">,</span> <span class="token string">"Linda"</span><span class="token punctuation">,</span> <span class="token string">"Black"</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
Now we create a nonpartitioned copy of
<code class="literal">
e
</code>
named
<code class="literal">
e2
</code>
. This can be done using the
<a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
<span class="command">
<strong>
mysql
</strong>
</span>
</a>
client as shown here:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa58190941"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> e2 <span class="token operator">LIKE</span> e<span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected (0.04 sec)</span>
<span class="token prompt">mysql></span> <span class="token keyword">ALTER</span> <span class="token keyword">TABLE</span> e2 <span class="token keyword">REMOVE</span> <span class="token keyword">PARTITIONING</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected (0.07 sec)</span>
<span class="token output">Records: 0 Duplicates: 0 Warnings: 0</span></code></pre>
</div>
<p>
You can see which partitions in table
<code class="literal">
e
</code>
contain rows by querying the Information Schema
<a class="link" href="information-schema-partitions-table.html" title="28.3.21 The INFORMATION_SCHEMA PARTITIONS Table">
<code class="literal">
PARTITIONS
</code>
</a>
table, like this:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa15024532"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> PARTITION_NAME<span class="token punctuation">,</span> TABLE_ROWS
<span class="token keyword">FROM</span> INFORMATION_SCHEMA<span class="token punctuation">.</span><span class="token keyword">PARTITIONS</span>
<span class="token keyword">WHERE</span> <span class="token keyword">TABLE_NAME</span> <span class="token operator">=</span> <span class="token string">'e'</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> PARTITION_NAME <span class="token punctuation">|</span> TABLE_ROWS <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> p0 <span class="token punctuation">|</span> 1 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> p1 <span class="token punctuation">|</span> 0 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> p2 <span class="token punctuation">|</span> 0 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> p3 <span class="token punctuation">|</span> 3 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">2 rows in set (0.00 sec)</span></code></pre>
</div>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
For partitioned
<code class="literal">
InnoDB
</code>
tables, the row
count given in the
<code class="literal">
TABLE_ROWS
</code>
column of the
Information Schema
<a class="link" href="information-schema-partitions-table.html" title="28.3.21 The INFORMATION_SCHEMA PARTITIONS Table">
<code class="literal">
PARTITIONS
</code>
</a>
table is only an estimated value used in SQL optimization, and
is not always exact.
</p>
</div>
<p>
To exchange partition
<code class="literal">
p0
</code>
in table
<code class="literal">
e
</code>
with table
<code class="literal">
e2
</code>
, you can
use
<a class="link" href="alter-table-partition-operations.html" title="15.1.9.1 ALTER TABLE Partition Operations">
<code class="literal">
ALTER
TABLE
</code>
</a>
, as shown here:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa63138188"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">ALTER</span> <span class="token keyword">TABLE</span> e <span class="token keyword">EXCHANGE</span> <span class="token keyword">PARTITION</span> p0 <span class="token keyword">WITH</span> <span class="token keyword">TABLE</span> e2<span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected (0.04 sec)</span></code></pre>
</div>
<p>
More precisely, the statement just issued causes any rows found
in the partition to be swapped with those found in the table.
You can observe how this has happened by querying the
Information Schema
<a class="link" href="information-schema-partitions-table.html" title="28.3.21 The INFORMATION_SCHEMA PARTITIONS Table">
<code class="literal">
PARTITIONS
</code>
</a>
table, as before. The table row that was previously found in
partition
<code class="literal">
p0
</code>
is no longer present:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa13202485"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> PARTITION_NAME<span class="token punctuation">,</span> TABLE_ROWS
<span class="token keyword">FROM</span> INFORMATION_SCHEMA<span class="token punctuation">.</span><span class="token keyword">PARTITIONS</span>
<span class="token keyword">WHERE</span> <span class="token keyword">TABLE_NAME</span> <span class="token operator">=</span> <span class="token string">'e'</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> PARTITION_NAME <span class="token punctuation">|</span> TABLE_ROWS <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> p0 <span class="token punctuation">|</span> 0 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> p1 <span class="token punctuation">|</span> 0 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> p2 <span class="token punctuation">|</span> 0 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> p3 <span class="token punctuation">|</span> 3 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">4 rows in set (0.00 sec)</span></code></pre>
</div>
<p>
If you query table
<code class="literal">
e2
</code>
, you can see that the
<span class="quote">
“
<span class="quote">
missing
</span>
”
</span>
row can now be found there:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa63809957"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> e2<span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> id <span class="token punctuation">|</span> fname <span class="token punctuation">|</span> lname <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 16 <span class="token punctuation">|</span> Frank <span class="token punctuation">|</span> White <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">1 row in set (0.00 sec)</span></code></pre>
</div>
<p>
The table to be exchanged with the partition does not
necessarily have to be empty. To demonstrate this, we first
insert a new row into table
<code class="literal">
e
</code>
, making sure
that this row is stored in partition
<code class="literal">
p0
</code>
by
choosing an
<code class="literal">
id
</code>
column value that is less than
50, and verifying this afterward by querying the
<a class="link" href="information-schema-partitions-table.html" title="28.3.21 The INFORMATION_SCHEMA PARTITIONS Table">
<code class="literal">
PARTITIONS
</code>
</a>
table:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa70809248"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">INSERT</span> <span class="token keyword">INTO</span> e <span class="token keyword">VALUES</span> <span class="token punctuation">(</span><span class="token number">41</span><span class="token punctuation">,</span> <span class="token string">"Michael"</span><span class="token punctuation">,</span> <span class="token string">"Green"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 1 row affected (0.05 sec)</span>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> PARTITION_NAME<span class="token punctuation">,</span> TABLE_ROWS
<span class="token keyword">FROM</span> INFORMATION_SCHEMA<span class="token punctuation">.</span><span class="token keyword">PARTITIONS</span>
<span class="token keyword">WHERE</span> <span class="token keyword">TABLE_NAME</span> <span class="token operator">=</span> <span class="token string">'e'</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> PARTITION_NAME <span class="token punctuation">|</span> TABLE_ROWS <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> p0 <span class="token punctuation">|</span> 1 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> p1 <span class="token punctuation">|</span> 0 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> p2 <span class="token punctuation">|</span> 0 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> p3 <span class="token punctuation">|</span> 3 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">4 rows in set (0.00 sec)</span></code></pre>
</div>
<p>
Now we once again exchange partition
<code class="literal">
p0
</code>
with
table
<code class="literal">
e2
</code>
using the same
<a class="link" href="alter-table-partition-operations.html" title="15.1.9.1 ALTER TABLE Partition Operations">
<code class="literal">
ALTER
TABLE
</code>
</a>
statement as previously:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa70205268"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">ALTER</span> <span class="token keyword">TABLE</span> e <span class="token keyword">EXCHANGE</span> <span class="token keyword">PARTITION</span> p0 <span class="token keyword">WITH</span> <span class="token keyword">TABLE</span> e2<span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected (0.28 sec)</span></code></pre>
</div>
<p>
The output of the following queries shows that the table row
that was stored in partition
<code class="literal">
p0
</code>
and the table
row that was stored in table
<code class="literal">
e2
</code>
, prior to
issuing the
<a class="link" href="alter-table-partition-operations.html" title="15.1.9.1 ALTER TABLE Partition Operations">
<code class="literal">
ALTER
TABLE
</code>
</a>
statement, have now switched places:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa28756420"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> e<span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> id <span class="token punctuation">|</span> fname <span class="token punctuation">|</span> lname <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 16 <span class="token punctuation">|</span> Frank <span class="token punctuation">|</span> White <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 1669 <span class="token punctuation">|</span> Jim <span class="token punctuation">|</span> Smith <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 337 <span class="token punctuation">|</span> Mary <span class="token punctuation">|</span> Jones <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 2005 <span class="token punctuation">|</span> Linda <span class="token punctuation">|</span> Black <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">4 rows in set (0.00 sec)</span>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> PARTITION_NAME<span class="token punctuation">,</span> TABLE_ROWS
<span class="token keyword">FROM</span> INFORMATION_SCHEMA<span class="token punctuation">.</span><span class="token keyword">PARTITIONS</span>
<span class="token keyword">WHERE</span> <span class="token keyword">TABLE_NAME</span> <span class="token operator">=</span> <span class="token string">'e'</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> PARTITION_NAME <span class="token punctuation">|</span> TABLE_ROWS <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> p0 <span class="token punctuation">|</span> 1 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> p1 <span class="token punctuation">|</span> 0 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> p2 <span class="token punctuation">|</span> 0 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> p3 <span class="token punctuation">|</span> 3 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">4 rows in set (0.00 sec)</span>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> e2<span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> id <span class="token punctuation">|</span> fname <span class="token punctuation">|</span> lname <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 41 <span class="token punctuation">|</span> Michael <span class="token punctuation">|</span> Green <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">1 row in set (0.00 sec)</span></code></pre>
</div>
<h4>
<a name="idm46045083575072">
</a>
Nonmatching Rows
</h4>
<p>
You should keep in mind that any rows found in the
nonpartitioned table prior to issuing the
<a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
<code class="literal">
ALTER TABLE ...
EXCHANGE PARTITION
</code>
</a>
statement must meet the conditions
required for them to be stored in the target partition;
otherwise, the statement fails. To see how this occurs, first
insert a row into
<code class="literal">
e2
</code>
that is outside the
boundaries of the partition definition for partition
<code class="literal">
p0
</code>
of table
<code class="literal">
e
</code>
. For
example, insert a row with an
<code class="literal">
id
</code>
column value
that is too large; then, try to exchange the table with the
partition again:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa56607812"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">INSERT</span> <span class="token keyword">INTO</span> e2 <span class="token keyword">VALUES</span> <span class="token punctuation">(</span><span class="token number">51</span><span class="token punctuation">,</span> <span class="token string">"Ellen"</span><span class="token punctuation">,</span> <span class="token string">"McDonald"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 1 row affected (0.08 sec)</span>
<span class="token prompt">mysql></span> <span class="token keyword">ALTER</span> <span class="token keyword">TABLE</span> e <span class="token keyword">EXCHANGE</span> <span class="token keyword">PARTITION</span> p0 <span class="token keyword">WITH</span> <span class="token keyword">TABLE</span> e2<span class="token punctuation">;</span>
<span class="token output">ERROR 1707 (HY000)<span class="token punctuation">:</span> Found row that does not match the partition</span></code></pre>
</div>
<p>
Only the
<code class="literal">
WITHOUT VALIDATION
</code>
option would
permit this operation to succeed:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa73145168"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">ALTER</span> <span class="token keyword">TABLE</span> e <span class="token keyword">EXCHANGE</span> <span class="token keyword">PARTITION</span> p0 <span class="token keyword">WITH</span> <span class="token keyword">TABLE</span> e2 <span class="token keyword">WITHOUT</span> <span class="token keyword">VALIDATION</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected (0.02 sec)</span></code></pre>
</div>
<p>
When a partition is exchanged with a table that contains rows
that do not match the partition definition, it is the
responsibility of the database administrator to fix the
non-matching rows, which can be performed using
<a class="link" href="repair-table.html" title="15.7.3.5 REPAIR TABLE Statement">
<code class="literal">
REPAIR TABLE
</code>
</a>
or
<a class="link" href="alter-table-partition-operations.html" title="15.1.9.1 ALTER TABLE Partition Operations">
<code class="literal">
ALTER
TABLE ... REPAIR PARTITION
</code>
</a>
.
</p>
<h4>
<a name="idm46045083560400">
</a>
Exchanging Partitions Without Row-By-Row Validation
</h4>
<p>
To avoid time consuming validation when exchanging a partition
with a table that has many rows, it is possible to skip the
row-by-row validation step by appending
<code class="literal">
WITHOUT
VALIDATION
</code>
to the
<a class="link" href="alter-table-partition-operations.html" title="15.1.9.1 ALTER TABLE Partition Operations">
<code class="literal">
ALTER
TABLE ... EXCHANGE PARTITION
</code>
</a>
statement.
</p>
<p>
The following example compares the difference between execution
times when exchanging a partition with a nonpartitioned table,
with and without validation. The partitioned table (table
<code class="literal">
e
</code>
) contains two partitions of 1 million rows
each. The rows in p0 of table e are removed and p0 is exchanged
with a nonpartitioned table of 1 million rows. The
<code class="literal">
WITH
VALIDATION
</code>
operation takes 0.74 seconds. By
comparison, the
<code class="literal">
WITHOUT VALIDATION
</code>
operation
takes 0.01 seconds.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa24552466"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token comment" spellcheck="true"># Create a partitioned table with 1 million rows in each partition</span>
<span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> e <span class="token punctuation">(</span>
id <span class="token datatype">INT</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span><span class="token punctuation">,</span>
fname <span class="token datatype">VARCHAR</span><span class="token punctuation">(</span><span class="token number">30</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
lname <span class="token datatype">VARCHAR</span><span class="token punctuation">(</span><span class="token number">30</span><span class="token punctuation">)</span>
<span class="token punctuation">)</span>
<span class="token keyword">PARTITION</span> <span class="token keyword">BY</span> <span class="token keyword">RANGE</span> <span class="token punctuation">(</span>id<span class="token punctuation">)</span> <span class="token punctuation">(</span>
<span class="token keyword">PARTITION</span> p0 <span class="token keyword">VALUES</span> <span class="token keyword">LESS</span> <span class="token keyword">THAN</span> <span class="token punctuation">(</span><span class="token number">1000001</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token keyword">PARTITION</span> p1 <span class="token keyword">VALUES</span> <span class="token keyword">LESS</span> <span class="token keyword">THAN</span> <span class="token punctuation">(</span><span class="token number">2000001</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token function">COUNT</span><span class="token punctuation">(</span><span class="token operator">*</span><span class="token punctuation">)</span> <span class="token keyword">FROM</span> e<span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">|</span> COUNT(*) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 2000000 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">1 row in set (0.27 sec)</span>
<span class="token comment" spellcheck="true"># View the rows in each partition</span>
<span class="token keyword">SELECT</span> PARTITION_NAME<span class="token punctuation">,</span> TABLE_ROWS <span class="token keyword">FROM</span> INFORMATION_SCHEMA<span class="token punctuation">.</span><span class="token keyword">PARTITIONS</span> <span class="token keyword">WHERE</span> <span class="token keyword">TABLE_NAME</span> <span class="token operator">=</span> <span class="token string">'e'</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> PARTITION_NAME <span class="token punctuation">|</span> TABLE_ROWS <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> p0 <span class="token punctuation">|</span> 1000000 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> p1 <span class="token punctuation">|</span> 1000000 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">2 rows in set (0.00 sec)</span>
<span class="token comment" spellcheck="true"># Create a nonpartitioned table of the same structure and populate it with 1 million rows</span>
<span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> e2 <span class="token punctuation">(</span>
id <span class="token datatype">INT</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span><span class="token punctuation">,</span>
fname <span class="token datatype">VARCHAR</span><span class="token punctuation">(</span><span class="token number">30</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
lname <span class="token datatype">VARCHAR</span><span class="token punctuation">(</span><span class="token number">30</span><span class="token punctuation">)</span>
<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token function">COUNT</span><span class="token punctuation">(</span><span class="token operator">*</span><span class="token punctuation">)</span> <span class="token keyword">FROM</span> e2<span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> COUNT(*) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 1000000 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">1 row in set (0.24 sec)</span>
<span class="token comment" spellcheck="true"># Create another nonpartitioned table of the same structure and populate it with 1 million rows</span>
<span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> e3 <span class="token punctuation">(</span>
id <span class="token datatype">INT</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span><span class="token punctuation">,</span>
fname <span class="token datatype">VARCHAR</span><span class="token punctuation">(</span><span class="token number">30</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
lname <span class="token datatype">VARCHAR</span><span class="token punctuation">(</span><span class="token number">30</span><span class="token punctuation">)</span>
<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token function">COUNT</span><span class="token punctuation">(</span><span class="token operator">*</span><span class="token punctuation">)</span> <span class="token keyword">FROM</span> e3<span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> COUNT(*) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 1000000 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">1 row in set (0.25 sec)</span>
<span class="token comment" spellcheck="true"># Drop the rows from p0 of table e</span>
<span class="token prompt">mysql></span> <span class="token keyword">DELETE</span> <span class="token keyword">FROM</span> e <span class="token keyword">WHERE</span> id <span class="token operator"><</span> <span class="token number">1000001</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 1000000 rows affected (5.55 sec)</span>
<span class="token comment" spellcheck="true"># Confirm that there are no rows in partition p0</span>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> PARTITION_NAME<span class="token punctuation">,</span> TABLE_ROWS <span class="token keyword">FROM</span> INFORMATION_SCHEMA<span class="token punctuation">.</span><span class="token keyword">PARTITIONS</span> <span class="token keyword">WHERE</span> <span class="token keyword">TABLE_NAME</span> <span class="token operator">=</span> <span class="token string">'e'</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> PARTITION_NAME <span class="token punctuation">|</span> TABLE_ROWS <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> p0 <span class="token punctuation">|</span> 0 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> p1 <span class="token punctuation">|</span> 1000000 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">2 rows in set (0.00 sec)</span>
<span class="token comment" spellcheck="true"># Exchange partition p0 of table e with the table e2 'WITH VALIDATION'</span>
<span class="token prompt">mysql></span> <span class="token keyword">ALTER</span> <span class="token keyword">TABLE</span> e <span class="token keyword">EXCHANGE</span> <span class="token keyword">PARTITION</span> p0 <span class="token keyword">WITH</span> <span class="token keyword">TABLE</span> e2 <span class="token keyword">WITH</span> <span class="token keyword">VALIDATION</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected (0.74 sec)</span>
<span class="token comment" spellcheck="true"># Confirm that the partition was exchanged with table e2</span>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> PARTITION_NAME<span class="token punctuation">,</span> TABLE_ROWS <span class="token keyword">FROM</span> INFORMATION_SCHEMA<span class="token punctuation">.</span><span class="token keyword">PARTITIONS</span> <span class="token keyword">WHERE</span> <span class="token keyword">TABLE_NAME</span> <span class="token operator">=</span> <span class="token string">'e'</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> PARTITION_NAME <span class="token punctuation">|</span> TABLE_ROWS <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> p0 <span class="token punctuation">|</span> 1000000 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> p1 <span class="token punctuation">|</span> 1000000 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">2 rows in set (0.00 sec)</span>
<span class="token comment" spellcheck="true"># Once again, drop the rows from p0 of table e</span>
<span class="token prompt">mysql></span> <span class="token keyword">DELETE</span> <span class="token keyword">FROM</span> e <span class="token keyword">WHERE</span> id <span class="token operator"><</span> <span class="token number">1000001</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 1000000 rows affected (5.55 sec)</span>
<span class="token comment" spellcheck="true"># Confirm that there are no rows in partition p0</span>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> PARTITION_NAME<span class="token punctuation">,</span> TABLE_ROWS <span class="token keyword">FROM</span> INFORMATION_SCHEMA<span class="token punctuation">.</span><span class="token keyword">PARTITIONS</span> <span class="token keyword">WHERE</span> <span class="token keyword">TABLE_NAME</span> <span class="token operator">=</span> <span class="token string">'e'</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> PARTITION_NAME <span class="token punctuation">|</span> TABLE_ROWS <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> p0 <span class="token punctuation">|</span> 0 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> p1 <span class="token punctuation">|</span> 1000000 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">2 rows in set (0.00 sec)</span>
<span class="token comment" spellcheck="true"># Exchange partition p0 of table e with the table e3 'WITHOUT VALIDATION'</span>
<span class="token prompt">mysql></span> <span class="token keyword">ALTER</span> <span class="token keyword">TABLE</span> e <span class="token keyword">EXCHANGE</span> <span class="token keyword">PARTITION</span> p0 <span class="token keyword">WITH</span> <span class="token keyword">TABLE</span> e3 <span class="token keyword">WITHOUT</span> <span class="token keyword">VALIDATION</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected (0.01 sec)</span>
<span class="token comment" spellcheck="true"># Confirm that the partition was exchanged with table e3</span>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> PARTITION_NAME<span class="token punctuation">,</span> TABLE_ROWS <span class="token keyword">FROM</span> INFORMATION_SCHEMA<span class="token punctuation">.</span><span class="token keyword">PARTITIONS</span> <span class="token keyword">WHERE</span> <span class="token keyword">TABLE_NAME</span> <span class="token operator">=</span> <span class="token string">'e'</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> PARTITION_NAME <span class="token punctuation">|</span> TABLE_ROWS <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> p0 <span class="token punctuation">|</span> 1000000 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> p1 <span class="token punctuation">|</span> 1000000 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">2 rows in set (0.00 sec)</span></code></pre>
</div>
<p>
If a partition is exchanged with a table that contains rows that
do not match the partition definition, it is the responsibility
of the database administrator to fix the non-matching rows,
which can be performed using
<a class="link" href="repair-table.html" title="15.7.3.5 REPAIR TABLE Statement">
<code class="literal">
REPAIR
TABLE
</code>
</a>
or
<a class="link" href="alter-table-partition-operations.html" title="15.1.9.1 ALTER TABLE Partition Operations">
<code class="literal">
ALTER
TABLE ... REPAIR PARTITION
</code>
</a>
.
</p>
<h4>
<a name="idm46045083544320">
</a>
Exchanging a Subpartition with a Nonpartitioned Table
</h4>
<p>
You can also exchange a subpartition of a subpartitioned table
(see
<a class="xref" href="partitioning-subpartitions.html" title="26.2.6 Subpartitioning">
Section 26.2.6, “Subpartitioning”
</a>
) with a
nonpartitioned table using an
<a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
<code class="literal">
ALTER TABLE ...
EXCHANGE PARTITION
</code>
</a>
statement. In the following
example, we first create a table
<code class="literal">
es
</code>
that is
partitioned by
<code class="literal">
RANGE
</code>
and subpartitioned by
<code class="literal">
KEY
</code>
, populate this table as we did table
<code class="literal">
e
</code>
, and then create an empty, nonpartitioned
copy
<code class="literal">
es2
</code>
of the table, as shown here:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa71794143"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> es <span class="token punctuation">(</span>
<span class="token prompt"> -></span> id <span class="token datatype">INT</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span><span class="token punctuation">,</span>
<span class="token prompt"> -></span> fname <span class="token datatype">VARCHAR</span><span class="token punctuation">(</span><span class="token number">30</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token prompt"> -></span> lname <span class="token datatype">VARCHAR</span><span class="token punctuation">(</span><span class="token number">30</span><span class="token punctuation">)</span>
<span class="token prompt"> -></span> <span class="token punctuation">)</span>
<span class="token prompt"> -></span> <span class="token keyword">PARTITION</span> <span class="token keyword">BY</span> <span class="token keyword">RANGE</span> <span class="token punctuation">(</span>id<span class="token punctuation">)</span>
<span class="token prompt"> -></span> <span class="token keyword">SUBPARTITION</span> <span class="token keyword">BY</span> <span class="token keyword">KEY</span> <span class="token punctuation">(</span>lname<span class="token punctuation">)</span>
<span class="token prompt"> -></span> <span class="token keyword">SUBPARTITIONS</span> <span class="token number">2</span> <span class="token punctuation">(</span>
<span class="token prompt"> -></span> <span class="token keyword">PARTITION</span> p0 <span class="token keyword">VALUES</span> <span class="token keyword">LESS</span> <span class="token keyword">THAN</span> <span class="token punctuation">(</span><span class="token number">50</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token prompt"> -></span> <span class="token keyword">PARTITION</span> p1 <span class="token keyword">VALUES</span> <span class="token keyword">LESS</span> <span class="token keyword">THAN</span> <span class="token punctuation">(</span><span class="token number">100</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token prompt"> -></span> <span class="token keyword">PARTITION</span> p2 <span class="token keyword">VALUES</span> <span class="token keyword">LESS</span> <span class="token keyword">THAN</span> <span class="token punctuation">(</span><span class="token number">150</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token prompt"> -></span> <span class="token keyword">PARTITION</span> p3 <span class="token keyword">VALUES</span> <span class="token keyword">LESS</span> <span class="token keyword">THAN</span> <span class="token punctuation">(</span><span class="token keyword">MAXVALUE</span><span class="token punctuation">)</span>
<span class="token prompt"> -></span> <span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected (2.76 sec)</span>
<span class="token prompt">mysql></span> <span class="token keyword">INSERT</span> <span class="token keyword">INTO</span> es <span class="token keyword">VALUES</span>
<span class="token prompt"> -></span> <span class="token punctuation">(</span><span class="token number">1669</span><span class="token punctuation">,</span> <span class="token string">"Jim"</span><span class="token punctuation">,</span> <span class="token string">"Smith"</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token prompt"> -></span> <span class="token punctuation">(</span><span class="token number">337</span><span class="token punctuation">,</span> <span class="token string">"Mary"</span><span class="token punctuation">,</span> <span class="token string">"Jones"</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token prompt"> -></span> <span class="token punctuation">(</span><span class="token number">16</span><span class="token punctuation">,</span> <span class="token string">"Frank"</span><span class="token punctuation">,</span> <span class="token string">"White"</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token prompt"> -></span> <span class="token punctuation">(</span><span class="token number">2005</span><span class="token punctuation">,</span> <span class="token string">"Linda"</span><span class="token punctuation">,</span> <span class="token string">"Black"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 4 rows affected (0.04 sec)</span>
<span class="token output">Records: 4 Duplicates: 0 Warnings: 0</span>
<span class="token prompt">mysql></span> <span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> es2 <span class="token operator">LIKE</span> es<span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected (1.27 sec)</span>
<span class="token prompt">mysql></span> <span class="token keyword">ALTER</span> <span class="token keyword">TABLE</span> es2 <span class="token keyword">REMOVE</span> <span class="token keyword">PARTITIONING</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected (0.70 sec)</span>
<span class="token output">Records: 0 Duplicates: 0 Warnings: 0</span></code></pre>
</div>
<p>
Although we did not explicitly name any of the subpartitions
when creating table
<code class="literal">
es
</code>
, we can obtain
generated names for these by including the
<code class="literal">
SUBPARTITION_NAME
</code>
column of the
<a class="link" href="information-schema-partitions-table.html" title="28.3.21 The INFORMATION_SCHEMA PARTITIONS Table">
<code class="literal">
PARTITIONS
</code>
</a>
table from
<code class="literal">
INFORMATION_SCHEMA
</code>
when selecting from that
table, as shown here:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa46790338"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> PARTITION_NAME<span class="token punctuation">,</span> SUBPARTITION_NAME<span class="token punctuation">,</span> TABLE_ROWS
<span class="token prompt"> -></span> <span class="token keyword">FROM</span> INFORMATION_SCHEMA<span class="token punctuation">.</span><span class="token keyword">PARTITIONS</span>
<span class="token prompt"> -></span> <span class="token keyword">WHERE</span> <span class="token keyword">TABLE_NAME</span> <span class="token operator">=</span> <span class="token string">'es'</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> PARTITION_NAME <span class="token punctuation">|</span> SUBPARTITION_NAME <span class="token punctuation">|</span> TABLE_ROWS <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> p0 <span class="token punctuation">|</span> p0sp0 <span class="token punctuation">|</span> 1 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> p0 <span class="token punctuation">|</span> p0sp1 <span class="token punctuation">|</span> 0 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> p1 <span class="token punctuation">|</span> p1sp0 <span class="token punctuation">|</span> 0 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> p1 <span class="token punctuation">|</span> p1sp1 <span class="token punctuation">|</span> 0 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> p2 <span class="token punctuation">|</span> p2sp0 <span class="token punctuation">|</span> 0 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> p2 <span class="token punctuation">|</span> p2sp1 <span class="token punctuation">|</span> 0 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> p3 <span class="token punctuation">|</span> p3sp0 <span class="token punctuation">|</span> 3 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> p3 <span class="token punctuation">|</span> p3sp1 <span class="token punctuation">|</span> 0 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">8 rows in set (0.00 sec)</span></code></pre>
</div>
<p>
The following
<a class="link" href="alter-table-partition-operations.html" title="15.1.9.1 ALTER TABLE Partition Operations">
<code class="literal">
ALTER
TABLE
</code>
</a>
statement exchanges subpartition
<code class="literal">
p3sp0
</code>
in table
<code class="literal">
es
</code>
with the
nonpartitioned table
<code class="literal">
es2
</code>
:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa18801498"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">ALTER</span> <span class="token keyword">TABLE</span> es <span class="token keyword">EXCHANGE</span> <span class="token keyword">PARTITION</span> p3sp0 <span class="token keyword">WITH</span> <span class="token keyword">TABLE</span> es2<span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected (0.29 sec)</span></code></pre>
</div>
<p>
You can verify that the rows were exchanged by issuing the
following queries:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa36223974"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> PARTITION_NAME<span class="token punctuation">,</span> SUBPARTITION_NAME<span class="token punctuation">,</span> TABLE_ROWS
<span class="token prompt"> -></span> <span class="token keyword">FROM</span> INFORMATION_SCHEMA<span class="token punctuation">.</span><span class="token keyword">PARTITIONS</span>
<span class="token prompt"> -></span> <span class="token keyword">WHERE</span> <span class="token keyword">TABLE_NAME</span> <span class="token operator">=</span> <span class="token string">'es'</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> PARTITION_NAME <span class="token punctuation">|</span> SUBPARTITION_NAME <span class="token punctuation">|</span> TABLE_ROWS <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> p0 <span class="token punctuation">|</span> p0sp0 <span class="token punctuation">|</span> 1 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> p0 <span class="token punctuation">|</span> p0sp1 <span class="token punctuation">|</span> 0 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> p1 <span class="token punctuation">|</span> p1sp0 <span class="token punctuation">|</span> 0 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> p1 <span class="token punctuation">|</span> p1sp1 <span class="token punctuation">|</span> 0 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> p2 <span class="token punctuation">|</span> p2sp0 <span class="token punctuation">|</span> 0 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> p2 <span class="token punctuation">|</span> p2sp1 <span class="token punctuation">|</span> 0 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> p3 <span class="token punctuation">|</span> p3sp0 <span class="token punctuation">|</span> 0 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> p3 <span class="token punctuation">|</span> p3sp1 <span class="token punctuation">|</span> 0 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">8 rows in set (0.00 sec)</span>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> es2<span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> id <span class="token punctuation">|</span> fname <span class="token punctuation">|</span> lname <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 1669 <span class="token punctuation">|</span> Jim <span class="token punctuation">|</span> Smith <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 337 <span class="token punctuation">|</span> Mary <span class="token punctuation">|</span> Jones <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 2005 <span class="token punctuation">|</span> Linda <span class="token punctuation">|</span> Black <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">3 rows in set (0.00 sec)</span></code></pre>
</div>
<p>
If a table is subpartitioned, you can exchange only a
subpartition of the table—not an entire
partition—with an unpartitioned table, as shown here:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa3224736"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">ALTER</span> <span class="token keyword">TABLE</span> es <span class="token keyword">EXCHANGE</span> <span class="token keyword">PARTITION</span> p3 <span class="token keyword">WITH</span> <span class="token keyword">TABLE</span> es2<span class="token punctuation">;</span>
<span class="token output">ERROR 1704 (HY000)<span class="token punctuation">:</span> Subpartitioned table, use subpartition instead of partition</span></code></pre>
</div>
<p>
Table structures are compared in a strict fashion; the number,
order, names, and types of columns and indexes of the
partitioned table and the nonpartitioned table must match
exactly. In addition, both tables must use the same storage
engine:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa62489758"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> es3 <span class="token operator">LIKE</span> e<span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected (1.31 sec)</span>
<span class="token prompt">mysql></span> <span class="token keyword">ALTER</span> <span class="token keyword">TABLE</span> es3 <span class="token keyword">REMOVE</span> <span class="token keyword">PARTITIONING</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected (0.53 sec)</span>
<span class="token output">Records: 0 Duplicates: 0 Warnings: 0</span>
<span class="token prompt">mysql></span> <span class="token keyword">SHOW</span> <span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> es3\G
<span class="token output"><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span> 1. row <span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span>
Table<span class="token punctuation">:</span> es3
Create Table<span class="token punctuation">:</span> CREATE TABLE `es3` (
`id` int(11) NOT NULL,
`fname` varchar(30) DEFAULT NULL,
`lname` varchar(30) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
</span><span class="token output">1 row in set (0.00 sec)</span>
<span class="token prompt">mysql></span> <span class="token keyword">ALTER</span> <span class="token keyword">TABLE</span> es3 <span class="token keyword">ENGINE</span> <span class="token operator">=</span> MyISAM<span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected (0.15 sec)</span>
<span class="token output">Records: 0 Duplicates: 0 Warnings: 0</span>
<span class="token prompt">mysql></span> <span class="token keyword">ALTER</span> <span class="token keyword">TABLE</span> es <span class="token keyword">EXCHANGE</span> <span class="token keyword">PARTITION</span> p3sp0 <span class="token keyword">WITH</span> <span class="token keyword">TABLE</span> es3<span class="token punctuation">;</span>
<span class="token output">ERROR 1497 (HY000)<span class="token punctuation">:</span> The mix of handlers in the partitions is not allowed in this version of MySQL</span></code></pre>
</div>
<p>
The
<code class="literal">
ALTER TABLE ... ENGINE ...
</code>
statement in
this example works because the previous
<code class="literal">
ALTER
TABLE
</code>
removed the partitioning from table
<code class="literal">
es3
</code>
.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/environment-variables.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h2 class="title">
<a name="environment-variables">
</a>
6.9 Environment Variables
</h2>
</div>
</div>
</div>
<a class="indexterm" name="idm46045302818864">
</a>
<a class="indexterm" name="idm46045302817376">
</a>
<a class="indexterm" name="idm46045302816304">
</a>
<p>
This section lists environment variables that are used directly or
indirectly by MySQL. Most of these can also be found in other places
in this manual.
</p>
<p>
Options on the command line take precedence over values specified in
option files and environment variables, and values in option files
take precedence over values in environment variables. In many cases,
it is preferable to use an option file instead of environment
variables to modify the behavior of MySQL. See
<a class="xref" href="option-files.html" title="6.2.2.2 Using Option Files">
Section 6.2.2.2, “Using Option Files”
</a>
.
</p>
<a class="indexterm" name="idm46045302813264">
</a>
<a class="indexterm" name="idm46045302812160">
</a>
<a class="indexterm" name="idm46045302810656">
</a>
<a class="indexterm" name="idm46045302809552">
</a>
<a class="indexterm" name="idm46045302808048">
</a>
<a class="indexterm" name="idm46045302806944">
</a>
<a class="indexterm" name="idm46045302805456">
</a>
<a class="indexterm" name="idm46045302804368">
</a>
<a class="indexterm" name="idm46045302802912">
</a>
<a class="indexterm" name="idm46045302801840">
</a>
<a class="indexterm" name="idm46045302800384">
</a>
<a class="indexterm" name="idm46045302799296">
</a>
<a class="indexterm" name="idm46045302797808">
</a>
<a class="indexterm" name="idm46045302796720">
</a>
<a class="indexterm" name="idm46045302795232">
</a>
<a class="indexterm" name="idm46045302794144">
</a>
<a class="indexterm" name="idm46045302792656">
</a>
<a class="indexterm" name="idm46045302791568">
</a>
<a class="indexterm" name="idm46045302790080">
</a>
<a class="indexterm" name="idm46045302788976">
</a>
<a class="indexterm" name="idm46045302787472">
</a>
<a class="indexterm" name="idm46045302786368">
</a>
<a class="indexterm" name="idm46045302784880">
</a>
<a class="indexterm" name="idm46045302783792">
</a>
<a class="indexterm" name="idm46045302782304">
</a>
<a class="indexterm" name="idm46045302781216">
</a>
<a class="indexterm" name="idm46045302779728">
</a>
<a class="indexterm" name="idm46045302778640">
</a>
<a class="indexterm" name="idm46045302777152">
</a>
<a class="indexterm" name="idm46045302776064">
</a>
<a class="indexterm" name="idm46045302774576">
</a>
<a class="indexterm" name="idm46045302773488">
</a>
<a class="indexterm" name="idm46045302772000">
</a>
<a class="indexterm" name="idm46045302770912">
</a>
<a class="indexterm" name="idm46045302769424">
</a>
<a class="indexterm" name="idm46045302768336">
</a>
<a class="indexterm" name="idm46045302766848">
</a>
<a class="indexterm" name="idm46045302765760">
</a>
<a class="indexterm" name="idm46045302764272">
</a>
<a class="indexterm" name="idm46045302763184">
</a>
<a class="indexterm" name="idm46045302761696">
</a>
<a class="indexterm" name="idm46045302760608">
</a>
<a class="indexterm" name="idm46045302759120">
</a>
<a class="indexterm" name="idm46045302758016">
</a>
<a class="indexterm" name="idm46045302756528">
</a>
<a class="indexterm" name="idm46045302755424">
</a>
<a class="indexterm" name="idm46045302753936">
</a>
<a class="indexterm" name="idm46045302752832">
</a>
<a class="indexterm" name="idm46045302751344">
</a>
<a class="indexterm" name="idm46045302750256">
</a>
<a class="indexterm" name="idm46045302748768">
</a>
<a class="indexterm" name="idm46045302747680">
</a>
<a class="indexterm" name="idm46045302746192">
</a>
<a class="indexterm" name="idm46045302745104">
</a>
<a class="indexterm" name="idm46045302743616">
</a>
<a class="indexterm" name="idm46045302742528">
</a>
<a class="indexterm" name="idm46045302741040">
</a>
<a class="indexterm" name="idm46045302739952">
</a>
<a class="indexterm" name="idm46045302738464">
</a>
<a class="indexterm" name="idm46045302737376">
</a>
<a class="indexterm" name="idm46045302735888">
</a>
<a class="indexterm" name="idm46045302734800">
</a>
<a class="indexterm" name="idm46045302733312">
</a>
<a class="indexterm" name="idm46045302732240">
</a>
<a class="indexterm" name="idm46045302730784">
</a>
<a class="indexterm" name="idm46045302729696">
</a>
<a class="indexterm" name="idm46045302728208">
</a>
<a class="indexterm" name="idm46045302727120">
</a>
<a class="indexterm" name="idm46045302725632">
</a>
<a class="indexterm" name="idm46045302724544">
</a>
<div class="informaltable">
<table summary="Environment variables that are used directly or indirectly by MySQL.">
<colgroup>
<col style="width: 40%"/>
<col style="width: 60%"/>
</colgroup>
<thead>
<tr>
<th>
Variable
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<code class="literal">
AUTHENTICATION_KERBEROS_CLIENT_LOG
</code>
</td>
<td>
Kerberos authentication logging level.
</td>
</tr>
<tr>
<td>
<code class="literal">
AUTHENTICATION_LDAP_CLIENT_LOG
</code>
</td>
<td>
Client-side LDAP authentication logging level.
</td>
</tr>
<tr>
<td>
<code class="literal">
AUTHENTICATION_PAM_LOG
</code>
</td>
<td>
<a class="link" href="pam-pluggable-authentication.html#pam-pluggable-authentication-debugging" title="PAM Authentication Debugging">
PAM
</a>
authentication plugin debug logging settings.
</td>
</tr>
<tr>
<td>
<code class="literal">
CC
</code>
</td>
<td>
The name of your C compiler (for running
<span class="command">
<strong>
CMake
</strong>
</span>
).
</td>
</tr>
<tr>
<td>
<code class="literal">
CXX
</code>
</td>
<td>
The name of your C++ compiler (for running
<span class="command">
<strong>
CMake
</strong>
</span>
).
</td>
</tr>
<tr>
<td>
<code class="literal">
CC
</code>
</td>
<td>
The name of your C compiler (for running
<span class="command">
<strong>
CMake
</strong>
</span>
).
</td>
</tr>
<tr>
<td>
<code class="literal">
DBI_USER
</code>
</td>
<td>
The default user name for Perl DBI.
</td>
</tr>
<tr>
<td>
<code class="literal">
DBI_TRACE
</code>
</td>
<td>
Trace options for Perl DBI.
</td>
</tr>
<tr>
<td>
<code class="literal">
HOME
</code>
</td>
<td>
The default path for the
<a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
<span class="command">
<strong>
mysql
</strong>
</span>
</a>
history file is
<code class="filename">
$HOME/.mysql_history
</code>
.
</td>
</tr>
<tr>
<td>
<code class="literal">
LD_RUN_PATH
</code>
</td>
<td>
Used to specify the location of
<code class="filename">
libmysqlclient.so
</code>
.
</td>
</tr>
<tr>
<td>
<code class="literal">
LIBMYSQL_ENABLE_CLEARTEXT_PLUGIN
</code>
</td>
<td>
Enable
<code class="literal">
mysql_clear_password
</code>
authentication plugin;
see
<a class="xref" href="cleartext-pluggable-authentication.html" title="8.4.1.4 Client-Side Cleartext Pluggable Authentication">
Section 8.4.1.4, “Client-Side Cleartext Pluggable Authentication”
</a>
.
</td>
</tr>
<tr>
<td>
<code class="literal">
LIBMYSQL_PLUGIN_DIR
</code>
</td>
<td>
Directory in which to look for client plugins.
</td>
</tr>
<tr>
<td>
<code class="literal">
LIBMYSQL_PLUGINS
</code>
</td>
<td>
Client plugins to preload.
</td>
</tr>
<tr>
<td>
<code class="literal">
MYSQL_DEBUG
</code>
</td>
<td>
Debug trace options when debugging.
</td>
</tr>
<tr>
<td>
<code class="literal">
MYSQL_GROUP_SUFFIX
</code>
</td>
<td>
Option group suffix value (like specifying
<a class="link" href="option-file-options.html#option_general_defaults-group-suffix">
<code class="option">
--defaults-group-suffix
</code>
</a>
).
</td>
</tr>
<tr>
<td>
<code class="literal">
MYSQL_HISTFILE
</code>
</td>
<td>
The path to the
<a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
<span class="command">
<strong>
mysql
</strong>
</span>
</a>
history file. If this variable
is set, its value overrides the default for
<code class="filename">
$HOME/.mysql_history
</code>
.
</td>
</tr>
<tr>
<td>
<code class="literal">
MYSQL_HISTIGNORE
</code>
</td>
<td>
Patterns specifying statements that
<a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
<span class="command">
<strong>
mysql
</strong>
</span>
</a>
should not
log to
<code class="filename">
$HOME/.mysql_history
</code>
, or
<code class="literal">
syslog
</code>
if
<a class="link" href="mysql-command-options.html#option_mysql_syslog">
<code class="option">
--syslog
</code>
</a>
is given.
</td>
</tr>
<tr>
<td>
<code class="literal">
MYSQL_HOME
</code>
</td>
<td>
The path to the directory in which the server-specific
<code class="filename">
my.cnf
</code>
file resides.
</td>
</tr>
<tr>
<td>
<code class="literal">
MYSQL_HOST
</code>
</td>
<td>
The default host name used by the
<a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
<span class="command">
<strong>
mysql
</strong>
</span>
</a>
command-line
client.
</td>
</tr>
<tr>
<td>
<code class="literal">
MYSQL_PS1
</code>
</td>
<td>
The command prompt to use in the
<a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
<span class="command">
<strong>
mysql
</strong>
</span>
</a>
command-line
client.
</td>
</tr>
<tr>
<td>
<code class="literal">
MYSQL_PWD
</code>
</td>
<td>
The default password when connecting to
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
. Using
this is insecure. See note following table.
</td>
</tr>
<tr>
<td>
<code class="literal">
MYSQL_TCP_PORT
</code>
</td>
<td>
The default TCP/IP port number.
</td>
</tr>
<tr>
<td>
<code class="literal">
MYSQL_TEST_LOGIN_FILE
</code>
</td>
<td>
The name of the
<code class="filename">
.mylogin.cnf
</code>
login path file.
</td>
</tr>
<tr>
<td>
<code class="literal">
MYSQL_TEST_TRACE_CRASH
</code>
</td>
<td>
Whether the test protocol trace plugin crashes clients. See note
following table.
</td>
</tr>
<tr>
<td>
<code class="literal">
MYSQL_TEST_TRACE_DEBUG
</code>
</td>
<td>
Whether the test protocol trace plugin produces output. See note
following table.
</td>
</tr>
<tr>
<td>
<code class="literal">
MYSQL_UNIX_PORT
</code>
</td>
<td>
The default Unix socket file name; used for connections to
<code class="literal">
localhost
</code>
.
</td>
</tr>
<tr>
<td>
<code class="literal">
MYSQLX_TCP_PORT
</code>
</td>
<td>
The X Plugin default TCP/IP port number.
</td>
</tr>
<tr>
<td>
<code class="literal">
MYSQLX_UNIX_PORT
</code>
</td>
<td>
The X Plugin default Unix socket file name; used for connections to
<code class="literal">
localhost
</code>
.
</td>
</tr>
<tr>
<td>
<code class="literal">
NOTIFY_SOCKET
</code>
</td>
<td>
Socket used by
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
to communicate with systemd.
</td>
</tr>
<tr>
<td>
<code class="literal">
PATH
</code>
</td>
<td>
Used by the shell to find MySQL programs.
</td>
</tr>
<tr>
<td>
<code class="literal">
PKG_CONFIG_PATH
</code>
</td>
<td>
Location of
<code class="filename">
mysqlclient.pc
</code>
<span class="command">
<strong>
pkg-config
</strong>
</span>
file. See note following table.
</td>
</tr>
<tr>
<td>
<code class="literal">
TMPDIR
</code>
</td>
<td>
The directory in which temporary files are created.
</td>
</tr>
<tr>
<td>
<code class="literal">
TZ
</code>
</td>
<td>
This should be set to your local time zone. See
<a class="xref" href="timezone-problems.html" title="B.3.3.7 Time Zone Problems">
Section B.3.3.7, “Time Zone Problems”
</a>
.
</td>
</tr>
<tr>
<td>
<code class="literal">
UMASK
</code>
</td>
<td>
The user-file creation mode when creating files. See note following
table.
</td>
</tr>
<tr>
<td>
<code class="literal">
UMASK_DIR
</code>
</td>
<td>
The user-directory creation mode when creating directories. See note
following table.
</td>
</tr>
<tr>
<td>
<code class="literal">
USER
</code>
</td>
<td>
The default user name on Windows when connecting to
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
.
</td>
</tr>
</tbody>
</table>
</div>
<div class="informaltable">
<table cellpadding="0" cellspacing="0" style="position: fixed; top: 0px; display: none; left: 401px; width: 739px;">
<thead>
<tr>
<th style="width: 295.188px;">
Variable
</th>
<th style="width: 442.812px;">
Description
</th>
</tr>
</thead>
</table>
</div>
<p>
For information about the
<a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
<span class="command">
<strong>
mysql
</strong>
</span>
</a>
history file, see
<a class="xref" href="mysql-logging.html" title="6.5.1.3 mysql Client Logging">
Section 6.5.1.3, “mysql Client Logging”
</a>
.
</p>
<p>
Use of
<code class="literal">
MYSQL_PWD
</code>
to specify a MySQL password must
be considered
<span class="emphasis">
<em>
extremely insecure
</em>
</span>
and should not
be used. Some versions of
<span class="command">
<strong>
ps
</strong>
</span>
include an option to
display the environment of running processes. On some systems, if
you set
<code class="literal">
MYSQL_PWD
</code>
, your password is exposed to
any other user who runs
<span class="command">
<strong>
ps
</strong>
</span>
. Even on systems
without such a version of
<span class="command">
<strong>
ps
</strong>
</span>
, it is unwise to
assume that there are no other methods by which users can examine
process environments.
</p>
<p>
<code class="literal">
MYSQL_PWD
</code>
is deprecated as of MySQL
8.4; expect it to be removed in a future version of
MySQL.
</p>
<p>
<code class="literal">
MYSQL_TEST_LOGIN_FILE
</code>
is the path name of the
login path file (the file created by
<a class="link" href="mysql-config-editor.html" title="6.6.7 mysql_config_editor — MySQL Configuration Utility">
<span class="command">
<strong>
mysql_config_editor
</strong>
</span>
</a>
). If not set, the default
value is
<code class="filename">
%APPDATA%\MySQL\.mylogin.cnf
</code>
directory
on Windows and
<code class="filename">
$HOME/.mylogin.cnf
</code>
on
non-Windows systems. See
<a class="xref" href="mysql-config-editor.html" title="6.6.7 mysql_config_editor — MySQL Configuration Utility">
Section 6.6.7, “mysql_config_editor — MySQL Configuration Utility”
</a>
.
</p>
<p>
The
<code class="literal">
MYSQL_TEST_TRACE_DEBUG
</code>
and
<code class="literal">
MYSQL_TEST_TRACE_CRASH
</code>
variables control the test
protocol trace client plugin, if MySQL is built with that plugin
enabled. For more information, see
<a class="ulink" href="/doc/extending-mysql/8.4/en/test-protocol-trace-plugin.html" target="_top">
Using the Test Protocol Trace Plugin
</a>
.
</p>
<p>
The default
<code class="literal">
UMASK
</code>
and
<code class="literal">
UMASK_DIR
</code>
values are
<code class="literal">
0640
</code>
and
<code class="literal">
0750
</code>
, respectively. MySQL assumes that the value
for
<code class="literal">
UMASK
</code>
or
<code class="literal">
UMASK_DIR
</code>
is in
octal if it starts with a zero. For example, setting
<code class="literal">
UMASK=0600
</code>
is equivalent to
<code class="literal">
UMASK=384
</code>
because 0600 octal is 384 decimal.
</p>
<p>
The
<code class="literal">
UMASK
</code>
and
<code class="literal">
UMASK_DIR
</code>
variables, despite their names, are used as modes, not masks:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
If
<code class="literal">
UMASK
</code>
is set,
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
uses
<code class="literal">
($UMASK | 0600)
</code>
as the mode for file
creation, so that newly created files have a mode in the range
from 0600 to 0666 (all values octal).
</p>
</li>
<li class="listitem">
<p>
If
<code class="literal">
UMASK_DIR
</code>
is set,
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
uses
<code class="literal">
($UMASK_DIR |
0700)
</code>
as the base mode for directory creation, which
then is AND-ed with
<code class="literal">
~(~$UMASK & 0666)
</code>
, so
that newly created directories have a mode in the range from
0700 to 0777 (all values octal). The AND operation may remove
read and write permissions from the directory mode, but not
execute permissions.
</p>
</li>
</ul>
</div>
<p>
See also
<a class="xref" href="file-permissions.html" title="B.3.3.1 Problems with File Permissions">
Section B.3.3.1, “Problems with File Permissions”
</a>
.
</p>
<p>
It may be necessary to set
<code class="literal">
PKG_CONFIG_PATH
</code>
if you
use
<span class="command">
<strong>
pkg-config
</strong>
</span>
for building MySQL programs. See
<a class="ulink" href="/doc/c-api/8.4/en/c-api-building-clients-pkg-config.html" target="_top">
Building C API Client Programs Using pkg-config
</a>
.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/performance-schema-wait-tables.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="performance-schema-wait-tables">
</a>
29.12.4 Performance Schema Wait Event Tables
</h3>
</div>
</div>
</div>
<div class="toc">
<dl class="toc">
<dt>
<span class="section">
<a href="performance-schema-events-waits-current-table.html">
29.12.4.1 The events_waits_current Table
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="performance-schema-events-waits-history-table.html">
29.12.4.2 The events_waits_history Table
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="performance-schema-events-waits-history-long-table.html">
29.12.4.3 The events_waits_history_long Table
</a>
</span>
</dt>
</dl>
</div>
<p>
The Performance Schema instruments waits, which are events that
take time. Within the event hierarchy, wait events nest within
stage events, which nest within statement events, which nest
within transaction events.
</p>
<p>
These tables store wait events:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="link" href="performance-schema-events-waits-current-table.html" title="29.12.4.1 The events_waits_current Table">
<code class="literal">
events_waits_current
</code>
</a>
: The
current wait event for each thread.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="performance-schema-events-waits-history-table.html" title="29.12.4.2 The events_waits_history Table">
<code class="literal">
events_waits_history
</code>
</a>
: The most
recent wait events that have ended per thread.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="performance-schema-events-waits-history-long-table.html" title="29.12.4.3 The events_waits_history_long Table">
<code class="literal">
events_waits_history_long
</code>
</a>
: The
most recent wait events that have ended globally (across all
threads).
</p>
</li>
</ul>
</div>
<p>
The following sections describe the wait event tables. There are
also summary tables that aggregate information about wait
events; see
<a class="xref" href="performance-schema-wait-summary-tables.html" title="29.12.20.1 Wait Event Summary Tables">
Section 29.12.20.1, “Wait Event Summary Tables”
</a>
.
</p>
<p>
For more information about the relationship between the three
wait event tables, see
<a class="xref" href="performance-schema-event-tables.html" title="29.9 Performance Schema Tables for Current and Historical Events">
Section 29.9, “Performance Schema Tables for Current and Historical Events”
</a>
.
</p>
<h4>
<a name="wait-event-configuration">
</a>
Configuring Wait Event Collection
</h4>
<p>
To control whether to collect wait events, set the state of the
relevant instruments and consumers:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
The
<a class="link" href="performance-schema-setup-instruments-table.html" title="29.12.2.3 The setup_instruments Table">
<code class="literal">
setup_instruments
</code>
</a>
table
contains instruments with names that begin with
<code class="literal">
wait
</code>
. Use these instruments to enable or
disable collection of individual wait event classes.
</p>
</li>
<li class="listitem">
<p>
The
<a class="link" href="performance-schema-setup-consumers-table.html" title="29.12.2.2 The setup_consumers Table">
<code class="literal">
setup_consumers
</code>
</a>
table
contains consumer values with names corresponding to the
current and historical wait event table names. Use these
consumers to filter collection of wait events.
</p>
</li>
</ul>
</div>
<p>
Some wait instruments are enabled by default; others are
disabled. For example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa19492852"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token keyword">NAME</span><span class="token punctuation">,</span> ENABLED<span class="token punctuation">,</span> TIMED
<span class="token keyword">FROM</span> performance_schema<span class="token punctuation">.</span>setup_instruments
<span class="token keyword">WHERE</span> <span class="token keyword">NAME</span> <span class="token operator">LIKE</span> <span class="token string">'wait/io/file/innodb%'</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> NAME <span class="token punctuation">|</span> ENABLED <span class="token punctuation">|</span> TIMED <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> wait/io/file/innodb/innodb_tablespace_open_file <span class="token punctuation">|</span> YES <span class="token punctuation">|</span> YES <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> wait/io/file/innodb/innodb_data_file <span class="token punctuation">|</span> YES <span class="token punctuation">|</span> YES <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> wait/io/file/innodb/innodb_log_file <span class="token punctuation">|</span> YES <span class="token punctuation">|</span> YES <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> wait/io/file/innodb/innodb_temp_file <span class="token punctuation">|</span> YES <span class="token punctuation">|</span> YES <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> wait/io/file/innodb/innodb_arch_file <span class="token punctuation">|</span> YES <span class="token punctuation">|</span> YES <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> wait/io/file/innodb/innodb_clone_file <span class="token punctuation">|</span> YES <span class="token punctuation">|</span> YES <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token keyword">NAME</span><span class="token punctuation">,</span> ENABLED<span class="token punctuation">,</span> TIMED
<span class="token keyword">FROM</span> performance_schema<span class="token punctuation">.</span>setup_instruments
<span class="token keyword">WHERE</span> <span class="token keyword">NAME</span> <span class="token operator">LIKE</span> <span class="token string">'wait/io/socket/%'</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> NAME <span class="token punctuation">|</span> ENABLED <span class="token punctuation">|</span> TIMED <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> wait/io/socket/sql/server_tcpip_socket <span class="token punctuation">|</span> NO <span class="token punctuation">|</span> NO <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> wait/io/socket/sql/server_unix_socket <span class="token punctuation">|</span> NO <span class="token punctuation">|</span> NO <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> wait/io/socket/sql/client_connection <span class="token punctuation">|</span> NO <span class="token punctuation">|</span> NO <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
<p>
The wait consumers are disabled by default:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa69491777"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token operator">*</span>
<span class="token keyword">FROM</span> performance_schema<span class="token punctuation">.</span>setup_consumers
<span class="token keyword">WHERE</span> <span class="token keyword">NAME</span> <span class="token operator">LIKE</span> <span class="token string">'events_waits%'</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> NAME <span class="token punctuation">|</span> ENABLED <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> events_waits_current <span class="token punctuation">|</span> NO <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> events_waits_history <span class="token punctuation">|</span> NO <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> events_waits_history_long <span class="token punctuation">|</span> NO <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
<p>
To control wait event collection at server startup, use lines
like these in your
<code class="filename">
my.cnf
</code>
file:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Enable:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-ini"><div class="docs-select-all right" id="sa92600268"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-ini"><span class="token selector">[mysqld]</span>
<span class="token constant">performance-schema-instrument</span><span class="token attr-value"><span class="token punctuation">=</span>'wait/%=ON'</span>
<span class="token constant">performance-schema-consumer-events-waits-current</span><span class="token attr-value"><span class="token punctuation">=</span>ON</span>
<span class="token constant">performance-schema-consumer-events-waits-history</span><span class="token attr-value"><span class="token punctuation">=</span>ON</span>
<span class="token constant">performance-schema-consumer-events-waits-history-long</span><span class="token attr-value"><span class="token punctuation">=</span>ON</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
Disable:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-ini"><div class="docs-select-all right" id="sa24136286"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-ini"><span class="token selector">[mysqld]</span>
<span class="token constant">performance-schema-instrument</span><span class="token attr-value"><span class="token punctuation">=</span>'wait/%=OFF'</span>
<span class="token constant">performance-schema-consumer-events-waits-current</span><span class="token attr-value"><span class="token punctuation">=</span>OFF</span>
<span class="token constant">performance-schema-consumer-events-waits-history</span><span class="token attr-value"><span class="token punctuation">=</span>OFF</span>
<span class="token constant">performance-schema-consumer-events-waits-history-long</span><span class="token attr-value"><span class="token punctuation">=</span>OFF</span></code></pre>
</div>
</li>
</ul>
</div>
<p>
To control wait event collection at runtime, update the
<a class="link" href="performance-schema-setup-instruments-table.html" title="29.12.2.3 The setup_instruments Table">
<code class="literal">
setup_instruments
</code>
</a>
and
<a class="link" href="performance-schema-setup-consumers-table.html" title="29.12.2.2 The setup_consumers Table">
<code class="literal">
setup_consumers
</code>
</a>
tables:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Enable:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa50382535"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">UPDATE</span> performance_schema<span class="token punctuation">.</span>setup_instruments
<span class="token keyword">SET</span> ENABLED <span class="token operator">=</span> <span class="token string">'YES'</span><span class="token punctuation">,</span> TIMED <span class="token operator">=</span> <span class="token string">'YES'</span>
<span class="token keyword">WHERE</span> <span class="token keyword">NAME</span> <span class="token operator">LIKE</span> <span class="token string">'wait/%'</span><span class="token punctuation">;</span>
<span class="token keyword">UPDATE</span> performance_schema<span class="token punctuation">.</span>setup_consumers
<span class="token keyword">SET</span> ENABLED <span class="token operator">=</span> <span class="token string">'YES'</span>
<span class="token keyword">WHERE</span> <span class="token keyword">NAME</span> <span class="token operator">LIKE</span> <span class="token string">'events_waits%'</span><span class="token punctuation">;</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
Disable:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa49176679"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">UPDATE</span> performance_schema<span class="token punctuation">.</span>setup_instruments
<span class="token keyword">SET</span> ENABLED <span class="token operator">=</span> <span class="token string">'NO'</span><span class="token punctuation">,</span> TIMED <span class="token operator">=</span> <span class="token string">'NO'</span>
<span class="token keyword">WHERE</span> <span class="token keyword">NAME</span> <span class="token operator">LIKE</span> <span class="token string">'wait/%'</span><span class="token punctuation">;</span>
<span class="token keyword">UPDATE</span> performance_schema<span class="token punctuation">.</span>setup_consumers
<span class="token keyword">SET</span> ENABLED <span class="token operator">=</span> <span class="token string">'NO'</span>
<span class="token keyword">WHERE</span> <span class="token keyword">NAME</span> <span class="token operator">LIKE</span> <span class="token string">'events_waits%'</span><span class="token punctuation">;</span></code></pre>
</div>
</li>
</ul>
</div>
<p>
To collect only specific wait events, enable only the
corresponding wait instruments. To collect wait events only for
specific wait event tables, enable the wait instruments but only
the wait consumers corresponding to the desired tables.
</p>
<p>
For additional information about configuring event collection,
see
<a class="xref" href="performance-schema-startup-configuration.html" title="29.3 Performance Schema Startup Configuration">
Section 29.3, “Performance Schema Startup Configuration”
</a>
,
and
<a class="xref" href="performance-schema-runtime-configuration.html" title="29.4 Performance Schema Runtime Configuration">
Section 29.4, “Performance Schema Runtime Configuration”
</a>
.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/example-user-variables.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="example-user-variables">
</a>
5.6.5 Using User-Defined Variables
</h3>
</div>
</div>
</div>
<p>
You can employ MySQL user variables to remember results without
having to store them in temporary variables in the client. (See
<a class="xref" href="user-variables.html" title="11.4 User-Defined Variables">
Section 11.4, “User-Defined Variables”
</a>
.)
</p>
<p>
For example, to find the articles with the highest and lowest
price you can do this:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa96391023"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token variable">@min_price</span><span class="token operator">:=</span><span class="token function">MIN</span><span class="token punctuation">(</span>price<span class="token punctuation">)</span><span class="token punctuation">,</span><span class="token variable">@max_price</span><span class="token operator">:=</span><span class="token function">MAX</span><span class="token punctuation">(</span>price<span class="token punctuation">)</span> <span class="token keyword">FROM</span> shop<span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> shop <span class="token keyword">WHERE</span> price<span class="token operator">=</span><span class="token variable">@min_price</span> <span class="token operator">OR</span> price<span class="token operator">=</span><span class="token variable">@max_price</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> article <span class="token punctuation">|</span> dealer <span class="token punctuation">|</span> price <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 0003 <span class="token punctuation">|</span> D <span class="token punctuation">|</span> 1.25 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 0004 <span class="token punctuation">|</span> D <span class="token punctuation">|</span> 19.95 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
It is also possible to store the name of a database object
such as a table or a column in a user variable and then to use
this variable in an SQL statement; however, this requires the
use of a prepared statement. See
<a class="xref" href="sql-prepared-statements.html" title="15.5 Prepared Statements">
Section 15.5, “Prepared Statements”
</a>
, for more
information.
</p>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/features.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="features">
</a>
1.2.2 The Main Features of MySQL
</h3>
</div>
</div>
</div>
<a class="indexterm" name="idm46045335204128">
</a>
<a class="indexterm" name="idm46045335203120">
</a>
<p>
This section describes some of the important characteristics of
the MySQL Database Software. In most respects, the roadmap applies
to all versions of MySQL. For information about features as they
are introduced into MySQL on a series-specific basis, see the
<span class="quote">
“
<span class="quote">
In a Nutshell
</span>
”
</span>
section of the appropriate Manual:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
MySQL 8.4:
<a class="xref" href="mysql-nutshell.html" title="1.4 What Is New in MySQL 8.4 since MySQL 8.0">
Section 1.4, “What Is New in MySQL 8.4 since MySQL 8.0”
</a>
</p>
</li>
<li class="listitem">
<p>
MySQL 8.0:
<a class="ulink" href="/doc/refman/8.0/en/mysql-nutshell.html" target="_top">
What Is New in MySQL 8.0
</a>
</p>
</li>
<li class="listitem">
<p>
MySQL 5.7:
<a class="ulink" href="/doc/refman/5.7/en/mysql-nutshell.html" target="_top">
What Is New in MySQL 5.7
</a>
</p>
</li>
</ul>
</div>
<h4>
<a name="idm46045335195824">
</a>
Internals and Portability
</h4>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Written in C and C++.
</p>
</li>
<li class="listitem">
<p>
Tested with a broad range of different compilers.
</p>
</li>
<li class="listitem">
<p>
Works on many different platforms. See
<a class="ulink" href="https://www.mysql.com/support/supportedplatforms/database.html" target="_blank">
https://www.mysql.com/support/supportedplatforms/database.html
</a>
.
</p>
</li>
<li class="listitem">
<p>
For portability, configured using
<span class="command">
<strong>
CMake
</strong>
</span>
.
</p>
</li>
<li class="listitem">
<p>
Tested with Purify (a commercial memory leakage detector) as
well as with Valgrind, a GPL tool
(
<a class="ulink" href="https://valgrind.org/" target="_blank">
https://valgrind.org/
</a>
).
</p>
</li>
<li class="listitem">
<p>
Uses multi-layered server design with independent modules.
</p>
</li>
<li class="listitem">
<p>
Designed to be fully multithreaded using kernel threads, to
easily use multiple CPUs if they are available.
</p>
</li>
<li class="listitem">
<p>
Provides transactional and nontransactional storage engines.
</p>
</li>
<li class="listitem">
<p>
Uses very fast B-tree disk tables (
<code class="literal">
MyISAM
</code>
)
with index compression.
</p>
</li>
<li class="listitem">
<p>
Designed to make it relatively easy to add other storage
engines. This is useful if you want to provide an SQL
interface for an in-house database.
</p>
</li>
<li class="listitem">
<p>
Uses a very fast thread-based memory allocation system.
</p>
</li>
<li class="listitem">
<p>
Executes very fast joins using an optimized nested-loop join.
</p>
</li>
<li class="listitem">
<p>
Implements in-memory hash tables, which are used as temporary
tables.
</p>
</li>
<li class="listitem">
<p>
Implements SQL functions using a highly optimized class
library that should be as fast as possible. Usually there is
no memory allocation at all after query initialization.
</p>
</li>
<li class="listitem">
<p>
Provides the server as a separate program for use in a
client/server networked environment.
</p>
</li>
</ul>
</div>
<h4>
<a name="idm46045335178736">
</a>
Data Types
</h4>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Many data types: signed/unsigned integers 1, 2, 3, 4, and 8
bytes long,
<a class="link" href="floating-point-types.html" title="13.1.4 Floating-Point Types (Approximate Value) - FLOAT, DOUBLE">
<code class="literal">
FLOAT
</code>
</a>
,
<a class="link" href="floating-point-types.html" title="13.1.4 Floating-Point Types (Approximate Value) - FLOAT, DOUBLE">
<code class="literal">
DOUBLE
</code>
</a>
,
<a class="link" href="char.html" title="13.3.2 The CHAR and VARCHAR Types">
<code class="literal">
CHAR
</code>
</a>
,
<a class="link" href="char.html" title="13.3.2 The CHAR and VARCHAR Types">
<code class="literal">
VARCHAR
</code>
</a>
,
<a class="link" href="binary-varbinary.html" title="13.3.3 The BINARY and VARBINARY Types">
<code class="literal">
BINARY
</code>
</a>
,
<a class="link" href="binary-varbinary.html" title="13.3.3 The BINARY and VARBINARY Types">
<code class="literal">
VARBINARY
</code>
</a>
,
<a class="link" href="blob.html" title="13.3.4 The BLOB and TEXT Types">
<code class="literal">
TEXT
</code>
</a>
,
<a class="link" href="blob.html" title="13.3.4 The BLOB and TEXT Types">
<code class="literal">
BLOB
</code>
</a>
,
<a class="link" href="datetime.html" title="13.2.2 The DATE, DATETIME, and TIMESTAMP Types">
<code class="literal">
DATE
</code>
</a>
,
<a class="link" href="time.html" title="13.2.3 The TIME Type">
<code class="literal">
TIME
</code>
</a>
,
<a class="link" href="datetime.html" title="13.2.2 The DATE, DATETIME, and TIMESTAMP Types">
<code class="literal">
DATETIME
</code>
</a>
,
<a class="link" href="datetime.html" title="13.2.2 The DATE, DATETIME, and TIMESTAMP Types">
<code class="literal">
TIMESTAMP
</code>
</a>
,
<a class="link" href="year.html" title="13.2.4 The YEAR Type">
<code class="literal">
YEAR
</code>
</a>
,
<a class="link" href="set.html" title="13.3.6 The SET Type">
<code class="literal">
SET
</code>
</a>
,
<a class="link" href="enum.html" title="13.3.5 The ENUM Type">
<code class="literal">
ENUM
</code>
</a>
, and OpenGIS spatial
types. See
<a class="xref" href="data-types.html" title="Chapter 13 Data Types">
Chapter 13,
<i>
Data Types
</i>
</a>
.
</p>
</li>
<li class="listitem">
<p>
Fixed-length and variable-length string types.
</p>
</li>
</ul>
</div>
<h4>
<a name="idm46045335160624">
</a>
Statements and Functions
</h4>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Full operator and function support in the
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
list and
<code class="literal">
WHERE
</code>
clause of queries. For example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa3321667"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token function">CONCAT</span><span class="token punctuation">(</span>first_name<span class="token punctuation">,</span> <span class="token string">' '</span><span class="token punctuation">,</span> last_name<span class="token punctuation">)</span>
<span class="token prompt"> -></span> <span class="token keyword">FROM</span> citizen
<span class="token prompt"> -></span> <span class="token keyword">WHERE</span> income<span class="token operator">/</span>dependents <span class="token operator">></span> <span class="token number">10000</span> <span class="token operator">AND</span> age <span class="token operator">></span> <span class="token number">30</span><span class="token punctuation">;</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
Full support for SQL
<code class="literal">
GROUP BY
</code>
and
<code class="literal">
ORDER BY
</code>
clauses. Support for group
functions (
<a class="link" href="aggregate-functions.html#function_count">
<code class="literal">
COUNT()
</code>
</a>
,
<a class="link" href="aggregate-functions.html#function_avg">
<code class="literal">
AVG()
</code>
</a>
,
<a class="link" href="aggregate-functions.html#function_std">
<code class="literal">
STD()
</code>
</a>
,
<a class="link" href="aggregate-functions.html#function_sum">
<code class="literal">
SUM()
</code>
</a>
,
<a class="link" href="aggregate-functions.html#function_max">
<code class="literal">
MAX()
</code>
</a>
,
<a class="link" href="aggregate-functions.html#function_min">
<code class="literal">
MIN()
</code>
</a>
, and
<a class="link" href="aggregate-functions.html#function_group-concat">
<code class="literal">
GROUP_CONCAT()
</code>
</a>
).
</p>
</li>
<li class="listitem">
<p>
Support for
<code class="literal">
LEFT OUTER JOIN
</code>
and
<code class="literal">
RIGHT OUTER JOIN
</code>
with both standard SQL and
ODBC syntax.
</p>
</li>
<li class="listitem">
<p>
Support for aliases on tables and columns as required by
standard SQL.
</p>
</li>
<li class="listitem">
<p>
Support for
<a class="link" href="delete.html" title="15.2.2 DELETE Statement">
<code class="literal">
DELETE
</code>
</a>
,
<a class="link" href="insert.html" title="15.2.7 INSERT Statement">
<code class="literal">
INSERT
</code>
</a>
,
<a class="link" href="replace.html" title="15.2.12 REPLACE Statement">
<code class="literal">
REPLACE
</code>
</a>
, and
<a class="link" href="update.html" title="15.2.17 UPDATE Statement">
<code class="literal">
UPDATE
</code>
</a>
to return the number of
rows that were changed (affected), or to return the number of
rows matched instead by setting a flag when connecting to the
server.
</p>
</li>
<li class="listitem">
<p>
Support for MySQL-specific
<a class="link" href="show.html" title="15.7.7 SHOW Statements">
<code class="literal">
SHOW
</code>
</a>
statements that retrieve information about databases, storage
engines, tables, and indexes. Support for the
<code class="literal">
INFORMATION_SCHEMA
</code>
database, implemented
according to standard SQL.
</p>
</li>
<li class="listitem">
<p>
An
<a class="link" href="explain.html" title="15.8.2 EXPLAIN Statement">
<code class="literal">
EXPLAIN
</code>
</a>
statement to show
how the optimizer resolves a query.
</p>
</li>
<li class="listitem">
<p>
Independence of function names from table or column names. For
example,
<code class="literal">
ABS
</code>
is a valid column name. The
only restriction is that for a function call, no spaces are
permitted between the function name and the
<span class="quote">
“
<span class="quote">
<code class="literal">
(
</code>
</span>
”
</span>
that follows it. See
<a class="xref" href="keywords.html" title="11.3 Keywords and Reserved Words">
Section 11.3, “Keywords and Reserved Words”
</a>
.
</p>
</li>
<li class="listitem">
<p>
You can refer to tables from different databases in the same
statement.
</p>
</li>
</ul>
</div>
<h4>
<a name="idm46045335129248">
</a>
Security
</h4>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
A privilege and password system that is very flexible and
secure, and that enables host-based verification.
</p>
</li>
<li class="listitem">
<p>
Password security by encryption of all password traffic when
you connect to a server.
</p>
</li>
</ul>
</div>
<h4>
<a name="idm46045335126416">
</a>
Scalability and Limits
</h4>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Support for large databases. We use MySQL Server with
databases that contain 50 million records. We also know of
users who use MySQL Server with 200,000 tables and about
5,000,000,000 rows.
</p>
</li>
<li class="listitem">
<p>
Support for up to 64 indexes per table. Each index may consist
of 1 to 16 columns or parts of columns. The maximum index
width for
<a class="link" href="innodb-storage-engine.html" title="Chapter 17 The InnoDB Storage Engine">
<code class="literal">
InnoDB
</code>
</a>
tables is either
767 bytes or 3072 bytes. See
<a class="xref" href="innodb-limits.html" title="17.21 InnoDB Limits">
Section 17.21, “InnoDB Limits”
</a>
.
The maximum index width for
<a class="link" href="myisam-storage-engine.html" title="18.2 The MyISAM Storage Engine">
<code class="literal">
MyISAM
</code>
</a>
tables is 1000 bytes. See
<a class="xref" href="myisam-storage-engine.html" title="18.2 The MyISAM Storage Engine">
Section 18.2, “The MyISAM Storage Engine”
</a>
. An index may use a
prefix of a column for
<a class="link" href="char.html" title="13.3.2 The CHAR and VARCHAR Types">
<code class="literal">
CHAR
</code>
</a>
,
<a class="link" href="char.html" title="13.3.2 The CHAR and VARCHAR Types">
<code class="literal">
VARCHAR
</code>
</a>
,
<a class="link" href="blob.html" title="13.3.4 The BLOB and TEXT Types">
<code class="literal">
BLOB
</code>
</a>
, or
<a class="link" href="blob.html" title="13.3.4 The BLOB and TEXT Types">
<code class="literal">
TEXT
</code>
</a>
column types.
</p>
</li>
</ul>
</div>
<h4>
<a name="idm46045335116416">
</a>
Connectivity
</h4>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Clients can connect to MySQL Server using several protocols:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
Clients can connect using TCP/IP sockets on any platform.
</p>
</li>
<li class="listitem">
<p>
On Windows systems, clients can connect using named pipes
if the server is started with the
<a class="link" href="server-system-variables.html#sysvar_named_pipe">
<code class="literal">
named_pipe
</code>
</a>
system
variable enabled. Windows servers also support
shared-memory connections if started with the
<a class="link" href="server-system-variables.html#sysvar_shared_memory">
<code class="literal">
shared_memory
</code>
</a>
system
variable enabled. Clients can connect through shared
memory by using the
<a class="link" href="connection-options.html#option_general_protocol">
<code class="option">
--protocol=memory
</code>
</a>
option.
</p>
</li>
<li class="listitem">
<p>
On Unix systems, clients can connect using Unix domain
socket files.
</p>
</li>
</ul>
</div>
</li>
<li class="listitem">
<p>
MySQL client programs can be written in many languages. A
client library written in C is available for clients written
in C or C++, or for any language that provides C bindings.
</p>
</li>
<li class="listitem">
<p>
APIs for C, C++, Eiffel, Java, Perl, PHP, Python, Ruby, and
Tcl are available, enabling MySQL clients to be written in
many languages. See
<a class="xref" href="connectors-apis.html" title="Chapter 31 Connectors and APIs">
Chapter 31,
<i>
Connectors and APIs
</i>
</a>
.
</p>
</li>
<li class="listitem">
<p>
The Connector/ODBC (MyODBC) interface provides MySQL support
for client programs that use ODBC (Open Database Connectivity)
connections. For example, you can use MS Access to connect to
your MySQL server. Clients can be run on Windows or Unix.
Connector/ODBC source is available. All ODBC 2.5 functions are
supported, as are many others. See
<a class="ulink" href="/doc/connector-odbc/en/" target="_top">
MySQL Connector/ODBC Developer Guide
</a>
.
</p>
</li>
<li class="listitem">
<p>
The Connector/J interface provides MySQL support for Java
client programs that use JDBC connections. Clients can be run
on Windows or Unix. Connector/J source is available. See
<a class="ulink" href="/doc/connector-j/en/" target="_top">
MySQL Connector/J Developer Guide
</a>
.
</p>
</li>
<li class="listitem">
<p>
MySQL Connector/NET enables developers to easily create .NET applications
that require secure, high-performance data connectivity with
MySQL. It implements the required ADO.NET interfaces and
integrates into ADO.NET aware tools. Developers can build
applications using their choice of .NET languages. MySQL Connector/NET is
a fully managed ADO.NET driver written in 100% pure C#. See
<a class="ulink" href="/doc/connector-net/en/" target="_top">
MySQL Connector/NET Developer Guide
</a>
.
</p>
</li>
</ul>
</div>
<h4>
<a name="idm46045341023408">
</a>
Localization
</h4>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
The server can provide error messages to clients in many
languages. See
<a class="xref" href="error-message-language.html" title="12.12 Setting the Error Message Language">
Section 12.12, “Setting the Error Message Language”
</a>
.
</p>
</li>
<li class="listitem">
<p>
Full support for several different character sets, including
<code class="literal">
latin1
</code>
(cp1252),
<code class="literal">
german
</code>
,
<code class="literal">
big5
</code>
,
<code class="literal">
ujis
</code>
, several
Unicode character sets, and more. For example, the
Scandinavian characters
<span class="quote">
“
<span class="quote">
<code class="literal">
å
</code>
</span>
”
</span>
,
<span class="quote">
“
<span class="quote">
<code class="literal">
ä
</code>
</span>
”
</span>
and
<span class="quote">
“
<span class="quote">
<code class="literal">
ö
</code>
</span>
”
</span>
are permitted in table
and column names.
</p>
</li>
<li class="listitem">
<p>
All data is saved in the chosen character set.
</p>
</li>
<li class="listitem">
<p>
Sorting and comparisons are done according to the default
character set and collation. It is possible to change this
when the MySQL server is started (see
<a class="xref" href="charset-server.html" title="12.3.2 Server Character Set and Collation">
Section 12.3.2, “Server Character Set and Collation”
</a>
). To see an example of very
advanced sorting, look at the Czech sorting code. MySQL Server
supports many different character sets that can be specified
at compile time and runtime.
</p>
</li>
<li class="listitem">
<p>
The server time zone can be changed dynamically, and
individual clients can specify their own time zone. See
<a class="xref" href="time-zone-support.html" title="7.1.15 MySQL Server Time Zone Support">
Section 7.1.15, “MySQL Server Time Zone Support”
</a>
.
</p>
</li>
</ul>
</div>
<h4>
<a name="idm46045335079696">
</a>
Clients and Tools
</h4>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
MySQL includes several client and utility programs. These
include both command-line programs such as
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
and
<a class="link" href="mysqladmin.html" title="6.5.2 mysqladmin — A MySQL Server Administration Program">
<span class="command">
<strong>
mysqladmin
</strong>
</span>
</a>
, and graphical programs such as
<a class="link" href="workbench.html" title="Chapter 33 MySQL Workbench">
MySQL Workbench
</a>
.
</p>
</li>
<li class="listitem">
<p>
MySQL Server has built-in support for SQL statements to check,
optimize, and repair tables. These statements are available
from the command line through the
<a class="link" href="mysqlcheck.html" title="6.5.3 mysqlcheck — A Table Maintenance Program">
<span class="command">
<strong>
mysqlcheck
</strong>
</span>
</a>
client. MySQL also includes
<a class="link" href="myisamchk.html" title="6.6.4 myisamchk — MyISAM Table-Maintenance Utility">
<span class="command">
<strong>
myisamchk
</strong>
</span>
</a>
, a very fast command-line utility
for performing these operations on
<code class="literal">
MyISAM
</code>
tables. See
<a class="xref" href="programs.html" title="Chapter 6 MySQL Programs">
Chapter 6,
<i>
MySQL Programs
</i>
</a>
.
</p>
</li>
<li class="listitem">
<p>
MySQL programs can be invoked with the
<code class="option">
--help
</code>
or
<code class="option">
-?
</code>
option to obtain online assistance.
</p>
</li>
</ul>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/mysql-shell-tutorial-javascript-documents-in-tables.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="mysql-shell-tutorial-javascript-documents-in-tables">
</a>
22.3.5 Documents in Tables
</h3>
</div>
</div>
</div>
<a class="indexterm" name="idm46045127447184">
</a>
<p>
In MySQL, a table may contain traditional relational data, JSON
values, or both. You can combine traditional data with JSON
documents by storing the documents in columns having a native
<a class="link" href="json.html" title="13.5 The JSON Data Type">
<code class="literal">
JSON
</code>
</a>
data type.
</p>
<p>
Examples in this section use the city table in the
<code class="literal">
world_x
</code>
schema.
</p>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h4 class="title">
<a name="idm46045127442656">
</a>
city Table Description
</h4>
</div>
</div>
</div>
<p>
The city table has five columns (or fields).
</p>
<pre class="screen">+---------------+------------+-------+-------+---------+------------------+
| Field | Type | Null | Key | Default | Extra |
+---------------+------------+-------+-------+---------+------------------+
| ID | int(11) | NO | PRI | null | auto_increment |
| Name | char(35) | NO | | | |
| CountryCode | char(3) | NO | | | |
| District | char(20) | NO | | | |
| Info | json | YES | | null | |
+---------------+------------+-------+-------+---------+------------------+
</pre>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h4 class="title">
<a name="mysql-shell-tutorial-javascript-insert-record">
</a>
Insert a Record
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045127438928">
</a>
<p>
To insert a document into the column of a table, pass to the
<code class="literal">
values()
</code>
method a well-formed JSON document
in the correct order. In the following example, a document is
passed as the final value to be inserted into the Info column.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-mysqlsh"><div class="docs-select-all right" id="sa95452562"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-mysqlsh"><span class="token prompt">mysql-js></span> db<span class="token punctuation">.</span>city<span class="token punctuation">.</span><span class="token function">insert</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">values</span><span class="token punctuation">(</span>
None<span class="token punctuation">,</span> <span class="token string">"San Francisco"</span><span class="token punctuation">,</span> <span class="token string">"USA"</span><span class="token punctuation">,</span> <span class="token string">"California"</span><span class="token punctuation">,</span> <span class="token string">'{"Population":830000}'</span><span class="token punctuation">)</span></code></pre>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h4 class="title">
<a name="mysql-shell-tutorial-javascript-select-record">
</a>
Select a Record
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045127432992">
</a>
<p>
You can issue a query with a search condition that evaluates
document values in the expression.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-mysqlsh"><div class="docs-select-all right" id="sa37436023"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-mysqlsh"><span class="token prompt">mysql-js></span> db<span class="token punctuation">.</span>city<span class="token punctuation">.</span><span class="token function">select</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token string">"ID"</span><span class="token punctuation">,</span> <span class="token string">"Name"</span><span class="token punctuation">,</span> <span class="token string">"CountryCode"</span><span class="token punctuation">,</span> <span class="token string">"District"</span><span class="token punctuation">,</span> <span class="token string">"Info"</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">where</span><span class="token punctuation">(</span>
<span class="token string">"CountryCode = :country and Info->'$.Population' > 1000000"</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">bind</span><span class="token punctuation">(</span>
<span class="token string">'country'</span><span class="token punctuation">,</span> <span class="token string">'USA'</span><span class="token punctuation">)</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> ID <span class="token punctuation">|</span> Name <span class="token punctuation">|</span> CountryCode <span class="token punctuation">|</span> District <span class="token punctuation">|</span> Info <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 3793 <span class="token punctuation">|</span> New York <span class="token punctuation">|</span> USA <span class="token punctuation">|</span> New York <span class="token punctuation">|</span> {"Population": 8008278} <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 3794 <span class="token punctuation">|</span> Los Angeles <span class="token punctuation">|</span> USA <span class="token punctuation">|</span> California <span class="token punctuation">|</span> {"Population": 3694820} <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 3795 <span class="token punctuation">|</span> Chicago <span class="token punctuation">|</span> USA <span class="token punctuation">|</span> Illinois <span class="token punctuation">|</span> {"Population": 2896016} <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 3796 <span class="token punctuation">|</span> Houston <span class="token punctuation">|</span> USA <span class="token punctuation">|</span> Texas <span class="token punctuation">|</span> {"Population": 1953631} <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 3797 <span class="token punctuation">|</span> Philadelphia <span class="token punctuation">|</span> USA <span class="token punctuation">|</span> Pennsylvania <span class="token punctuation">|</span> {"Population": 1517550} <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 3798 <span class="token punctuation">|</span> Phoenix <span class="token punctuation">|</span> USA <span class="token punctuation">|</span> Arizona <span class="token punctuation">|</span> {"Population": 1321045} <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 3799 <span class="token punctuation">|</span> San Diego <span class="token punctuation">|</span> USA <span class="token punctuation">|</span> California <span class="token punctuation">|</span> {"Population": 1223400} <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 3800 <span class="token punctuation">|</span> Dallas <span class="token punctuation">|</span> USA <span class="token punctuation">|</span> Texas <span class="token punctuation">|</span> {"Population": 1188580} <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 3801 <span class="token punctuation">|</span> San Antonio <span class="token punctuation">|</span> USA <span class="token punctuation">|</span> Texas <span class="token punctuation">|</span> {"Population": 1144646} <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">9 rows in set (0.01 sec)</span></code></pre>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h4 class="title">
<a name="idm46045127426672">
</a>
Related Information
</h4>
</div>
</div>
</div>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
See
<a class="ulink" href="/doc/x-devapi-userguide/en/devapi-users-working-with-relational-tables-and-documents.html" target="_top">
Working with Relational Tables and Documents
</a>
for more information.
</p>
</li>
<li class="listitem">
<p>
See
<a class="xref" href="json.html" title="13.5 The JSON Data Type">
Section 13.5, “The JSON Data Type”
</a>
for a detailed description of the
data type.
</p>
</li>
</ul>
</div>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/mysql-cluster-ndbinfo-cpudata.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="mysql-cluster-ndbinfo-cpudata">
</a>
25.6.17.14 The ndbinfo cpudata Table
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045090059856">
</a>
<p>
The
<code class="literal">
cpudata
</code>
table provides data about CPU
usage during the last second.
</p>
<p>
The
<code class="literal">
cpustat
</code>
table contains the following
columns:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
node_id
</code>
</p>
<p>
Node ID
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
cpu_no
</code>
</p>
<p>
CPU ID
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
cpu_online
</code>
</p>
<p>
1 if the CPU is currently online, otherwise 0
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
cpu_userspace_time
</code>
</p>
<p>
CPU time spent in userspace
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
cpu_idle_time
</code>
</p>
<p>
CPU time spent idle
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
cpu_system_time
</code>
</p>
<p>
CPU time spent in system time
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
cpu_interrupt_time
</code>
</p>
<p>
CPU time spent handling interrupts (hardware and software)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
cpu_exec_vm_time
</code>
</p>
<p>
CPU time spent in virtual machine execution
</p>
</li>
</ul>
</div>
<h5>
<a name="idm46045090040352">
</a>
Notes
</h5>
<p>
The
<code class="literal">
cpudata
</code>
table is available only on Linux
and Solaris operating systems.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/charset-errors.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h2 class="title">
<a name="charset-errors">
</a>
12.6 Error Message Character Set
</h2>
</div>
</div>
</div>
<p>
This section describes how the MySQL server uses character sets
for constructing error messages. For information about the
language of error messages (rather than the character set), see
<a class="xref" href="error-message-language.html" title="12.12 Setting the Error Message Language">
Section 12.12, “Setting the Error Message Language”
</a>
. For general information
about configuring error logging, see
<a class="xref" href="error-log.html" title="7.4.2 The Error Log">
Section 7.4.2, “The Error Log”
</a>
.
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="xref" href="charset-errors.html#charset-errors-construction" title="Character Set for Error Message Construction">
Character Set for Error Message Construction
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="charset-errors.html#charset-errors-disposition" title="Character Set for Error Message Disposition">
Character Set for Error Message Disposition
</a>
</p>
</li>
</ul>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h3 class="title">
<a name="charset-errors-construction">
</a>
Character Set for Error Message Construction
</h3>
</div>
</div>
</div>
<p>
The server constructs error messages as follows:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
The message template uses UTF-8
(
<code class="literal">
utf8mb3
</code>
).
</p>
</li>
<li class="listitem">
<p>
Parameters in the message template are replaced with values
that apply to a specific error occurrence:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
Identifiers such as table or column names use UTF-8
internally so they are copied as is.
</p>
</li>
<li class="listitem">
<p>
Character (nonbinary) string values are converted from
their character set to UTF-8.
</p>
</li>
<li class="listitem">
<p>
Binary string values are copied as is for bytes in the
range
<code class="literal">
0x20
</code>
to
<code class="literal">
0x7E
</code>
, and using
<code class="literal">
\x
</code>
hexadecimal encoding for bytes outside that range. For
example, if a duplicate-key error occurs for an attempt
to insert
<code class="literal">
0x41CF9F
</code>
into a
<a class="link" href="binary-varbinary.html" title="13.3.3 The BINARY and VARBINARY Types">
<code class="literal">
VARBINARY
</code>
</a>
unique column,
the resulting error message uses UTF-8 with some bytes
hexadecimal encoded:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-none"><div class="docs-select-all right" id="sa90726953"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-none">Duplicate entry 'A\xCF\x9F' for key 1</code></pre>
</div>
</li>
</ul>
</div>
</li>
</ul>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h3 class="title">
<a name="charset-errors-disposition">
</a>
Character Set for Error Message Disposition
</h3>
</div>
</div>
</div>
<p>
An error message, once constructed, can be written by the server
to the error log or sent to clients:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
If the server writes the error message to the error log, it
writes it in UTF-8, as constructed, without conversion to
another character set.
</p>
</li>
<li class="listitem">
<p>
If the server sends the error message to a client program,
the server converts it from UTF-8 to the character set
specified by the
<a class="link" href="server-system-variables.html#sysvar_character_set_results">
<code class="literal">
character_set_results
</code>
</a>
system variable. If
<a class="link" href="server-system-variables.html#sysvar_character_set_results">
<code class="literal">
character_set_results
</code>
</a>
has a
value of
<code class="literal">
NULL
</code>
or
<code class="literal">
binary
</code>
, no conversion occurs. No
conversion occurs if the variable value is
<code class="literal">
utf8mb3
</code>
or
<code class="literal">
utf8mb4
</code>
,
either, because those character sets have a repertoire that
includes all UTF-8 characters used in message construction.
</p>
<p>
If characters cannot be represented in
<a class="link" href="server-system-variables.html#sysvar_character_set_results">
<code class="literal">
character_set_results
</code>
</a>
, some
encoding may occur during the conversion. The encoding uses
Unicode code point values:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
Characters in the Basic Multilingual Plane (BMP) range
(
<code class="literal">
0x0000
</code>
to
<code class="literal">
0xFFFF
</code>
)
are written using
<code class="literal">
\
<em class="replaceable">
<code>
nnnn
</code>
</em>
</code>
notation.
</p>
</li>
<li class="listitem">
<p>
Characters outside the BMP range
(
<code class="literal">
0x10000
</code>
to
<code class="literal">
0x10FFFF
</code>
) are written using
<code class="literal">
\+
<em class="replaceable">
<code>
nnnnnn
</code>
</em>
</code>
notation.
</p>
</li>
</ul>
</div>
<p>
Clients can set
<a class="link" href="server-system-variables.html#sysvar_character_set_results">
<code class="literal">
character_set_results
</code>
</a>
to
control the character set in which they receive error
messages. The variable can be set directly, or indirectly by
means such as
<a class="link" href="set-names.html" title="15.7.6.3 SET NAMES Statement">
<code class="literal">
SET NAMES
</code>
</a>
. For
more information about
<a class="link" href="server-system-variables.html#sysvar_character_set_results">
<code class="literal">
character_set_results
</code>
</a>
, see
<a class="xref" href="charset-connection.html" title="12.4 Connection Character Sets and Collations">
Section 12.4, “Connection Character Sets and Collations”
</a>
.
</p>
</li>
</ul>
</div>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/function-resolution.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="function-resolution">
</a>
11.2.5 Function Name Parsing and Resolution
</h3>
</div>
</div>
</div>
<a class="indexterm" name="idm46045219705072">
</a>
<a class="indexterm" name="idm46045219703616">
</a>
<p>
MySQL supports built-in (native) functions, loadable functions,
and stored functions. This section describes how the server
recognizes whether the name of a built-in function is used as a
function call or as an identifier, and how the server determines
which function to use in cases when functions of different types
exist with a given name.
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="xref" href="function-resolution.html#function-name-parsing" title="Built-In Function Name Parsing">
Built-In Function Name Parsing
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="function-resolution.html#function-name-resolution" title="Function Name Resolution">
Function Name Resolution
</a>
</p>
</li>
</ul>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h4 class="title">
<a name="function-name-parsing">
</a>
Built-In Function Name Parsing
</h4>
</div>
</div>
</div>
<p>
The parser uses default rules for parsing names of built-in
functions. These rules can be changed by enabling the
<a class="link" href="sql-mode.html#sqlmode_ignore_space">
<code class="literal">
IGNORE_SPACE
</code>
</a>
SQL mode.
</p>
<p>
When the parser encounters a word that is the name of a
built-in function, it must determine whether the name
signifies a function call or is instead a nonexpression
reference to an identifier such as a table or column name. For
example, in the following statements, the first reference to
<code class="literal">
count
</code>
is a function call, whereas the
second reference is a table name:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa13537488"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> <span class="token function">COUNT</span><span class="token punctuation">(</span><span class="token operator">*</span><span class="token punctuation">)</span> <span class="token keyword">FROM</span> mytable<span class="token punctuation">;</span>
<span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> <span class="token function">count</span> <span class="token punctuation">(</span>i <span class="token datatype">INT</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
The parser should recognize the name of a built-in function as
indicating a function call only when parsing what is expected
to be an expression. That is, in nonexpression context,
function names are permitted as identifiers.
</p>
<p>
However, some built-in functions have special parsing or
implementation considerations, so the parser uses the
following rules by default to distinguish whether their names
are being used as function calls or as identifiers in
nonexpression context:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
To use the name as a function call in an expression, there
must be no whitespace between the name and the following
<code class="literal">
(
</code>
parenthesis character.
</p>
</li>
<li class="listitem">
<p>
Conversely, to use the function name as an identifier, it
must not be followed immediately by a parenthesis.
</p>
</li>
</ul>
</div>
<p>
The requirement that function calls be written with no
whitespace between the name and the parenthesis applies only
to the built-in functions that have special considerations.
<code class="literal">
COUNT
</code>
is one such name. The
<code class="filename">
sql/lex.h
</code>
source file lists the names of
these special functions for which following whitespace
determines their interpretation: names defined by the
<code class="literal">
SYM_FN()
</code>
macro in the
<code class="literal">
symbols[]
</code>
array.
</p>
<p>
The following list names the functions in MySQL
8.4 that are affected by the
<a class="link" href="sql-mode.html#sqlmode_ignore_space">
<code class="literal">
IGNORE_SPACE
</code>
</a>
setting and
listed as special in the
<code class="filename">
sql/lex.h
</code>
source
file. You may find it easiest to treat the no-whitespace
requirement as applying to all function calls.
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
ADDDATE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
BIT_AND
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
BIT_OR
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
BIT_XOR
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
CAST
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
COUNT
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
CURDATE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
CURTIME
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
DATE_ADD
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
DATE_SUB
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
EXTRACT
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
GROUP_CONCAT
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MAX
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MID
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MIN
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
NOW
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
POSITION
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SESSION_USER
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
STD
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
STDDEV
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
STDDEV_POP
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
STDDEV_SAMP
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SUBDATE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SUBSTR
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SUBSTRING
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SUM
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SYSDATE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SYSTEM_USER
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
TRIM
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
VARIANCE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
VAR_POP
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
VAR_SAMP
</code>
</p>
</li>
</ul>
</div>
<p>
For functions not listed as special in
<code class="filename">
sql/lex.h
</code>
, whitespace does not matter.
They are interpreted as function calls only when used in
expression context and may be used freely as identifiers
otherwise.
<code class="literal">
ASCII
</code>
is one such name. However,
for these nonaffected function names, interpretation may vary
in expression context:
<code class="literal">
<em class="replaceable">
<code>
func_name
</code>
</em>
()
</code>
is
interpreted as a built-in function if there is one with the
given name; if not,
<code class="literal">
<em class="replaceable">
<code>
func_name
</code>
</em>
()
</code>
is
interpreted as a loadable function or stored function if one
exists with that name.
</p>
<p>
The
<a class="link" href="sql-mode.html#sqlmode_ignore_space">
<code class="literal">
IGNORE_SPACE
</code>
</a>
SQL mode
can be used to modify how the parser treats function names
that are whitespace-sensitive:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
With
<a class="link" href="sql-mode.html#sqlmode_ignore_space">
<code class="literal">
IGNORE_SPACE
</code>
</a>
disabled, the parser interprets the name as a function
call when there is no whitespace between the name and the
following parenthesis. This occurs even when the function
name is used in nonexpression context:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa81957347"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> <span class="token function">count</span><span class="token punctuation">(</span>i <span class="token datatype">INT</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output">ERROR 1064 (42000)<span class="token punctuation">:</span> You have an error in your SQL syntax ...
near 'count(i INT)'</span></code></pre>
</div>
<p>
To eliminate the error and cause the name to be treated as
an identifier, either use whitespace following the name or
write it as a quoted identifier (or both):
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa7110845"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> <span class="token function">count</span> <span class="token punctuation">(</span>i <span class="token datatype">INT</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> <span class="token punctuation">`</span>count<span class="token punctuation">`</span><span class="token punctuation">(</span>i <span class="token datatype">INT</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> <span class="token punctuation">`</span>count<span class="token punctuation">`</span> <span class="token punctuation">(</span>i <span class="token datatype">INT</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
With
<a class="link" href="sql-mode.html#sqlmode_ignore_space">
<code class="literal">
IGNORE_SPACE
</code>
</a>
enabled, the parser loosens the requirement that there be
no whitespace between the function name and the following
parenthesis. This provides more flexibility in writing
function calls. For example, either of the following
function calls are legal:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa2022324"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> <span class="token function">COUNT</span><span class="token punctuation">(</span><span class="token operator">*</span><span class="token punctuation">)</span> <span class="token keyword">FROM</span> mytable<span class="token punctuation">;</span>
<span class="token keyword">SELECT</span> <span class="token function">COUNT</span> <span class="token punctuation">(</span><span class="token operator">*</span><span class="token punctuation">)</span> <span class="token keyword">FROM</span> mytable<span class="token punctuation">;</span></code></pre>
</div>
<p>
However, enabling
<a class="link" href="sql-mode.html#sqlmode_ignore_space">
<code class="literal">
IGNORE_SPACE
</code>
</a>
also has
the side effect that the parser treats the affected
function names as reserved words (see
<a class="xref" href="keywords.html" title="11.3 Keywords and Reserved Words">
Section 11.3, “Keywords and Reserved Words”
</a>
). This means that a space
following the name no longer signifies its use as an
identifier. The name can be used in function calls with or
without following whitespace, but causes a syntax error in
nonexpression context unless it is quoted. For example,
with
<a class="link" href="sql-mode.html#sqlmode_ignore_space">
<code class="literal">
IGNORE_SPACE
</code>
</a>
enabled, both of the following statements fail with a
syntax error because the parser interprets
<code class="literal">
count
</code>
as a reserved word:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa46795349"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> <span class="token function">count</span><span class="token punctuation">(</span>i <span class="token datatype">INT</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> <span class="token function">count</span> <span class="token punctuation">(</span>i <span class="token datatype">INT</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
To use the function name in nonexpression context, write
it as a quoted identifier:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa86385223"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> <span class="token punctuation">`</span>count<span class="token punctuation">`</span><span class="token punctuation">(</span>i <span class="token datatype">INT</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> <span class="token punctuation">`</span>count<span class="token punctuation">`</span> <span class="token punctuation">(</span>i <span class="token datatype">INT</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
</div>
</li>
</ul>
</div>
<p>
To enable the
<a class="link" href="sql-mode.html#sqlmode_ignore_space">
<code class="literal">
IGNORE_SPACE
</code>
</a>
SQL mode, use this statement:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa55254509"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SET</span> sql_mode <span class="token operator">=</span> <span class="token string">'IGNORE_SPACE'</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
<a class="link" href="sql-mode.html#sqlmode_ignore_space">
<code class="literal">
IGNORE_SPACE
</code>
</a>
is also enabled
by certain other composite modes such as
<a class="link" href="sql-mode.html#sqlmode_ansi">
<code class="literal">
ANSI
</code>
</a>
that include it in
their value:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa74763131"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SET</span> sql_mode <span class="token operator">=</span> <span class="token string">'ANSI'</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
Check
<a class="xref" href="sql-mode.html" title="7.1.11 Server SQL Modes">
Section 7.1.11, “Server SQL Modes”
</a>
, to see which composite modes
enable
<a class="link" href="sql-mode.html#sqlmode_ignore_space">
<code class="literal">
IGNORE_SPACE
</code>
</a>
.
</p>
<p>
To minimize the dependency of SQL code on the
<a class="link" href="sql-mode.html#sqlmode_ignore_space">
<code class="literal">
IGNORE_SPACE
</code>
</a>
setting, use
these guidelines:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Avoid creating loadable functions or stored functions that
have the same name as a built-in function.
</p>
</li>
<li class="listitem">
<p>
Avoid using function names in nonexpression context. For
example, these statements use
<code class="literal">
count
</code>
(one of the affected function names affected by
<a class="link" href="sql-mode.html#sqlmode_ignore_space">
<code class="literal">
IGNORE_SPACE
</code>
</a>
), so they
fail with or without whitespace following the name if
<a class="link" href="sql-mode.html#sqlmode_ignore_space">
<code class="literal">
IGNORE_SPACE
</code>
</a>
is enabled:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa85283696"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> <span class="token function">count</span><span class="token punctuation">(</span>i <span class="token datatype">INT</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> <span class="token function">count</span> <span class="token punctuation">(</span>i <span class="token datatype">INT</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
If you must use a function name in nonexpression context,
write it as a quoted identifier:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa75043031"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> <span class="token punctuation">`</span>count<span class="token punctuation">`</span><span class="token punctuation">(</span>i <span class="token datatype">INT</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> <span class="token punctuation">`</span>count<span class="token punctuation">`</span> <span class="token punctuation">(</span>i <span class="token datatype">INT</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
</div>
</li>
</ul>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h4 class="title">
<a name="function-name-resolution">
</a>
Function Name Resolution
</h4>
</div>
</div>
</div>
<p>
The following rules describe how the server resolves
references to function names for function creation and
invocation:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Built-in functions and loadable functions
</p>
<p>
An error occurs if you try to create a loadable function
with the same name as a built-in function.
</p>
<p>
<code class="literal">
IF NOT EXISTS
</code>
has no effect in such
cases. See
<a class="xref" href="create-function-loadable.html" title="15.7.4.1 CREATE FUNCTION Statement for Loadable Functions">
Section 15.7.4.1, “CREATE FUNCTION Statement for Loadable Functions”
</a>
, for
more information.
</p>
</li>
<li class="listitem">
<p>
Built-in functions and stored functions
</p>
<p>
It is possible to create a stored function with the same
name as a built-in function, but to invoke the stored
function it is necessary to qualify it with a schema name.
For example, if you create a stored function named
<code class="literal">
PI
</code>
in the
<code class="literal">
test
</code>
schema, invoke it as
<code class="literal">
test.PI()
</code>
because
the server resolves
<a class="link" href="mathematical-functions.html#function_pi">
<code class="literal">
PI()
</code>
</a>
without a qualifier as a reference to the built-in
function. The server generates a warning if the stored
function name collides with a built-in function name. The
warning can be displayed with
<a class="link" href="show-warnings.html" title="15.7.7.42 SHOW WARNINGS Statement">
<code class="literal">
SHOW
WARNINGS
</code>
</a>
.
</p>
<p>
<code class="literal">
IF NOT EXISTS
</code>
has no effect in such
cases; see
<a class="xref" href="create-procedure.html" title="15.1.17 CREATE PROCEDURE and CREATE FUNCTION Statements">
Section 15.1.17, “CREATE PROCEDURE and CREATE FUNCTION Statements”
</a>
.
</p>
</li>
<li class="listitem">
<p>
Loadable functions and stored functions
</p>
<p>
It is possible to create a stored function with the same
name as an existing loadable function, or the other way
around. The server generates a warning if a proposed
stored function name collides with an existing loadable
function name, or if a proposed loadable function name
would be the same as that of an existing stored function.
In either case, once both functions exist, it is necessary
thereafter to qualify the stored function with a schema
name when invoking it; the server assumes in such cases
that the unqualified name refers to the loadable function.
</p>
<p>
MySQL 8.4 supports
<code class="literal">
IF NOT
EXISTS
</code>
with
<a class="link" href="create-function.html" title="15.1.14 CREATE FUNCTION Statement">
<code class="literal">
CREATE
FUNCTION
</code>
</a>
statements, but it has no effect in
such cases.
</p>
</li>
</ul>
</div>
<p>
The preceding function name resolution rules have implications
for upgrading to versions of MySQL that implement new built-in
functions:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
If you have already created a loadable function with a
given name and upgrade MySQL to a version that implements
a new built-in function with the same name, the loadable
function becomes inaccessible. To correct this, use
<a class="link" href="drop-function.html" title="15.1.26 DROP FUNCTION Statement">
<code class="literal">
DROP FUNCTION
</code>
</a>
to drop the
loadable function and
<a class="link" href="create-function.html" title="15.1.14 CREATE FUNCTION Statement">
<code class="literal">
CREATE
FUNCTION
</code>
</a>
to re-create the loadable function with
a different nonconflicting name. Then modify any affected
code to use the new name.
</p>
</li>
<li class="listitem">
<p>
If a new version of MySQL implements a built-in function
or loadable function with the same name as an existing
stored function, you have two choices: Rename the stored
function to use a nonconflicting name, or change any calls
to the function that do not do so already to use a schema
qualifier
(
<code class="literal">
<em class="replaceable">
<code>
schema_name
</code>
</em>
.
<em class="replaceable">
<code>
func_name
</code>
</em>
()
</code>
syntax). In either case, modify any affected code
accordingly.
</p>
</li>
</ul>
</div>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/enterprise-encryption-functions.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="enterprise-encryption-functions">
</a>
8.6.5 MySQL Enterprise Encryption Component Function Descriptions
</h3>
</div>
</div>
</div>
<p>
MySQL Enterprise Encryption functions have these general characteristics:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
For arguments of the wrong type or an incorrect number of
arguments, each function returns an error.
</p>
</li>
<li class="listitem">
<p>
If the arguments are not suitable to permit a function to
perform the requested operation, it returns
<code class="literal">
NULL
</code>
or 0 as appropriate. This occurs, for
example, if a function does not support a specified algorithm,
a key length is too short or long, or a string expected to be
a key string in PEM format is not a valid key.
</p>
</li>
<li class="listitem">
<p>
The underlying SSL library takes care of randomness
initialization.
</p>
</li>
</ul>
</div>
<p>
The component functions only support the RSA encryption algorithm.
</p>
<p>
For additional examples and discussion, see
<a class="xref" href="enterprise-encryption-usage.html" title="8.6.3 MySQL Enterprise Encryption Usage and Examples">
Section 8.6.3, “MySQL Enterprise Encryption Usage and Examples”
</a>
.
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<a name="function_asymmetric-decrypt">
</a>
<p>
<a class="link" href="enterprise-encryption-functions.html#function_asymmetric-decrypt">
<code class="literal">
asymmetric_decrypt(
<em class="replaceable">
<code>
algorithm
</code>
</em>
,
<em class="replaceable">
<code>
data_str
</code>
</em>
,
<em class="replaceable">
<code>
priv_key_str
</code>
</em>
)
</code>
</a>
</p>
<a class="indexterm" name="idm46045231840608">
</a>
<p>
Decrypts an encrypted string using the given algorithm and key
string, and returns the resulting plaintext as a binary
string. If decryption fails, the result is
<code class="literal">
NULL
</code>
.
</p>
<p>
For the legacy version of this function in use before MySQL
8.0.29, see
<a class="ulink" href="/doc/refman/8.0/en/enterprise-encryption-functions-legacy.html" target="_top">
MySQL Enterprise Encryption Legacy Function Descriptions
</a>
.
</p>
<p>
By default, the
<code class="literal">
component_enterprise_encryption
</code>
function
assumes that encrypted text uses the RSAES-OAEP padding
scheme. The function supports decryption for content encrypted
by the old
<code class="literal">
openssl_udf
</code>
shared library
functions if the system variable
<a class="link" href="server-system-variables.html#sysvar_enterprise_encryption.rsa_support_legacy_padding">
<code class="literal">
enterprise_encryption.rsa_support_legacy_padding
</code>
</a>
is set to
<code class="literal">
ON
</code>
(the default is
<code class="literal">
OFF
</code>
). When this is
<code class="literal">
ON
</code>
,
the function also supports the RSAES-PKCS1-v1_5 padding
scheme, as used by the old
<code class="literal">
openssl_udf
</code>
shared library functions. When the variable is set to
<code class="literal">
OFF
</code>
, content encrypted by the legacy
functions cannot be decrypted, and the function returns null
output for such content.
</p>
<p>
<em class="replaceable">
<code>
algorithm
</code>
</em>
is the encryption
algorithm used to create the key. The supported algorithm
value is
<code class="literal">
'RSA'
</code>
.
</p>
<p>
<em class="replaceable">
<code>
data_str
</code>
</em>
is the encrypted string to
decrypt, which was encrypted with
<a class="link" href="enterprise-encryption-functions.html#function_asymmetric-encrypt">
<code class="literal">
asymmetric_encrypt()
</code>
</a>
.
</p>
<p>
<em class="replaceable">
<code>
priv_key_str
</code>
</em>
is a valid PEM encoded
RSA private key. For successful decryption, the key string
must correspond to the public key string used with
<a class="link" href="enterprise-encryption-functions.html#function_asymmetric-encrypt">
<code class="literal">
asymmetric_encrypt()
</code>
</a>
to produce
the encrypted string. The
<a class="link" href="enterprise-encryption-functions.html#function_asymmetric-encrypt">
<code class="literal">
asymmetric_encrypt()
</code>
</a>
component
function only supports encryption using a public key, so
decryption takes place with the corresponding private key.
</p>
<p>
For a usage example, see the description of
<a class="link" href="enterprise-encryption-functions.html#function_asymmetric-encrypt">
<code class="literal">
asymmetric_encrypt()
</code>
</a>
.
</p>
</li>
<li class="listitem">
<a name="function_asymmetric-encrypt">
</a>
<p>
<a class="link" href="enterprise-encryption-functions.html#function_asymmetric-encrypt">
<code class="literal">
asymmetric_encrypt(
<em class="replaceable">
<code>
algorithm
</code>
</em>
,
<em class="replaceable">
<code>
data_str
</code>
</em>
,
<em class="replaceable">
<code>
pub_key_str
</code>
</em>
)
</code>
</a>
</p>
<a class="indexterm" name="idm46045231811952">
</a>
<p>
Encrypts a string using the given algorithm and key string,
and returns the resulting ciphertext as a binary string. If
encryption fails, the result is
<code class="literal">
NULL
</code>
.
</p>
<p>
For the legacy version of this function in use before MySQL
8.0.29, see
<a class="ulink" href="/doc/refman/8.0/en/enterprise-encryption-functions-legacy.html" target="_top">
MySQL Enterprise Encryption Legacy Function Descriptions
</a>
.
</p>
<p>
<em class="replaceable">
<code>
algorithm
</code>
</em>
is the encryption
algorithm used to create the key. The supported algorithm
value is
<code class="literal">
'RSA'
</code>
.
</p>
<p>
<em class="replaceable">
<code>
data_str
</code>
</em>
is the string to encrypt.
The length of this string cannot be greater than the key
string length in bytes, minus 42 (to account for the padding).
</p>
<p>
<em class="replaceable">
<code>
pub_key_str
</code>
</em>
is a valid PEM encoded
RSA public key. The
<a class="link" href="enterprise-encryption-functions.html#function_asymmetric-encrypt">
<code class="literal">
asymmetric_encrypt()
</code>
</a>
component
function only supports encryption using a public key.
</p>
<p>
To recover the original unencrypted string, pass the encrypted
string to
<a class="link" href="enterprise-encryption-functions.html#function_asymmetric-decrypt">
<code class="literal">
asymmetric_decrypt()
</code>
</a>
,
along with the other part of the key pair used for encryption,
as in the following example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa97418736"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token comment" spellcheck="true">-- Generate private/public key pair</span>
<span class="token keyword">SET</span> <span class="token variable">@priv</span> <span class="token operator">=</span> <span class="token function">create_asymmetric_priv_key</span><span class="token punctuation">(</span><span class="token string">'RSA'</span><span class="token punctuation">,</span> <span class="token number">2048</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">SET</span> <span class="token variable">@pub</span> <span class="token operator">=</span> <span class="token function">create_asymmetric_pub_key</span><span class="token punctuation">(</span><span class="token string">'RSA'</span><span class="token punctuation">,</span> <span class="token variable">@priv</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">-- Encrypt using public key, decrypt using private key</span>
<span class="token keyword">SET</span> <span class="token variable">@ciphertext</span> <span class="token operator">=</span> <span class="token function">asymmetric_encrypt</span><span class="token punctuation">(</span><span class="token string">'RSA'</span><span class="token punctuation">,</span> <span class="token string">'The quick brown fox'</span><span class="token punctuation">,</span> <span class="token variable">@pub</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">SET</span> <span class="token variable">@plaintext</span> <span class="token operator">=</span> <span class="token function">asymmetric_decrypt</span><span class="token punctuation">(</span><span class="token string">'RSA'</span><span class="token punctuation">,</span> <span class="token variable">@ciphertext</span><span class="token punctuation">,</span> <span class="token variable">@priv</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
Suppose that:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa65360178"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SET</span> <span class="token variable">@s</span> <span class="token operator">=</span> a <span class="token keyword">string</span> <span class="token keyword">to</span> be encrypted
<span class="token keyword">SET</span> <span class="token variable">@priv</span> <span class="token operator">=</span> a valid private RSA <span class="token keyword">key</span> <span class="token keyword">string</span> <span class="token keyword">in</span> PEM <span class="token keyword">format</span>
<span class="token keyword">SET</span> <span class="token variable">@pub</span> <span class="token operator">=</span> the corresponding public RSA <span class="token keyword">key</span> <span class="token keyword">string</span> <span class="token keyword">in</span> PEM <span class="token keyword">format</span></code></pre>
</div>
<p>
Then these identity relationships hold:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa77791079"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token function">asymmetric_decrypt</span><span class="token punctuation">(</span><span class="token string">'RSA'</span><span class="token punctuation">,</span> <span class="token function">asymmetric_encrypt</span><span class="token punctuation">(</span><span class="token string">'RSA'</span><span class="token punctuation">,</span> <span class="token variable">@s</span><span class="token punctuation">,</span> <span class="token variable">@pub</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token variable">@priv</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token variable">@s</span></code></pre>
</div>
</li>
<li class="listitem">
<a name="function_asymmetric-sign">
</a>
<p>
<a class="link" href="enterprise-encryption-functions.html#function_asymmetric-sign">
<code class="literal">
asymmetric_sign(
<em class="replaceable">
<code>
algorithm
</code>
</em>
,
<em class="replaceable">
<code>
text
</code>
</em>
,
<em class="replaceable">
<code>
priv_key_str
</code>
</em>
,
<em class="replaceable">
<code>
digest_type
</code>
</em>
)
</code>
</a>
</p>
<a class="indexterm" name="idm46045231788960">
</a>
<p>
Signs a digest string or data string using a private key, and
returns the signature as a binary string. If signing fails,
the result is
<code class="literal">
NULL
</code>
.
</p>
<p>
For the legacy version of this function in use before MySQL
8.0.29, see
<a class="ulink" href="/doc/refman/8.0/en/enterprise-encryption-functions-legacy.html" target="_top">
MySQL Enterprise Encryption Legacy Function Descriptions
</a>
.
</p>
<p>
<em class="replaceable">
<code>
algorithm
</code>
</em>
is the encryption
algorithm used to create the key. The supported algorithm
value is
<code class="literal">
'RSA'
</code>
.
</p>
<p>
<em class="replaceable">
<code>
text
</code>
</em>
is a data string or digest
string. The function accepts digests but does not require
them, as it is also capable of handling data strings of an
arbitrary length. A digest string can be generated by calling
<a class="link" href="enterprise-encryption-functions.html#function_create-digest">
<code class="literal">
create_digest()
</code>
</a>
.
</p>
<p>
<em class="replaceable">
<code>
priv_key_str
</code>
</em>
is the private key
string to use for signing the digest string. It must be a
valid PEM encoded RSA private key.
</p>
<p>
<em class="replaceable">
<code>
digest_type
</code>
</em>
is the algorithm to be
used to sign the data. The supported
<em class="replaceable">
<code>
digest_type
</code>
</em>
values are
<code class="literal">
'SHA224'
</code>
,
<code class="literal">
'SHA256'
</code>
,
<code class="literal">
'SHA384'
</code>
, and
<code class="literal">
'SHA512'
</code>
when OpenSSL 1.0.1 is in use. If OpenSSL 1.1.1 is in use, the
additional
<em class="replaceable">
<code>
digest_type
</code>
</em>
values
<code class="literal">
'SHA3-224'
</code>
,
<code class="literal">
'SHA3-256'
</code>
,
<code class="literal">
'SHA3-384'
</code>
, and
<code class="literal">
'SHA3-512'
</code>
are available.
</p>
<p>
For a usage example, see the description of
<a class="link" href="enterprise-encryption-functions.html#function_asymmetric-verify">
<code class="literal">
asymmetric_verify()
</code>
</a>
.
</p>
</li>
<li class="listitem">
<a name="function_asymmetric-verify">
</a>
<p>
<a class="link" href="enterprise-encryption-functions.html#function_asymmetric-verify">
<code class="literal">
asymmetric_verify(
<em class="replaceable">
<code>
algorithm
</code>
</em>
,
<em class="replaceable">
<code>
text
</code>
</em>
,
<em class="replaceable">
<code>
sig_str
</code>
</em>
,
<em class="replaceable">
<code>
pub_key_str
</code>
</em>
,
<em class="replaceable">
<code>
digest_type
</code>
</em>
)
</code>
</a>
</p>
<a class="indexterm" name="idm46045231762848">
</a>
<p>
Verifies whether the signature string matches the digest
string, and returns 1 or 0 to indicate whether verification
succeeded or failed. If verification fails, the result is
<code class="literal">
NULL
</code>
.
</p>
<p>
By default, the
<code class="literal">
component_enterprise_encryption
</code>
function
assumes that signatures use the RSASSA-PSS signature scheme.
The function supports verification for signatures produced by
the old
<code class="literal">
openssl_udf
</code>
shared library
functions if the system variable
<a class="link" href="server-system-variables.html#sysvar_enterprise_encryption.rsa_support_legacy_padding">
<code class="literal">
enterprise_encryption.rsa_support_legacy_padding
</code>
</a>
is set to
<code class="literal">
ON
</code>
(the default is
<code class="literal">
OFF
</code>
). When this is
<code class="literal">
ON
</code>
,
the function also supports the RSASSA-PKCS1-v1_5 signature
scheme, as used by the old
<code class="literal">
openssl_udf
</code>
shared library functions; when it is
<code class="literal">
OFF
</code>
,
signatures produced by the legacy functions cannot be
verified, and the function returns null output for such
content.
</p>
<p>
<em class="replaceable">
<code>
algorithm
</code>
</em>
is the encryption
algorithm used to create the key. The supported algorithm
value is
<code class="literal">
'RSA'
</code>
.
</p>
<p>
<em class="replaceable">
<code>
text
</code>
</em>
is a data string or digest
string. The component function accepts digests but does not
require them, as it is also capable of handling data strings
of an arbitrary length. A digest string can be generated by
calling
<a class="link" href="enterprise-encryption-functions.html#function_create-digest">
<code class="literal">
create_digest()
</code>
</a>
.
</p>
<p>
<em class="replaceable">
<code>
sig_str
</code>
</em>
is the signature string to
be verified. A signature string can be generated by calling
<a class="link" href="enterprise-encryption-functions.html#function_asymmetric-sign">
<code class="literal">
asymmetric_sign()
</code>
</a>
.
</p>
<p>
<em class="replaceable">
<code>
pub_key_str
</code>
</em>
is the public key
string of the signer. It corresponds to the private key passed
to
<a class="link" href="enterprise-encryption-functions.html#function_asymmetric-sign">
<code class="literal">
asymmetric_sign()
</code>
</a>
to
generate the signature string. It must be a valid PEM encoded
RSA public key.
</p>
<p>
<em class="replaceable">
<code>
digest_type
</code>
</em>
is the algorithm that
was used to sign the data. The supported
<em class="replaceable">
<code>
digest_type
</code>
</em>
values are
<code class="literal">
'SHA224'
</code>
,
<code class="literal">
'SHA256'
</code>
,
<code class="literal">
'SHA384'
</code>
, and
<code class="literal">
'SHA512'
</code>
when OpenSSL 1.0.1 is in use. If OpenSSL 1.1.1 is in use, the
additional
<em class="replaceable">
<code>
digest_type
</code>
</em>
values
<code class="literal">
'SHA3-224'
</code>
,
<code class="literal">
'SHA3-256'
</code>
,
<code class="literal">
'SHA3-384'
</code>
, and
<code class="literal">
'SHA3-512'
</code>
are available.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa8873469"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token comment" spellcheck="true">-- Set the encryption algorithm and digest type</span>
<span class="token keyword">SET</span> <span class="token variable">@algo</span> <span class="token operator">=</span> <span class="token string">'RSA'</span><span class="token punctuation">;</span>
<span class="token keyword">SET</span> <span class="token variable">@dig_type</span> <span class="token operator">=</span> <span class="token string">'SHA512'</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">-- Create private/public key pair</span>
<span class="token keyword">SET</span> <span class="token variable">@priv</span> <span class="token operator">=</span> <span class="token function">create_asymmetric_priv_key</span><span class="token punctuation">(</span><span class="token variable">@algo</span><span class="token punctuation">,</span> <span class="token number">2048</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">SET</span> <span class="token variable">@pub</span> <span class="token operator">=</span> <span class="token function">create_asymmetric_pub_key</span><span class="token punctuation">(</span><span class="token variable">@algo</span><span class="token punctuation">,</span> <span class="token variable">@priv</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">-- Generate digest from string</span>
<span class="token keyword">SET</span> <span class="token variable">@dig</span> <span class="token operator">=</span> <span class="token function">create_digest</span><span class="token punctuation">(</span><span class="token variable">@dig_type</span><span class="token punctuation">,</span> <span class="token string">'The quick brown fox'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">-- Generate signature for digest and verify signature against digest</span>
<span class="token keyword">SET</span> <span class="token variable">@sig</span> <span class="token operator">=</span> <span class="token function">asymmetric_sign</span><span class="token punctuation">(</span><span class="token variable">@algo</span><span class="token punctuation">,</span> <span class="token variable">@dig</span><span class="token punctuation">,</span> <span class="token variable">@priv</span><span class="token punctuation">,</span> <span class="token variable">@dig_type</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">SET</span> <span class="token variable">@verf</span> <span class="token operator">=</span> <span class="token function">asymmetric_verify</span><span class="token punctuation">(</span><span class="token variable">@algo</span><span class="token punctuation">,</span> <span class="token variable">@dig</span><span class="token punctuation">,</span> <span class="token variable">@sig</span><span class="token punctuation">,</span> <span class="token variable">@pub</span><span class="token punctuation">,</span> <span class="token variable">@dig_type</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
</div>
</li>
<li class="listitem">
<a name="function_create-asymmetric-priv-key">
</a>
<p>
<a class="link" href="enterprise-encryption-functions.html#function_create-asymmetric-priv-key">
<code class="literal">
create_asymmetric_priv_key(
<em class="replaceable">
<code>
algorithm
</code>
</em>
,
<em class="replaceable">
<code>
key_length
</code>
</em>
)
</code>
</a>
</p>
<a class="indexterm" name="idm46045231728320">
</a>
<p>
Creates a private key using the given algorithm and key
length, and returns the key as a binary string in PEM format.
The key is in PKCS #8 format. If key generation fails, the
result is
<code class="literal">
NULL
</code>
.
</p>
<p>
For the legacy version of this function in use before MySQL
8.0.29, see
<a class="ulink" href="/doc/refman/8.0/en/enterprise-encryption-functions-legacy.html" target="_top">
MySQL Enterprise Encryption Legacy Function Descriptions
</a>
.
</p>
<p>
<em class="replaceable">
<code>
algorithm
</code>
</em>
is the encryption
algorithm used to create the key. The supported algorithm
value is
<code class="literal">
'RSA'
</code>
.
</p>
<p>
<em class="replaceable">
<code>
key_length
</code>
</em>
is the key length in
bits. If you exceed the maximum allowed key length or specify
less than the minimum, key generation fails and the result is
null output. The minimum allowed key length in bits is 2048.
The maximum allowed key length is the value of the
<a class="link" href="server-system-variables.html#sysvar_enterprise_encryption.maximum_rsa_key_size">
<code class="literal">
enterprise_encryption.maximum_rsa_key_size
</code>
</a>
system variable, which defaults to 4096. It has a maximum
setting of 16384, which is the maximum key length allowed for
the RSA algorithm. See
<a class="xref" href="enterprise-encryption-configuring.html" title="8.6.2 Configuring MySQL Enterprise Encryption">
Section 8.6.2, “Configuring MySQL Enterprise Encryption”
</a>
.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
Generating longer keys can consume significant CPU
resources. Limiting the key length using the
<a class="link" href="server-system-variables.html#sysvar_enterprise_encryption.maximum_rsa_key_size">
<code class="literal">
enterprise_encryption.maximum_rsa_key_size
</code>
</a>
system variable lets you provide adequate security for your
requirements while balancing this with resource usage.
</p>
</div>
<p>
This example creates a 2048-bit RSA private key, then derives
a public key from the private key:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa1301430"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SET</span> <span class="token variable">@priv</span> <span class="token operator">=</span> <span class="token function">create_asymmetric_priv_key</span><span class="token punctuation">(</span><span class="token string">'RSA'</span><span class="token punctuation">,</span> <span class="token number">2048</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">SET</span> <span class="token variable">@pub</span> <span class="token operator">=</span> <span class="token function">create_asymmetric_pub_key</span><span class="token punctuation">(</span><span class="token string">'RSA'</span><span class="token punctuation">,</span> <span class="token variable">@priv</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
</div>
</li>
<li class="listitem">
<a name="function_create-asymmetric-pub-key">
</a>
<p>
<a class="link" href="enterprise-encryption-functions.html#function_create-asymmetric-pub-key">
<code class="literal">
create_asymmetric_pub_key(
<em class="replaceable">
<code>
algorithm
</code>
</em>
,
<em class="replaceable">
<code>
priv_key_str
</code>
</em>
)
</code>
</a>
</p>
<a class="indexterm" name="idm46045231707616">
</a>
<p>
Derives a public key from the given private key using the
given algorithm, and returns the key as a binary string in PEM
format. The key is in PKCS #8 format. If key derivation fails,
the result is
<code class="literal">
NULL
</code>
.
</p>
<p>
For the legacy version of this function in use before MySQL
8.0.29, see
<a class="ulink" href="/doc/refman/8.0/en/enterprise-encryption-functions-legacy.html" target="_top">
MySQL Enterprise Encryption Legacy Function Descriptions
</a>
.
</p>
<p>
<em class="replaceable">
<code>
algorithm
</code>
</em>
is the encryption
algorithm used to create the key. The supported algorithm
value is
<code class="literal">
'RSA'
</code>
.
</p>
<p>
<em class="replaceable">
<code>
priv_key_str
</code>
</em>
is a valid PEM encoded
RSA private key.
</p>
<p>
For a usage example, see the description of
<a class="link" href="enterprise-encryption-functions.html#function_create-asymmetric-priv-key">
<code class="literal">
create_asymmetric_priv_key()
</code>
</a>
.
</p>
</li>
<li class="listitem">
<a name="function_create-digest">
</a>
<p>
<a class="link" href="enterprise-encryption-functions.html#function_create-digest">
<code class="literal">
create_digest(
<em class="replaceable">
<code>
digest_type
</code>
</em>
,
<em class="replaceable">
<code>
str
</code>
</em>
)
</code>
</a>
</p>
<a class="indexterm" name="idm46045231692720">
</a>
<p>
Creates a digest from the given string using the given digest
type, and returns the digest as a binary string. If digest
generation fails, the result is
<code class="literal">
NULL
</code>
.
</p>
<p>
For the legacy version of this function in use before MySQL
8.0.29, see
<a class="ulink" href="/doc/refman/8.0/en/enterprise-encryption-functions-legacy.html" target="_top">
MySQL Enterprise Encryption Legacy Function Descriptions
</a>
.
</p>
<p>
The resulting digest string is suitable for use with
<a class="link" href="enterprise-encryption-functions.html#function_asymmetric-sign">
<code class="literal">
asymmetric_sign()
</code>
</a>
and
<a class="link" href="enterprise-encryption-functions.html#function_asymmetric-verify">
<code class="literal">
asymmetric_verify()
</code>
</a>
. The
component versions of these functions accept digests but do
not require them, as they are capable of handling data of an
arbitrary length.
</p>
<p>
<em class="replaceable">
<code>
digest_type
</code>
</em>
is the digest algorithm
to be used to generate the digest string. The supported
<em class="replaceable">
<code>
digest_type
</code>
</em>
values are
<code class="literal">
'SHA224'
</code>
,
<code class="literal">
'SHA256'
</code>
,
<code class="literal">
'SHA384'
</code>
, and
<code class="literal">
'SHA512'
</code>
when OpenSSL 1.0.1 is in use. If OpenSSL 1.1.1 is in use, the
additional
<em class="replaceable">
<code>
digest_type
</code>
</em>
values
<code class="literal">
'SHA3-224'
</code>
,
<code class="literal">
'SHA3-256'
</code>
,
<code class="literal">
'SHA3-384'
</code>
, and
<code class="literal">
'SHA3-512'
</code>
are available.
</p>
<p>
<em class="replaceable">
<code>
str
</code>
</em>
is the non-null data string for
which the digest is to be generated.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa15793625"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SET</span> <span class="token variable">@dig</span> <span class="token operator">=</span> <span class="token function">create_digest</span><span class="token punctuation">(</span><span class="token string">'SHA512'</span><span class="token punctuation">,</span> <span class="token string">'The quick brown fox'</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
</div>
</li>
</ul>
</div>
</div>
<br/>
</div>
|