url
stringlengths 45
122
| content
stringlengths 380
3.07M
|
---|---|
https://dev.mysql.com/doc/refman/8.4/en/show-table-status.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="show-table-status">
</a>
15.7.7.38 SHOW TABLE STATUS Statement
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045169287984">
</a>
<a class="indexterm" name="idm46045169286928">
</a>
<a class="indexterm" name="idm46045169285440">
</a>
<a class="indexterm" name="idm46045169283952">
</a>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa92183339"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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">TABLE</span> <span class="token keyword">STATUS</span>
<span class="token punctuation">[</span>{<span class="token keyword">FROM</span> <span class="token operator">|</span> <span class="token keyword">IN</span>} <em class="replaceable">db_name</em><span class="token punctuation">]</span>
<span class="token punctuation">[</span><span class="token operator">LIKE</span> <span class="token string">'<em class="replaceable">pattern</em>'</span> <span class="token operator">|</span> <span class="token keyword">WHERE</span> <em class="replaceable">expr</em><span class="token punctuation">]</span></code></pre>
</div>
<p>
<a class="link" href="show-table-status.html" title="15.7.7.38 SHOW TABLE STATUS Statement">
<code class="literal">
SHOW TABLE STATUS
</code>
</a>
works like
<a class="link" href="show-tables.html" title="15.7.7.39 SHOW TABLES Statement">
<code class="literal">
SHOW TABLES
</code>
</a>
, but provides a lot
of information about each non-
<code class="literal">
TEMPORARY
</code>
table. You can also get this list using the
<a class="link" href="mysqlshow.html" title="6.5.6 mysqlshow — Display Database, Table, and Column Information">
<span class="command">
<strong>
mysqlshow
--status
<em class="replaceable">
<code>
db_name
</code>
</em>
</strong>
</span>
</a>
command.
The
<a class="link" href="string-comparison-functions.html#operator_like">
<code class="literal">
LIKE
</code>
</a>
clause, if present,
indicates which table names to match. The
<code class="literal">
WHERE
</code>
clause can be given to select rows
using more general conditions, as discussed in
<a class="xref" href="extended-show.html" title="28.8 Extensions to SHOW Statements">
Section 28.8, “Extensions to SHOW Statements”
</a>
.
</p>
<p>
This statement also displays information about views.
</p>
<p>
<a class="link" href="show-table-status.html" title="15.7.7.38 SHOW TABLE STATUS Statement">
<code class="literal">
SHOW TABLE STATUS
</code>
</a>
output has
these columns:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
Name
</code>
</p>
<p>
The name of the table.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
Engine
</code>
</p>
<p>
The storage engine for the table. See
<a class="xref" href="innodb-storage-engine.html" title="Chapter 17 The InnoDB Storage Engine">
Chapter 17,
<i>
The InnoDB Storage Engine
</i>
</a>
, and
<a class="xref" href="storage-engines.html" title="Chapter 18 Alternative Storage Engines">
Chapter 18,
<i>
Alternative Storage Engines
</i>
</a>
.
</p>
<p>
For partitioned tables,
<code class="literal">
Engine
</code>
shows the
name of the storage engine used by all partitions.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
Version
</code>
</p>
<p>
This column is unused. With the removal of
<code class="filename">
.frm
</code>
files in MySQL 8.0, this column
now reports a hardcoded value of
<code class="literal">
10
</code>
,
which was the last
<code class="filename">
.frm
</code>
file version
used in MySQL 5.7.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
Row_format
</code>
</p>
<p>
The row-storage format (
<code class="literal">
Fixed
</code>
,
<code class="literal">
Dynamic
</code>
,
<code class="literal">
Compressed
</code>
,
<code class="literal">
Redundant
</code>
,
<code class="literal">
Compact
</code>
).
For
<code class="literal">
MyISAM
</code>
tables,
<code class="literal">
Dynamic
</code>
corresponds to what
<a class="link" href="myisamchk.html" title="6.6.4 myisamchk — MyISAM Table-Maintenance Utility">
<span class="command">
<strong>
myisamchk -dvv
</strong>
</span>
</a>
reports as
<code class="literal">
Packed
</code>
.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
Rows
</code>
</p>
<p>
The number of rows. Some storage engines, such as
<code class="literal">
MyISAM
</code>
, store the exact count. For other
storage engines, such as
<code class="literal">
InnoDB
</code>
, this
value is an approximation, and may vary from the actual
value by as much as 40% to 50%. In such cases, use
<code class="literal">
SELECT COUNT(*)
</code>
to obtain an accurate
count.
</p>
<p>
The
<code class="literal">
Rows
</code>
value is
<code class="literal">
NULL
</code>
for
<code class="literal">
INFORMATION_SCHEMA
</code>
tables.
</p>
<p>
For
<a class="link" href="innodb-storage-engine.html" title="Chapter 17 The InnoDB Storage Engine">
<code class="literal">
InnoDB
</code>
</a>
tables, the row
count is only a rough estimate used in SQL optimization.
(This is also true if the
<a class="link" href="innodb-storage-engine.html" title="Chapter 17 The InnoDB Storage Engine">
<code class="literal">
InnoDB
</code>
</a>
table is partitioned.)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
Avg_row_length
</code>
</p>
<p>
The average row length.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
Data_length
</code>
</p>
<p>
For
<code class="literal">
MyISAM
</code>
,
<code class="literal">
Data_length
</code>
is the length of the data
file, in bytes.
</p>
<p>
For
<code class="literal">
InnoDB
</code>
,
<code class="literal">
Data_length
</code>
is the approximate amount of
space allocated for the clustered index, in bytes.
Specifically, it is the clustered index size, in pages,
multiplied by the
<code class="literal">
InnoDB
</code>
page size.
</p>
<p>
Refer to the notes at the end of this section for
information regarding other storage engines.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
Max_data_length
</code>
</p>
<p>
For
<code class="literal">
MyISAM
</code>
,
<code class="literal">
Max_data_length
</code>
is maximum length of the
data file. This is the total number of bytes of data that
can be stored in the table, given the data pointer size
used.
</p>
<p>
Unused for
<code class="literal">
InnoDB
</code>
.
</p>
<p>
Refer to the notes at the end of this section for
information regarding other storage engines.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
Index_length
</code>
</p>
<p>
For
<code class="literal">
MyISAM
</code>
,
<code class="literal">
Index_length
</code>
is the length of the index
file, in bytes.
</p>
<p>
For
<code class="literal">
InnoDB
</code>
,
<code class="literal">
Index_length
</code>
is the approximate amount of
space allocated for non-clustered indexes, in bytes.
Specifically, it is the sum of non-clustered index sizes, in
pages, multiplied by the
<code class="literal">
InnoDB
</code>
page
size.
</p>
<p>
Refer to the notes at the end of this section for
information regarding other storage engines.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
Data_free
</code>
</p>
<p>
The number of allocated but unused bytes.
</p>
<p>
<code class="literal">
InnoDB
</code>
tables report the free space of
the tablespace to which the table belongs. For a table
located in the shared tablespace, this is the free space of
the shared tablespace. If you are using multiple tablespaces
and the table has its own tablespace, the free space is for
only that table. Free space means the number of bytes in
completely free extents minus a safety margin. Even if free
space displays as 0, it may be possible to insert rows as
long as new extents need not be allocated.
</p>
<p>
For NDB Cluster,
<code class="literal">
Data_free
</code>
shows the
space allocated on disk for, but not used by, a Disk Data
table or fragment on disk. (In-memory data resource usage is
reported by the
<code class="literal">
Data_length
</code>
column.)
</p>
<p>
For partitioned tables, this value is only an estimate and
may not be absolutely correct. A more accurate method of
obtaining this information in such cases is to query the
<code class="literal">
INFORMATION_SCHEMA
</code>
<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 shown in
this example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa88615181"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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">SUM</span><span class="token punctuation">(</span>DATA_FREE<span class="token punctuation">)</span>
<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> TABLE_SCHEMA <span class="token operator">=</span> <span class="token string">'mydb'</span>
<span class="token operator">AND</span> <span class="token keyword">TABLE_NAME</span> <span class="token operator">=</span> <span class="token string">'mytable'</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
For more information, see
<a class="xref" href="information-schema-partitions-table.html" title="28.3.21 The INFORMATION_SCHEMA PARTITIONS Table">
Section 28.3.21, “The INFORMATION_SCHEMA PARTITIONS Table”
</a>
.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
Auto_increment
</code>
</p>
<p>
The next
<code class="literal">
AUTO_INCREMENT
</code>
value.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
Create_time
</code>
</p>
<p>
When the table was created.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
Update_time
</code>
</p>
<p>
When the data file was last updated. For some storage
engines, this value is
<code class="literal">
NULL
</code>
. For example,
<code class="literal">
InnoDB
</code>
stores multiple tables in its
<a class="link" href="glossary.html#glos_system_tablespace" title="system tablespace">
system
tablespace
</a>
and the data file timestamp does not
apply. Even with
<a class="link" href="glossary.html#glos_file_per_table" title="file-per-table">
file-per-table
</a>
mode with each
<code class="literal">
InnoDB
</code>
table in a separate
<code class="literal">
.ibd
</code>
file,
<a class="link" href="glossary.html#glos_change_buffering" title="change buffering">
change
buffering
</a>
can delay the write to the data file, so
the file modification time is different from the time of the
last insert, update, or delete. For
<code class="literal">
MyISAM
</code>
, the data file timestamp is used;
however, on Windows the timestamp is not updated by updates,
so the value is inaccurate.
</p>
<p>
<code class="literal">
Update_time
</code>
displays a timestamp value
for the last
<a class="link" href="update.html" title="15.2.17 UPDATE Statement">
<code class="literal">
UPDATE
</code>
</a>
,
<a class="link" href="insert.html" title="15.2.7 INSERT Statement">
<code class="literal">
INSERT
</code>
</a>
, or
<a class="link" href="delete.html" title="15.2.2 DELETE Statement">
<code class="literal">
DELETE
</code>
</a>
performed on
<code class="literal">
InnoDB
</code>
tables that are not partitioned.
For MVCC, the timestamp value reflects the
<a class="link" href="commit.html" title="15.3.1 START TRANSACTION, COMMIT, and ROLLBACK Statements">
<code class="literal">
COMMIT
</code>
</a>
time, which is
considered the last update time. Timestamps are not
persisted when the server is restarted or when the table is
evicted from the
<code class="literal">
InnoDB
</code>
data dictionary
cache.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
Check_time
</code>
</p>
<p>
When the table was last checked. Not all storage engines
update this time, in which case, the value is always
<code class="literal">
NULL
</code>
.
</p>
<p>
For partitioned
<a class="link" href="innodb-storage-engine.html" title="Chapter 17 The InnoDB Storage Engine">
<code class="literal">
InnoDB
</code>
</a>
tables,
<code class="literal">
Check_time
</code>
is always
<code class="literal">
NULL
</code>
.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
Collation
</code>
</p>
<p>
The table default collation. The output does not explicitly
list the table default character set, but the collation name
begins with the character set name.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
Checksum
</code>
</p>
<p>
The live checksum value, if any.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
Create_options
</code>
</p>
<p>
Extra options used with
<a class="link" href="create-table.html" title="15.1.20 CREATE TABLE Statement">
<code class="literal">
CREATE
TABLE
</code>
</a>
.
</p>
<p>
<code class="literal">
Create_options
</code>
shows
<code class="literal">
partitioned
</code>
for a partitioned table.
</p>
<p>
<code class="literal">
Create_options
</code>
shows the
<code class="literal">
ENCRYPTION
</code>
clause for file-per-table
tablespaces if the table is encrypted or if the specified
encryption differs from the schema encryption. The
encryption clause is not shown for tables created in general
tablespaces. To identify encrypted file-per-table and
general tablespaces, query the
<a class="link" href="information-schema-innodb-tablespaces-table.html" title="28.4.24 The INFORMATION_SCHEMA INNODB_TABLESPACES Table">
<code class="literal">
INNODB_TABLESPACES
</code>
</a>
<code class="literal">
ENCRYPTION
</code>
column.
</p>
<p>
When creating a table with
<a class="link" href="glossary.html#glos_strict_mode" title="strict mode">
strict mode
</a>
disabled, the storage engine's default row format is
used if the specified row format is not supported. The
actual row format of the table is reported in the
<code class="literal">
Row_format
</code>
column.
<code class="literal">
Create_options
</code>
shows the row format that
was specified in the
<a class="link" href="create-table.html" title="15.1.20 CREATE TABLE Statement">
<code class="literal">
CREATE
TABLE
</code>
</a>
statement.
</p>
<p>
When altering the storage engine of a table, table options
that are not applicable to the new storage engine are
retained in the table definition to enable reverting the
table with its previously defined options to the original
storage engine, if necessary.
<code class="literal">
Create_options
</code>
may show retained options.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
Comment
</code>
</p>
<p>
The comment used when creating the table (or information as
to why MySQL could not access the table information).
</p>
</li>
</ul>
</div>
<h5>
<a name="idm46045169157904">
</a>
Notes
</h5>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
For
<code class="literal">
InnoDB
</code>
tables,
<a class="link" href="show-table-status.html" title="15.7.7.38 SHOW TABLE STATUS Statement">
<code class="literal">
SHOW TABLE STATUS
</code>
</a>
does not
give accurate statistics except for the physical size
reserved by the table. The row count is only a rough
estimate used in SQL optimization.
</p>
</li>
<li class="listitem">
<p>
For
<a class="link" href="mysql-cluster.html" title="Chapter 25 MySQL NDB Cluster 8.4">
<code class="literal">
NDB
</code>
</a>
tables, the output of
this statement shows appropriate values for the
<code class="literal">
Avg_row_length
</code>
and
<code class="literal">
Data_length
</code>
columns, with the exception
that
<a class="link" href="blob.html" title="13.3.4 The BLOB and TEXT Types">
<code class="literal">
BLOB
</code>
</a>
columns are not
taken into account.
</p>
</li>
<li class="listitem">
<p>
For
<a class="link" href="mysql-cluster.html" title="Chapter 25 MySQL NDB Cluster 8.4">
<code class="literal">
NDB
</code>
</a>
tables,
<code class="literal">
Data_length
</code>
includes data stored in main
memory only; the
<code class="literal">
Max_data_length
</code>
and
<code class="literal">
Data_free
</code>
columns apply to Disk Data.
</p>
</li>
<li class="listitem">
<p>
For NDB Cluster Disk Data tables,
<code class="literal">
Max_data_length
</code>
shows the space allocated
for the disk part of a Disk Data table or fragment.
(In-memory data resource usage is reported by the
<code class="literal">
Data_length
</code>
column.)
</p>
</li>
<li class="listitem">
<p>
For
<code class="literal">
MEMORY
</code>
tables, the
<code class="literal">
Data_length
</code>
,
<code class="literal">
Max_data_length
</code>
, and
<code class="literal">
Index_length
</code>
values approximate the
actual amount of allocated memory. The allocation algorithm
reserves memory in large amounts to reduce the number of
allocation operations.
</p>
</li>
<li class="listitem">
<p>
For views, most columns displayed by
<a class="link" href="show-table-status.html" title="15.7.7.38 SHOW TABLE STATUS Statement">
<code class="literal">
SHOW TABLE STATUS
</code>
</a>
are 0 or
<code class="literal">
NULL
</code>
except that
<code class="literal">
Name
</code>
indicates the view name,
<code class="literal">
Create_time
</code>
indicates the creation time, and
<code class="literal">
Comment
</code>
says
<code class="literal">
VIEW
</code>
.
</p>
</li>
</ul>
</div>
<p>
Table information is also available from the
<code class="literal">
INFORMATION_SCHEMA
</code>
<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. See
<a class="xref" href="information-schema-tables-table.html" title="28.3.38 The INFORMATION_SCHEMA TABLES Table">
Section 28.3.38, “The INFORMATION_SCHEMA TABLES Table”
</a>
.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/replication-features-variables.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="replication-features-variables">
</a>
19.5.1.39 Replication and Variables
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045134848128">
</a>
<a class="indexterm" name="idm46045134846640">
</a>
<a class="indexterm" name="idm46045134845152">
</a>
<a class="indexterm" name="idm46045134843664">
</a>
<a class="indexterm" name="idm46045134842176">
</a>
<p>
System variables are not replicated correctly when using
<code class="literal">
STATEMENT
</code>
mode, except for the following
variables when they are used with session scope:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="link" href="replication-options-source.html#sysvar_auto_increment_increment">
<code class="literal">
auto_increment_increment
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="replication-options-source.html#sysvar_auto_increment_offset">
<code class="literal">
auto_increment_offset
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="server-system-variables.html#sysvar_character_set_client">
<code class="literal">
character_set_client
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="server-system-variables.html#sysvar_character_set_connection">
<code class="literal">
character_set_connection
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="server-system-variables.html#sysvar_character_set_database">
<code class="literal">
character_set_database
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="server-system-variables.html#sysvar_character_set_server">
<code class="literal">
character_set_server
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="server-system-variables.html#sysvar_collation_connection">
<code class="literal">
collation_connection
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="server-system-variables.html#sysvar_collation_database">
<code class="literal">
collation_database
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="server-system-variables.html#sysvar_collation_server">
<code class="literal">
collation_server
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="server-system-variables.html#sysvar_foreign_key_checks">
<code class="literal">
foreign_key_checks
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="server-system-variables.html#sysvar_identity">
<code class="literal">
identity
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="server-system-variables.html#sysvar_last_insert_id">
<code class="literal">
last_insert_id
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="server-system-variables.html#sysvar_lc_time_names">
<code class="literal">
lc_time_names
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="server-system-variables.html#sysvar_pseudo_thread_id">
<code class="literal">
pseudo_thread_id
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="server-system-variables.html#sysvar_sql_auto_is_null">
<code class="literal">
sql_auto_is_null
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="server-system-variables.html#sysvar_time_zone">
<code class="literal">
time_zone
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="server-system-variables.html#sysvar_timestamp">
<code class="literal">
timestamp
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="server-system-variables.html#sysvar_unique_checks">
<code class="literal">
unique_checks
</code>
</a>
</p>
</li>
</ul>
</div>
<p>
When
<code class="literal">
MIXED
</code>
mode is used, the variables in the
preceding list, when used with session scope, cause a switch
from statement-based to row-based logging. See
<a class="xref" href="binary-log-mixed.html" title="7.4.4.3 Mixed Binary Logging Format">
Section 7.4.4.3, “Mixed Binary Logging Format”
</a>
.
</p>
<p>
<a class="link" href="server-system-variables.html#sysvar_sql_mode">
<code class="literal">
sql_mode
</code>
</a>
is also replicated
except for the
<a class="link" href="sql-mode.html#sqlmode_no_dir_in_create">
<code class="literal">
NO_DIR_IN_CREATE
</code>
</a>
mode; the
replica always preserves its own value for
<a class="link" href="sql-mode.html#sqlmode_no_dir_in_create">
<code class="literal">
NO_DIR_IN_CREATE
</code>
</a>
, regardless
of changes to it on the source. This is true for all replication
formats.
</p>
<p>
However, when
<a class="link" href="mysqlbinlog.html" title="6.6.9 mysqlbinlog — Utility for Processing Binary Log Files">
<span class="command">
<strong>
mysqlbinlog
</strong>
</span>
</a>
parses a
<code class="literal">
SET @@sql_mode =
<em class="replaceable">
<code>
mode
</code>
</em>
</code>
statement, the full
<em class="replaceable">
<code>
mode
</code>
</em>
value, including
<a class="link" href="sql-mode.html#sqlmode_no_dir_in_create">
<code class="literal">
NO_DIR_IN_CREATE
</code>
</a>
, is passed to
the receiving server. For this reason, replication of such a
statement may not be safe when
<code class="literal">
STATEMENT
</code>
mode
is in use.
</p>
<p>
The
<a class="link" href="server-system-variables.html#sysvar_default_storage_engine">
<code class="literal">
default_storage_engine
</code>
</a>
system variable is not replicated, regardless of the logging
mode; this is intended to facilitate replication between
different storage engines.
</p>
<p>
The
<a class="link" href="server-system-variables.html#sysvar_read_only">
<code class="literal">
read_only
</code>
</a>
system variable
is not replicated. In addition, the enabling this variable has
different effects with regard to temporary tables, table
locking, and the
<a class="link" href="set-password.html" title="15.7.1.10 SET PASSWORD Statement">
<code class="literal">
SET PASSWORD
</code>
</a>
statement in different MySQL versions.
</p>
<p>
The
<a class="link" href="server-system-variables.html#sysvar_max_heap_table_size">
<code class="literal">
max_heap_table_size
</code>
</a>
system
variable is not replicated. Increasing the value of this
variable on the source without doing so on the replica can lead
eventually to
<span class="errortext">
Table is full
</span>
errors on the
replica when trying to execute
<a class="link" href="insert.html" title="15.2.7 INSERT Statement">
<code class="literal">
INSERT
</code>
</a>
statements on a
<a class="link" href="memory-storage-engine.html" title="18.3 The MEMORY Storage Engine">
<code class="literal">
MEMORY
</code>
</a>
table on the source that is
thus permitted to grow larger than its counterpart on the
replica. For more information, see
<a class="xref" href="replication-features-memory.html" title="19.5.1.21 Replication and MEMORY Tables">
Section 19.5.1.21, “Replication and MEMORY Tables”
</a>
.
</p>
<p>
In statement-based replication, session variables are not
replicated properly when used in statements that update tables.
For example, the following sequence of statements does not
insert the same data on the source and the replica:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa45702363"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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> max_join_size<span class="token operator">=</span><span class="token number">1000</span><span class="token punctuation">;</span>
<span class="token keyword">INSERT</span> <span class="token keyword">INTO</span> mytable <span class="token keyword">VALUES</span><span class="token punctuation">(</span><span class="token variable">@@max_join_size</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
This does not apply to the common sequence:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa87823290"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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 punctuation">.</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> mytable <span class="token keyword">VALUES</span><span class="token punctuation">(</span><span class="token function">CONVERT_TZ</span><span class="token punctuation">(</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">,</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">,</span> <span class="token variable">@@time_zone</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
Replication of session variables is not a problem when row-based
replication is being used, in which case, session variables are
always replicated safely. See
<a class="xref" href="replication-formats.html" title="19.2.1 Replication Formats">
Section 19.2.1, “Replication Formats”
</a>
.
</p>
<p>
The following session variables are written to the binary log
and honored by the replica when parsing the binary log,
regardless of the logging format:
</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_sql_mode">
<code class="literal">
sql_mode
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="server-system-variables.html#sysvar_foreign_key_checks">
<code class="literal">
foreign_key_checks
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="server-system-variables.html#sysvar_unique_checks">
<code class="literal">
unique_checks
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="server-system-variables.html#sysvar_character_set_client">
<code class="literal">
character_set_client
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="server-system-variables.html#sysvar_collation_connection">
<code class="literal">
collation_connection
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="server-system-variables.html#sysvar_collation_database">
<code class="literal">
collation_database
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="server-system-variables.html#sysvar_collation_server">
<code class="literal">
collation_server
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="server-system-variables.html#sysvar_sql_auto_is_null">
<code class="literal">
sql_auto_is_null
</code>
</a>
</p>
</li>
</ul>
</div>
<div class="important" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Important
</div>
<p>
Even though session variables relating to character sets and
collations are written to the binary log, replication between
different character sets is not supported.
</p>
</div>
<p>
To help reduce possible confusion, we recommend that you always
use the same setting for 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 on both source and replica, especially when you are
running MySQL on platforms with case-sensitive file systems. 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 when initializing the server.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/group-replication-launching.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="group-replication-launching">
</a>
20.2.1.4 Launching Group Replication
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045134114624">
</a>
<p>
It is first necessary to ensure that the Group Replication
plugin is installed on server s1. If you used
<code class="literal">
plugin_load_add='group_replication.so'
</code>
in the
option file then the Group Replication plugin is already
installed, and you can proceed to the next step. Otherwise, you
must install the plugin manually; to do this, connect to the
server 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, and issue the
SQL statement shown here:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa29244611"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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">PLUGIN</span> <span class="token keyword">group_replication</span> <span class="token keyword">SONAME</span> <span class="token string">'group_replication.so'</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
To check that the plugin was installed successfully, issue
<code class="literal">
SHOW PLUGINS;
</code>
and check the output. It should
show something like this:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa40645657"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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">PLUGINS</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 class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="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> Status <span class="token punctuation">|</span> Type <span class="token punctuation">|</span> Library <span class="token punctuation">|</span> License <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 class="token punctuation">-</span><span class="token punctuation">-</span><span class="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> binlog <span class="token punctuation">|</span> ACTIVE <span class="token punctuation">|</span> STORAGE ENGINE <span class="token punctuation">|</span> NULL <span class="token punctuation">|</span> PROPRIETARY <span class="token punctuation">|</span></span>
<span class="token punctuation">(</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> group_replication <span class="token punctuation">|</span> ACTIVE <span class="token punctuation">|</span> GROUP REPLICATION <span class="token punctuation">|</span> group_replication.so <span class="token punctuation">|</span> PROPRIETARY <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 class="token punctuation">-</span><span class="token punctuation">-</span><span class="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>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/mysql-cluster-added-deprecated-removed.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="mysql-cluster-added-deprecated-removed">
</a>
25.2.5 Options, Variables, and Parameters Added, Deprecated or Removed in NDB
8.4
</h3>
</div>
</div>
</div>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="xref" href="mysql-cluster-added-deprecated-removed.html#params-added-ndb-8.4" title="Parameters Introduced in NDB 8.4">
Parameters Introduced in NDB 8.4
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="mysql-cluster-added-deprecated-removed.html#params-deprecated-ndb-8.4" title="Parameters Deprecated in NDB 8.4">
Parameters Deprecated in NDB 8.4
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="mysql-cluster-added-deprecated-removed.html#params-removed-ndb-8.4" title="Parameters Removed in NDB 8.4">
Parameters Removed in NDB 8.4
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="mysql-cluster-added-deprecated-removed.html#optvars-added-ndb-8.4" title="Options and Variables Introduced in NDB 8.4">
Options and Variables Introduced in NDB 8.4
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="mysql-cluster-added-deprecated-removed.html#optvars-deprecated-ndb-8.4" title="Options and Variables Deprecated in NDB 8.4">
Options and Variables Deprecated in NDB 8.4
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="mysql-cluster-added-deprecated-removed.html#optvars-removed-ndb-8.4" title="Options and Variables Removed in NDB 8.4">
Options and Variables Removed in NDB 8.4
</a>
</p>
</li>
</ul>
</div>
<p>
The next few sections contain information about
<code class="literal">
NDB
</code>
node configuration parameters and
NDB-specific
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
options and variables that
have been added to, deprecated in, or removed from NDB
8.4 since NDB 8.0.
</p>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h4 class="title">
<a name="params-added-ndb-8.4">
</a>
Parameters Introduced in NDB 8.4
</h4>
</div>
</div>
</div>
<p>
The following node configuration parameters have been added in NDB
8.4.
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-requirecertificate">
RequireCertificate
</a>
</code>
:
Node is required to find key and certificate in TLS search
path. Added in NDB 8.3.0.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-tcp-definition.html#ndbparam-tcp-requirelinktls">
RequireLinkTls
</a>
</code>
:
Read-only; is set to true if either endpoint of this
connection requires TLS. Added in NDB 8.3.0.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-mgm-definition.html#ndbparam-mgmd-requiretls">
RequireTls
</a>
</code>
:
Client connection must authenticate with TLS before being used
otherwise. Added in NDB 8.3.0.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-requiretls">
RequireTls
</a>
</code>
:
Require TLS-authenticated secure connections. Added in NDB
8.3.0.
</p>
</li>
</ul>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h4 class="title">
<a name="params-deprecated-ndb-8.4">
</a>
Parameters Deprecated in NDB 8.4
</h4>
</div>
</div>
</div>
<p>
No node configuration parameters have been deprecated in NDB 8.4.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h4 class="title">
<a name="params-removed-ndb-8.4">
</a>
Parameters Removed in NDB 8.4
</h4>
</div>
</div>
</div>
<p>
No node configuration parameters have been removed in NDB 8.4.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h4 class="title">
<a name="optvars-added-ndb-8.4">
</a>
Options and Variables Introduced in NDB 8.4
</h4>
</div>
</div>
</div>
<p>
The following system variables, status variables, and server
options have been added in NDB 8.4.
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-options-variables.html#option_mysqld_ndb-mgm-tls">
ndb-mgm-tls
</a>
</code>
:
Whether TLS connection requirements are strict or relaxed.
Added in NDB 8.3.0-ndb-8.3.0.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-options-variables.html#option_mysqld_ndb-tls-search-path">
ndb-tls-search-path
</a>
</code>
:
Directories to search for NDB TLS CAs and private keys. Added
in NDB 8.3.0-ndb-8.3.0.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-options-variables.html#sysvar_ndb_log_cache_size">
ndb_log_cache_size
</a>
</code>
:
Set size of transaction cache used for recording NDB binary
log. Added in NDB 8.4.3-ndb-8.4.3.
</p>
</li>
</ul>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h4 class="title">
<a name="optvars-deprecated-ndb-8.4">
</a>
Options and Variables Deprecated in NDB 8.4
</h4>
</div>
</div>
</div>
<p>
No system variables, status variables, or server options have been
deprecated in NDB 8.4.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h4 class="title">
<a name="optvars-removed-ndb-8.4">
</a>
Options and Variables Removed in NDB 8.4
</h4>
</div>
</div>
</div>
<p>
No system variables, status variables, or options have been
removed in NDB 8.4.
</p>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/fulltext-search-ngram.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="fulltext-search-ngram">
</a>
14.9.8 ngram Full-Text Parser
</h3>
</div>
</div>
</div>
<p>
The built-in MySQL full-text parser uses the white space between
words as a delimiter to determine where words begin and end,
which is a limitation when working with ideographic languages
that do not use word delimiters. To address this limitation,
MySQL provides an ngram full-text parser that supports Chinese,
Japanese, and Korean (CJK). The ngram full-text parser is
supported for use with
<a class="link" href="innodb-storage-engine.html" title="Chapter 17 The InnoDB Storage Engine">
<code class="literal">
InnoDB
</code>
</a>
and
<a class="link" href="myisam-storage-engine.html" title="18.2 The MyISAM Storage Engine">
<code class="literal">
MyISAM
</code>
</a>
.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
MySQL also provides a MeCab full-text parser plugin for
Japanese, which tokenizes documents into meaningful words. For
more information, see
<a class="xref" href="fulltext-search-mecab.html" title="14.9.9 MeCab Full-Text Parser Plugin">
Section 14.9.9, “MeCab Full-Text Parser Plugin”
</a>
.
</p>
</div>
<p>
An ngram is a contiguous sequence of
<em class="replaceable">
<code>
n
</code>
</em>
characters from a given sequence of
text. The ngram parser tokenizes a sequence of text into a
contiguous sequence of
<em class="replaceable">
<code>
n
</code>
</em>
characters.
For example, you can tokenize
<span class="quote">
“
<span class="quote">
abcd
</span>
”
</span>
for different
values of
<em class="replaceable">
<code>
n
</code>
</em>
using the ngram full-text
parser.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-simple"><div class="docs-select-all right" id="sa5930408"><div class="copy-help left">Press ⌘+C to 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">n<span class="token operator">=</span>1<span class="token operator">:</span> 'a'<span class="token punctuation">,</span> 'b'<span class="token punctuation">,</span> 'c'<span class="token punctuation">,</span> 'd'
n<span class="token operator">=</span>2<span class="token operator">:</span> 'ab'<span class="token punctuation">,</span> 'bc'<span class="token punctuation">,</span> 'cd'
n<span class="token operator">=</span>3<span class="token operator">:</span> 'abc'<span class="token punctuation">,</span> 'bcd'
n<span class="token operator">=</span>4<span class="token operator">:</span> 'abcd'</code></pre>
</div>
<p>
The ngram full-text parser is a built-in server plugin. As with
other built-in server plugins, it is automatically loaded when
the server is started.
</p>
<p>
The full-text search syntax described in
<a class="xref" href="fulltext-search.html" title="14.9 Full-Text Search Functions">
Section 14.9, “Full-Text Search Functions”
</a>
applies to the ngram parser
plugin. Differences in parsing behavior are described in this
section. Full-text-related configuration options, except for
minimum and maximum word length options
(
<a class="link" href="innodb-parameters.html#sysvar_innodb_ft_min_token_size">
<code class="literal">
innodb_ft_min_token_size
</code>
</a>
,
<a class="link" href="innodb-parameters.html#sysvar_innodb_ft_max_token_size">
<code class="literal">
innodb_ft_max_token_size
</code>
</a>
,
<a class="link" href="server-system-variables.html#sysvar_ft_min_word_len">
<code class="literal">
ft_min_word_len
</code>
</a>
,
<a class="link" href="server-system-variables.html#sysvar_ft_max_word_len">
<code class="literal">
ft_max_word_len
</code>
</a>
) are also
applicable.
</p>
<h4>
<a name="idm46045201293696">
</a>
Configuring ngram Token Size
</h4>
<p>
The ngram parser has a default ngram token size of 2 (bigram).
For example, with a token size of 2, the ngram parser parses the
string
<span class="quote">
“
<span class="quote">
abc def
</span>
”
</span>
into four tokens:
<span class="quote">
“
<span class="quote">
ab
</span>
”
</span>
,
<span class="quote">
“
<span class="quote">
bc
</span>
”
</span>
,
<span class="quote">
“
<span class="quote">
de
</span>
”
</span>
and
<span class="quote">
“
<span class="quote">
ef
</span>
”
</span>
.
</p>
<p>
ngram token size is configurable using the
<a class="link" href="server-system-variables.html#sysvar_ngram_token_size">
<code class="literal">
ngram_token_size
</code>
</a>
configuration
option, which has a minimum value of 1 and maximum value of 10.
</p>
<p>
Typically,
<a class="link" href="server-system-variables.html#sysvar_ngram_token_size">
<code class="literal">
ngram_token_size
</code>
</a>
is
set to the size of the largest token that you want to search
for. If you only intend to search for single characters, set
<a class="link" href="server-system-variables.html#sysvar_ngram_token_size">
<code class="literal">
ngram_token_size
</code>
</a>
to 1. A
smaller token size produces a smaller full-text search index,
and faster searches. If you need to search for words comprised
of more than one character, set
<a class="link" href="server-system-variables.html#sysvar_ngram_token_size">
<code class="literal">
ngram_token_size
</code>
</a>
accordingly.
For example,
<span class="quote">
“
<span class="quote">
Happy Birthday
</span>
”
</span>
is
<span class="quote">
“
<span class="quote">
<span class="phrase" lang="zh-cn">
生日快乐
</span>
</span>
”
</span>
in
simplified Chinese, where
<span class="quote">
“
<span class="quote">
<span class="phrase" lang="zh-cn">
生日
</span>
</span>
”
</span>
is
<span class="quote">
“
<span class="quote">
birthday
</span>
”
</span>
, and
<span class="quote">
“
<span class="quote">
<span class="phrase" lang="zh-cn">
快乐
</span>
</span>
”
</span>
translates
as
<span class="quote">
“
<span class="quote">
happy
</span>
”
</span>
. To search on two-character words such
as these, set
<a class="link" href="server-system-variables.html#sysvar_ngram_token_size">
<code class="literal">
ngram_token_size
</code>
</a>
to a value of 2 or higher.
</p>
<p>
As a read-only variable,
<a class="link" href="server-system-variables.html#sysvar_ngram_token_size">
<code class="literal">
ngram_token_size
</code>
</a>
may only be
set as part of a startup string or in a configuration file:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Startup string:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa39143297"><div class="copy-help left">Press ⌘+C to 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">--ngram_token_size</span><span class="token attr-value"><span class="token punctuation">=</span>2</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
Configuration file:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-ini"><div class="docs-select-all right" id="sa22435550"><div class="copy-help left">Press ⌘+C to 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">ngram_token_size</span><span class="token attr-value"><span class="token punctuation">=</span>2</span></code></pre>
</div>
</li>
</ul>
</div>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
The following minimum and maximum word length configuration
options are ignored for
<code class="literal">
FULLTEXT
</code>
indexes
that use the ngram parser:
<a class="link" href="innodb-parameters.html#sysvar_innodb_ft_min_token_size">
<code class="literal">
innodb_ft_min_token_size
</code>
</a>
,
<a class="link" href="innodb-parameters.html#sysvar_innodb_ft_max_token_size">
<code class="literal">
innodb_ft_max_token_size
</code>
</a>
,
<a class="link" href="server-system-variables.html#sysvar_ft_min_word_len">
<code class="literal">
ft_min_word_len
</code>
</a>
, and
<a class="link" href="server-system-variables.html#sysvar_ft_max_word_len">
<code class="literal">
ft_max_word_len
</code>
</a>
.
</p>
</div>
<h4>
<a name="idm46045201266384">
</a>
Creating a FULLTEXT Index that Uses the ngram Parser
</h4>
<p>
To create a
<code class="literal">
FULLTEXT
</code>
index that uses the
ngram parser, specify
<code class="literal">
WITH PARSER ngram
</code>
with
<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>
, or
<a class="link" href="create-index.html" title="15.1.15 CREATE INDEX Statement">
<code class="literal">
CREATE INDEX
</code>
</a>
.
</p>
<p>
The following example demonstrates creating a table with an
<code class="literal">
ngram
</code>
<code class="literal">
FULLTEXT
</code>
index,
inserting sample data (Simplified Chinese text), and viewing
tokenized data in 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.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa82243211"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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> test<span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> articles <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>
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>
body <span class="token datatype">TEXT</span><span class="token punctuation">,</span>
<span class="token keyword">FULLTEXT</span> <span class="token punctuation">(</span>title<span class="token punctuation">,</span>body<span class="token punctuation">)</span> <span class="token keyword">WITH</span> <span class="token keyword">PARSER</span> ngram
<span class="token punctuation">)</span> <span class="token keyword">ENGINE</span><span class="token operator">=</span>InnoDB <span class="token keyword">CHARACTER</span> <span class="token keyword">SET</span> utf8mb4<span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">SET</span> <span class="token keyword">NAMES</span> utf8mb4<span class="token punctuation">;</span>
<span class="token keyword">INSERT</span> <span class="token keyword">INTO</span> articles <span class="token punctuation">(</span>title<span class="token punctuation">,</span>body<span class="token punctuation">)</span> <span class="token keyword">VALUES</span>
<span class="token punctuation">(</span><span class="token string">'数据库管理'</span><span class="token punctuation">,</span><span class="token string">'在本教程中我将向你展示如何管理数据库'</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token punctuation">(</span><span class="token string">'数据库应用开发'</span><span class="token punctuation">,</span><span class="token string">'学习开发数据库应用程序'</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 keyword">GLOBAL</span> innodb_ft_aux_table<span class="token operator">=</span><span class="token string">"test/articles"</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> INFORMATION_SCHEMA<span class="token punctuation">.</span>INNODB_FT_INDEX_CACHE <span class="token keyword">ORDER</span> <span class="token keyword">BY</span> doc_id<span class="token punctuation">,</span> position<span class="token punctuation">;</span></code></pre>
</div>
<p>
To add a
<code class="literal">
FULLTEXT
</code>
index to an existing table,
you can use
<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>
. For example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa32541260"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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> articles <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>
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>
body <span class="token datatype">TEXT</span>
<span class="token punctuation">)</span> <span class="token keyword">ENGINE</span><span class="token operator">=</span>InnoDB <span class="token keyword">CHARACTER</span> <span class="token keyword">SET</span> utf8mb4<span class="token punctuation">;</span>
<span class="token keyword">ALTER</span> <span class="token keyword">TABLE</span> articles <span class="token keyword">ADD</span> <span class="token keyword">FULLTEXT</span> <span class="token keyword">INDEX</span> ft_index <span class="token punctuation">(</span>title<span class="token punctuation">,</span>body<span class="token punctuation">)</span> <span class="token keyword">WITH</span> <span class="token keyword">PARSER</span> ngram<span class="token punctuation">;</span>
<span class="token comment" spellcheck="true"># Or:</span>
<span class="token keyword">CREATE</span> <span class="token keyword">FULLTEXT</span> <span class="token keyword">INDEX</span> ft_index <span class="token keyword">ON</span> articles <span class="token punctuation">(</span>title<span class="token punctuation">,</span>body<span class="token punctuation">)</span> <span class="token keyword">WITH</span> <span class="token keyword">PARSER</span> ngram<span class="token punctuation">;</span></code></pre>
</div>
<h4>
<a name="idm46045201249536">
</a>
ngram Parser Space Handling
</h4>
<p>
The ngram parser eliminates spaces when parsing. For example:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<span class="quote">
“
<span class="quote">
ab cd
</span>
”
</span>
is parsed to
<span class="quote">
“
<span class="quote">
ab
</span>
”
</span>
,
<span class="quote">
“
<span class="quote">
cd
</span>
”
</span>
</p>
</li>
<li class="listitem">
<p>
<span class="quote">
“
<span class="quote">
a bc
</span>
”
</span>
is parsed to
<span class="quote">
“
<span class="quote">
bc
</span>
”
</span>
</p>
</li>
</ul>
</div>
<h4>
<a name="idm46045201244288">
</a>
ngram Parser Stopword Handling
</h4>
<p>
The built-in MySQL full-text parser compares words to entries in
the stopword list. If a word is equal to an entry in the
stopword list, the word is excluded from the index. For the
ngram parser, stopword handling is performed differently.
Instead of excluding tokens that are equal to entries in the
stopword list, the ngram parser excludes tokens that
<span class="emphasis">
<em>
contain
</em>
</span>
stopwords. For example, assuming
<a class="link" href="server-system-variables.html#sysvar_ngram_token_size">
<code class="literal">
ngram_token_size=2
</code>
</a>
, a document
that contains
<span class="quote">
“
<span class="quote">
a,b
</span>
”
</span>
is parsed to
<span class="quote">
“
<span class="quote">
a,
</span>
”
</span>
and
<span class="quote">
“
<span class="quote">
,b
</span>
”
</span>
. If a comma (
<span class="quote">
“
<span class="quote">
,
</span>
”
</span>
) is defined
as a stopword, both
<span class="quote">
“
<span class="quote">
a,
</span>
”
</span>
and
<span class="quote">
“
<span class="quote">
,b
</span>
”
</span>
are
excluded from the index because they contain a comma.
</p>
<p>
By default, the ngram parser uses the default stopword list,
which contains a list of English stopwords. For a stopword list
applicable to Chinese, Japanese, or Korean, you must create your
own. For information about creating a stopword list, see
<a class="xref" href="fulltext-stopwords.html" title="14.9.4 Full-Text Stopwords">
Section 14.9.4, “Full-Text Stopwords”
</a>
.
</p>
<p>
Stopwords greater in length than
<a class="link" href="server-system-variables.html#sysvar_ngram_token_size">
<code class="literal">
ngram_token_size
</code>
</a>
are ignored.
</p>
<h4>
<a name="idm46045201234848">
</a>
ngram Parser Term Search
</h4>
<p>
For
<span class="emphasis">
<em>
natural language mode
</em>
</span>
search, the
search term is converted to a union of ngram terms. For example,
the string
<span class="quote">
“
<span class="quote">
abc
</span>
”
</span>
(assuming
<a class="link" href="server-system-variables.html#sysvar_ngram_token_size">
<code class="literal">
ngram_token_size=2
</code>
</a>
) is
converted to
<span class="quote">
“
<span class="quote">
ab bc
</span>
”
</span>
. Given two documents, one
containing
<span class="quote">
“
<span class="quote">
ab
</span>
”
</span>
and the other containing
<span class="quote">
“
<span class="quote">
abc
</span>
”
</span>
, the search term
<span class="quote">
“
<span class="quote">
ab bc
</span>
”
</span>
matches
both documents.
</p>
<p>
For
<span class="emphasis">
<em>
boolean mode search
</em>
</span>
, the search term is
converted to an ngram phrase search. For example, the string
'abc' (assuming
<a class="link" href="server-system-variables.html#sysvar_ngram_token_size">
<code class="literal">
ngram_token_size=2
</code>
</a>
) is
converted to '
<span class="quote">
“
<span class="quote">
ab bc
</span>
”
</span>
'. Given two documents, one
containing 'ab' and the other containing 'abc', the search
phrase '
<span class="quote">
“
<span class="quote">
ab bc
</span>
”
</span>
' only matches the document
containing 'abc'.
</p>
<h4>
<a name="idm46045201226448">
</a>
ngram Parser Wildcard Search
</h4>
<p>
Because an ngram
<code class="literal">
FULLTEXT
</code>
index contains only
ngrams, and does not contain information about the beginning of
terms, wildcard searches may return unexpected results. The
following behaviors apply to wildcard searches using ngram
<code class="literal">
FULLTEXT
</code>
search indexes:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
If the prefix term of a wildcard search is shorter than
ngram token size, the query returns all indexed rows that
contain ngram tokens starting with the prefix term. For
example, assuming
<a class="link" href="server-system-variables.html#sysvar_ngram_token_size">
<code class="literal">
ngram_token_size=2
</code>
</a>
, a
search on
<span class="quote">
“
<span class="quote">
a*
</span>
”
</span>
returns all rows starting with
<span class="quote">
“
<span class="quote">
a
</span>
”
</span>
.
</p>
</li>
<li class="listitem">
<p>
If the prefix term of a wildcard search is longer than ngram
token size, the prefix term is converted to an ngram phrase
and the wildcard operator is ignored. For example, assuming
<a class="link" href="server-system-variables.html#sysvar_ngram_token_size">
<code class="literal">
ngram_token_size=2
</code>
</a>
, an
<span class="quote">
“
<span class="quote">
abc*
</span>
”
</span>
wildcard search is converted to
<span class="quote">
“
<span class="quote">
ab bc
</span>
”
</span>
.
</p>
</li>
</ul>
</div>
<h4>
<a name="idm46045201216928">
</a>
ngram Parser Phrase Search
</h4>
<p>
Phrase searches are converted to ngram phrase searches. For
example, The search phrase
<span class="quote">
“
<span class="quote">
abc
</span>
”
</span>
is converted to
<span class="quote">
“
<span class="quote">
ab bc
</span>
”
</span>
, which returns documents containing
<span class="quote">
“
<span class="quote">
abc
</span>
”
</span>
and
<span class="quote">
“
<span class="quote">
ab bc
</span>
”
</span>
.
</p>
<p>
The search phrase
<span class="quote">
“
<span class="quote">
abc def
</span>
”
</span>
is converted to
<span class="quote">
“
<span class="quote">
ab bc de ef
</span>
”
</span>
, which returns documents containing
<span class="quote">
“
<span class="quote">
abc def
</span>
”
</span>
and
<span class="quote">
“
<span class="quote">
ab bc de ef
</span>
”
</span>
. A
document that contains
<span class="quote">
“
<span class="quote">
abcdef
</span>
”
</span>
is not returned.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/mysql-enterprise-telemetry.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h2 class="title">
<a name="mysql-enterprise-telemetry">
</a>
32.9 MySQL Telemetry
</h2>
</div>
</div>
</div>
<a class="indexterm" name="idm46045060155264">
</a>
<p>
The MySQL telemetry component is based on the OpenTelemetry (OTel)
project, an open-source, vendor-neutral observability framework
providing a common observability standard. It enables users to
instrument their applications in order to export observability
data: traces, metrics and logs, enabling increased granularity of
debugging and testing.
</p>
<p>
For more information, see
<a class="xref" href="telemetry.html" title="Chapter 35 Telemetry">
Chapter 35,
<i>
Telemetry
</i>
</a>
.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/condition-filtering.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="condition-filtering">
</a>
10.2.1.13 Condition Filtering
</h4>
</div>
</div>
</div>
<p>
In join processing, prefix rows are those rows passed from one
table in a join to the next. In general, the optimizer
attempts to put tables with low prefix counts early in the
join order to keep the number of row combinations from
increasing rapidly. To the extent that the optimizer can use
information about conditions on rows selected from one table
and passed to the next, the more accurately it can compute row
estimates and choose the best execution plan.
</p>
<p>
Without condition filtering, the prefix row count for a table
is based on the estimated number of rows selected by the
<code class="literal">
WHERE
</code>
clause according to whichever access
method the optimizer chooses. Condition filtering enables the
optimizer to use other relevant conditions in the
<code class="literal">
WHERE
</code>
clause not taken into account by the
access method, and thus improve its prefix row count
estimates. For example, even though there might be an
index-based access method that can be used to select rows from
the current table in a join, there might also be additional
conditions for the table in the
<code class="literal">
WHERE
</code>
clause that can filter (further restrict) the estimate for
qualifying rows passed to the next table.
</p>
<p>
A condition contributes to the filtering estimate only if:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
It refers to the current table.
</p>
</li>
<li class="listitem">
<p>
It depends on a constant value or values from earlier
tables in the join sequence.
</p>
</li>
<li class="listitem">
<p>
It was not already taken into account by the access
method.
</p>
</li>
</ul>
</div>
<p>
In
<a class="link" href="explain.html" title="15.8.2 EXPLAIN Statement">
<code class="literal">
EXPLAIN
</code>
</a>
output, the
<code class="literal">
rows
</code>
column indicates the row estimate for
the chosen access method, and the
<code class="literal">
filtered
</code>
column reflects the effect of condition filtering.
<code class="literal">
filtered
</code>
values are expressed as
percentages. The maximum value is 100, which means no
filtering of rows occurred. Values decreasing from 100
indicate increasing amounts of filtering.
</p>
<p>
The prefix row count (the number of rows estimated to be
passed from the current table in a join to the next) is the
product of the
<code class="literal">
rows
</code>
and
<code class="literal">
filtered
</code>
values. That is, the prefix row
count is the estimated row count, reduced by the estimated
filtering effect. For example, if
<code class="literal">
rows
</code>
is
1000 and
<code class="literal">
filtered
</code>
is 20%, condition
filtering reduces the estimated row count of 1000 to a prefix
row count of 1000 × 20% = 1000 × .2 = 200.
</p>
<p>
Consider the following query:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa95816594"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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> employee <span class="token keyword">JOIN</span> department <span class="token keyword">ON</span> employee<span class="token punctuation">.</span>dept_no <span class="token operator">=</span> department<span class="token punctuation">.</span>dept_no
<span class="token keyword">WHERE</span> employee<span class="token punctuation">.</span>first_name <span class="token operator">=</span> <span class="token string">'John'</span>
<span class="token operator">AND</span> employee<span class="token punctuation">.</span>hire_date <span class="token operator">BETWEEN</span> <span class="token string">'2018-01-01'</span> <span class="token operator">AND</span> <span class="token string">'2018-06-01'</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
Suppose that the data set has these characteristics:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
The
<code class="literal">
employee
</code>
table has 1024 rows.
</p>
</li>
<li class="listitem">
<p>
The
<code class="literal">
department
</code>
table has 12 rows.
</p>
</li>
<li class="listitem">
<p>
Both tables have an index on
<code class="literal">
dept_no
</code>
.
</p>
</li>
<li class="listitem">
<p>
The
<code class="literal">
employee
</code>
table has an index on
<code class="literal">
first_name
</code>
.
</p>
</li>
<li class="listitem">
<p>
8 rows satisfy this condition on
<code class="literal">
employee.first_name
</code>
:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa75874779"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql">employee<span class="token punctuation">.</span>first_name <span class="token operator">=</span> <span class="token string">'John'</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
150 rows satisfy this condition on
<code class="literal">
employee.hire_date
</code>
:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa54153249"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql">employee<span class="token punctuation">.</span>hire_date <span class="token operator">BETWEEN</span> <span class="token string">'2018-01-01'</span> <span class="token operator">AND</span> <span class="token string">'2018-06-01'</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
1 row satisfies both conditions:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa8630614"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql">employee<span class="token punctuation">.</span>first_name <span class="token operator">=</span> <span class="token string">'John'</span>
<span class="token operator">AND</span> employee<span class="token punctuation">.</span>hire_date <span class="token operator">BETWEEN</span> <span class="token string">'2018-01-01'</span> <span class="token operator">AND</span> <span class="token string">'2018-06-01'</span></code></pre>
</div>
</li>
</ul>
</div>
<p>
Without condition filtering,
<a class="link" href="explain.html" title="15.8.2 EXPLAIN Statement">
<code class="literal">
EXPLAIN
</code>
</a>
produces output like
this:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-none"><div class="docs-select-all right" id="sa97289758"><div class="copy-help left">Press ⌘+C to 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">+----+------------+--------+------------------+---------+---------+------+----------+
| id | table | type | possible_keys | key | ref | rows | filtered |
+----+------------+--------+------------------+---------+---------+------+----------+
| 1 | employee | ref | name,h_date,dept | name | const | 8 | 100.00 |
| 1 | department | eq_ref | PRIMARY | PRIMARY | dept_no | 1 | 100.00 |
+----+------------+--------+------------------+---------+---------+------+----------+</code></pre>
</div>
<p>
For
<code class="literal">
employee
</code>
, the access method on the
<code class="literal">
name
</code>
index picks up the 8 rows that match a
name of
<code class="literal">
'John'
</code>
. No filtering is done
(
<code class="literal">
filtered
</code>
is 100%), so all rows are prefix
rows for the next table: The prefix row count is
<code class="literal">
rows
</code>
×
<code class="literal">
filtered
</code>
=
8 × 100% = 8.
</p>
<p>
With condition filtering, the optimizer additionally takes
into account conditions from the
<code class="literal">
WHERE
</code>
clause not taken into account by the access method. In this
case, the optimizer uses heuristics to estimate a filtering
effect of 16.31% for the
<a class="link" href="comparison-operators.html#operator_between">
<code class="literal">
BETWEEN
</code>
</a>
condition on
<code class="literal">
employee.hire_date
</code>
. As a
result,
<a class="link" href="explain.html" title="15.8.2 EXPLAIN Statement">
<code class="literal">
EXPLAIN
</code>
</a>
produces output
like this:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-none"><div class="docs-select-all right" id="sa75839927"><div class="copy-help left">Press ⌘+C to 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">+----+------------+--------+------------------+---------+---------+------+----------+
| id | table | type | possible_keys | key | ref | rows | filtered |
+----+------------+--------+------------------+---------+---------+------+----------+
| 1 | employee | ref | name,h_date,dept | name | const | 8 | 16.31 |
| 1 | department | eq_ref | PRIMARY | PRIMARY | dept_no | 1 | 100.00 |
+----+------------+--------+------------------+---------+---------+------+----------+</code></pre>
</div>
<p>
Now the prefix row count is
<code class="literal">
rows
</code>
×
<code class="literal">
filtered
</code>
= 8 × 16.31% = 1.3, which
more closely reflects actual data set.
</p>
<p>
Normally, the optimizer does not calculate the condition
filtering effect (prefix row count reduction) for the last
joined table because there is no next table to pass rows to.
An exception occurs for
<a class="link" href="explain.html" title="15.8.2 EXPLAIN Statement">
<code class="literal">
EXPLAIN
</code>
</a>
: To provide more
information, the filtering effect is calculated for all joined
tables, including the last one.
</p>
<p>
To control whether the optimizer considers additional
filtering conditions, use the
<a class="link" href="switchable-optimizations.html#optflag_condition-fanout-filter">
<code class="literal">
condition_fanout_filter
</code>
</a>
flag
of the
<a class="link" href="server-system-variables.html#sysvar_optimizer_switch">
<code class="literal">
optimizer_switch
</code>
</a>
system variable (see
<a class="xref" href="switchable-optimizations.html" title="10.9.2 Switchable Optimizations">
Section 10.9.2, “Switchable Optimizations”
</a>
). This flag is
enabled by default but can be disabled to suppress condition
filtering (for example, if a particular query is found to
yield better performance without it).
</p>
<p>
If the optimizer overestimates the effect of condition
filtering, performance may be worse than if condition
filtering is not used. In such cases, these techniques may
help:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
If a column is not indexed, index it so that the optimizer
has some information about the distribution of column
values and can improve its row estimates.
</p>
</li>
<li class="listitem">
<p>
Similarly, if no column histogram information is
available, generate a histogram (see
<a class="xref" href="optimizer-statistics.html" title="10.9.6 Optimizer Statistics">
Section 10.9.6, “Optimizer Statistics”
</a>
).
</p>
</li>
<li class="listitem">
<p>
Change the join order. Ways to accomplish this include
join-order optimizer hints (see
<a class="xref" href="optimizer-hints.html" title="10.9.3 Optimizer Hints">
Section 10.9.3, “Optimizer Hints”
</a>
),
<code class="literal">
STRAIGHT_JOIN
</code>
immediately following the
<code class="literal">
SELECT
</code>
, and the
<code class="literal">
STRAIGHT_JOIN
</code>
join operator.
</p>
</li>
<li class="listitem">
<p>
Disable condition filtering for the session:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa16379787"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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> optimizer_switch <span class="token operator">=</span> <span class="token string">'condition_fanout_filter=off'</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
Or, for a given query, using an optimizer hint:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa86543194"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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 comment" spellcheck="true">/*+ SET_VAR(optimizer_switch = 'condition_fanout_filter=off') */</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span></code></pre>
</div>
</li>
</ul>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/group-replication-background.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h2 class="title">
<a name="group-replication-background">
</a>
20.1 Group Replication Background
</h2>
</div>
</div>
</div>
<div class="toc">
<dl class="toc">
<dt>
<span class="section">
<a href="group-replication-replication-technologies.html">
20.1.1 Replication Technologies
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="group-replication-use-cases.html">
20.1.2 Group Replication Use Cases
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="group-replication-deploying-in-multi-primary-or-single-primary-mode.html">
20.1.3 Multi-Primary and Single-Primary Modes
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="group-replication-details.html">
20.1.4 Group Replication Services
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="group-replication-plugin-architecture.html">
20.1.5 Group Replication Plugin Architecture
</a>
</span>
</dt>
</dl>
</div>
<a class="indexterm" name="idm46045134588512">
</a>
<p>
This section provides background information on MySQL Group
Replication.
</p>
<p>
The most common way to create a fault-tolerant system is to resort
to making components redundant, in other words the component can be
removed and the system should continue to operate as expected. This
creates a set of challenges that raise complexity of such systems to
a whole different level. Specifically, replicated databases have to
deal with the fact that they require maintenance and administration
of several servers instead of just one. Moreover, as servers are
cooperating together to create the group several other classic
distributed systems problems have to be dealt with, such as network
partitioning or split brain scenarios.
</p>
<p>
Therefore, the ultimate challenge is to fuse the logic of the
database and data replication with the logic of having several
servers coordinated in a consistent and simple way. In other words,
to have multiple servers agreeing on the state of the system and the
data on each and every change that the system goes through. This can
be summarized as having servers reaching agreement on each database
state transition, so that they all progress as one single database
or alternatively that they eventually converge to the same state.
Meaning that they need to operate as a (distributed) state machine.
</p>
<p>
MySQL Group Replication provides distributed state machine
replication with strong coordination between servers. Servers
coordinate themselves automatically when they are part of the same
group. The group can operate in a single-primary mode with automatic
primary election, where only one server accepts updates at a time.
Alternatively, for more advanced users the group can be deployed in
multi-primary mode, where all servers can accept updates, even if
they are issued concurrently. This power comes at the expense of
applications having to work around the limitations imposed by such
deployments.
</p>
<p>
There is a built-in group membership service that keeps the view of
the group consistent and available for all servers at any given
point in time. Servers can leave and join the group and the view is
updated accordingly. Sometimes servers can leave the group
unexpectedly, in which case the failure detection mechanism detects
this and notifies the group that the view has changed. This is all
automatic.
</p>
<p>
For a transaction to commit, the majority of the group have to agree
on the order of a given transaction in the global sequence of
transactions. Deciding to commit or abort a transaction is done by
each server individually, but all servers make the same decision. If
there is a network partition, resulting in a split where members are
unable to reach agreement, then the system does not progress until
this issue is resolved. Hence there is also a built-in, automatic,
split-brain protection mechanism.
</p>
<p>
All of this is powered by the provided Group Communication System
(GCS) protocols. These provide a failure detection mechanism, a
group membership service, and safe and completely ordered message
delivery. All these properties are key to creating a system which
ensures that data is consistently replicated across the group of
servers. At the very core of this technology lies an implementation
of the Paxos algorithm. It acts as the group communication engine.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/json-functions.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h2 class="title">
<a name="json-functions">
</a>
14.17 JSON Functions
</h2>
</div>
</div>
</div>
<div class="toc">
<dl class="toc">
<dt>
<span class="section">
<a href="json-function-reference.html">
14.17.1 JSON Function Reference
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="json-creation-functions.html">
14.17.2 Functions That Create JSON Values
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="json-search-functions.html">
14.17.3 Functions That Search JSON Values
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="json-modification-functions.html">
14.17.4 Functions That Modify JSON Values
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="json-attribute-functions.html">
14.17.5 Functions That Return JSON Value Attributes
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="json-table-functions.html">
14.17.6 JSON Table Functions
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="json-validation-functions.html">
14.17.7 JSON Schema Validation Functions
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="json-utility-functions.html">
14.17.8 JSON Utility Functions
</a>
</span>
</dt>
</dl>
</div>
<a class="indexterm" name="idm46045195837968">
</a>
<p>
The functions described in this section perform operations on JSON
values. For discussion of the
<a class="link" href="json.html" title="13.5 The JSON Data Type">
<code class="literal">
JSON
</code>
</a>
data type and additional examples showing how to use these
functions, see
<a class="xref" href="json.html" title="13.5 The JSON Data Type">
Section 13.5, “The JSON Data Type”
</a>
.
</p>
<p>
For functions that take a JSON argument, an error occurs if the
argument is not a valid JSON value. Arguments parsed as JSON are
indicated by
<em class="replaceable">
<code>
json_doc
</code>
</em>
; arguments
indicated by
<em class="replaceable">
<code>
val
</code>
</em>
are not parsed.
</p>
<p>
Functions that return JSON values always perform normalization of
these values (see
<a class="xref" href="json.html#json-normalization" title="Normalization, Merging, and Autowrapping of JSON Values">
Normalization, Merging, and Autowrapping of JSON Values
</a>
), and thus
orders them.
<span class="emphasis">
<em>
The precise outcome of the sort is subject to
change at any time; do not rely on it to be consistent between
releases
</em>
</span>
.
</p>
<p>
A set of spatial functions for operating on GeoJSON values is also
available. See
<a class="xref" href="spatial-geojson-functions.html" title="14.16.11 Spatial GeoJSON Functions">
Section 14.16.11, “Spatial GeoJSON Functions”
</a>
.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/upgrading-from-previous-series.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h2 class="title">
<a name="upgrading-from-previous-series">
</a>
3.5 Changes in MySQL 8.4
</h2>
</div>
</div>
</div>
<p>
Before upgrading to MySQL 8.4, review the changes
linked in this section to identify those that apply to your
current MySQL installation and applications.
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="ulink" href="/doc/refman/8.4/en/mysql-nutshell.html" target="_top">
Overview
of changes in MySQL 8.4.0
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="ulink" href="/doc/relnotes/mysql/8.4/en/news-8-4-0.html" target="_top">
MySQL
8.4.0 Release Notes
</a>
</p>
</li>
</ul>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/point-in-time-recovery-positions.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="point-in-time-recovery-positions">
</a>
9.5.2 Point-in-Time Recovery Using Event Positions
</h3>
</div>
</div>
</div>
<p>
The last section,
<a class="xref" href="point-in-time-recovery-binlog.html" title="9.5.1 Point-in-Time Recovery Using Binary Log">
Section 9.5.1, “Point-in-Time Recovery Using Binary Log”
</a>
, explains the
general idea of using the binary log to perform a
point-in-time-recovery. The section explains the operation in
details with an example.
</p>
<p>
As an example, suppose that around 20:06:00 on March 11, 2020,
an SQL statement was executed that deleted a table. You can
perform a point-in-time recovery to restore the server up to its
state right before the table deletion. These are some sample
steps to achieve that:
</p>
<div class="orderedlist">
<ol class="orderedlist" type="1">
<li class="listitem">
<p>
Restore the last full backup created before the
point-in-time of interest (call it
<code class="literal">
t
<sub>
p
</sub>
</code>
, which is
20:06:00 on March 11, 2020 in our example). When finished,
note the binary log position up to which you have restored
the server for later use, and restart the server.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
While the last binary log position recovered is also
displayed by InnoDB after the restore and server restart,
that is
<span class="emphasis">
<em>
not
</em>
</span>
a reliable means for
obtaining the ending log position of your restore, as
there could be DDL events and non-InnoDB changes that have
taken place after the time reflected by the displayed
position. Your backup and restore tool should provide you
with the last binary log position for your recovery: for
example, if you are using
<a class="link" href="mysqlbinlog.html" title="6.6.9 mysqlbinlog — Utility for Processing Binary Log Files">
<span class="command">
<strong>
mysqlbinlog
</strong>
</span>
</a>
for the task, check the stop position of the binary log
replay; if you are using MySQL Enterprise Backup, the last binary log
position has been saved in your backup. See
<a class="ulink" href="/doc/mysql-enterprise-backup/8.4/en/advanced.point.html" target="_top">
Point-in-Time Recovery
</a>
.
</p>
</div>
</li>
<li class="listitem">
<p>
Find the precise binary log event position corresponding to
the point in time up to which you want to restore your
database. In our example, given that we know the rough time
where the table deletion took place
(
<code class="literal">
t
<sub>
p
</sub>
</code>
), we can find
the log position by checking the log contents around that
time using the
<a class="link" href="mysqlbinlog.html" title="6.6.9 mysqlbinlog — Utility for Processing Binary Log Files">
<span class="command">
<strong>
mysqlbinlog
</strong>
</span>
</a>
utility. Use
the
<a class="link" href="mysqlbinlog.html#option_mysqlbinlog_start-datetime">
<code class="option">
--start-datetime
</code>
</a>
and
<a class="link" href="mysqlbinlog.html#option_mysqlbinlog_stop-datetime">
<code class="option">
--stop-datetime
</code>
</a>
options
to specify a short time period around
<code class="literal">
t
<sub>
p
</sub>
</code>
, and then look
for the event in the output. For example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa18339269"><div class="copy-help left">Press ⌘+C to 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">mysqlbinlog</span> <span class="token constant">--start-datetime</span>=<span class="token atrule">"2020-03-11 20:05:00"</span> \
<span class="token constant">--stop-datetime</span>=<span class="token atrule">"2020-03-11 20:08:00"</span> <span class="token property">--verbose</span> \
/var/lib/mysql/bin<span class="token punctuation">.</span>123456 | grep <span class="token property">-C</span> 15 <span class="token atrule">"DROP TABLE"</span>
/*!80014 SET @@session<span class="token punctuation">.</span>original_server_version<span class="token attr-value"><span class="token punctuation">=</span>80019*//*!*/;</span>
/*!80014 SET @@session<span class="token punctuation">.</span>immediate_server_version<span class="token attr-value"><span class="token punctuation">=</span>80019*//*!*/;</span>
SET @@SESSION<span class="token punctuation">.</span>GTID_NEXT= <span class="token atrule">'ANONYMOUS'</span>/*!*/<span class="token punctuation">;</span>
<span class="token comment" spellcheck="true"># at 232</span>
<span class="token comment" spellcheck="true">#200311 20:06:20 server id 1 end_log_pos 355 CRC32 0x2fc1e5ea Query thread_id=16 exec_time=0 error_code=0</span>
SET TIMESTAMP<span class="token attr-value"><span class="token punctuation">=</span>1583971580/*!*/;</span>
SET @@session<span class="token punctuation">.</span>pseudo_thread_id<span class="token attr-value"><span class="token punctuation">=</span>16/*!*/;</span>
SET @@session<span class="token punctuation">.</span>foreign_key_checks<span class="token attr-value"><span class="token punctuation">=</span>1,</span> @@session<span class="token punctuation">.</span>sql_auto_is_null<span class="token attr-value"><span class="token punctuation">=</span>0,</span> @@session<span class="token punctuation">.</span>unique_checks<span class="token attr-value"><span class="token punctuation">=</span>1,</span> @@session<span class="token punctuation">.</span>autocommit<span class="token attr-value"><span class="token punctuation">=</span>1/*!*/;</span>
SET @@session<span class="token punctuation">.</span>sql_mode<span class="token attr-value"><span class="token punctuation">=</span>1168113696/*!*/;</span>
SET @@session<span class="token punctuation">.</span>auto_increment_increment<span class="token attr-value"><span class="token punctuation">=</span>1,</span> @@session<span class="token punctuation">.</span>auto_increment_offset<span class="token attr-value"><span class="token punctuation">=</span>1/*!*/;</span>
/*!\C utf8mb4 *//*!*/<span class="token punctuation">;</span>
SET @@session<span class="token punctuation">.</span>character_set_client<span class="token attr-value"><span class="token punctuation">=</span>255,@@session.collation_connection=255,@@session.collation_server=255/*!*/;</span>
SET @@session<span class="token punctuation">.</span>lc_time_names<span class="token attr-value"><span class="token punctuation">=</span>0/*!*/;</span>
SET @@session<span class="token punctuation">.</span>collation_database<span class="token attr-value"><span class="token punctuation">=</span>DEFAULT/*!*/;</span>
/*!80011 SET @@session<span class="token punctuation">.</span>default_collation_for_utf8mb4<span class="token attr-value"><span class="token punctuation">=</span>255*//*!*/;</span>
DROP TABLE `pets`<span class="token punctuation">.</span>`cats` /* generated by server */
/*!*/<span class="token punctuation">;</span>
<span class="token comment" spellcheck="true"># at 355</span>
<span class="token comment" spellcheck="true">#200311 20:07:48 server id 1 end_log_pos 434 CRC32 0x123d65df Anonymous_GTID last_committed=1 sequence_number=2 rbr_only=no original_committed_timestamp=1583971668462467 immediate_commit_timestamp=1583971668462467 transaction_length=473</span>
<span class="token comment" spellcheck="true"># original_commit_timestamp=1583971668462467 (2020-03-11 20:07:48.462467 EDT)</span>
<span class="token comment" spellcheck="true"># immediate_commit_timestamp=1583971668462467 (2020-03-11 20:07:48.462467 EDT)</span>
/*!80001 SET @@session<span class="token punctuation">.</span>original_commit_timestamp<span class="token attr-value"><span class="token punctuation">=</span>1583971668462467*//*!*/;</span>
/*!80014 SET @@session<span class="token punctuation">.</span>original_server_version<span class="token attr-value"><span class="token punctuation">=</span>80019*//*!*/;</span>
/*!80014 SET @@session<span class="token punctuation">.</span>immediate_server_version<span class="token attr-value"><span class="token punctuation">=</span>80019*//*!*/;</span>
SET @@SESSION<span class="token punctuation">.</span>GTID_NEXT= <span class="token atrule">'ANONYMOUS'</span>/*!*/<span class="token punctuation">;</span>
<span class="token comment" spellcheck="true"># at 434</span>
<span class="token comment" spellcheck="true">#200311 20:07:48 server id 1 end_log_pos 828 CRC32 0x57fac9ac Query thread_id=16 exec_time=0 error_code=0 Xid = 217</span>
use `pets`/*!*/<span class="token punctuation">;</span>
SET TIMESTAMP<span class="token attr-value"><span class="token punctuation">=</span>1583971668/*!*/;</span>
/*!80013 SET @@session<span class="token punctuation">.</span>sql_require_primary_key<span class="token attr-value"><span class="token punctuation">=</span>0*//*!*/;</span>
CREATE TABLE dogs</code></pre>
</div>
<p>
From the output of
<a class="link" href="mysqlbinlog.html" title="6.6.9 mysqlbinlog — Utility for Processing Binary Log Files">
<span class="command">
<strong>
mysqlbinlog
</strong>
</span>
</a>
, the
<code class="literal">
DROP TABLE `pets`.`cats`
</code>
statement can be
found in the segment of the binary log between the line
<code class="literal">
# at 232
</code>
and
<code class="literal">
# at 355
</code>
,
which means the statement takes place
<span class="emphasis">
<em>
after
</em>
</span>
the log position 232, and the log
is at position 355 after the
<code class="literal">
DROP TABLE
</code>
statement.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
Only use the
<a class="link" href="mysqlbinlog.html#option_mysqlbinlog_start-datetime">
<code class="option">
--start-datetime
</code>
</a>
and
<a class="link" href="mysqlbinlog.html#option_mysqlbinlog_stop-datetime">
<code class="option">
--stop-datetime
</code>
</a>
options to help you find the actual event positions of
interest. Using the two options to specify the range of
binary log segment to apply is not recommended: there is a
higher risk of missing binary log events when using the
options. Use
<a class="link" href="mysqlbinlog.html#option_mysqlbinlog_start-position">
<code class="option">
--start-position
</code>
</a>
and
<a class="link" href="mysqlbinlog.html#option_mysqlbinlog_stop-position">
<code class="option">
--stop-position
</code>
</a>
instead.
</p>
</div>
</li>
<li class="listitem">
<p>
Apply the events in binary log file to the server, starting
with the log position your found in step 1 (assume it is
155) and ending at the position you have found in step 2
that is
<span class="emphasis">
<em>
before
</em>
</span>
your point-in-time of
interest (which is 232):
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa77577236"><div class="copy-help left">Press ⌘+C to 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">mysqlbinlog</span> <span class="token constant">--start-position</span><span class="token attr-value"><span class="token punctuation">=</span>155</span> <span class="token constant">--stop-position</span><span class="token attr-value"><span class="token punctuation">=</span>232</span> /var/lib/mysql/bin<span class="token punctuation">.</span>123456 \
| mysql <span class="token property">-u</span> root <span class="token property">-p</span></code></pre>
</div>
<p>
The command recovers all the transactions from the starting
position until just before the stop position. Because the
output of
<a class="link" href="mysqlbinlog.html" title="6.6.9 mysqlbinlog — Utility for Processing Binary Log Files">
<span class="command">
<strong>
mysqlbinlog
</strong>
</span>
</a>
includes
<code class="literal">
SET TIMESTAMP
</code>
statements before each SQL
statement recorded, the recovered data and related MySQL
logs reflect the original times at which the transactions
were executed.
</p>
<p>
Your database has now been restored to the point-in-time of
interest,
<code class="literal">
t
<sub>
p
</sub>
</code>
,
right before the table
<code class="literal">
pets.cats
</code>
was
dropped.
</p>
</li>
<li class="listitem">
<p>
Beyond the point-in-time recovery that has been finished, if
you also want to reexecute all the statements
<span class="emphasis">
<em>
after
</em>
</span>
your point-in-time of interest,
use
<a class="link" href="mysqlbinlog.html" title="6.6.9 mysqlbinlog — Utility for Processing Binary Log Files">
<span class="command">
<strong>
mysqlbinlog
</strong>
</span>
</a>
again to apply all the
events after
<code class="literal">
t
<sub>
p
</sub>
</code>
to
the server. We noted in step 2 that after the statement we
wanted to skip, the log is at position 355; we can use it
for the
<a class="link" href="mysqlbinlog.html#option_mysqlbinlog_start-position">
<code class="option">
--start-position
</code>
</a>
option, so that any statements after the position are
included:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa4423772"><div class="copy-help left">Press ⌘+C to 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">mysqlbinlog</span> <span class="token constant">--start-position</span><span class="token attr-value"><span class="token punctuation">=</span>355</span> /var/lib/mysql/bin<span class="token punctuation">.</span>123456 \
| mysql <span class="token property">-u</span> root <span class="token property">-p</span></code></pre>
</div>
<p>
Your database has been restored the latest statement
recorded in the binary log file, but with the selected event
skipped.
</p>
</li>
</ol>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/mysql-cluster-programs-ndb-mgm.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="mysql-cluster-programs-ndb-mgm">
</a>
25.5.5 ndb_mgm — The NDB Cluster Management Client
</h3>
</div>
</div>
</div>
<a class="indexterm" name="idm46045106433568">
</a>
<a class="indexterm" name="idm46045106432624">
</a>
<a class="indexterm" name="idm46045106431264">
</a>
<a class="indexterm" name="idm46045106429936">
</a>
<a class="indexterm" name="idm46045106428544">
</a>
<a class="indexterm" name="idm46045106427216">
</a>
<a class="indexterm" name="idm46045106425856">
</a>
<p>
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>
management client process is
actually not needed to run the cluster. Its value lies in
providing a set of commands for checking the cluster's status,
starting backups, and performing other administrative functions.
The management client accesses the management server using a C
API. Advanced users can also employ this API for programming
dedicated management processes to perform tasks similar to those
performed by
<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>
To start the management client, it is necessary to supply the
host name and port number of the management server:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa3048634"><div class="copy-help left">Press ⌘+C to 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_mgm</span> <span class="token punctuation">[</span><em class="replaceable">host_name</em> <span class="token punctuation">[</span><em class="replaceable">port_num</em><span class="token punctuation">]</span><span class="token punctuation">]</span></code></pre>
</div>
<p>
For example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa19403710"><div class="copy-help left">Press ⌘+C to 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_mgm</span> ndb_mgmd<span class="token punctuation">.</span>mysql<span class="token punctuation">.</span>com 1186</code></pre>
</div>
<p>
The default host name and port number are
<code class="literal">
localhost
</code>
and 1186, respectively.
</p>
<a class="indexterm" name="idm46045106415040">
</a>
<a class="indexterm" name="idm46045106413552">
</a>
<a class="indexterm" name="idm46045106412064">
</a>
<a class="indexterm" name="idm46045106410560">
</a>
<p>
All options that can be used with
<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>
are
shown in the following table. Additional descriptions follow the
table.
</p>
<p>
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a name="option_ndb_mgm_backup-password-from-stdin">
</a>
<a class="link" href="mysql-cluster-programs-ndb-mgm.html#option_ndb_mgm_backup-password-from-stdin">
<code class="option">
--backup-password-from-stdin[=TRUE|FALSE]
</code>
</a>
</p>
<a class="indexterm" name="idm46045106404144">
</a>
<a class="indexterm" name="idm46045106402640">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for backup-password-from-stdin">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--backup-password-from-stdin
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
This option enables input of the backup password from the
system shell (
<code class="literal">
stdin
</code>
) when using
<code class="option">
--execute "START BACKUP"
</code>
or similar to
create a backup. Use of this option requires use of
<a class="link" href="mysql-cluster-programs-ndb-mgm.html#option_ndb_mgm_execute">
<code class="option">
--execute
</code>
</a>
as well.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_mgm_character-sets-dir">
</a>
<a class="link" href="mysql-cluster-programs-ndb-mgm.html#option_ndb_mgm_character-sets-dir">
<code class="option">
--character-sets-dir
</code>
</a>
</p>
<a class="indexterm" name="idm46045106390256">
</a>
<a class="indexterm" name="idm46045106388800">
</a>
<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=path
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Directory containing character sets.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_mgm_connect-retries">
</a>
<a class="link" href="mysql-cluster-programs-ndb-mgm.html#option_ndb_mgm_connect-retries">
<code class="option">
--connect-retries=
<em class="replaceable">
<code>
#
</code>
</em>
</code>
</a>
</p>
<a class="indexterm" name="idm46045106378752">
</a>
<a class="indexterm" name="idm46045106377264">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for connect-retries">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--connect-retries=#
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
Numeric
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
3
</code>
</td>
</tr>
<tr>
<th>
Minimum Value
</th>
<td>
<code class="literal">
0
</code>
</td>
</tr>
<tr>
<th>
Maximum Value
</th>
<td>
<code class="literal">
4294967295
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
This option specifies the number of times following the
first attempt to retry a connection before giving up (the
client always tries the connection at least once). The
length of time to wait per attempt is set using
<a class="link" href="mysql-cluster-programs-ndb-mgmd.html#option_ndb_mgmd_connect-retry-delay">
<code class="option">
--connect-retry-delay
</code>
</a>
.
</p>
<p>
This option is synonymous with the
<a class="link" href="mysql-cluster-programs-ndb-mgm.html#option_ndb_mgm_try-reconnect">
<code class="option">
--try-reconnect
</code>
</a>
option,
which is now deprecated.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_mgm_connect-retry-delay">
</a>
<a class="link" href="mysql-cluster-programs-ndb-mgm.html#option_ndb_mgm_connect-retry-delay">
<code class="option">
--connect-retry-delay
</code>
</a>
</p>
<a class="indexterm" name="idm46045106355344">
</a>
<a class="indexterm" name="idm46045106353888">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for connect-retry-delay">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--connect-retry-delay=#
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
Integer
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
5
</code>
</td>
</tr>
<tr>
<th>
Minimum Value
</th>
<td>
<code class="literal">
0
</code>
</td>
</tr>
<tr>
<th>
Maximum Value
</th>
<td>
<code class="literal">
5
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Number of seconds to wait between attempts to contact
management server.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_mgm_connect-string">
</a>
<a class="link" href="mysql-cluster-programs-ndb-mgm.html#option_ndb_mgm_connect-string">
<code class="option">
--connect-string
</code>
</a>
</p>
<a class="indexterm" name="idm46045106334704">
</a>
<a class="indexterm" name="idm46045106333216">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for connect-string">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--connect-string=connection_string
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
String
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
[none]
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Same as
<a class="link" href="mysql-cluster-programs-ndb-mgm.html#option_ndb_mgm_ndb-connectstring">
<code class="option">
--ndb-connectstring
</code>
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_mgm_core-file">
</a>
<a class="link" href="mysql-cluster-programs-ndb-mgm.html#option_ndb_mgm_core-file">
<code class="option">
--core-file
</code>
</a>
</p>
<a class="indexterm" name="idm46045106317808">
</a>
<a class="indexterm" name="idm46045106316320">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for core-file">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--core-file
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Write core file on error; used in debugging.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_mgm_defaults-extra-file">
</a>
<a class="link" href="mysql-cluster-programs-ndb-mgm.html#option_ndb_mgm_defaults-extra-file">
<code class="option">
--defaults-extra-file
</code>
</a>
</p>
<a class="indexterm" name="idm46045106306480">
</a>
<a class="indexterm" name="idm46045106305024">
</a>
<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=path
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
String
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
[none]
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Read given file after global files are read.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_mgm_defaults-file">
</a>
<a class="link" href="mysql-cluster-programs-ndb-mgm.html#option_ndb_mgm_defaults-file">
<code class="option">
--defaults-file
</code>
</a>
</p>
<a class="indexterm" name="idm46045106290608">
</a>
<a class="indexterm" name="idm46045106289120">
</a>
<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=path
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
String
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
[none]
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Read default options from given file only.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_mgm_defaults-group-suffix">
</a>
<a class="link" href="mysql-cluster-programs-ndb-mgm.html#option_ndb_mgm_defaults-group-suffix">
<code class="option">
--defaults-group-suffix
</code>
</a>
</p>
<a class="indexterm" name="idm46045106274848">
</a>
<a class="indexterm" name="idm46045106273392">
</a>
<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=string
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
String
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
[none]
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Also read groups with concat(group, suffix).
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_mgm_encrypt-backup">
</a>
<a class="link" href="mysql-cluster-programs-ndb-mgm.html#option_ndb_mgm_encrypt-backup">
<code class="option">
--encrypt-backup
</code>
</a>
</p>
<a class="indexterm" name="idm46045106259040">
</a>
<a class="indexterm" name="idm46045106257552">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for encrypt-backup">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--encrypt-backup
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
When used, this option causes all backups to be encrypted.
To make this happen whenever
<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>
is
run, put the option in the
<code class="literal">
[ndb_mgm]
</code>
section of the
<code class="filename">
my.cnf
</code>
file.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_mgm_execute">
</a>
<a class="link" href="mysql-cluster-programs-ndb-mgm.html#option_ndb_mgm_execute">
<code class="option">
--execute=
<code class="literal">
command
</code>
</code>
</a>
,
<code class="option">
-e
<code class="literal">
command
</code>
</code>
</p>
<a class="indexterm" name="idm46045106243728">
</a>
<a class="indexterm" name="idm46045106242240">
</a>
<a class="indexterm" name="idm46045106240752">
</a>
<a class="indexterm" name="idm46045106239264">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for execute">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--execute=command
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
This option can be used to send a command to the NDB Cluster
management client from the system shell. For example, either
of the following is equivalent to executing
<a class="link" href="mysql-cluster-mgm-client-commands.html#ndbclient-show">
<code class="literal">
SHOW
</code>
</a>
in the management
client:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa12723900"><div class="copy-help left">Press ⌘+C to 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_mgm</span> <span class="token property">-e</span> <span class="token atrule">"SHOW"</span>
<span class="token prompt">$> </span><span class="token command">ndb_mgm</span> <span class="token constant">--execute</span>=<span class="token atrule">"SHOW"</span></code></pre>
</div>
<p>
This is analogous to how the
<a class="link" href="mysql-command-options.html#option_mysql_execute">
<code class="option">
--execute
</code>
</a>
or
<code class="option">
-e
</code>
option works 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>
command-line client. See
<a class="xref" href="command-line-options.html" title="6.2.2.1 Using Options on the Command Line">
Section 6.2.2.1, “Using Options on the Command Line”
</a>
.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
If the management client command to be passed using this
option contains any space characters, then the command
<span class="emphasis">
<em>
must
</em>
</span>
be enclosed in quotation marks.
Either single or double quotation marks may be used. If
the management client command contains no space
characters, the quotation marks are optional.
</p>
</div>
</li>
<li class="listitem">
<p>
<a name="option_ndb_mgm_help">
</a>
<a class="link" href="mysql-cluster-programs-ndb-mgm.html#option_ndb_mgm_help">
<code class="option">
--help
</code>
</a>
</p>
<a class="indexterm" name="idm46045106220464">
</a>
<a class="indexterm" name="idm46045106218976">
</a>
<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>
<p>
Display help text and exit.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_mgm_login-path">
</a>
<a class="link" href="mysql-cluster-programs-ndb-mgm.html#option_ndb_mgm_login-path">
<code class="option">
--login-path
</code>
</a>
</p>
<a class="indexterm" name="idm46045106209120">
</a>
<a class="indexterm" name="idm46045106207632">
</a>
<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=path
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
String
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
[none]
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Read given path from login file.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_mgm_no-login-paths">
</a>
<a class="link" href="mysql-cluster-programs-ndb-mgm.html#option_ndb_mgm_no-login-paths">
<code class="option">
--no-login-paths
</code>
</a>
</p>
<a class="indexterm" name="idm46045106193424">
</a>
<a class="indexterm" name="idm46045106191936">
</a>
<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>
<p>
Skips reading options from the login path file.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_mgm_ndb-connectstring">
</a>
<a class="link" href="mysql-cluster-programs-ndb-mgm.html#option_ndb_mgm_ndb-connectstring">
<code class="option">
--ndb-connectstring
</code>
</a>
</p>
<a class="indexterm" name="idm46045106182272">
</a>
<a class="indexterm" name="idm46045106180816">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for ndb-connectstring">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--ndb-connectstring=connection_string
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
String
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
[none]
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Set connect string for connecting to
<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>
. Syntax:
[
<code class="literal">
nodeid=
<em class="replaceable">
<code>
id
</code>
</em>
;
</code>
][
<code class="literal">
host=
</code>
]
<code class="literal">
<em class="replaceable">
<code>
hostname
</code>
</em>
</code>
[
<code class="literal">
:
<em class="replaceable">
<code>
port
</code>
</em>
</code>
].
Overrides entries in
<code class="literal">
NDB_CONNECTSTRING
</code>
and
<code class="filename">
my.cnf
</code>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_mgm_ndb-nodeid">
</a>
<a class="link" href="mysql-cluster-programs-ndb-mgm.html#option_ndb_mgm_ndb-nodeid">
<code class="option">
--ndb-nodeid
</code>
</a>
</p>
<a class="indexterm" name="idm46045106160208">
</a>
<a class="indexterm" name="idm46045106158720">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for ndb-nodeid">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--ndb-nodeid=#
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
Integer
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
[none]
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Set node ID for this node, overriding any ID set by
<a class="link" href="mysql-cluster-programs-ndb-mgm.html#option_ndb_mgm_ndb-connectstring">
<code class="option">
--ndb-connectstring
</code>
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_mgm_ndb-mgm-tls">
</a>
<a class="link" href="mysql-cluster-programs-ndb-mgm.html#option_ndb_mgm_ndb-mgm-tls">
<code class="option">
--ndb-mgm-tls
</code>
</a>
</p>
<a class="indexterm" name="idm46045106143440">
</a>
<a class="indexterm" name="idm46045106141952">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for ndb-mgm-tls">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--ndb-mgm-tls=level
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
Enumeration
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
relaxed
</code>
</td>
</tr>
<tr>
<th>
Valid Values
</th>
<td>
<p class="valid-value">
<code class="literal">
relaxed
</code>
</p>
<p class="valid-value">
<code class="literal">
strict
</code>
</p>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Sets the level of TLS support required to connect to the
management server; one of
<code class="literal">
relaxed
</code>
or
<code class="literal">
strict
</code>
.
<code class="literal">
relaxed
</code>
(the
default) means that a TLS connection is attempted, but
success is not required;
<code class="literal">
strict
</code>
means
that TLS is required to connect.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_mgm_ndb-mgmd-host">
</a>
<a class="link" href="mysql-cluster-programs-ndb-mgm.html#option_ndb_mgm_ndb-mgmd-host">
<code class="option">
--ndb-mgmd-host
</code>
</a>
</p>
<a class="indexterm" name="idm46045106120896">
</a>
<a class="indexterm" name="idm46045106119408">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for ndb-mgmd-host">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--ndb-mgmd-host=connection_string
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
String
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
[none]
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Same as
<a class="link" href="mysql-cluster-programs-ndb-mgm.html#option_ndb_mgm_ndb-connectstring">
<code class="option">
--ndb-connectstring
</code>
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_mgm_ndb-optimized-node-selection">
</a>
<a class="link" href="mysql-cluster-programs-ndb-mgm.html#option_ndb_mgm_ndb-optimized-node-selection">
<code class="option">
--ndb-optimized-node-selection
</code>
</a>
</p>
<a class="indexterm" name="idm46045106104144">
</a>
<a class="indexterm" name="idm46045106102640">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for ndb-optimized-node-selection">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--ndb-optimized-node-selection
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Enable optimizations for selection of nodes for
transactions. Enabled by default; use
<code class="option">
--skip-ndb-optimized-node-selection
</code>
to
disable.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_mgm_ndb-tls-search-path">
</a>
<a class="link" href="mysql-cluster-programs-ndb-mgm.html#option_ndb_mgm_ndb-tls-search-path">
<code class="option">
--ndb-tls-search-path
</code>
</a>
</p>
<a class="indexterm" name="idm46045106092288">
</a>
<a class="indexterm" name="idm46045106090832">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for ndb-tls-search-path">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--ndb-tls-search-path=list
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
Path name
</td>
</tr>
<tr>
<th>
Default Value (Unix)
</th>
<td>
<code class="literal">
$HOME/ndb-tls
</code>
</td>
</tr>
<tr>
<th>
Default Value (Windows)
</th>
<td>
<code class="literal">
$HOMEDIR/ndb-tls
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Specify a list of directories to search for a CA file. On
Unix platforms, the directory names are separated by colons
(
<code class="literal">
:
</code>
); on Windows systems, the semicolon
character (
<code class="literal">
;
</code>
) is used as the separator. A
directory reference may be relative or absolute; it may
contain one or more environment variables, each denoted by a
prefixed dollar sign (
<code class="literal">
$
</code>
), and expanded
prior to use.
</p>
<p>
Searching begins with the leftmost named directory and
proceeds from left to right until a file is found. An empty
string denotes an empty search path, which causes all
searches to fail. A string consisting of a single dot
(
<code class="literal">
.
</code>
) indicates that the search path
limited to the current working directory.
</p>
<p>
If no search path is supplied, the compiled-in default value
is used. This value depends on the platform used: On
Windows, this is
<code class="literal">
\ndb-tls
</code>
; on other
platforms (including Linux), it is
<code class="literal">
$HOME/ndb-tls
</code>
. This can be overridden by
compiling NDB Cluster using
<a class="link" href="source-configuration-options.html#option_cmake_with_ndb_tls_search_path">
<code class="option">
-DWITH_NDB_TLS_SEARCH_PATH
</code>
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_mgm_no-defaults">
</a>
<a class="link" href="mysql-cluster-programs-ndb-mgm.html#option_ndb_mgm_no-defaults">
<code class="option">
--no-defaults
</code>
</a>
</p>
<a class="indexterm" name="idm46045106067072">
</a>
<a class="indexterm" name="idm46045106065584">
</a>
<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>
<p>
Do not read default options from any option file other than
login file.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_mgm_print-defaults">
</a>
<a class="link" href="mysql-cluster-programs-ndb-mgm.html#option_ndb_mgm_print-defaults">
<code class="option">
--print-defaults
</code>
</a>
</p>
<a class="indexterm" name="idm46045106055696">
</a>
<a class="indexterm" name="idm46045106054208">
</a>
<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>
<p>
Print program argument list and exit.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_mgm_test-tls">
</a>
<a class="link" href="mysql-cluster-programs-ndb-mgm.html#option_ndb_mgm_test-tls">
<code class="option">
--test-tls
</code>
</a>
</p>
<a class="indexterm" name="idm46045106044720">
</a>
<a class="indexterm" name="idm46045106043232">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for test-tls">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--test-tls
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Connect using TLS, then exit. Output if successful is
similar to what is shown here:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa33989433"><div class="copy-help left">Press ⌘+C to 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">>$ ndb_mgm <span class="token property">--test-tls</span>
Connected to Management Server at<span class="token punctuation">:</span> sakila<span class="token punctuation">:</span>1186
>$</code></pre>
</div>
<p>
See
<a class="xref" href="mysql-cluster-tls.html" title="25.6.15 TLS Link Encryption for NDB Cluster">
Section 25.6.15, “TLS Link Encryption for NDB Cluster”
</a>
, for more
information.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_mgm_try-reconnect">
</a>
<a class="link" href="mysql-cluster-programs-ndb-mgm.html#option_ndb_mgm_try-reconnect">
<code class="option">
--try-reconnect=
<em class="replaceable">
<code>
number
</code>
</em>
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for try-reconnect">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--try-reconnect=#
</code>
</td>
</tr>
<tr>
<th>
Deprecated
</th>
<td>
Yes
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
Numeric
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
Integer
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
12
</code>
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
3
</code>
</td>
</tr>
<tr>
<th>
Minimum Value
</th>
<td>
<code class="literal">
0
</code>
</td>
</tr>
<tr>
<th>
Maximum Value
</th>
<td>
<code class="literal">
4294967295
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
If the connection to the management server is broken, the
node tries to reconnect to it every 5 seconds until it
succeeds. By using this option, it is possible to limit the
number of attempts to
<em class="replaceable">
<code>
number
</code>
</em>
before giving up and reporting an error instead.
</p>
<p>
This option is deprecated and subject to removal in a future
release. Use
<a class="link" href="mysql-cluster-programs-ndb-mgm.html#option_ndb_mgm_connect-retries">
<code class="option">
--connect-retries
</code>
</a>
, instead.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_mgm_usage">
</a>
<a class="link" href="mysql-cluster-programs-ndb-mgm.html#option_ndb_mgm_usage">
<code class="option">
--usage
</code>
</a>
</p>
<a class="indexterm" name="idm46045106004256">
</a>
<a class="indexterm" name="idm46045106002768">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for usage">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--usage
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Display help text and exit; same as
<a class="link" href="mysql-cluster-programs-ndb-mgm.html#option_ndb_mgm_help">
<code class="option">
--help
</code>
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_mgm_version">
</a>
<a class="link" href="mysql-cluster-programs-ndb-mgm.html#option_ndb_mgm_version">
<code class="option">
--version
</code>
</a>
</p>
<a class="indexterm" name="idm46045105992160">
</a>
<a class="indexterm" name="idm46045105990672">
</a>
<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>
<p>
Display version information and exit.
</p>
</li>
</ul>
</div>
<p>
Additional information about using
<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>
can be found in
<a class="xref" href="mysql-cluster-mgm-client-commands.html" title="25.6.1 Commands in the NDB Cluster Management Client">
Section 25.6.1, “Commands in the NDB Cluster Management Client”
</a>
.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/mysql-cluster-tcp-definition.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="mysql-cluster-tcp-definition">
</a>
25.4.3.10 NDB Cluster TCP/IP Connections
</h4>
</div>
</div>
</div>
<p>
TCP/IP is the default transport mechanism for all connections
between nodes in an NDB Cluster. Normally it is not necessary to
define TCP/IP connections; NDB Cluster automatically sets up
such connections for all data nodes, management nodes, and SQL
or API nodes.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
For an exception to this rule, see
<a class="xref" href="mysql-cluster-tcp-definition-direct.html" title="25.4.3.11 NDB Cluster TCP/IP Connections Using Direct Connections">
Section 25.4.3.11, “NDB Cluster TCP/IP Connections Using Direct Connections”
</a>
.
</p>
</div>
<p>
To override the default connection parameters, it is necessary
to define a connection using one or more
<code class="literal">
[tcp]
</code>
sections in the
<code class="filename">
config.ini
</code>
file. Each
<code class="literal">
[tcp]
</code>
section explicitly defines a TCP/IP
connection between two NDB Cluster nodes, and must contain at a
minimum the parameters
<a class="link" href="mysql-cluster-tcp-definition.html#ndbparam-tcp-nodeid1">
<code class="literal">
NodeId1
</code>
</a>
and
<a class="link" href="mysql-cluster-tcp-definition.html#ndbparam-tcp-nodeid2">
<code class="literal">
NodeId2
</code>
</a>
, as well as any
connection parameters to override.
</p>
<p>
It is also possible to change the default values for these
parameters by setting them in the
<code class="literal">
[tcp
default]
</code>
section.
</p>
<div class="important" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Important
</div>
<p>
Any
<code class="literal">
[tcp]
</code>
sections in the
<code class="filename">
config.ini
</code>
file should be listed
<span class="emphasis">
<em>
last
</em>
</span>
, following all other sections in the
file. However, this is not required for a
<code class="literal">
[tcp
default]
</code>
section. This requirement is a known issue
with the way in which the
<code class="filename">
config.ini
</code>
file
is read by the NDB Cluster management server.
</p>
</div>
<p>
Connection parameters which can be set in
<code class="literal">
[tcp]
</code>
and
<code class="literal">
[tcp default]
</code>
sections of the
<code class="filename">
config.ini
</code>
file are listed
here:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a name="ndbparam-tcp-allowunresolvedhostnames">
</a>
<code class="literal">
AllowUnresolvedHostNames
</code>
</p>
<a class="indexterm" name="idm46045109570832">
</a>
<div class="informaltable">
<a name="allowunresolvedhostnames-tcp-table">
</a>
<table frame="box" rules="all" summary="AllowUnresolvedHostNames TCP 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>
By default, when a management node fails to resolve a host
name while trying to connect, this results in a fatal error.
This behavior can be overridden by setting
<code class="literal">
AllowUnresolvedHostNames
</code>
to
<code class="literal">
true
</code>
in the
<code class="literal">
[tcp
default]
</code>
section of the global configuration file
(usually named
<code class="filename">
config.ini
</code>
), in which
case failure to resolve a host name is treated as a warning
and
<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>
startup continues
uninterrupted.
</p>
</li>
<li class="listitem">
<p>
<a name="ndbparam-tcp-checksum">
</a>
<code class="literal">
Checksum
</code>
</p>
<a class="indexterm" name="idm46045109546400">
</a>
<div class="informaltable">
<a name="checksum-tcp-table">
</a>
<table frame="box" rules="all" summary="Checksum TCP 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>
This parameter is disabled by default. When it is enabled
(set to
<code class="literal">
Y
</code>
or
<code class="literal">
1
</code>
),
checksums for all messages are calculated before they placed
in the send buffer. This feature ensures that messages are
not corrupted while waiting in the send buffer, or by the
transport mechanism.
</p>
</li>
<li class="listitem">
<p>
<a name="ndbparam-tcp-group">
</a>
<code class="literal">
Group
</code>
</p>
<p>
When
<a class="link" href="mysql-cluster-options-variables.html#sysvar_ndb_optimized_node_selection">
<code class="literal">
ndb_optimized_node_selection
</code>
</a>
is enabled, node proximity is used in some cases to select
which node to connect to. This parameter can be used to
influence proximity by setting it to a lower value, which is
interpreted as
<span class="quote">
“
<span class="quote">
closer
</span>
”
</span>
. See the description of
the system variable for more information.
</p>
</li>
<li class="listitem">
<p>
<a name="ndbparam-tcp-hostname1">
</a>
<code class="literal">
HostName1
</code>
</p>
<a class="indexterm" name="idm46045109520624">
</a>
<div class="informaltable">
<a name="hostname1-tcp-table">
</a>
<table frame="box" rules="all" summary="HostName1 TCP 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>
The
<code class="literal">
HostName1
</code>
and
<a class="link" href="mysql-cluster-tcp-definition.html#ndbparam-tcp-hostname2">
<code class="literal">
HostName2
</code>
</a>
parameters
can be used to specify specific network interfaces to be
used for a given TCP connection between two nodes. The
values used for these parameters can be host names or IP
addresses.
</p>
</li>
<li class="listitem">
<p>
<a name="ndbparam-tcp-hostname2">
</a>
<code class="literal">
HostName2
</code>
</p>
<a class="indexterm" name="idm46045109498688">
</a>
<div class="informaltable">
<a name="hostname2-tcp-table">
</a>
<table frame="box" rules="all" summary="HostName2 TCP 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>
The
<a class="link" href="mysql-cluster-tcp-definition.html#ndbparam-tcp-hostname1">
<code class="literal">
HostName1
</code>
</a>
and
<code class="literal">
HostName2
</code>
parameters can be used to
specify specific network interfaces to be used for a given
TCP connection between two nodes. The values used for these
parameters can be host names or IP addresses.
</p>
</li>
<li class="listitem">
<p>
<a name="ndbparam-tcp-nodeid1">
</a>
<code class="literal">
NodeId1
</code>
</p>
<a class="indexterm" name="idm46045109476768">
</a>
<div class="informaltable">
<a name="nodeid1-tcp-table">
</a>
<table frame="box" rules="all" summary="NodeId1 TCP 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>
numeric
</td>
</tr>
<tr>
<th>
Default
</th>
<td>
[none]
</td>
</tr>
<tr>
<th>
Range
</th>
<td>
1 - 255
</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>
To identify a connection between two nodes it is necessary
to provide their node IDs in the
<code class="literal">
[tcp]
</code>
section of the configuration file as the values of
<code class="literal">
NodeId1
</code>
and
<a class="link" href="mysql-cluster-tcp-definition.html#ndbparam-tcp-nodeid2">
<code class="literal">
NodeId2
</code>
</a>
. These are
the same unique
<code class="literal">
Id
</code>
values for each of
these nodes as described in
<a class="xref" href="mysql-cluster-api-definition.html" title="25.4.3.7 Defining SQL and Other API Nodes in an NDB Cluster">
Section 25.4.3.7, “Defining SQL and Other API Nodes in an NDB Cluster”
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="ndbparam-tcp-nodeid2">
</a>
<code class="literal">
NodeId2
</code>
</p>
<a class="indexterm" name="idm46045109452624">
</a>
<div class="informaltable">
<a name="nodeid2-tcp-table">
</a>
<table frame="box" rules="all" summary="NodeId2 TCP 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>
numeric
</td>
</tr>
<tr>
<th>
Default
</th>
<td>
[none]
</td>
</tr>
<tr>
<th>
Range
</th>
<td>
1 - 255
</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>
To identify a connection between two nodes it is necessary
to provide their node IDs in the
<code class="literal">
[tcp]
</code>
section of the configuration file as the values of
<a class="link" href="mysql-cluster-tcp-definition.html#ndbparam-tcp-nodeid1">
<code class="literal">
NodeId1
</code>
</a>
and
<code class="literal">
NodeId2
</code>
. These are the same unique
<code class="literal">
Id
</code>
values for each of these nodes as
described in
<a class="xref" href="mysql-cluster-api-definition.html" title="25.4.3.7 Defining SQL and Other API Nodes in an NDB Cluster">
Section 25.4.3.7, “Defining SQL and Other API Nodes in an NDB Cluster”
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="ndbparam-tcp-nodeidserver">
</a>
<a class="link" href="mysql-cluster-tcp-definition.html#ndbparam-tcp-nodeidserver">
<code class="literal">
NodeIdServer
</code>
</a>
</p>
<a class="indexterm" name="idm46045109427968">
</a>
<a class="indexterm" name="idm46045109426896">
</a>
<div class="informaltable">
<a name="nodeidserver-tcp-table">
</a>
<table frame="box" rules="all" summary="NodeIdServer TCP 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>
numeric
</td>
</tr>
<tr>
<th>
Default
</th>
<td>
[none]
</td>
</tr>
<tr>
<th>
Range
</th>
<td>
1 - 63
</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 server side of a TCP connection.
</p>
</li>
<li class="listitem">
<p>
<a name="ndbparam-tcp-overloadlimit">
</a>
<code class="literal">
OverloadLimit
</code>
</p>
<a class="indexterm" name="idm46045109406624">
</a>
<div class="informaltable">
<a name="overloadlimit-tcp-table">
</a>
<table frame="box" rules="all" summary="OverloadLimit TCP 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 - 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>
When more than this many unsent bytes are in the send
buffer, the connection is considered overloaded.
</p>
<p>
This parameter can be used to determine the amount of unsent
data that must be present in the send buffer before the
connection is considered overloaded. 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>
, for
more information.
</p>
</li>
<li class="listitem">
<p>
<a name="ndbparam-tcp-preferipversion">
</a>
<a class="link" href="mysql-cluster-tcp-definition.html#ndbparam-tcp-preferipversion">
<code class="literal">
PreferIPVersion
</code>
</a>
</p>
<a class="indexterm" name="idm46045109384880">
</a>
<div class="informaltable">
<a name="preferipversion-tcp-table">
</a>
<table frame="box" rules="all" summary="PreferIPVersion TCP 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>
enumeration
</td>
</tr>
<tr>
<th>
Default
</th>
<td>
4
</td>
</tr>
<tr>
<th>
Range
</th>
<td>
4, 6
</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>
Determines the preference of DNS resolution for IP version 4
or version 6. Because the configuration retrieval mechanism
employed by NDB Cluster requires that all connections use
the same preference, this parameter should be set in the
<code class="literal">
[tcp default]
</code>
of the
<code class="filename">
config.ini
</code>
global configuration file.
</p>
</li>
<li class="listitem">
<p>
<a name="ndbparam-tcp-presendchecksum">
</a>
<a class="link" href="mysql-cluster-tcp-definition.html#ndbparam-tcp-presendchecksum">
<code class="literal">
PreSendChecksum
</code>
</a>
</p>
<a class="indexterm" name="idm46045109362656">
</a>
<div class="informaltable">
<a name="presendchecksum-tcp-table">
</a>
<table frame="box" rules="all" summary="PreSendChecksum TCP 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>
If this parameter and
<a class="link" href="mysql-cluster-tcp-definition.html#ndbparam-tcp-checksum">
<code class="literal">
Checksum
</code>
</a>
are both
enabled, perform pre-send checksum checks, and check all TCP
signals between nodes for errors. Has no effect if
<code class="literal">
Checksum
</code>
is not also enabled.
</p>
</li>
<li class="listitem">
<p>
<a name="ndbparam-tcp-proxy">
</a>
<a class="link" href="mysql-cluster-tcp-definition.html#ndbparam-tcp-proxy">
<code class="literal">
Proxy
</code>
</a>
</p>
<a class="indexterm" name="idm46045109340304">
</a>
<a class="indexterm" name="idm46045109339232">
</a>
<div class="informaltable">
<a name="proxy-tcp-table">
</a>
<table frame="box" rules="all" summary="Proxy TCP 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 a proxy for the TCP connection.
</p>
</li>
<li class="listitem">
<p>
<a name="ndbparam-tcp-receivebuffermemory">
</a>
<a class="link" href="mysql-cluster-tcp-definition.html#ndbparam-tcp-receivebuffermemory">
<code class="literal">
ReceiveBufferMemory
</code>
</a>
</p>
<a class="indexterm" name="idm46045109318400">
</a>
<div class="informaltable">
<a name="receivebuffermemory-tcp-table">
</a>
<table frame="box" rules="all" summary="ReceiveBufferMemory TCP 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>
2M
</td>
</tr>
<tr>
<th>
Range
</th>
<td>
16K - 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>
Specifies the size of the buffer used when receiving data
from the TCP/IP socket.
</p>
<p>
The default value of this parameter is 2MB. The minimum
possible value is 16KB; the theoretical maximum is 4GB.
</p>
</li>
<li class="listitem">
<p>
<a name="ndbparam-tcp-requirelinktls">
</a>
<a class="link" href="mysql-cluster-tcp-definition.html#ndbparam-tcp-requirelinktls">
<code class="literal">
RequireLinkTls
</code>
</a>
</p>
<a class="indexterm" name="idm46045109297376">
</a>
<div class="informaltable">
<a name="requirelinktls-tcp-table">
</a>
<table frame="box" rules="all" summary="RequireLinkTls TCP 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 the node at either endpoint of this TCP connection
requires TLS authentication, the value of this parameter is
<code class="literal">
true
</code>
, otherwise
<code class="literal">
false
</code>
.
The value is set by
<code class="literal">
NDB
</code>
, and cannot be
changed by the user.
</p>
</li>
<li class="listitem">
<p>
<a name="ndbparam-tcp-sendbuffermemory">
</a>
<a class="link" href="mysql-cluster-tcp-definition.html#ndbparam-tcp-sendbuffermemory">
<code class="literal">
SendBufferMemory
</code>
</a>
</p>
<a class="indexterm" name="idm46045109274704">
</a>
<div class="informaltable">
<a name="sendbuffermemory-tcp-table">
</a>
<table frame="box" rules="all" summary="SendBufferMemory TCP 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>
2M
</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>
TCP transporters use a buffer to store all messages before
performing the send call to the operating system. When this
buffer reaches 64KB its contents are sent; these are also
sent when a round of messages have been executed. To handle
temporary overload situations it is also possible to define
a bigger send buffer.
</p>
<p>
If this parameter is set explicitly, then the memory is not
dedicated to each transporter; instead, the value used
denotes the hard limit for how much memory (out of the total
available memory—that is,
<code class="literal">
TotalSendBufferMemory
</code>
) that may be used
by a single transporter. For more information about
configuring dynamic transporter send buffer memory
allocation in NDB Cluster, 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>
<p>
The default size of the send buffer is 2MB, which is the
size recommended in most situations. The minimum size is 64
KB; the theoretical maximum is 4 GB.
</p>
</li>
<li class="listitem">
<p>
<a name="ndbparam-tcp-sendsignalid">
</a>
<code class="literal">
SendSignalId
</code>
</p>
<a class="indexterm" name="idm46045109251344">
</a>
<div class="informaltable">
<a name="sendsignalid-tcp-table">
</a>
<table frame="box" rules="all" summary="SendSignalId TCP 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 (debug builds: true)
</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>
To be able to retrace a distributed message datagram, it is
necessary to identify each message. When this parameter is
set to
<code class="literal">
Y
</code>
, message IDs are transported
over the network. This feature is disabled by default in
production builds, and enabled in
<code class="literal">
-debug
</code>
builds.
</p>
</li>
<li class="listitem">
<p>
<a name="ndbparam-tcp-tcpbind_inaddr_any">
</a>
<code class="literal">
TcpBind_INADDR_ANY
</code>
</p>
<p>
Setting this parameter to
<code class="literal">
TRUE
</code>
or
<code class="literal">
1
</code>
binds
<code class="literal">
IP_ADDR_ANY
</code>
so
that connections can be made from anywhere (for
autogenerated connections). The default is
<code class="literal">
FALSE
</code>
(
<code class="literal">
0
</code>
).
</p>
</li>
<li class="listitem">
<p>
<a name="ndbparam-tcp-tcpspintime">
</a>
<a class="link" href="mysql-cluster-tcp-definition.html#ndbparam-tcp-tcpspintime">
<code class="literal">
TcpSpinTime
</code>
</a>
</p>
<a class="indexterm" name="idm46045109223312">
</a>
<div class="informaltable">
<a name="tcpspintime-tcp-table">
</a>
<table frame="box" rules="all" summary="TcpSpinTime TCP 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>
µsec
</td>
</tr>
<tr>
<th>
Default
</th>
<td>
0
</td>
</tr>
<tr>
<th>
Range
</th>
<td>
0 - 2000
</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>
Controls spin for a TCP transporter; no enable, set to a
nonzero value. This works for both the data node and
management or SQL node side of the connection.
</p>
</li>
<li class="listitem">
<p>
<a name="ndbparam-tcp-tcp_maxseg_size">
</a>
<a class="link" href="mysql-cluster-tcp-definition.html#ndbparam-tcp-tcp_maxseg_size">
<code class="literal">
TCP_MAXSEG_SIZE
</code>
</a>
</p>
<a class="indexterm" name="idm46045109202864">
</a>
<div class="informaltable">
<a name="tcp_maxseg_size-tcp-table">
</a>
<table frame="box" rules="all" summary="TCP_MAXSEG_SIZE TCP 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>
0
</td>
</tr>
<tr>
<th>
Range
</th>
<td>
0 - 2G
</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>
Determines the size of the memory set during TCP transporter
initialization. The default is recommended for most common
usage cases.
</p>
</li>
<li class="listitem">
<p>
<a name="ndbparam-tcp-tcp_rcv_buf_size">
</a>
<a class="link" href="mysql-cluster-tcp-definition.html#ndbparam-tcp-tcp_rcv_buf_size">
<code class="literal">
TCP_RCV_BUF_SIZE
</code>
</a>
</p>
<a class="indexterm" name="idm46045109182352">
</a>
<div class="informaltable">
<a name="tcp_rcv_buf_size-tcp-table">
</a>
<table frame="box" rules="all" summary="TCP_RCV_BUF_SIZE TCP 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>
0
</td>
</tr>
<tr>
<th>
Range
</th>
<td>
0 - 2G
</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>
Determines the size of the receive buffer set during TCP
transporter initialization. The default and minimum value is
0, which allows the operating system or platform to set this
value. The default is recommended for most common usage
cases.
</p>
</li>
<li class="listitem">
<p>
<a name="ndbparam-tcp-tcp_snd_buf_size">
</a>
<a class="link" href="mysql-cluster-tcp-definition.html#ndbparam-tcp-tcp_snd_buf_size">
<code class="literal">
TCP_SND_BUF_SIZE
</code>
</a>
</p>
<a class="indexterm" name="idm46045109161760">
</a>
<div class="informaltable">
<a name="tcp_snd_buf_size-tcp-table">
</a>
<table frame="box" rules="all" summary="TCP_SND_BUF_SIZE TCP 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>
0
</td>
</tr>
<tr>
<th>
Range
</th>
<td>
0 - 2G
</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>
Determines the size of the send buffer set during TCP
transporter initialization. The default and minimum value is
0, which allows the operating system or platform to set this
value. The default is recommended for most common usage
cases.
</p>
</li>
</ul>
</div>
<p>
<a name="mysql-cluster-tcp-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="idm46045109141424">
</a>
<p class="title">
<b>
Table 25.20 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/replication-mode-change-online-enable-gtids.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="replication-mode-change-online-enable-gtids">
</a>
19.1.4.2 Enabling GTID Transactions Online
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045145438720">
</a>
<p>
This section describes how to enable GTID transactions, and
optionally auto-positioning, on servers that are already online
and using anonymous transactions. This procedure does not require
taking the server offline and is suited to use in production.
However, if you have the possibility to take the servers offline
when enabling GTID transactions that process is easier.
</p>
<p>
You can set up replication channels to assign GTIDs to replicated
transactions that do not already have any. This feature enables
replication from a source server that does not use GTID-based
replication, to a replica that does. If it is possible to enable
GTIDs on the replication source server, as described in this
procedure, use this approach instead. Assigning GTIDs is designed
for replication source servers where you cannot enable GTIDs. For
more information on this option, see
<a class="xref" href="replication-gtids-assign-anon.html" title="19.1.3.6 Replication From a Source Without GTIDs to a Replica With GTIDs">
Section 19.1.3.6, “Replication From a Source Without GTIDs to a Replica With GTIDs”
</a>
.
</p>
<p>
Before you start, ensure that
<a class="link" href="replication-options-gtids.html#sysvar_gtid_mode">
<code class="literal">
gtid_mode
</code>
</a>
is
<code class="literal">
OFF
</code>
on all servers.
</p>
<p>
The following procedure can be paused at any time and later
resumed where it was, or reversed by jumping to the corresponding
step of
<a class="xref" href="replication-mode-change-online-disable-gtids.html" title="19.1.4.3 Disabling GTID Transactions Online">
Section 19.1.4.3, “Disabling GTID Transactions Online”
</a>
,
the online procedure to disable GTIDs. This makes the procedure
fault-tolerant because any unrelated issues that may appear in the
middle of the procedure can be handled as usual, and then the
procedure continued where it was left off.
</p>
<p>
To enable GTID transactions, you must complete each of the
following steps before continuing to the next one.
</p>
<div class="orderedlist">
<ol class="orderedlist" type="1">
<li class="listitem">
<p>
On each server, execute the following statement:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa78529951"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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">@@GLOBAL.enforce_gtid_consistency</span> <span class="token operator">=</span> WARN<span class="token punctuation">;</span></code></pre>
</div>
<p>
Let the server run for a while with your normal workload and
monitor the logs. If this step causes any warnings in the log,
adjust your application so that it only uses GTID-compatible
features and does not generate any warnings.
</p>
</li>
<li class="listitem">
<p>
On each server, execute this statement:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa10124416"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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">@@GLOBAL.enforce_gtid_consistency</span> <span class="token operator">=</span> <span class="token keyword">ON</span><span class="token punctuation">;</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
On each server, execute the following statement:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa34830458"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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">@@GLOBAL.gtid_mode</span> <span class="token operator">=</span> OFF_PERMISSIVE<span class="token punctuation">;</span></code></pre>
</div>
<p>
The order in which the servers execute this statement makes no
difference, but all servers must do so before beginning the
next step.
</p>
</li>
<li class="listitem">
<p>
On each server, execute the followng statement:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa33810939"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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">@@GLOBAL.gtid_mode</span> <span class="token operator">=</span> ON_PERMISSIVE<span class="token punctuation">;</span></code></pre>
</div>
<p>
As in the previous step, it makes no difference which server
executes the statement first, as long as each server does so
before proceeding further.
</p>
</li>
<li class="listitem">
<p>
On each server, wait until
<a class="link" href="server-status-variables.html#statvar_Ongoing_anonymous_transaction_count">
<code class="literal">
Ongoing_anonymous_transaction_count
</code>
</a>
is
<code class="literal">
0
</code>
. You can check its value using a
<a class="link" href="show-status.html" title="15.7.7.37 SHOW STATUS Statement">
<code class="literal">
SHOW STATUS
</code>
</a>
statement, like
this:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa73846659"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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">STATUS</span> <span class="token operator">LIKE</span> <span class="token string">'Ongoing%'</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> 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 class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> Ongoing_anonymous_transaction_count <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>
<span class="token output">1 row in set (0.00 sec)</span></code></pre>
</div>
<p>
On a replica, it is theoretically possible that this is
<code class="literal">
0
</code>
and then a nonzero value again. This is
not a problem, as long as it is
<code class="literal">
0
</code>
at least
once.
</p>
</li>
<li class="listitem">
<p>
Wait for all transactions generated up to the previous step to
replicate to all servers. You can do this without stopping
updates; what matters is that all anonymous transactions are
replicated before proceeding further.
</p>
<p>
See
<a class="xref" href="replication-mode-change-online-verify-transactions.html" title="19.1.4.4 Verifying Replication of Anonymous Transactions">
Section 19.1.4.4, “Verifying Replication of Anonymous Transactions”
</a>
for one method of checking that all anonymous transactions
have replicated to all servers.
</p>
</li>
<li class="listitem">
<p>
If you use binary logs for anything other than replication,
such as point-in-time backup and restore, wait until you no
longer need the old binary logs containing transactions
without GTIDs.
</p>
<p>
For instance, after all transactions have been replicated, you
can execute
<a class="link" href="flush.html#flush-logs">
<code class="literal">
FLUSH LOGS
</code>
</a>
on the
server where you are taking backups. Then either explicitly
take a backup or wait for the next iteration of any periodic
backup routine you may have set up.
</p>
<p>
Ideally, you should wait for the server to purge all binary
logs that existed when the previous step was completed, and
for any backup taken before then to expire.
</p>
<p>
Keep in mind that binary logs containing anonymous
transactions (that is, transactions without GTIDs) cannot be
used following the next step, after which, you must make sure
that no transactions without GTIDs remain uncommitted on any
server.
</p>
</li>
<li class="listitem">
<p>
On each server, execute this statement:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa94025864"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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">@@GLOBAL.GTID_MODE</span> <span class="token operator">=</span> <span class="token keyword">ON</span><span class="token punctuation">;</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
On each server, add
<code class="literal">
gtid-mode=ON
</code>
and
<code class="literal">
enforce-gtid-consistency=ON
</code>
to
<code class="filename">
my.cnf
</code>
. This guarantees that GTIDs are
used for all transactions which have not already been
processed. To start using the GTID protocol so that you can
later perform automatic failover, execute the the next set of
statements on each replica. If you use multi-source
replication, do this for each channel, including the
<code class="literal">
FOR CHANNEL
<em class="replaceable">
<code>
channel
</code>
</em>
</code>
clause:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa87470205"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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">STOP</span> <span class="token keyword">REPLICA</span> <span class="token punctuation">[</span><span class="token keyword">FOR</span> <span class="token keyword">CHANNEL</span> <span class="token string">'<em class="replaceable">channel</em>'</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">SOURCE</span> <span class="token keyword">TO</span> <span class="token keyword">SOURCE_AUTO_POSITION</span> <span class="token operator">=</span> <span class="token number">1</span> <span class="token punctuation">[</span><span class="token keyword">FOR</span> <span class="token keyword">CHANNEL</span> <span class="token string">'<em class="replaceable">channel</em>'</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
<span class="token keyword">START</span> <span class="token keyword">REPLICA</span> <span class="token punctuation">[</span><span class="token keyword">FOR</span> <span class="token keyword">CHANNEL</span> <span class="token string">'<em class="replaceable">channel</em>'</span><span class="token punctuation">]</span><span class="token punctuation">;</span></code></pre>
</div>
</li>
</ol>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/replication-encrypted-connections.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="replication-encrypted-connections">
</a>
19.3.1 Setting Up Replication to Use Encrypted Connections
</h3>
</div>
</div>
</div>
<p>
To use an encrypted connection for the transfer of the binary log
required during replication, both the source and the replica
servers must support encrypted network connections. If either
server does not support encrypted connections (because it has not
been compiled or configured for them), replication through an
encrypted connection is not possible.
</p>
<p>
Setting up encrypted connections for replication is similar to
doing so for client/server connections. You must obtain (or
create) a suitable security certificate that you can use on the
source, and a similar certificate (from the same certificate
authority) on each replica. You must also obtain suitable key
files.
</p>
<p>
For more information on setting up a server and client for
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>
.
</p>
<p>
To enable encrypted connections on the source, you must create or
obtain suitable certificate and key files, and then add the
following configuration parameters to the
<code class="literal">
[mysqld]
</code>
section of the source
<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="sa67142327"><div class="copy-help left">Press ⌘+C to 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>cacert.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>
The paths to the files may be relative or absolute; we recommend
that you always use complete paths for this purpose.
</p>
<p>
The configuration parameters are as follows:
</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>
To enable encrypted connections on the replica, use 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.
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
To name the replica's certificate and SSL private key
files using
<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>
, add the appropriate
<code class="literal">
SOURCE_SSL_
<em class="replaceable">
<code>
xxx
</code>
</em>
</code>
options, like this:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa98331123"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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"> -></span> <span class="token keyword">SOURCE_SSL_CA</span> <span class="token operator">=</span> <span class="token string">'ca_file_name'</span><span class="token punctuation">,</span>
<span class="token prompt"> -></span> <span class="token keyword">SOURCE_SSL_CAPATH</span> <span class="token operator">=</span> <span class="token string">'ca_directory_name'</span><span class="token punctuation">,</span>
<span class="token prompt"> -></span> <span class="token keyword">SOURCE_SSL_CERT</span> <span class="token operator">=</span> <span class="token string">'cert_file_name'</span><span class="token punctuation">,</span>
<span class="token prompt"> -></span> <span class="token keyword">SOURCE_SSL_KEY</span> <span class="token operator">=</span> <span class="token string">'key_file_name'</span><span class="token punctuation">,</span></code></pre>
</div>
<p>
These options correspond to the
<code class="option">
--ssl-
<em class="replaceable">
<code>
xxx
</code>
</em>
</code>
options
with the same names, as described in
<a class="xref" href="connection-options.html#encrypted-connection-options" title="Command Options for Encrypted Connections">
Command Options for Encrypted Connections
</a>
. For these
options to take effect,
<code class="literal">
SOURCE_SSL=1
</code>
must
also be set. For a replication connection, specifying a value
for either of
<code class="literal">
SOURCE_SSL_CA
</code>
or
<code class="literal">
SOURCE_SSL_CAPATH
</code>
corresponds to setting
<code class="option">
--ssl-mode=VERIFY_CA
</code>
. The connection attempt
succeeds only if a valid matching Certificate Authority (CA)
certificate is found using the specified information.
</p>
</li>
<li class="listitem">
<p>
To activate host name identity verification, add the
<code class="literal">
SOURCE_SSL_VERIFY_SERVER_CERT
</code>
option, like
this:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa71568071"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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"> -></span> <span class="token keyword">SOURCE_SSL_VERIFY_SERVER_CERT</span><span class="token operator">=</span><span class="token number">1</span><span class="token punctuation">,</span></code></pre>
</div>
<p>
For a replication connection, specifying
<code class="literal">
SOURCE_SSL_VERIFY_SERVER_CERT=1
</code>
corresponds
to setting
<code class="option">
--ssl-mode=VERIFY_IDENTITY
</code>
, as
described in
<a class="xref" href="connection-options.html#encrypted-connection-options" title="Command Options for Encrypted Connections">
Command Options for Encrypted Connections
</a>
.
For this option to take effect,
<code class="literal">
SOURCE_SSL=1
</code>
must also be set. Host name
identity verification does not work with self-signed
certificates.
</p>
</li>
<li class="listitem">
<p>
To activate certificate revocation list (CRL) checks, add the
<code class="literal">
SOURCE_SSL_CRL
</code>
or
<code class="literal">
SOURCE_SSL_CRLPATH
</code>
option, as shown here:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa2573113"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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"> -></span> <span class="token keyword">SOURCE_SSL_CRL</span> <span class="token operator">=</span> <span class="token string">'crl_file_name'</span><span class="token punctuation">,</span>
<span class="token prompt"> -></span> <span class="token keyword">SOURCE_SSL_CRLPATH</span> <span class="token operator">=</span> <span class="token string">'crl_directory_name'</span><span class="token punctuation">,</span></code></pre>
</div>
<p>
These options correspond to the
<code class="option">
--ssl-
<em class="replaceable">
<code>
xxx
</code>
</em>
</code>
options
with the same names, as described in
<a class="xref" href="connection-options.html#encrypted-connection-options" title="Command Options for Encrypted Connections">
Command Options for Encrypted Connections
</a>
. If they are
not specified, no CRL checking takes place.
</p>
</li>
<li class="listitem">
<p>
To specify lists of ciphers, ciphersuites, and encryption
protocols permitted by the replica for the replication
connection, use the
<code class="literal">
SOURCE_SSL_CIPHER
</code>
,
<code class="literal">
SOURCE_TLS_VERSION
</code>
, and
<code class="literal">
SOURCE_TLS_CIPHERSUITES
</code>
options, like this:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa90286653"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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"> -></span> <span class="token keyword">SOURCE_SSL_CIPHER</span> <span class="token operator">=</span> <span class="token string">'cipher_list'</span><span class="token punctuation">,</span>
<span class="token prompt"> -></span> <span class="token keyword">SOURCE_TLS_VERSION</span> <span class="token operator">=</span> <span class="token string">'protocol_list'</span><span class="token punctuation">,</span>
<span class="token prompt"> -></span> <span class="token keyword">SOURCE_TLS_CIPHERSUITES</span> <span class="token operator">=</span> <span class="token string">'ciphersuite_list'</span><span class="token punctuation">,</span></code></pre>
</div>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
The
<code class="literal">
SOURCE_SSL_CIPHER
</code>
option specifies
a colon-separated list of one or more ciphers permitted by
the replica for the replication connection.
</p>
</li>
<li class="listitem">
<p>
The
<code class="literal">
SOURCE_TLS_VERSION
</code>
option specifies
a comma-separated list of the TLS encryption protocols
permitted by the replica for the replication connection,
in a format like that for the
<a class="link" href="server-system-variables.html#sysvar_tls_version">
<code class="literal">
tls_version
</code>
</a>
server system
variable. The connection procedure negotiates the use of
the highest TLS version that both the source and the
replica permit. To be able to connect, the replica must
have at least one TLS version in common with the source.
</p>
</li>
<li class="listitem">
<p>
The
<code class="literal">
SOURCE_TLS_CIPHERSUITES
</code>
option
specifies a colon-separated list of one or more
ciphersuites that are permitted by the replica for the
replication connection if TLSv1.3 is used for the
connection. If this option is set to
<code class="literal">
NULL
</code>
when TLSv1.3 is used (which is the
default if you do not set the option), the ciphersuites
that are enabled by default are allowed. If you set the
option to an empty string, no cipher suites are allowed,
and TLSv1.3 is therefore not used.
</p>
</li>
</ul>
</div>
<p>
The protocols, ciphers, and ciphersuites that you can specify
in these lists depend on the SSL library used to compile
MySQL. For information about the formats, the permitted
values, and the defaults if you do not specify the options,
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>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
You can use the
<code class="literal">
SOURCE_TLS_CIPHERSUITES
</code>
option to specify any selection of ciphersuites, including
only non-default ciphersuites if you want.
</p>
</div>
</li>
<li class="listitem">
<p>
After the source information has been updated, start the
replication process on the replica, like this:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa60707337"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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">START</span> <span class="token keyword">REPLICA</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
You can use 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>
statement to confirm that an encrypted
connection was established successfully.
</p>
</li>
<li class="listitem">
<p>
Requiring encrypted connections on the replica does not ensure
that the source requires encrypted connections from replicas.
If you want to ensure that the source only accepts replicas
that connect using encrypted connections, create a replication
user account on the source using the
<code class="literal">
REQUIRE
SSL
</code>
option, then grant that user the
<a class="link" href="privileges-provided.html#priv_replication-slave">
<code class="literal">
REPLICATION SLAVE
</code>
</a>
privilege.
For example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa13922875"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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">'repl'</span>@<span class="token string">'%.example.com'</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 prompt"> -></span> <span class="token keyword">REQUIRE</span> <span class="token keyword">SSL</span><span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">GRANT</span> <span class="token keyword">REPLICATION</span> <span class="token keyword">SLAVE</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 prompt"> -></span> <span class="token keyword">TO</span> <span class="token string">'repl'</span>@<span class="token string">'%.example.com'</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
If you have an existing replication user account on the
source, you can add
<code class="literal">
REQUIRE SSL
</code>
to it with
this statement:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa64691426"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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">USER</span> <span class="token string">'repl'</span>@<span class="token string">'%.example.com'</span> <span class="token keyword">REQUIRE</span> <span class="token keyword">SSL</span><span class="token punctuation">;</span></code></pre>
</div>
</li>
</ul>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/query-issues.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="query-issues">
</a>
B.3.4 Query-Related Issues
</h3>
</div>
</div>
</div>
<div class="toc">
<dl class="toc">
<dt>
<span class="section">
<a href="case-sensitivity.html">
B.3.4.1 Case Sensitivity in String Searches
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="using-date.html">
B.3.4.2 Problems Using DATE Columns
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="problems-with-null.html">
B.3.4.3 Problems with NULL Values
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="problems-with-alias.html">
B.3.4.4 Problems with Column Aliases
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="nontransactional-tables.html">
B.3.4.5 Rollback Failure for Nontransactional Tables
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="deleting-from-related-tables.html">
B.3.4.6 Deleting Rows from Related Tables
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="no-matching-rows.html">
B.3.4.7 Solving Problems with No Matching Rows
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="problems-with-float.html">
B.3.4.8 Problems with Floating-Point Values
</a>
</span>
</dt>
</dl>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/installing-source-distribution.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="installing-source-distribution">
</a>
2.8.4 Installing MySQL Using a Standard Source Distribution
</h3>
</div>
</div>
</div>
<p>
To install MySQL from a standard source distribution:
</p>
<div class="orderedlist">
<ol class="orderedlist" type="1">
<li class="listitem">
<p>
Verify that your system satisfies the tool requirements listed
at
<a class="xref" href="source-installation-prerequisites.html" title="2.8.2 Source Installation Prerequisites">
Section 2.8.2, “Source Installation Prerequisites”
</a>
.
</p>
</li>
<li class="listitem">
<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>
.
</p>
</li>
<li class="listitem">
<p>
Configure, build, and install the distribution using the
instructions in this section.
</p>
</li>
<li class="listitem">
<p>
Perform postinstallation procedures using the instructions in
<a class="xref" href="postinstallation.html" title="2.9 Postinstallation Setup and Testing">
Section 2.9, “Postinstallation Setup and Testing”
</a>
.
</p>
</li>
</ol>
</div>
<p>
MySQL uses
<span class="command">
<strong>
CMake
</strong>
</span>
as the build framework on all
platforms. The instructions given here should enable you to
produce a working installation. For additional information on
using
<span class="command">
<strong>
CMake
</strong>
</span>
to build MySQL, see
<a class="ulink" href="/doc/internals/en/cmake.html" target="_top">
How to Build MySQL
Server with CMake
</a>
.
</p>
<p>
If you start from a source RPM, use the following command to make
a binary RPM that you can install. If you do not have
<span class="command">
<strong>
rpmbuild
</strong>
</span>
, use
<span class="command">
<strong>
rpm
</strong>
</span>
instead.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa21440044"><div class="copy-help left">Press ⌘+C to 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">rpmbuild</span> <span class="token property">--rebuild</span> <span class="token property">--clean</span> MySQL-<em class="replaceable">VERSION</em><span class="token punctuation">.</span>src<span class="token punctuation">.</span>rpm</code></pre>
</div>
<p>
The result is one or more binary RPM packages that you install as
indicated in
<a class="xref" href="linux-installation-rpm.html" title="2.5.4 Installing MySQL on Linux Using RPM Packages from Oracle">
Section 2.5.4, “Installing MySQL on Linux Using RPM Packages from Oracle”
</a>
.
</p>
<p>
The sequence for installation from a compressed
<span class="command">
<strong>
tar
</strong>
</span>
file or Zip archive source distribution is
similar to the process for installing from a generic binary
distribution (see
<a class="xref" href="binary-installation.html" title="2.2 Installing MySQL on Unix/Linux Using Generic Binaries">
Section 2.2, “Installing MySQL on Unix/Linux Using Generic Binaries”
</a>
), except
that it is used on all platforms and includes steps to configure
and compile the distribution. For example, with a compressed
<span class="command">
<strong>
tar
</strong>
</span>
file source distribution on Unix, the basic
installation command sequence looks like this:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa16949329"><div class="copy-help left">Press ⌘+C to 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 comment" spellcheck="true"># Preconfiguration setup</span>
<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 comment" spellcheck="true"># Beginning of source-build specific instructions</span>
<span class="token prompt">$> </span><span class="token command">tar</span> zxvf mysql-<em class="replaceable">VERSION</em><span class="token punctuation">.</span>tar<span class="token punctuation">.</span>gz
<span class="token prompt">$> </span><span class="token command">cd</span> mysql-<em class="replaceable">VERSION</em>
<span class="token prompt">$> </span><span class="token command">mkdir</span> bld
<span class="token prompt">$> </span><span class="token command">cd</span> bld
<span class="token prompt">$> </span><span class="token command">cmake</span> <span class="token punctuation">.</span><span class="token punctuation">.</span>
<span class="token prompt">$> </span><span class="token command">make</span>
<span class="token prompt">$> </span><span class="token command">make</span> install
<span class="token comment" spellcheck="true"># End of source-build specific instructions</span>
<span class="token comment" spellcheck="true"># Postinstallation setup</span>
<span class="token prompt">$> </span><span class="token command">cd</span> /usr/local/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>
<p>
A more detailed version of the source-build specific instructions
is shown following.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
The procedure shown here does not set up any passwords for MySQL
accounts. After following the procedure, proceed to
<a class="xref" href="postinstallation.html" title="2.9 Postinstallation Setup and Testing">
Section 2.9, “Postinstallation Setup and Testing”
</a>
, for postinstallation setup
and testing.
</p>
</div>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="xref" href="installing-source-distribution.html#installing-source-distribution-preconfiguration" title="Perform Preconfiguration Setup">
Perform Preconfiguration Setup
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="installing-source-distribution.html#installing-source-distribution-obtain-distribution" title="Obtain and Unpack the Distribution">
Obtain and Unpack the Distribution
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="installing-source-distribution.html#installing-source-distribution-configure-distribution" title="Configure the Distribution">
Configure the Distribution
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="installing-source-distribution.html#installing-source-distribution-build-distribution" title="Build the Distribution">
Build the Distribution
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="installing-source-distribution.html#installing-source-distribution-install-distribution" title="Install the Distribution">
Install the Distribution
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="installing-source-distribution.html#installing-source-distribution-postinstallation" title="Perform Postinstallation Setup">
Perform Postinstallation Setup
</a>
</p>
</li>
</ul>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h4 class="title">
<a name="installing-source-distribution-preconfiguration">
</a>
Perform Preconfiguration Setup
</h4>
</div>
</div>
</div>
<p>
On Unix, set up the
<code class="literal">
mysql
</code>
user that owns the
database directory and that should be used to run and execute
the MySQL server, and the group to which this user belongs. For
details, see
<a class="xref" href="binary-installation.html#binary-installation-createsysuser" title="Create a mysql User and Group">
Create a mysql User and Group
</a>
. Then
perform the following steps as the
<code class="literal">
mysql
</code>
user, except as noted.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h4 class="title">
<a name="installing-source-distribution-obtain-distribution">
</a>
Obtain and Unpack the Distribution
</h4>
</div>
</div>
</div>
<p>
Pick the directory under which you want to unpack the
distribution and change location into it.
</p>
<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>
.
</p>
<p>
Unpack the distribution into the current directory:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
To unpack a compressed
<span class="command">
<strong>
tar
</strong>
</span>
file,
<span class="command">
<strong>
tar
</strong>
</span>
can decompress 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="sa74745520"><div class="copy-help left">Press ⌘+C to 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> zxvf mysql-<em class="replaceable">VERSION</em><span class="token punctuation">.</span>tar<span class="token punctuation">.</span>gz</code></pre>
</div>
<p>
If your
<span class="command">
<strong>
tar
</strong>
</span>
does not have
<code class="literal">
z
</code>
option support, use
<span class="command">
<strong>
gunzip
</strong>
</span>
to decompress the distribution and
<span class="command">
<strong>
tar
</strong>
</span>
to unpack it:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa87137834"><div class="copy-help left">Press ⌘+C to 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">gunzip</span> < mysql-<em class="replaceable">VERSION</em><span class="token punctuation">.</span>tar<span class="token punctuation">.</span>gz | tar xvf -</code></pre>
</div>
<p>
Alternatively,
<span class="command">
<strong>
CMake
</strong>
</span>
can decompress and
unpack the distribution:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa84623119"><div class="copy-help left">Press ⌘+C to 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">cmake</span> <span class="token property">-E</span> tar zxvf mysql-<em class="replaceable">VERSION</em><span class="token punctuation">.</span>tar<span class="token punctuation">.</span>gz</code></pre>
</div>
</li>
<li class="listitem">
<p>
To unpack a Zip archive, use
<span class="command">
<strong>
WinZip
</strong>
</span>
or
another tool that can read
<code class="filename">
.zip
</code>
files.
</p>
</li>
</ul>
</div>
<p>
Unpacking the distribution file creates a directory named
<code class="filename">
mysql-
<em class="replaceable">
<code>
VERSION
</code>
</em>
</code>
.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h4 class="title">
<a name="installing-source-distribution-configure-distribution">
</a>
Configure the Distribution
</h4>
</div>
</div>
</div>
<p>
Change location into the top-level directory of the unpacked
distribution:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa91816187"><div class="copy-help left">Press ⌘+C to 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> mysql-<em class="replaceable">VERSION</em></code></pre>
</div>
<p>
Build outside of the source tree to keep the tree clean. If the
top-level source directory is named
<code class="filename">
mysql-src
</code>
under your current working
directory, you can build in a directory named
<code class="filename">
build
</code>
at the same level. Create the
directory and go there:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa95178304"><div class="copy-help left">Press ⌘+C to 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">mkdir</span> bld
<span class="token prompt">$> </span><span class="token command">cd</span> bld</code></pre>
</div>
<p>
Configure the build directory. The minimum configuration command
includes no options to override configuration defaults:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa65649578"><div class="copy-help left">Press ⌘+C to 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">cmake</span> <span class="token punctuation">.</span><span class="token punctuation">.</span>/mysql-src</code></pre>
</div>
<p>
The build directory need not be outside the source tree. For
example, you can build in a directory named
<code class="filename">
build
</code>
under the top-level source tree. To
do this, starting with
<code class="filename">
mysql-src
</code>
as your
current working directory, create the directory
<code class="filename">
build
</code>
and then go there:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa25167705"><div class="copy-help left">Press ⌘+C to 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">mkdir</span> build
<span class="token prompt">$> </span><span class="token command">cd</span> build</code></pre>
</div>
<p>
Configure the build directory. The minimum configuration command
includes no options to override configuration defaults:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa93530715"><div class="copy-help left">Press ⌘+C to 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">cmake</span> <span class="token punctuation">.</span><span class="token punctuation">.</span></code></pre>
</div>
<p>
If you have multiple source trees at the same level (for
example, to build multiple versions of MySQL), the second
strategy can be advantageous. The first strategy places all
build directories at the same level, which requires that you
choose a unique name for each. With the second strategy, you can
use the same name for the build directory within each source
tree. The following instructions assume this second strategy.
</p>
<p>
On Windows, specify the development environment. For example,
the following commands configure MySQL for 32-bit or 64-bit
builds, respectively:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa43751918"><div class="copy-help left">Press ⌘+C to 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">cmake</span> <span class="token punctuation">.</span><span class="token punctuation">.</span> <span class="token property">-G</span> <span class="token atrule">"Visual Studio 12 2013"</span>
<span class="token prompt">$> </span><span class="token command">cmake</span> <span class="token punctuation">.</span><span class="token punctuation">.</span> <span class="token property">-G</span> <span class="token atrule">"Visual Studio 12 2013 Win64"</span></code></pre>
</div>
<p>
On macOS, to use the Xcode IDE:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa73658087"><div class="copy-help left">Press ⌘+C to 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">cmake</span> <span class="token punctuation">.</span><span class="token punctuation">.</span> <span class="token property">-G</span> Xcode</code></pre>
</div>
<p>
When you run
<span class="command">
<strong>
Cmake
</strong>
</span>
, you might want to add
options to the command line. Here are some examples:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="link" href="source-configuration-options.html#option_cmake_build_config">
<code class="option">
-DBUILD_CONFIG=mysql_release
</code>
</a>
:
Configure the source with the same build options used by
Oracle to produce binary distributions for official MySQL
releases.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="source-configuration-options.html#option_cmake_cmake_install_prefix">
<code class="option">
-DCMAKE_INSTALL_PREFIX=
<em class="replaceable">
<code>
dir_name
</code>
</em>
</code>
</a>
:
Configure the distribution for installation under a
particular location.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="source-configuration-options.html#option_cmake_cpack_monolithic_install">
<code class="option">
-DCPACK_MONOLITHIC_INSTALL=1
</code>
</a>
:
Cause
<span class="command">
<strong>
make package
</strong>
</span>
to generate a single
installation file rather than multiple files.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="source-configuration-options.html#option_cmake_with_debug">
<code class="option">
-DWITH_DEBUG=1
</code>
</a>
: Build the
distribution with debugging support.
</p>
</li>
</ul>
</div>
<p>
For a more extensive list of options, see
<a class="xref" href="source-configuration-options.html" title="2.8.7 MySQL Source-Configuration Options">
Section 2.8.7, “MySQL Source-Configuration Options”
</a>
.
</p>
<p>
To list the configuration options, use one of the following
commands:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa96771446"><div class="copy-help left">Press ⌘+C to 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">cmake</span> <span class="token punctuation">.</span><span class="token punctuation">.</span> <span class="token property">-L</span> <span class="token comment" spellcheck="true"># overview</span>
<span class="token prompt">$> </span><span class="token command">cmake</span> <span class="token punctuation">.</span><span class="token punctuation">.</span> <span class="token property">-LH</span> <span class="token comment" spellcheck="true"># overview with help text</span>
<span class="token prompt">$> </span><span class="token command">cmake</span> <span class="token punctuation">.</span><span class="token punctuation">.</span> <span class="token property">-LAH</span> <span class="token comment" spellcheck="true"># all params with help text</span>
<span class="token prompt">$> </span><span class="token command">ccmake</span> <span class="token punctuation">.</span><span class="token punctuation">.</span> <span class="token comment" spellcheck="true"># interactive display</span></code></pre>
</div>
<p>
If
<span class="command">
<strong>
CMake
</strong>
</span>
fails, you might need to reconfigure
by running it again with different options. If you do
reconfigure, take note of the following:
</p>
<a class="indexterm" name="idm46045329513008">
</a>
<a class="indexterm" name="idm46045329511920">
</a>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
If
<span class="command">
<strong>
CMake
</strong>
</span>
is run after it has previously
been run, it may use information that was gathered during
its previous invocation. This information is stored in
<code class="filename">
CMakeCache.txt
</code>
. When
<span class="command">
<strong>
CMake
</strong>
</span>
starts, it looks for that file and
reads its contents if it exists, on the assumption that the
information is still correct. That assumption is invalid
when you reconfigure.
</p>
</li>
<li class="listitem">
<p>
Each time you run
<span class="command">
<strong>
CMake
</strong>
</span>
, you must run
<span class="command">
<strong>
make
</strong>
</span>
again to recompile. However, you may
want to remove old object files from previous builds first
because they were compiled using different configuration
options.
</p>
</li>
</ul>
</div>
<p>
To prevent old object files or configuration information from
being used, run these commands in the build directory on Unix
before re-running
<span class="command">
<strong>
CMake
</strong>
</span>
:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa23171168"><div class="copy-help left">Press ⌘+C to 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">make</span> clean
<span class="token prompt">$> </span><span class="token command">rm</span> CMakeCache<span class="token punctuation">.</span>txt</code></pre>
</div>
<p>
Or, on Windows:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa37989542"><div class="copy-help left">Press ⌘+C to 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">devenv</span> MySQL<span class="token punctuation">.</span>sln /clean
<span class="token prompt">$> </span><span class="token command">del</span> CMakeCache<span class="token punctuation">.</span>txt</code></pre>
</div>
<p>
Before asking on the
<a class="ulink" href="https://mysqlcommunity.slack.com/" target="_blank">
MySQL Community
Slack
</a>
, check the files in the
<code class="filename">
CMakeFiles
</code>
directory for useful information
about the failure. To file a bug report, please use the
instructions in
<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>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h4 class="title">
<a name="installing-source-distribution-build-distribution">
</a>
Build the Distribution
</h4>
</div>
</div>
</div>
<p>
On Unix:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa23112457"><div class="copy-help left">Press ⌘+C to 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">make</span>
<span class="token prompt">$> </span><span class="token command">make</span> VERBOSE<span class="token attr-value"><span class="token punctuation">=</span>1</span></code></pre>
</div>
<p>
The second command sets
<code class="literal">
VERBOSE
</code>
to show the
commands for each compiled source.
</p>
<p>
Use
<span class="command">
<strong>
gmake
</strong>
</span>
instead on systems where you are
using GNU
<span class="command">
<strong>
make
</strong>
</span>
and it has been installed as
<span class="command">
<strong>
gmake
</strong>
</span>
.
</p>
<p>
On Windows:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa8588986"><div class="copy-help left">Press ⌘+C to 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">devenv</span> MySQL<span class="token punctuation">.</span>sln /build RelWithDebInfo</code></pre>
</div>
<p>
If you have gotten to the compilation stage, but the
distribution does not build, see
<a class="xref" href="compilation-problems.html" title="2.8.8 Dealing with Problems Compiling MySQL">
Section 2.8.8, “Dealing with Problems Compiling MySQL”
</a>
, for help. If that does
not solve the problem, please enter it into our bugs database
using the instructions given in
<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>
.
If you have installed the latest versions of the required tools,
and they crash trying to process our configuration files, please
report that also. However, if you get a
<code class="literal">
command not
found
</code>
error or a similar problem for required tools,
do not report it. Instead, make sure that all the required tools
are installed and that your
<code class="literal">
PATH
</code>
variable is
set correctly so that your shell can find them.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h4 class="title">
<a name="installing-source-distribution-install-distribution">
</a>
Install the Distribution
</h4>
</div>
</div>
</div>
<p>
On Unix:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa93996107"><div class="copy-help left">Press ⌘+C to 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">make</span> install</code></pre>
</div>
<p>
This installs the files under the configured installation
directory (by default,
<code class="filename">
/usr/local/mysql
</code>
).
You might need to run the command as
<code class="literal">
root
</code>
.
</p>
<p>
To install in a specific directory, add a
<code class="literal">
DESTDIR
</code>
parameter to the command line:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa87419501"><div class="copy-help left">Press ⌘+C to 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">make</span> install DESTDIR=<span class="token atrule">"/opt/mysql"</span></code></pre>
</div>
<p>
Alternatively, generate installation package files that you can
install where you like:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa15818716"><div class="copy-help left">Press ⌘+C to 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">make</span> package</code></pre>
</div>
<p>
This operation produces one or more
<code class="filename">
.tar.gz
</code>
files that can be installed like generic binary distribution
packages. See
<a class="xref" href="binary-installation.html" title="2.2 Installing MySQL on Unix/Linux Using Generic Binaries">
Section 2.2, “Installing MySQL on Unix/Linux Using Generic Binaries”
</a>
. If you run
<span class="command">
<strong>
CMake
</strong>
</span>
with
<a class="link" href="source-configuration-options.html#option_cmake_cpack_monolithic_install">
<code class="option">
-DCPACK_MONOLITHIC_INSTALL=1
</code>
</a>
, the
operation produces a single file. Otherwise, it produces
multiple files.
</p>
<p>
On Windows, generate the data directory, then create a
<code class="filename">
.zip
</code>
archive installation package:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa85263756"><div class="copy-help left">Press ⌘+C to 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">devenv</span> MySQL<span class="token punctuation">.</span>sln /build RelWithDebInfo /project initial_database
<span class="token prompt">$> </span><span class="token command">devenv</span> MySQL<span class="token punctuation">.</span>sln /build RelWithDebInfo /project package</code></pre>
</div>
<p>
You can install the resulting
<code class="filename">
.zip
</code>
archive
where you like. See
<a class="xref" href="windows-install-archive.html" title="2.3.3 Configuration: Manually">
Section 2.3.3, “Configuration: Manually”
</a>
.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h4 class="title">
<a name="installing-source-distribution-postinstallation">
</a>
Perform Postinstallation Setup
</h4>
</div>
</div>
</div>
<p>
The remainder of the installation process involves setting up
the configuration file, creating the core databases, and
starting the MySQL server. 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 class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
The accounts that are listed in the MySQL grant tables
initially have no passwords. After starting the server, you
should set up passwords for them using the instructions in
<a class="xref" href="postinstallation.html" title="2.9 Postinstallation Setup and Testing">
Section 2.9, “Postinstallation Setup and Testing”
</a>
.
</p>
</div>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/mysql-shell-tutorial-python-documents-in-tables.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="mysql-shell-tutorial-python-documents-in-tables">
</a>
22.4.5 Documents in Tables
</h3>
</div>
</div>
</div>
<a class="indexterm" name="idm46045126739680">
</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="idm46045126735152">
</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-python-insert-record">
</a>
Insert a Record
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045126731312">
</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="sa95015125"><div class="copy-help left">Press ⌘+C to 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-py></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-python-select-record">
</a>
Select a Record
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045126725440">
</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="sa10168084"><div class="copy-help left">Press ⌘+C to 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-py></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="idm46045126720288">
</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/replication-features-json.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="replication-features-json">
</a>
19.5.1.17 Replication of JSON Documents
</h4>
</div>
</div>
</div>
<p>
In MySQL 8.4, it is possible to log partial updates
to JSON documents (see
<a class="xref" href="json.html#json-partial-updates" title="Partial Updates of JSON Values">
Partial Updates of JSON Values
</a>
).
The logging behavior depends on the format used, as described
here:
</p>
<p>
<b>
Statement-based replication.
</b>
JSON partial updates are always logged as partial updates.
This cannot be disabled when using statement-based logging.
</p>
<p>
<b>
Row-based replication.
</b>
JSON partial updates are not logged as such by default, but
instead are logged as complete documents. To enable logging of
partial updates, set
<a class="link" href="replication-options-binary-log.html#sysvar_binlog_row_value_options">
<code class="literal">
binlog_row_value_options=PARTIAL_JSON
</code>
</a>
.
If a replication source has this variable set, partial updates
received from that source are handled and applied by a replica
regardless of the replica's own setting for the variable.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/innodb-in-memory-structures.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h2 class="title">
<a name="innodb-in-memory-structures">
</a>
17.5 InnoDB In-Memory Structures
</h2>
</div>
</div>
</div>
<div class="toc">
<dl class="toc">
<dt>
<span class="section">
<a href="innodb-buffer-pool.html">
17.5.1 Buffer Pool
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="innodb-change-buffer.html">
17.5.2 Change Buffer
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="innodb-adaptive-hash.html">
17.5.3 Adaptive Hash Index
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="innodb-redo-log-buffer.html">
17.5.4 Log Buffer
</a>
</span>
</dt>
</dl>
</div>
<a class="indexterm" name="idm46045167181472">
</a>
<p>
This section describes
<code class="literal">
InnoDB
</code>
in-memory
structures and related topics.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/myisam-check.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="myisam-check">
</a>
9.6.2 How to Check MyISAM Tables for Errors
</h3>
</div>
</div>
</div>
<a class="indexterm" name="idm46045230608608">
</a>
<a class="indexterm" name="idm46045230607152">
</a>
<a class="indexterm" name="idm46045230605664">
</a>
<p>
To check a
<code class="literal">
MyISAM
</code>
table, use the following
commands:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="link" href="myisamchk.html" title="6.6.4 myisamchk — MyISAM Table-Maintenance Utility">
<span class="command">
<strong>
myisamchk
<em class="replaceable">
<code>
tbl_name
</code>
</em>
</strong>
</span>
</a>
</p>
<p>
This finds 99.99% of all errors. What it cannot find is
corruption that involves
<span class="emphasis">
<em>
only
</em>
</span>
the data
file (which is very unusual). If you want to check a table,
you should normally run
<a class="link" href="myisamchk.html" title="6.6.4 myisamchk — MyISAM Table-Maintenance Utility">
<span class="command">
<strong>
myisamchk
</strong>
</span>
</a>
without
options or with the
<code class="option">
-s
</code>
(silent) option.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="myisamchk.html" title="6.6.4 myisamchk — MyISAM Table-Maintenance Utility">
<span class="command">
<strong>
myisamchk -m
<em class="replaceable">
<code>
tbl_name
</code>
</em>
</strong>
</span>
</a>
</p>
<p>
This finds 99.999% of all errors. It first checks all index
entries for errors and then reads through all rows. It
calculates a checksum for all key values in the rows and
verifies that the checksum matches the checksum for the keys
in the index tree.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="myisamchk.html" title="6.6.4 myisamchk — MyISAM Table-Maintenance Utility">
<span class="command">
<strong>
myisamchk -e
<em class="replaceable">
<code>
tbl_name
</code>
</em>
</strong>
</span>
</a>
</p>
<p>
This does a complete and thorough check of all data
(
<code class="option">
-e
</code>
means
<span class="quote">
“
<span class="quote">
extended check
</span>
”
</span>
).
It does a check-read of every key for each row to verify
that they indeed point to the correct row. This may take a
long time for a large table that has many indexes. Normally,
<a class="link" href="myisamchk.html" title="6.6.4 myisamchk — MyISAM Table-Maintenance Utility">
<span class="command">
<strong>
myisamchk
</strong>
</span>
</a>
stops after the first error it
finds. If you want to obtain more information, you can add
the
<code class="option">
-v
</code>
(verbose) option. This causes
<a class="link" href="myisamchk.html" title="6.6.4 myisamchk — MyISAM Table-Maintenance Utility">
<span class="command">
<strong>
myisamchk
</strong>
</span>
</a>
to keep going, up through a
maximum of 20 errors.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="myisamchk.html" title="6.6.4 myisamchk — MyISAM Table-Maintenance Utility">
<span class="command">
<strong>
myisamchk -e -i
<em class="replaceable">
<code>
tbl_name
</code>
</em>
</strong>
</span>
</a>
</p>
<p>
This is like the previous command, but the
<code class="option">
-i
</code>
option tells
<a class="link" href="myisamchk.html" title="6.6.4 myisamchk — MyISAM Table-Maintenance Utility">
<span class="command">
<strong>
myisamchk
</strong>
</span>
</a>
to print additional statistical
information.
</p>
</li>
</ul>
</div>
<p>
In most cases, a simple
<a class="link" href="myisamchk.html" title="6.6.4 myisamchk — MyISAM Table-Maintenance Utility">
<span class="command">
<strong>
myisamchk
</strong>
</span>
</a>
command
with no arguments other than the table name is sufficient to
check a table.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/cursor-restrictions.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="cursor-restrictions">
</a>
15.6.6.5 Restrictions on Server-Side Cursors
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045176106128">
</a>
<a class="indexterm" name="idm46045176104672">
</a>
<p>
Server-side cursors are implemented in the C API using the
<a class="ulink" href="/doc/c-api/8.4/en/mysql-stmt-attr-set.html" target="_top">
<code class="literal">
mysql_stmt_attr_set()
</code>
</a>
function.
The same implementation is used for cursors in stored routines.
A server-side cursor enables a result set to be generated on the
server side, but not transferred to the client except for those
rows that the client requests. For example, if a client executes
a query but is only interested in the first row, the remaining
rows are not transferred.
</p>
<p>
In MySQL, a server-side cursor is materialized into an internal
temporary table. Initially, this is a
<code class="literal">
MEMORY
</code>
table, but is converted to a
<code class="literal">
MyISAM
</code>
table
when its size exceeds the minimum value of the
<a class="link" href="server-system-variables.html#sysvar_max_heap_table_size">
<code class="literal">
max_heap_table_size
</code>
</a>
and
<a class="link" href="server-system-variables.html#sysvar_tmp_table_size">
<code class="literal">
tmp_table_size
</code>
</a>
system
variables. The same restrictions apply to internal temporary
tables created to hold the result set for a cursor as for other
uses of internal temporary tables. See
<a class="xref" href="internal-temporary-tables.html" title="10.4.4 Internal Temporary Table Use in MySQL">
Section 10.4.4, “Internal Temporary Table Use in MySQL”
</a>
. One limitation of
the implementation is that for a large result set, retrieving
its rows through a cursor might be slow.
</p>
<p>
Cursors are read only; you cannot use a cursor to update rows.
</p>
<p>
<code class="literal">
UPDATE WHERE CURRENT OF
</code>
and
<code class="literal">
DELETE
WHERE CURRENT OF
</code>
are not implemented, because
updatable cursors are not supported.
</p>
<p>
Cursors are nonholdable (not held open after a commit).
</p>
<p>
Cursors are asensitive.
</p>
<p>
Cursors are nonscrollable.
</p>
<p>
Cursors are not named. The statement handler acts as the cursor
ID.
</p>
<p>
You can have open only a single cursor per prepared statement.
If you need several cursors, you must prepare several
statements.
</p>
<p>
You cannot use a cursor for a statement that generates a result
set if the statement is not supported in prepared mode. This
includes statements such as
<a class="link" href="check-table.html" title="15.7.3.2 CHECK TABLE Statement">
<code class="literal">
CHECK
TABLE
</code>
</a>
,
<code class="literal">
HANDLER READ
</code>
, and
<a class="link" href="show-binlog-events.html" title="15.7.7.3 SHOW BINLOG EVENTS Statement">
<code class="literal">
SHOW BINLOG EVENTS
</code>
</a>
.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/faqs-stored-procs.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h2 class="title">
<a name="faqs-stored-procs">
</a>
A.4 MySQL 8.4 FAQ: Stored Procedures and Functions
</h2>
</div>
</div>
</div>
<div class="qandaset">
<a name="idm46045056374464">
</a>
<dl>
<dt>
A.4.1.
<a href="faqs-stored-procs.html#faq-mysql-have-procedures-functions">
Does MySQL support stored procedures and functions?
</a>
</dt>
<dt>
A.4.2.
<a href="faqs-stored-procs.html#faq-mysql-where-procedures-functions-docs">
Where can I find documentation for MySQL stored procedures and
stored functions?
</a>
</dt>
<dt>
A.4.3.
<a href="faqs-stored-procs.html#faq-mysql-where-procedures-forum">
Is there a discussion forum for MySQL stored procedures?
</a>
</dt>
<dt>
A.4.4.
<a href="faqs-stored-procs.html#faq-mysql-where-ansi-2003-spec">
Where can I find the ANSI SQL 2003 specification for stored
procedures?
</a>
</dt>
<dt>
A.4.5.
<a href="faqs-stored-procs.html#faq-mysql-how-manage-routines">
How do you manage stored routines?
</a>
</dt>
<dt>
A.4.6.
<a href="faqs-stored-procs.html#faq-mysql-how-view-procedures-functions">
Is there a way to view all stored procedures and stored
functions in a given database?
</a>
</dt>
<dt>
A.4.7.
<a href="faqs-stored-procs.html#faq-mysql-where-procedures-stored">
Where are stored procedures stored?
</a>
</dt>
<dt>
A.4.8.
<a href="faqs-stored-procs.html#faq-mysql-how-group-procedures-functions">
Is it possible to group stored procedures or stored functions
into packages?
</a>
</dt>
<dt>
A.4.9.
<a href="faqs-stored-procs.html#faq-mysql-can-procedure-call-procedure">
Can a stored procedure call another stored procedure?
</a>
</dt>
<dt>
A.4.10.
<a href="faqs-stored-procs.html#faq-mysql-can-procedure-call-trigger">
Can a stored procedure call a trigger?
</a>
</dt>
<dt>
A.4.11.
<a href="faqs-stored-procs.html#faq-mysql-can-procedure-access-table">
Can a stored procedure access tables?
</a>
</dt>
<dt>
A.4.12.
<a href="faqs-stored-procs.html#faq-mysql-can-procedure-raise-error">
Do stored procedures have a statement for raising application
errors?
</a>
</dt>
<dt>
A.4.13.
<a href="faqs-stored-procs.html#faq-mysql-have-exceptions">
Do stored procedures provide exception handling?
</a>
</dt>
<dt>
A.4.14.
<a href="faqs-stored-procs.html#faq-mysql-can-routine-results">
Can MySQL stored routines return result sets?
</a>
</dt>
<dt>
A.4.15.
<a href="faqs-stored-procs.html#faq-mysql-have-with-recompile">
Is WITH RECOMPILE supported for stored
procedures?
</a>
</dt>
<dt>
A.4.16.
<a href="faqs-stored-procs.html#faq-mysql-have-mod-plsql">
Is there a MySQL equivalent to using
mod_plsql as a gateway on Apache to talk
directly to a stored procedure in the database?
</a>
</dt>
<dt>
A.4.17.
<a href="faqs-stored-procs.html#faq-mysql-can-procedure-array">
Can I pass an array as input to a stored procedure?
</a>
</dt>
<dt>
A.4.18.
<a href="faqs-stored-procs.html#faq-mysql-can-pass-cursor-in">
Can I pass a cursor as an IN parameter to a
stored procedure?
</a>
</dt>
<dt>
A.4.19.
<a href="faqs-stored-procs.html#faq-mysql-can-return-cursor-out">
Can I return a cursor as an OUT parameter
from a stored procedure?
</a>
</dt>
<dt>
A.4.20.
<a href="faqs-stored-procs.html#faq-mysql-can-print-var-in-procedure">
Can I print out a variable's value within a stored routine for
debugging purposes?
</a>
</dt>
<dt>
A.4.21.
<a href="faqs-stored-procs.html#faq-mysql-can-rollback-transaction-procedure">
Can I commit or roll back transactions inside a stored
procedure?
</a>
</dt>
<dt>
A.4.22.
<a href="faqs-stored-procs.html#faq-mysql-can-procedures-replicatation">
Do MySQL stored procedures and functions work with replication?
</a>
</dt>
<dt>
A.4.23.
<a href="faqs-stored-procs.html#faq-mysql-are-procedures-replicated">
Are stored procedures and functions created on a replication
source server replicated to a replica?
</a>
</dt>
<dt>
A.4.24.
<a href="faqs-stored-procs.html#faq-mysql-how-procedures-replicated">
How are actions that take place inside stored procedures and
functions replicated?
</a>
</dt>
<dt>
A.4.25.
<a href="faqs-stored-procs.html#faq-mysql-security-procedures-replication">
Are there special security requirements for using stored
procedures and functions together with replication?
</a>
</dt>
<dt>
A.4.26.
<a href="faqs-stored-procs.html#faq-mysql-limitations-procedures-replication">
What limitations exist for replicating stored procedure and
function actions?
</a>
</dt>
<dt>
A.4.27.
<a href="faqs-stored-procs.html#faq-mysql-limitations-pit-recovery">
Do the preceding limitations affect the ability of MySQL to do
point-in-time recovery?
</a>
</dt>
<dt>
A.4.28.
<a href="faqs-stored-procs.html#faq-mysql-when-limitations-resolved">
What is being done to correct the aforementioned limitations?
</a>
</dt>
</dl>
<table border="0" style="width: 100%;">
<colgroup>
<col align="left" width="1%"/>
<col/>
</colgroup>
<tbody>
<tr class="question">
<td align="left" valign="top">
<a name="faq-mysql-have-procedures-functions">
</a>
<a name="idm46045056373712">
</a>
<p>
<b>
A.4.1.
</b>
</p>
</td>
<td align="left" valign="top">
<p>
Does MySQL support stored procedures and functions?
</p>
</td>
</tr>
<tr class="answer">
<td align="left" valign="top">
</td>
<td align="left" valign="top">
<p>
Yes. MySQL supports two types of stored routines, stored
procedures, and stored functions.
</p>
</td>
</tr>
<tr class="question">
<td align="left" valign="top">
<a name="faq-mysql-where-procedures-functions-docs">
</a>
<a name="idm46045056371536">
</a>
<p>
<b>
A.4.2.
</b>
</p>
</td>
<td align="left" valign="top">
<p>
Where can I find documentation for MySQL stored procedures and
stored functions?
</p>
</td>
</tr>
<tr class="answer">
<td align="left" valign="top">
</td>
<td align="left" valign="top">
<p>
See
<a class="xref" href="stored-routines.html" title="27.2 Using Stored Routines">
Section 27.2, “Using Stored Routines”
</a>
.
</p>
</td>
</tr>
<tr class="question">
<td align="left" valign="top">
<a name="faq-mysql-where-procedures-forum">
</a>
<a name="idm46045056368832">
</a>
<p>
<b>
A.4.3.
</b>
</p>
</td>
<td align="left" valign="top">
<p>
Is there a discussion forum for MySQL stored procedures?
</p>
</td>
</tr>
<tr class="answer">
<td align="left" valign="top">
</td>
<td align="left" valign="top">
<p>
Yes. See
<a class="ulink" href="https://forums.mysql.com/list.php?98" target="_blank">
https://forums.mysql.com/list.php?98
</a>
.
</p>
</td>
</tr>
<tr class="question">
<td align="left" valign="top">
<a name="faq-mysql-where-ansi-2003-spec">
</a>
<a name="idm46045056366080">
</a>
<p>
<b>
A.4.4.
</b>
</p>
</td>
<td align="left" valign="top">
<p>
Where can I find the ANSI SQL 2003 specification for stored
procedures?
</p>
</td>
</tr>
<tr class="answer">
<td align="left" valign="top">
</td>
<td align="left" valign="top">
<p>
Unfortunately, the official specifications are not freely
available (ANSI makes them available for purchase). However,
there are books, such as
<em class="citetitle">
SQL-99 Complete,
Really
</em>
by Peter Gulutzan and Trudy Pelzer, that
provide a comprehensive overview of the standard, including
coverage of stored procedures.
</p>
</td>
</tr>
<tr class="question">
<td align="left" valign="top">
<a name="faq-mysql-how-manage-routines">
</a>
<a name="idm46045056363248">
</a>
<p>
<b>
A.4.5.
</b>
</p>
</td>
<td align="left" valign="top">
<p>
How do you manage stored routines?
</p>
</td>
</tr>
<tr class="answer">
<td align="left" valign="top">
</td>
<td align="left" valign="top">
<p>
It is always good practice to use a clear naming scheme for your
stored routines. You can manage stored procedures with
<code class="literal">
CREATE [FUNCTION|PROCEDURE]
</code>
,
<code class="literal">
ALTER
[FUNCTION|PROCEDURE]
</code>
,
<code class="literal">
DROP
[FUNCTION|PROCEDURE]
</code>
, and
<code class="literal">
SHOW CREATE
[FUNCTION|PROCEDURE]
</code>
. You can obtain information about
existing stored procedures using the
<a class="link" href="information-schema-routines-table.html" title="28.3.30 The INFORMATION_SCHEMA ROUTINES Table">
<code class="literal">
ROUTINES
</code>
</a>
table in the
<code class="literal">
INFORMATION_SCHEMA
</code>
database (see
<a class="xref" href="information-schema-routines-table.html" title="28.3.30 The INFORMATION_SCHEMA ROUTINES Table">
Section 28.3.30, “The INFORMATION_SCHEMA ROUTINES Table”
</a>
).
</p>
</td>
</tr>
<tr class="question">
<td align="left" valign="top">
<a name="faq-mysql-how-view-procedures-functions">
</a>
<a name="idm46045056355504">
</a>
<p>
<b>
A.4.6.
</b>
</p>
</td>
<td align="left" valign="top">
<p>
Is there a way to view all stored procedures and stored
functions in a given database?
</p>
</td>
</tr>
<tr class="answer">
<td align="left" valign="top">
</td>
<td align="left" valign="top">
<p>
Yes. For a database named
<em class="replaceable">
<code>
dbname
</code>
</em>
, use
this query on the
<a class="link" href="information-schema-routines-table.html" title="28.3.30 The INFORMATION_SCHEMA ROUTINES Table">
<code class="literal">
INFORMATION_SCHEMA.ROUTINES
</code>
</a>
table:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa3645708"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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> ROUTINE_TYPE<span class="token punctuation">,</span> ROUTINE_NAME
<span class="token keyword">FROM</span> INFORMATION_SCHEMA<span class="token punctuation">.</span>ROUTINES
<span class="token keyword">WHERE</span> ROUTINE_SCHEMA<span class="token operator">=</span><span class="token string">'<em class="replaceable">dbname</em>'</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
For more information, see
<a class="xref" href="information-schema-routines-table.html" title="28.3.30 The INFORMATION_SCHEMA ROUTINES Table">
Section 28.3.30, “The INFORMATION_SCHEMA ROUTINES Table”
</a>
.
</p>
<p>
The body of a stored routine can be viewed using
<a class="link" href="show-create-function.html" title="15.7.7.9 SHOW CREATE FUNCTION Statement">
<code class="literal">
SHOW CREATE FUNCTION
</code>
</a>
(for a
stored function) or
<a class="link" href="show-create-procedure.html" title="15.7.7.10 SHOW CREATE PROCEDURE Statement">
<code class="literal">
SHOW CREATE
PROCEDURE
</code>
</a>
(for a stored procedure). See
<a class="xref" href="show-create-procedure.html" title="15.7.7.10 SHOW CREATE PROCEDURE Statement">
Section 15.7.7.10, “SHOW CREATE PROCEDURE Statement”
</a>
, for more information.
</p>
</td>
</tr>
<tr class="question">
<td align="left" valign="top">
<a name="faq-mysql-where-procedures-stored">
</a>
<a name="idm46045056345376">
</a>
<p>
<b>
A.4.7.
</b>
</p>
</td>
<td align="left" valign="top">
<p>
Where are stored procedures stored?
</p>
</td>
</tr>
<tr class="answer">
<td align="left" valign="top">
</td>
<td align="left" valign="top">
<p>
Stored procedures are stored in the
<code class="literal">
mysql.routines
</code>
and
<code class="literal">
mysql.parameters
</code>
tables, which are part of
the data dictionary. You cannot access these tables directly.
Instead, query the
<code class="literal">
INFORMATION_SCHEMA
</code>
<a class="link" href="information-schema-routines-table.html" title="28.3.30 The INFORMATION_SCHEMA ROUTINES Table">
<code class="literal">
ROUTINES
</code>
</a>
and
<a class="link" href="information-schema-parameters-table.html" title="28.3.20 The INFORMATION_SCHEMA PARAMETERS Table">
<code class="literal">
PARAMETERS
</code>
</a>
tables. See
<a class="xref" href="information-schema-routines-table.html" title="28.3.30 The INFORMATION_SCHEMA ROUTINES Table">
Section 28.3.30, “The INFORMATION_SCHEMA ROUTINES Table”
</a>
, and
<a class="xref" href="information-schema-parameters-table.html" title="28.3.20 The INFORMATION_SCHEMA PARAMETERS Table">
Section 28.3.20, “The INFORMATION_SCHEMA PARAMETERS Table”
</a>
.
</p>
<p>
You can also use
<a class="link" href="show-create-function.html" title="15.7.7.9 SHOW CREATE FUNCTION Statement">
<code class="literal">
SHOW CREATE
FUNCTION
</code>
</a>
to obtain information about stored functions,
and
<a class="link" href="show-create-procedure.html" title="15.7.7.10 SHOW CREATE PROCEDURE Statement">
<code class="literal">
SHOW CREATE PROCEDURE
</code>
</a>
to
obtain information about stored procedures. See
<a class="xref" href="show-create-procedure.html" title="15.7.7.10 SHOW CREATE PROCEDURE Statement">
Section 15.7.7.10, “SHOW CREATE PROCEDURE Statement”
</a>
.
</p>
</td>
</tr>
<tr class="question">
<td align="left" valign="top">
<a name="faq-mysql-how-group-procedures-functions">
</a>
<a name="idm46045056333456">
</a>
<p>
<b>
A.4.8.
</b>
</p>
</td>
<td align="left" valign="top">
<p>
Is it possible to group stored procedures or stored functions
into packages?
</p>
</td>
</tr>
<tr class="answer">
<td align="left" valign="top">
</td>
<td align="left" valign="top">
<p>
No. This is not supported in MySQL.
</p>
</td>
</tr>
<tr class="question">
<td align="left" valign="top">
<a name="faq-mysql-can-procedure-call-procedure">
</a>
<a name="idm46045056331376">
</a>
<p>
<b>
A.4.9.
</b>
</p>
</td>
<td align="left" valign="top">
<p>
Can a stored procedure call another stored procedure?
</p>
</td>
</tr>
<tr class="answer">
<td align="left" valign="top">
</td>
<td align="left" valign="top">
<p>
Yes.
</p>
</td>
</tr>
<tr class="question">
<td align="left" valign="top">
<a name="faq-mysql-can-procedure-call-trigger">
</a>
<a name="idm46045056329408">
</a>
<p>
<b>
A.4.10.
</b>
</p>
</td>
<td align="left" valign="top">
<p>
Can a stored procedure call a trigger?
</p>
</td>
</tr>
<tr class="answer">
<td align="left" valign="top">
</td>
<td align="left" valign="top">
<p>
A stored procedure can execute an SQL statement, such as an
<a class="link" href="update.html" title="15.2.17 UPDATE Statement">
<code class="literal">
UPDATE
</code>
</a>
, that causes a trigger to
activate.
</p>
</td>
</tr>
<tr class="question">
<td align="left" valign="top">
<a name="faq-mysql-can-procedure-access-table">
</a>
<a name="idm46045056326128">
</a>
<p>
<b>
A.4.11.
</b>
</p>
</td>
<td align="left" valign="top">
<p>
Can a stored procedure access tables?
</p>
</td>
</tr>
<tr class="answer">
<td align="left" valign="top">
</td>
<td align="left" valign="top">
<p>
Yes. A stored procedure can access one or more tables as
required.
</p>
</td>
</tr>
<tr class="question">
<td align="left" valign="top">
<a name="faq-mysql-can-procedure-raise-error">
</a>
<a name="idm46045056324032">
</a>
<p>
<b>
A.4.12.
</b>
</p>
</td>
<td align="left" valign="top">
<p>
Do stored procedures have a statement for raising application
errors?
</p>
</td>
</tr>
<tr class="answer">
<td align="left" valign="top">
</td>
<td align="left" valign="top">
<p>
Yes. MySQL implements the SQL standard
<code class="literal">
SIGNAL
</code>
and
<code class="literal">
RESIGNAL
</code>
statements. See
<a class="xref" href="condition-handling.html" title="15.6.7 Condition Handling">
Section 15.6.7, “Condition Handling”
</a>
.
</p>
</td>
</tr>
<tr class="question">
<td align="left" valign="top">
<a name="faq-mysql-have-exceptions">
</a>
<a name="idm46045056319872">
</a>
<p>
<b>
A.4.13.
</b>
</p>
</td>
<td align="left" valign="top">
<p>
Do stored procedures provide exception handling?
</p>
</td>
</tr>
<tr class="answer">
<td align="left" valign="top">
</td>
<td align="left" valign="top">
<p>
MySQL implements
<a class="link" href="handler.html" title="15.2.5 HANDLER Statement">
<code class="literal">
HANDLER
</code>
</a>
definitions according to the SQL standard. See
<a class="xref" href="declare-handler.html" title="15.6.7.2 DECLARE ... HANDLER Statement">
Section 15.6.7.2, “DECLARE ... HANDLER Statement”
</a>
, for details.
</p>
</td>
</tr>
<tr class="question">
<td align="left" valign="top">
<a name="faq-mysql-can-routine-results">
</a>
<a name="idm46045056315936">
</a>
<p>
<b>
A.4.14.
</b>
</p>
</td>
<td align="left" valign="top">
<p>
Can MySQL stored routines return result sets?
</p>
</td>
</tr>
<tr class="answer">
<td align="left" valign="top">
</td>
<td align="left" valign="top">
<p>
<span class="emphasis">
<em>
Stored procedures
</em>
</span>
can, but stored functions
cannot. If you perform an ordinary
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
inside a stored procedure,
the result set is returned directly to the client. You need to
use the MySQL 4.1 (or higher) client/server protocol for this to
work. This means that, for example, in PHP, you need to use the
<code class="literal">
mysqli
</code>
extension rather than the old
<code class="literal">
mysql
</code>
extension.
</p>
</td>
</tr>
<tr class="question">
<td align="left" valign="top">
<a name="faq-mysql-have-with-recompile">
</a>
<a name="idm46045056310560">
</a>
<p>
<b>
A.4.15.
</b>
</p>
</td>
<td align="left" valign="top">
<p>
Is
<code class="literal">
WITH RECOMPILE
</code>
supported for stored
procedures?
</p>
</td>
</tr>
<tr class="answer">
<td align="left" valign="top">
</td>
<td align="left" valign="top">
<p>
No.
</p>
</td>
</tr>
<tr class="question">
<td align="left" valign="top">
<a name="faq-mysql-have-mod-plsql">
</a>
<a name="idm46045056307888">
</a>
<p>
<b>
A.4.16.
</b>
</p>
</td>
<td align="left" valign="top">
<p>
Is there a MySQL equivalent to using
<code class="literal">
mod_plsql
</code>
as a gateway on Apache to talk
directly to a stored procedure in the database?
</p>
</td>
</tr>
<tr class="answer">
<td align="left" valign="top">
</td>
<td align="left" valign="top">
<p>
There is no equivalent in MySQL.
</p>
</td>
</tr>
<tr class="question">
<td align="left" valign="top">
<a name="faq-mysql-can-procedure-array">
</a>
<a name="idm46045056305104">
</a>
<p>
<b>
A.4.17.
</b>
</p>
</td>
<td align="left" valign="top">
<p>
Can I pass an array as input to a stored procedure?
</p>
</td>
</tr>
<tr class="answer">
<td align="left" valign="top">
</td>
<td align="left" valign="top">
<p>
No.
</p>
</td>
</tr>
<tr class="question">
<td align="left" valign="top">
<a name="faq-mysql-can-pass-cursor-in">
</a>
<a name="idm46045056303136">
</a>
<p>
<b>
A.4.18.
</b>
</p>
</td>
<td align="left" valign="top">
<p>
Can I pass a cursor as an
<code class="literal">
IN
</code>
parameter to a
stored procedure?
</p>
</td>
</tr>
<tr class="answer">
<td align="left" valign="top">
</td>
<td align="left" valign="top">
<p>
Cursors are only available inside stored procedures.
</p>
</td>
</tr>
<tr class="question">
<td align="left" valign="top">
<a name="faq-mysql-can-return-cursor-out">
</a>
<a name="idm46045056300432">
</a>
<p>
<b>
A.4.19.
</b>
</p>
</td>
<td align="left" valign="top">
<p>
Can I return a cursor as an
<code class="literal">
OUT
</code>
parameter
from a stored procedure?
</p>
</td>
</tr>
<tr class="answer">
<td align="left" valign="top">
</td>
<td align="left" valign="top">
<p>
Cursors are only available inside stored procedures. However, if
you do not open a cursor on a
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
, the result is sent
directly to the client. You can also
<code class="literal">
SELECT
INTO
</code>
variables. See
<a class="xref" href="select.html" title="15.2.13 SELECT Statement">
Section 15.2.13, “SELECT Statement”
</a>
.
</p>
</td>
</tr>
<tr class="question">
<td align="left" valign="top">
<a name="faq-mysql-can-print-var-in-procedure">
</a>
<a name="idm46045056294992">
</a>
<p>
<b>
A.4.20.
</b>
</p>
</td>
<td align="left" valign="top">
<p>
Can I print out a variable's value within a stored routine for
debugging purposes?
</p>
</td>
</tr>
<tr class="answer">
<td align="left" valign="top">
</td>
<td align="left" valign="top">
<p>
Yes, you can do this in a
<span class="emphasis">
<em>
stored procedure
</em>
</span>
,
but not in a stored function. If you perform an ordinary
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
inside a stored procedure,
the result set is returned directly to the client. You must use
the MySQL 4.1 (or above) client/server protocol for this to
work. This means that, for example, in PHP, you need to use the
<code class="literal">
mysqli
</code>
extension rather than the old
<code class="literal">
mysql
</code>
extension.
</p>
</td>
</tr>
<tr class="question">
<td align="left" valign="top">
<a name="faq-mysql-can-rollback-transaction-procedure">
</a>
<a name="idm46045056289472">
</a>
<p>
<b>
A.4.21.
</b>
</p>
</td>
<td align="left" valign="top">
<p>
Can I commit or roll back transactions inside a stored
procedure?
</p>
</td>
</tr>
<tr class="answer">
<td align="left" valign="top">
</td>
<td align="left" valign="top">
<p>
Yes. However, you cannot perform transactional operations within
a stored function.
</p>
</td>
</tr>
<tr class="question">
<td align="left" valign="top">
<a name="faq-mysql-can-procedures-replicatation">
</a>
<a name="idm46045056287392">
</a>
<p>
<b>
A.4.22.
</b>
</p>
</td>
<td align="left" valign="top">
<p>
Do MySQL stored procedures and functions work with replication?
</p>
</td>
</tr>
<tr class="answer">
<td align="left" valign="top">
</td>
<td align="left" valign="top">
<p>
Yes, standard actions carried out in stored procedures and
functions are replicated from a replication source server to a
replica. There are a few limitations that are described in
detail in
<a class="xref" href="stored-programs-logging.html" title="27.7 Stored Program Binary Logging">
Section 27.7, “Stored Program Binary Logging”
</a>
.
</p>
</td>
</tr>
<tr class="question">
<td align="left" valign="top">
<a name="faq-mysql-are-procedures-replicated">
</a>
<a name="idm46045056284464">
</a>
<p>
<b>
A.4.23.
</b>
</p>
</td>
<td align="left" valign="top">
<p>
Are stored procedures and functions created on a replication
source server replicated to a replica?
</p>
</td>
</tr>
<tr class="answer">
<td align="left" valign="top">
</td>
<td align="left" valign="top">
<p>
Yes, creation of stored procedures and functions carried out
through normal DDL statements on a replication source server are
replicated to a replica, so that the objects exist on both
servers.
<code class="literal">
ALTER
</code>
and
<code class="literal">
DROP
</code>
statements for stored procedures and functions are also
replicated.
</p>
</td>
</tr>
<tr class="question">
<td align="left" valign="top">
<a name="faq-mysql-how-procedures-replicated">
</a>
<a name="idm46045056280640">
</a>
<p>
<b>
A.4.24.
</b>
</p>
</td>
<td align="left" valign="top">
<p>
How are actions that take place inside stored procedures and
functions replicated?
</p>
</td>
</tr>
<tr class="answer">
<td align="left" valign="top">
</td>
<td align="left" valign="top">
<p>
MySQL records each DML event that occurs in a stored procedure
and replicates those individual actions to a replica. The actual
calls made to execute stored procedures are not replicated.
</p>
<p>
Stored functions that change data are logged as function
invocations, not as the DML events that occur inside each
function.
</p>
</td>
</tr>
<tr class="question">
<td align="left" valign="top">
<a name="faq-mysql-security-procedures-replication">
</a>
<a name="idm46045056277744">
</a>
<p>
<b>
A.4.25.
</b>
</p>
</td>
<td align="left" valign="top">
<p>
Are there special security requirements for using stored
procedures and functions together with replication?
</p>
</td>
</tr>
<tr class="answer">
<td align="left" valign="top">
</td>
<td align="left" valign="top">
<p>
Yes. Because a replica has authority to execute any statement
read from a source's binary log, special security constraints
exist for using stored functions with replication. If
replication or binary logging in general (for the purpose of
point-in-time recovery) is active, then MySQL DBAs have two
security options open to them:
</p>
<div class="orderedlist">
<ol class="orderedlist" type="1">
<li class="listitem">
<p>
Any user wishing to create stored functions must be
granted the
<a class="link" href="privileges-provided.html#priv_super">
<code class="literal">
SUPER
</code>
</a>
privilege.
</p>
</li>
<li class="listitem">
<p>
Alternatively, a DBA can set the
<a class="link" href="replication-options-binary-log.html#sysvar_log_bin_trust_function_creators">
<code class="literal">
log_bin_trust_function_creators
</code>
</a>
system variable to 1, which enables anyone with the
standard
<a class="link" href="privileges-provided.html#priv_create-routine">
<code class="literal">
CREATE ROUTINE
</code>
</a>
privilege to create stored functions.
</p>
</li>
</ol>
</div>
<p>
</p>
</td>
</tr>
<tr class="question">
<td align="left" valign="top">
<a name="faq-mysql-limitations-procedures-replication">
</a>
<a name="idm46045056268768">
</a>
<p>
<b>
A.4.26.
</b>
</p>
</td>
<td align="left" valign="top">
<p>
What limitations exist for replicating stored procedure and
function actions?
</p>
</td>
</tr>
<tr class="answer">
<td align="left" valign="top">
</td>
<td align="left" valign="top">
<p>
Nondeterministic (random) or time-based actions embedded in
stored procedures may not replicate properly. By their very
nature, randomly produced results are not predictable and cannot
be exactly reproduced; therefore, random actions replicated to a
replica do not mirror those performed on a source. Declaring
stored functions to be
<code class="literal">
DETERMINISTIC
</code>
or
setting the
<a class="link" href="replication-options-binary-log.html#sysvar_log_bin_trust_function_creators">
<code class="literal">
log_bin_trust_function_creators
</code>
</a>
system variable to 0 keeps random operations producing random
values from being invoked.
</p>
<p>
In addition, time-based actions cannot be reproduced on a
replica because the timing of such actions in a stored procedure
is not reproducible through the binary log used for replication.
It records only DML events and does not factor in timing
constraints.
</p>
<p>
Finally, nontransactional tables for which errors occur during
large DML actions (such as bulk inserts) may experience
replication issues in that a source may be partially updated
from DML activity, but no updates are done to the replica
because of the errors that occurred. A workaround is for a
function's DML actions to be carried out with the
<code class="literal">
IGNORE
</code>
keyword so that updates on the source
that cause errors are ignored and updates that do not cause
errors are replicated to the replica.
</p>
</td>
</tr>
<tr class="question">
<td align="left" valign="top">
<a name="faq-mysql-limitations-pit-recovery">
</a>
<a name="idm46045056261872">
</a>
<p>
<b>
A.4.27.
</b>
</p>
</td>
<td align="left" valign="top">
<p>
Do the preceding limitations affect the ability of MySQL to do
point-in-time recovery?
</p>
</td>
</tr>
<tr class="answer">
<td align="left" valign="top">
</td>
<td align="left" valign="top">
<p>
The same limitations that affect replication do affect
point-in-time recovery.
</p>
</td>
</tr>
<tr class="question">
<td align="left" valign="top">
<a name="faq-mysql-when-limitations-resolved">
</a>
<a name="idm46045056259712">
</a>
<p>
<b>
A.4.28.
</b>
</p>
</td>
<td align="left" valign="top">
<p>
What is being done to correct the aforementioned limitations?
</p>
</td>
</tr>
<tr class="answer">
<td align="left" valign="top">
</td>
<td align="left" valign="top">
<p>
You can choose either statement-based replication or row-based
replication. The original replication implementation is based on
statement-based binary logging. Row-based binary logging
resolves the limitations mentioned earlier.
</p>
<p>
<span class="firstterm">
Mixed
</span>
replication is also
available (by starting the server with
<a class="link" href="replication-options-binary-log.html#sysvar_binlog_format">
<code class="option">
--binlog-format=mixed
</code>
</a>
). This
hybrid form of replication
<span class="quote">
“
<span class="quote">
knows
</span>
”
</span>
whether
statement-level replication can safely be used, or row-level
replication is required.
</p>
<p>
For additional information, see
<a class="xref" href="replication-formats.html" title="19.2.1 Replication Formats">
Section 19.2.1, “Replication Formats”
</a>
.
</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/performance-schema-connection-tables.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="performance-schema-connection-tables">
</a>
29.12.8 Performance Schema Connection Tables
</h3>
</div>
</div>
</div>
<div class="toc">
<dl class="toc">
<dt>
<span class="section">
<a href="performance-schema-accounts-table.html">
29.12.8.1 The accounts Table
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="performance-schema-hosts-table.html">
29.12.8.2 The hosts Table
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="performance-schema-users-table.html">
29.12.8.3 The users Table
</a>
</span>
</dt>
</dl>
</div>
<p>
When a client connects to the MySQL server, it does so under a
particular user name and from a particular host. The Performance
Schema provides statistics about these connections, tracking
them per account (user and host combination) as well as
separately per user name and host name, using these tables:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<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>
: Connection statistics
per client account
</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>
: Connection statistics
per client host name
</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>
: Connection statistics
per client user name
</p>
</li>
</ul>
</div>
<p>
The meaning of
<span class="quote">
“
<span class="quote">
account
</span>
”
</span>
in the connection tables
is similar to its meaning in the MySQL grant tables in the
<code class="literal">
mysql
</code>
system database, in the sense that the
term refers to a combination of user and host values. They
differ in that, for grant tables, the host part of an account
can be a pattern, whereas for Performance Schema tables, the
host value is always a specific nonpattern host name.
</p>
<p>
Each connection table has
<code class="literal">
CURRENT_CONNECTIONS
</code>
and
<code class="literal">
TOTAL_CONNECTIONS
</code>
columns to track the
current and total number of connections per
<span class="quote">
“
<span class="quote">
tracking
value
</span>
”
</span>
on which its statistics are based. The tables
differ in what they use for the tracking value. 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
<code class="literal">
USER
</code>
and
<code class="literal">
HOST
</code>
columns to
track connections per user and host combination. The
<a class="link" href="performance-schema-users-table.html" title="29.12.8.3 The users Table">
<code class="literal">
users
</code>
</a>
and
<a class="link" href="performance-schema-hosts-table.html" title="29.12.8.2 The hosts Table">
<code class="literal">
hosts
</code>
</a>
tables have a
<code class="literal">
USER
</code>
and
<code class="literal">
HOST
</code>
column,
respectively, to track connections per user name and host name.
</p>
<p>
The Performance Schema also counts internal threads and threads
for user sessions that failed to authenticate, using rows with
<code class="literal">
USER
</code>
and
<code class="literal">
HOST
</code>
column
values of
<code class="literal">
NULL
</code>
.
</p>
<p>
Suppose that clients named
<code class="literal">
user1
</code>
and
<code class="literal">
user2
</code>
each connect one time from
<code class="literal">
hosta
</code>
and
<code class="literal">
hostb
</code>
. The
Performance Schema tracks the connections as follows:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<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 four
rows, for the
<code class="literal">
user1
</code>
/
<code class="literal">
hosta
</code>
,
<code class="literal">
user1
</code>
/
<code class="literal">
hostb
</code>
,
<code class="literal">
user2
</code>
/
<code class="literal">
hosta
</code>
, and
<code class="literal">
user2
</code>
/
<code class="literal">
hostb
</code>
account
values, each row counting one connection per account.
</p>
</li>
<li class="listitem">
<p>
The
<a class="link" href="performance-schema-hosts-table.html" title="29.12.8.2 The hosts Table">
<code class="literal">
hosts
</code>
</a>
table has two rows,
for
<code class="literal">
hosta
</code>
and
<code class="literal">
hostb
</code>
,
each row counting two connections per host name.
</p>
</li>
<li class="listitem">
<p>
The
<a class="link" href="performance-schema-users-table.html" title="29.12.8.3 The users Table">
<code class="literal">
users
</code>
</a>
table has two rows,
for
<code class="literal">
user1
</code>
and
<code class="literal">
user2
</code>
,
each row counting two connections per user name.
</p>
</li>
</ul>
</div>
<p>
When a client connects, the Performance Schema determines which
row in each connection table applies, using the tracking value
appropriate to each table. If there is no such row, one is
added. Then the Performance Schema increments by one the
<code class="literal">
CURRENT_CONNECTIONS
</code>
and
<code class="literal">
TOTAL_CONNECTIONS
</code>
columns in that row.
</p>
<p>
When a client disconnects, the Performance Schema decrements by
one the
<code class="literal">
CURRENT_CONNECTIONS
</code>
column in the row
and leaves the
<code class="literal">
TOTAL_CONNECTIONS
</code>
column
unchanged.
</p>
<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
connection tables. It has these effects:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Rows are removed for accounts, hosts, or users that have no
current connections (rows with
<code class="literal">
CURRENT_CONNECTIONS
= 0
</code>
).
</p>
</li>
<li class="listitem">
<p>
Nonremoved rows are reset to count only current connections:
For rows with
<code class="literal">
CURRENT_CONNECTIONS > 0
</code>
,
<code class="literal">
TOTAL_CONNECTIONS
</code>
is reset to
<code class="literal">
CURRENT_CONNECTIONS
</code>
.
</p>
</li>
<li class="listitem">
<p>
Summary tables that depend on the connection table are
implicitly truncated, as described later in this section.
</p>
</li>
</ul>
</div>
<p>
The Performance Schema maintains summary tables that aggregate
connection statistics for various event types by account, host,
or user. These tables have
<code class="literal">
_summary_by_account
</code>
,
<code class="literal">
_summary_by_host
</code>
, or
<code class="literal">
_summary_by_user
</code>
in the name. To identify
them, use this query:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa21263555"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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">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> TABLE_SCHEMA <span class="token operator">=</span> <span class="token string">'performance_schema'</span>
<span class="token operator">AND</span> <span class="token keyword">TABLE_NAME</span> <span class="token operator">REGEXP</span> <span class="token string">'_summary_by_(account|host|user)'</span>
<span class="token keyword">ORDER</span> <span class="token keyword">BY</span> <span class="token keyword">TABLE_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 class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="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_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 class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="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_errors_summary_by_account_by_error <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> events_errors_summary_by_host_by_error <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> events_errors_summary_by_user_by_error <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> events_stages_summary_by_account_by_event_name <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> events_stages_summary_by_host_by_event_name <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> events_stages_summary_by_user_by_event_name <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> events_statements_summary_by_account_by_event_name <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> events_statements_summary_by_host_by_event_name <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> events_statements_summary_by_user_by_event_name <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> events_transactions_summary_by_account_by_event_name <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> events_transactions_summary_by_host_by_event_name <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> events_transactions_summary_by_user_by_event_name <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> events_waits_summary_by_account_by_event_name <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> events_waits_summary_by_host_by_event_name <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> events_waits_summary_by_user_by_event_name <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> memory_summary_by_account_by_event_name <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> memory_summary_by_host_by_event_name <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> memory_summary_by_user_by_event_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 class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="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 details about individual connection summary tables, consult
the section that describes tables for the summarized event type:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Wait event summaries:
<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>
</li>
<li class="listitem">
<p>
Stage event summaries:
<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>
</li>
<li class="listitem">
<p>
Statement event summaries:
<a class="xref" href="performance-schema-statement-summary-tables.html" title="29.12.20.3 Statement Summary Tables">
Section 29.12.20.3, “Statement Summary Tables”
</a>
</p>
</li>
<li class="listitem">
<p>
Transaction event summaries:
<a class="xref" href="performance-schema-transaction-summary-tables.html" title="29.12.20.5 Transaction Summary Tables">
Section 29.12.20.5, “Transaction Summary Tables”
</a>
</p>
</li>
<li class="listitem">
<p>
Memory event summaries:
<a class="xref" href="performance-schema-memory-summary-tables.html" title="29.12.20.10 Memory Summary Tables">
Section 29.12.20.10, “Memory Summary Tables”
</a>
</p>
</li>
<li class="listitem">
<p>
Error event summaries:
<a class="xref" href="performance-schema-error-summary-tables.html" title="29.12.20.11 Error Summary Tables">
Section 29.12.20.11, “Error Summary Tables”
</a>
</p>
</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
connection summary tables. It removes rows for accounts, hosts,
or users with no connections, and resets the summary columns to
zero for the remaining rows. In addition, each summary table
that is aggregated by account, host, user, or thread is
implicitly truncated by truncation of the connection table on
which it depends. The following table describes the relationship
between connection table truncation and implicitly truncated
tables.
</p>
<div class="table">
<a name="idm46045072120800">
</a>
<p class="title">
<b>
Table 29.2 Implicit Effects of Connection Table Truncation
</b>
</p>
<div class="table-contents">
<table summary="Which Performance Schema summary tables are implicity truncated by connection table truncation.">
<colgroup>
<col style="width: 40%"/>
<col style="width: 60%"/>
</colgroup>
<thead>
<tr>
<th>
Truncated Connection Table
</th>
<th>
Implicitly Truncated Summary Tables
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<code class="literal">
accounts
</code>
</td>
<td>
Tables with names containing
<code class="literal">
_summary_by_account
</code>
,
<code class="literal">
_summary_by_thread
</code>
</td>
</tr>
<tr>
<td>
<code class="literal">
hosts
</code>
</td>
<td>
Tables with names containing
<code class="literal">
_summary_by_account
</code>
,
<code class="literal">
_summary_by_host
</code>
,
<code class="literal">
_summary_by_thread
</code>
</td>
</tr>
<tr>
<td>
<code class="literal">
users
</code>
</td>
<td>
Tables with names containing
<code class="literal">
_summary_by_account
</code>
,
<code class="literal">
_summary_by_user
</code>
,
<code class="literal">
_summary_by_thread
</code>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<br class="table-break"/>
<p>
Truncating a
<code class="literal">
_summary_global
</code>
summary table
also implicitly truncates its corresponding connection and
thread summary tables. For example, truncating
<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>
implicitly truncates the wait event summary tables that are
aggregated by account, host, user, or thread.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/group-replication-configuring-ssl-for-recovery.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="group-replication-configuring-ssl-for-recovery">
</a>
20.6.3.2 Secure Socket Layer (SSL) Connections for Distributed Recovery
</h4>
</div>
</div>
</div>
<div class="important" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Important
</div>
<p>
When using the MySQL communication stack
(
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_communication_stack">
<code class="literal">
group_replication_communication_stack=MYSQL
</code>
</a>
)
AND secure connections between members
(
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_ssl_mode">
<code class="literal">
group_replication_ssl_mode
</code>
</a>
is not set to
<code class="literal">
DISABLED
</code>
), the security
settings discussed in this section are applied not just to
distributed recovery connections, but to group communications
between members in general. See
<a class="xref" href="group-replication-connection-security.html" title="20.6.1 Communication Stack for Connection Security Management">
Section 20.6.1, “Communication Stack for Connection Security Management”
</a>
.
</p>
</div>
<p>
Whether the distributed recovery connection is made using the
standard SQL client connection or a distributed recovery
endpoint, to configure the connection securely, you can use
Group Replication's dedicated distributed recovery SSL options.
These options correspond to the server SSL options that are used
for group communication connections, but they are only applied
for distributed recovery connections. By default, distributed
recovery connections do not use SSL, even if you activated SSL
for group communication connections, and the server SSL options
are not applied for distributed recovery connections. You must
configure these connections separately.
</p>
<p>
If a remote cloning operation is used as part of distributed
recovery, Group Replication automatically configures the clone
plugin's SSL options to match your settings for the distributed
recovery SSL options. (For details of how the clone plugin uses
SSL, see
<a class="xref" href="clone-plugin-remote.html#clone-plugin-remote-ssl" title="Configuring an Encrypted Connection for Cloning">
Configuring an Encrypted Connection for Cloning
</a>
.)
</p>
<p>
The distributed recovery SSL options are as follows:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_recovery_use_ssl">
<code class="literal">
group_replication_recovery_use_ssl
</code>
</a>
:
Set to
<code class="literal">
ON
</code>
to make Group Replication use
SSL for distributed recovery connections, including remote
cloning operations and state transfer from a donor's
binary log. If the server you connect to does not use the
default configuration for this (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>
), use the
other distributed recovery SSL options to determine which
certificates and cipher suites to use.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_recovery_ssl_ca">
<code class="literal">
group_replication_recovery_ssl_ca
</code>
</a>
:
The path name of the Certificate Authority (CA) file to use
for distributed recovery connections. Group Replication
automatically configures the clone SSL option
<a class="link" href="clone-plugin-options-variables.html#sysvar_clone_ssl_ca">
<code class="literal">
clone_ssl_ca
</code>
</a>
to match this.
</p>
<p>
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_recovery_ssl_capath">
<code class="literal">
group_replication_recovery_ssl_capath
</code>
</a>
:
The path name of a directory that contains trusted SSL
certificate authority (CA) certificate files.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_recovery_ssl_cert">
<code class="literal">
group_replication_recovery_ssl_cert
</code>
</a>
:
The path name of the SSL public key certificate file to use
for distributed recovery connections. Group Replication
automatically configures the clone SSL option
<a class="link" href="clone-plugin-options-variables.html#sysvar_clone_ssl_cert">
<code class="literal">
clone_ssl_cert
</code>
</a>
to match
this.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_recovery_ssl_key">
<code class="literal">
group_replication_recovery_ssl_key
</code>
</a>
:
The path name of the SSL private key file to use for
distributed recovery connections. Group Replication
automatically configures the clone SSL option
<a class="link" href="clone-plugin-options-variables.html#sysvar_clone_ssl_cert">
<code class="literal">
clone_ssl_cert
</code>
</a>
to match
this.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_recovery_ssl_verify_server_cert">
<code class="literal">
group_replication_recovery_ssl_verify_server_cert
</code>
</a>
:
Makes the distributed recovery connection check the server's
Common Name value in the donor sent certificate. Setting
this option to
<code class="literal">
ON
</code>
is the equivalent for
distributed recovery connections of setting
<code class="literal">
VERIFY_IDENTITY
</code>
for the
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_ssl_mode">
<code class="literal">
group_replication_ssl_mode
</code>
</a>
option for group communication connections.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_recovery_ssl_crl">
<code class="literal">
group_replication_recovery_ssl_crl
</code>
</a>
:
The path name of a file containing certificate revocation
lists.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_recovery_ssl_crlpath">
<code class="literal">
group_replication_recovery_ssl_crlpath
</code>
</a>
:
The path name of a directory containing certificate
revocation lists.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_recovery_ssl_cipher">
<code class="literal">
group_replication_recovery_ssl_cipher
</code>
</a>
:
A list of permissible ciphers for connection encryption for
the distributed recovery connection. Specify a list of one
or more cipher names, separated by colons. For information
about which encryption ciphers MySQL 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>
</li>
<li class="listitem">
<p>
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_recovery_tls_version">
<code class="literal">
group_replication_recovery_tls_version
</code>
</a>
:
A comma-separated list of one or more permitted TLS
protocols for connection encryption when this server
instance is the client in the distributed recovery
connection, that is, the joining member. The default for
this system variable depends on the TLS protocol versions
supported in the MySQL Server release. The group members
involved in each distributed recovery connection as the
client (joining member) and server (donor) negotiate the
highest protocol version that they are both set up to
support.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_recovery_tls_ciphersuites">
<code class="literal">
group_replication_recovery_tls_ciphersuites
</code>
</a>
:
A colon-separated list of one or more permitted ciphersuites
when TLSv1.3 is used for connection encryption for the
distributed recovery connection, and this server instance is
the client in the distributed recovery connection, that is,
the joining member. If this system variable is set to
<code class="literal">
NULL
</code>
when TLSv1.3 is used (which is the
default if you do not set the system variable), the
ciphersuites that are enabled by default are allowed, as
listed in
<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>
. If
this system variable is set to the empty string, no cipher
suites are allowed, and TLSv1.3 is therefore not used.
</p>
</li>
</ul>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/spatial-aggregate-functions.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="spatial-aggregate-functions">
</a>
14.16.12 Spatial Aggregate Functions
</h3>
</div>
</div>
</div>
<a class="indexterm" name="idm46045196077616">
</a>
<a class="indexterm" name="idm46045196076528">
</a>
<p>
MySQL supports aggregate functions that perform a calculation on a
set of values. For general information about these functions, see
<a class="xref" href="aggregate-functions.html" title="14.19.1 Aggregate Function Descriptions">
Section 14.19.1, “Aggregate Function Descriptions”
</a>
. This section describes the
<a class="link" href="spatial-aggregate-functions.html#function_st-collect">
<code class="literal">
ST_Collect()
</code>
</a>
spatial aggregate
function.
</p>
<p>
<a class="link" href="spatial-aggregate-functions.html#function_st-collect">
<code class="literal">
ST_Collect()
</code>
</a>
can be used as a
window function, as signified in its syntax description by
<code class="literal">
[
<em class="replaceable">
<code>
over_clause
</code>
</em>
]
</code>
,
representing an optional
<code class="literal">
OVER
</code>
clause.
<em class="replaceable">
<code>
over_clause
</code>
</em>
is described in
<a class="xref" href="window-functions-usage.html" title="14.20.2 Window Function Concepts and Syntax">
Section 14.20.2, “Window Function Concepts and Syntax”
</a>
, which also includes
other information about window function usage.
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<a name="function_st-collect">
</a>
<p>
<a class="link" href="spatial-aggregate-functions.html#function_st-collect">
<code class="literal">
ST_Collect([DISTINCT]
<em class="replaceable">
<code>
g
</code>
</em>
)
[
<em class="replaceable">
<code>
over_clause
</code>
</em>
]
</code>
</a>
</p>
<a class="indexterm" name="idm46045196062240">
</a>
<p>
Aggregates geometry values and returns a single geometry
collection value. With the
<code class="literal">
DISTINCT
</code>
option,
returns the aggregation of the distinct geometry arguments.
</p>
<p>
As with other aggregate functions,
<code class="literal">
GROUP BY
</code>
may be used to group arguments into subsets.
<a class="link" href="spatial-aggregate-functions.html#function_st-collect">
<code class="literal">
ST_Collect()
</code>
</a>
returns an
aggregate value for each subset.
</p>
<p>
This function executes as a window function if
<em class="replaceable">
<code>
over_clause
</code>
</em>
is present.
<em class="replaceable">
<code>
over_clause
</code>
</em>
is as described in
<a class="xref" href="window-functions-usage.html" title="14.20.2 Window Function Concepts and Syntax">
Section 14.20.2, “Window Function Concepts and Syntax”
</a>
. In contrast to most
aggregate functions that support windowing,
<a class="link" href="spatial-aggregate-functions.html#function_st-collect">
<code class="literal">
ST_Collect()
</code>
</a>
permits use of
<em class="replaceable">
<code>
over_clause
</code>
</em>
together with
<code class="literal">
DISTINCT
</code>
.
</p>
<p>
<a class="link" href="spatial-aggregate-functions.html#function_st-collect">
<code class="literal">
ST_Collect()
</code>
</a>
handles its
arguments as follows:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
<code class="literal">
NULL
</code>
arguments are ignored.
</p>
</li>
<li class="listitem">
<p>
If all arguments are
<code class="literal">
NULL
</code>
or the
aggregate result is empty, 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>
If there are multiple geometry arguments and those
arguments are in the same SRS, the return value is in that
SRS. 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_aggregation" target="_top">
<code class="literal">
ER_GIS_DIFFERENT_SRIDS_AGGREGATION
</code>
</a>
error occurs.
</p>
</li>
<li class="listitem">
<p>
The result is the narrowest
<code class="literal">
Multi
<em class="replaceable">
<code>
Xxx
</code>
</em>
</code>
or
<code class="literal">
GeometryCollection
</code>
value possible, with
the result type determined from the
non-
<code class="literal">
NULL
</code>
geometry arguments as follows:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: square; ">
<li class="listitem">
<p>
If all arguments are
<code class="literal">
Point
</code>
values,
the result is a
<code class="literal">
MultiPoint
</code>
value.
</p>
</li>
<li class="listitem">
<p>
If all arguments are
<code class="literal">
LineString
</code>
values, the result is a
<code class="literal">
MultiLineString
</code>
value.
</p>
</li>
<li class="listitem">
<p>
If all arguments are
<code class="literal">
Polygon
</code>
values, the result is a
<code class="literal">
MultiPolygon
</code>
value.
</p>
</li>
<li class="listitem">
<p>
Otherwise, the arguments are a mix of geometry types
and the result is a
<code class="literal">
GeometryCollection
</code>
value.
</p>
</li>
</ul>
</div>
</li>
</ul>
</div>
<p>
This example data set shows hypothetical products by year and
location of manufacture:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa5847084"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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> product <span class="token punctuation">(</span>
<span class="token datatype">year</span> <span class="token datatype">INTEGER</span><span class="token punctuation">,</span>
product <span class="token datatype">VARCHAR</span><span class="token punctuation">(</span><span class="token number">256</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
location <span class="token keyword">Geometry</span>
<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">INSERT</span> <span class="token keyword">INTO</span> product
<span class="token punctuation">(</span><span class="token datatype">year</span><span class="token punctuation">,</span> product<span class="token punctuation">,</span> location<span class="token punctuation">)</span> <span class="token keyword">VALUES</span>
<span class="token punctuation">(</span><span class="token number">2000</span><span class="token punctuation">,</span> <span class="token string">"Calculator"</span><span class="token punctuation">,</span> <span class="token function">ST_GeomFromText</span><span class="token punctuation">(</span><span class="token string">'point(60 -24)'</span><span class="token punctuation">,</span><span class="token number">4326</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token punctuation">(</span><span class="token number">2000</span><span class="token punctuation">,</span> <span class="token string">"Computer"</span> <span class="token punctuation">,</span> <span class="token function">ST_GeomFromText</span><span class="token punctuation">(</span><span class="token string">'point(28 -77)'</span><span class="token punctuation">,</span><span class="token number">4326</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token punctuation">(</span><span class="token number">2000</span><span class="token punctuation">,</span> <span class="token string">"Abacus"</span> <span class="token punctuation">,</span> <span class="token function">ST_GeomFromText</span><span class="token punctuation">(</span><span class="token string">'point(28 -77)'</span><span class="token punctuation">,</span><span class="token number">4326</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token punctuation">(</span><span class="token number">2000</span><span class="token punctuation">,</span> <span class="token string">"TV"</span> <span class="token punctuation">,</span> <span class="token function">ST_GeomFromText</span><span class="token punctuation">(</span><span class="token string">'point(38 60)'</span><span class="token punctuation">,</span><span class="token number">4326</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token punctuation">(</span><span class="token number">2001</span><span class="token punctuation">,</span> <span class="token string">"Calculator"</span><span class="token punctuation">,</span> <span class="token function">ST_GeomFromText</span><span class="token punctuation">(</span><span class="token string">'point(60 -24)'</span><span class="token punctuation">,</span><span class="token number">4326</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token punctuation">(</span><span class="token number">2001</span><span class="token punctuation">,</span> <span class="token string">"Computer"</span> <span class="token punctuation">,</span> <span class="token function">ST_GeomFromText</span><span class="token punctuation">(</span><span class="token string">'point(28 -77)'</span><span class="token punctuation">,</span><span class="token number">4326</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
Some sample queries using
<a class="link" href="spatial-aggregate-functions.html#function_st-collect">
<code class="literal">
ST_Collect()
</code>
</a>
on the data set:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa70736094"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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">ST_AsText</span><span class="token punctuation">(</span>ST_Collect<span class="token punctuation">(</span>location<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token keyword">AS</span> result
<span class="token keyword">FROM</span> product<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>
<span class="token output"><span class="token punctuation">|</span> result <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>
<span class="token output"><span class="token punctuation">|</span> MULTIPOINT((60 <span class="token punctuation">-</span>24),(28 <span class="token punctuation">-</span>77),(28 <span class="token punctuation">-</span>77),(38 60),(60 <span class="token punctuation">-</span>24),(28 <span class="token punctuation">-</span>77)) <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>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token function">ST_AsText</span><span class="token punctuation">(</span>ST_Collect<span class="token punctuation">(</span><span class="token keyword">DISTINCT</span> location<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token keyword">AS</span> result
<span class="token keyword">FROM</span> product<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> result <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> MULTIPOINT((60 <span class="token punctuation">-</span>24),(28 <span class="token punctuation">-</span>77),(38 60)) <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 prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token datatype">year</span><span class="token punctuation">,</span> <span class="token function">ST_AsText</span><span class="token punctuation">(</span>ST_Collect<span class="token punctuation">(</span>location<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token keyword">AS</span> result
<span class="token keyword">FROM</span> product <span class="token keyword">GROUP</span> <span class="token keyword">BY</span> <span class="token datatype">year</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> year <span class="token punctuation">|</span> result <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> 2000 <span class="token punctuation">|</span> MULTIPOINT((60 <span class="token punctuation">-</span>24),(28 <span class="token punctuation">-</span>77),(28 <span class="token punctuation">-</span>77),(38 60)) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 2001 <span class="token punctuation">|</span> MULTIPOINT((60 <span class="token punctuation">-</span>24),(28 <span class="token punctuation">-</span>77)) <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 prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token datatype">year</span><span class="token punctuation">,</span> <span class="token function">ST_AsText</span><span class="token punctuation">(</span>ST_Collect<span class="token punctuation">(</span><span class="token keyword">DISTINCT</span> location<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token keyword">AS</span> result
<span class="token keyword">FROM</span> product <span class="token keyword">GROUP</span> <span class="token keyword">BY</span> <span class="token datatype">year</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>
<span class="token output"><span class="token punctuation">|</span> year <span class="token punctuation">|</span> result <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>
<span class="token output"><span class="token punctuation">|</span> 2000 <span class="token punctuation">|</span> MULTIPOINT((60 <span class="token punctuation">-</span>24),(28 <span class="token punctuation">-</span>77),(38 60)) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 2001 <span class="token punctuation">|</span> MULTIPOINT((60 <span class="token punctuation">-</span>24),(28 <span class="token punctuation">-</span>77)) <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>
<span class="token comment" spellcheck="true"># selects nothing</span>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> ST_Collect<span class="token punctuation">(</span>location<span class="token punctuation">)</span> <span class="token keyword">AS</span> result
<span class="token keyword">FROM</span> product <span class="token keyword">WHERE</span> <span class="token datatype">year</span> <span class="token operator">=</span> <span class="token number">1999</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>
<span class="token output"><span class="token punctuation">|</span> result <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>
<span class="token output"><span class="token punctuation">|</span> NULL <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>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token function">ST_AsText</span><span class="token punctuation">(</span>ST_Collect<span class="token punctuation">(</span>location<span class="token punctuation">)</span>
<span class="token keyword">OVER</span> <span class="token punctuation">(</span><span class="token keyword">ORDER</span> <span class="token keyword">BY</span> <span class="token datatype">year</span><span class="token punctuation">,</span> product <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 keyword">CURRENT</span> <span class="token keyword">ROW</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
<span class="token keyword">AS</span> result
<span class="token keyword">FROM</span> product<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> result <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> MULTIPOINT((28 <span class="token punctuation">-</span>77)) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> MULTIPOINT((28 <span class="token punctuation">-</span>77),(60 <span class="token punctuation">-</span>24)) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> MULTIPOINT((60 <span class="token punctuation">-</span>24),(28 <span class="token punctuation">-</span>77)) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> MULTIPOINT((28 <span class="token punctuation">-</span>77),(38 60)) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> MULTIPOINT((38 60),(60 <span class="token punctuation">-</span>24)) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> MULTIPOINT((60 <span class="token punctuation">-</span>24),(28 <span class="token punctuation">-</span>77)) <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></code></pre>
</div>
</li>
</ul>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/mysql-gr-memory-monitoring-ps-sample-queries.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="mysql-gr-memory-monitoring-ps-sample-queries">
</a>
20.7.9.2 Example Queries
</h4>
</div>
</div>
</div>
<p>
This section describes sample queries using the instruments and
events for monitoring Group Replication memory usage. The
queries retrieve data from the
<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>
<p>
The memory data can be queried for individual events, for
example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa73089173"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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> performance_schema<span class="token punctuation">.</span>memory_summary_global_by_event_name
<span class="token keyword">WHERE</span> EVENT_NAME <span class="token operator">=</span> <span class="token string">'memory/group_rpl/write_set_encoded'</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>
EVENT_NAME<span class="token punctuation">:</span> memory/group_rpl/write_set_encoded
COUNT_ALLOC<span class="token punctuation">:</span> 1
COUNT_FREE<span class="token punctuation">:</span> 0
SUM_NUMBER_OF_BYTES_ALLOC<span class="token punctuation">:</span> 45
SUM_NUMBER_OF_BYTES_FREE<span class="token punctuation">:</span> 0
LOW_COUNT_USED<span class="token punctuation">:</span> 0
CURRENT_COUNT_USED<span class="token punctuation">:</span> 1
HIGH_COUNT_USED<span class="token punctuation">:</span> 1
LOW_NUMBER_OF_BYTES_USED<span class="token punctuation">:</span> 0
CURRENT_NUMBER_OF_BYTES_USED<span class="token punctuation">:</span> 45
HIGH_NUMBER_OF_BYTES_USED<span class="token punctuation">:</span> 45</span></code></pre>
</div>
<p>
See
<a class="xref" href="performance-schema-memory-summary-tables.html" title="29.12.20.10 Memory Summary Tables">
Section 29.12.20.10, “Memory Summary Tables”
</a>
for more information on the columns.
</p>
<p>
You can also define queries which sum various events to provide
overviews of specific areas of memory usage.
</p>
<p>
The following examples are described:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="xref" href="mysql-gr-memory-monitoring-ps-sample-queries.html#mysql-gr-memory-monitoring-ps-sample-queries-transaction-capture" title="Memory Used to Capture Transactions">
Memory Used to Capture Transactions
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="mysql-gr-memory-monitoring-ps-sample-queries.html#mysql-gr-memory-monitoring-ps-sample-queries-transaction-broadcast" title="Memory Used to Broadcast Transactions">
Memory Used to Broadcast Transactions
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="mysql-gr-memory-monitoring-ps-sample-queries.html#mysql-gr-memory-monitoring-ps-sample-queries-total-memory" title="Total Memory Used in Group Replication">
Total Memory Used in Group Replication
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="mysql-gr-memory-monitoring-ps-sample-queries.html#mysql-gr-memory-monitoring-ps-sample-queries-certification-memory" title="Memory Used in Certification">
Memory Used in Certification
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="mysql-gr-memory-monitoring-ps-sample-queries.html#mysql-gr-memory-monitoring-ps-sample-queries-certification-memory" title="Memory Used in Certification">
Memory Used in Certification
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="mysql-gr-memory-monitoring-ps-sample-queries.html#mysql-gr-memory-monitoring-ps-sample-queries-pipeline-memory" title="Memory Used in Replication Pipeline">
Memory Used in Replication Pipeline
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="mysql-gr-memory-monitoring-ps-sample-queries.html#mysql-gr-memory-monitoring-ps-sample-queries-consistency-memory" title="Memory Used in Consistency">
Memory Used in Consistency
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="mysql-gr-memory-monitoring-ps-sample-queries.html#mysql-gr-memory-monitoring-ps-sample-queries-message-memory" title="Memory Used in Delivery Message Service">
Memory Used in Delivery Message Service
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="mysql-gr-memory-monitoring-ps-sample-queries.html#mysql-gr-memory-monitoring-ps-sample-queries-send-receive-transaction" title="Memory Used to Broadcast and Receive Transactions">
Memory Used to Broadcast and Receive Transactions
</a>
</p>
</li>
</ul>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="mysql-gr-memory-monitoring-ps-sample-queries-transaction-capture">
</a>
Memory Used to Capture Transactions
</h5>
</div>
</div>
</div>
<p>
The memory allocated to capture user transactions is a sum of
the
<code class="literal">
write_set_encoded
</code>
,
<code class="literal">
write_set_extraction
</code>
, and
<code class="literal">
Log_event
</code>
event's values. For example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa83982330"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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">SELECT</span>
<span class="token punctuation">(</span><span class="token operator">CASE</span>
<span class="token keyword">WHEN</span> EVENT_NAME <span class="token operator">LIKE</span> <span class="token string">'memory/group_rpl/write_set_encoded'</span>
<span class="token keyword">THEN</span> <span class="token string">'memory/group_rpl/memory_gr'</span>
<span class="token keyword">WHEN</span> EVENT_NAME <span class="token operator">=</span> <span class="token string">'memory/sql/write_set_extraction'</span>
<span class="token keyword">THEN</span> <span class="token string">'memory/group_rpl/memory_gr'</span>
<span class="token keyword">WHEN</span> EVENT_NAME <span class="token operator">=</span> <span class="token string">'memory/sql/Log_event'</span>
<span class="token keyword">THEN</span> <span class="token string">'memory/group_rpl/memory_gr'</span>
<span class="token keyword">ELSE</span> <span class="token string">'memory_gr_rest'</span>
<span class="token keyword">END</span><span class="token punctuation">)</span> <span class="token keyword">AS</span> EVENT_NAME<span class="token punctuation">,</span>
<span class="token function">SUM</span><span class="token punctuation">(</span>COUNT_ALLOC<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token function">SUM</span><span class="token punctuation">(</span>COUNT_FREE<span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token function">SUM</span><span class="token punctuation">(</span>SUM_NUMBER_OF_BYTES_ALLOC<span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token function">SUM</span><span class="token punctuation">(</span>SUM_NUMBER_OF_BYTES_FREE<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token function">SUM</span><span class="token punctuation">(</span>LOW_COUNT_USED<span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token function">SUM</span><span class="token punctuation">(</span>CURRENT_COUNT_USED<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token function">SUM</span><span class="token punctuation">(</span>HIGH_COUNT_USED<span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token function">SUM</span><span class="token punctuation">(</span>LOW_NUMBER_OF_BYTES_USED<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token function">SUM</span><span class="token punctuation">(</span>CURRENT_NUMBER_OF_BYTES_USED<span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token function">SUM</span><span class="token punctuation">(</span>HIGH_NUMBER_OF_BYTES_USED<span class="token punctuation">)</span>
<span class="token keyword">FROM</span> performance_schema<span class="token punctuation">.</span>memory_summary_global_by_event_name
<span class="token keyword">GROUP</span> <span class="token keyword">BY</span> <span class="token punctuation">(</span><span class="token operator">CASE</span>
<span class="token keyword">WHEN</span> EVENT_NAME <span class="token operator">LIKE</span> <span class="token string">'memory/group_rpl/write_set_encoded'</span>
<span class="token keyword">THEN</span> <span class="token string">'memory/group_rpl/memory_gr'</span>
<span class="token keyword">WHEN</span> EVENT_NAME <span class="token operator">=</span> <span class="token string">'memory/sql/write_set_extraction'</span>
<span class="token keyword">THEN</span> <span class="token string">'memory/group_rpl/memory_gr'</span>
<span class="token keyword">WHEN</span> EVENT_NAME <span class="token operator">=</span> <span class="token string">'memory/sql/Log_event'</span>
<span class="token keyword">THEN</span> <span class="token string">'memory/group_rpl/memory_gr'</span>
<span class="token keyword">ELSE</span> <span class="token string">'memory_gr_rest'</span>
<span class="token keyword">END</span><span class="token punctuation">)</span>
<span class="token punctuation">)</span> f
<span class="token keyword">WHERE</span> f<span class="token punctuation">.</span>EVENT_NAME <span class="token operator">!=</span> <span class="token string">'memory_gr_rest'</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>
EVENT_NAME<span class="token punctuation">:</span> memory/group_rpl/memory_gr
SUM(COUNT_ALLOC)<span class="token punctuation">:</span> 127
SUM(COUNT_FREE)<span class="token punctuation">:</span> 117
SUM(SUM_NUMBER_OF_BYTES_ALLOC)<span class="token punctuation">:</span> 54808
SUM(SUM_NUMBER_OF_BYTES_FREE)<span class="token punctuation">:</span> 52051
SUM(LOW_COUNT_USED)<span class="token punctuation">:</span> 0
SUM(CURRENT_COUNT_USED)<span class="token punctuation">:</span> 10
SUM(HIGH_COUNT_USED)<span class="token punctuation">:</span> 35
SUM(LOW_NUMBER_OF_BYTES_USED)<span class="token punctuation">:</span> 0
SUM(CURRENT_NUMBER_OF_BYTES_USED)<span class="token punctuation">:</span> 2757
SUM(HIGH_NUMBER_OF_BYTES_USED)<span class="token punctuation">:</span> 15630</span></code></pre>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="mysql-gr-memory-monitoring-ps-sample-queries-transaction-broadcast">
</a>
Memory Used to Broadcast Transactions
</h5>
</div>
</div>
</div>
<p>
The memory allocated to broadcast transactions is a sum of the
<code class="literal">
Gcs_message_data::m_buffer
</code>
,
<code class="literal">
transaction_data
</code>
, and
<code class="literal">
GCS_XCom::xcom_cache
</code>
event values. For
example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa41526974"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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">SELECT</span>
<span class="token punctuation">(</span><span class="token operator">CASE</span>
<span class="token keyword">WHEN</span> EVENT_NAME <span class="token operator">=</span> <span class="token string">'memory/group_rpl/Gcs_message_data::m_buffer'</span>
<span class="token keyword">THEN</span> <span class="token string">'memory/group_rpl/memory_gr'</span>
<span class="token keyword">WHEN</span> EVENT_NAME <span class="token operator">=</span> <span class="token string">'memory/group_rpl/GCS_XCom::xcom_cache'</span>
<span class="token keyword">THEN</span> <span class="token string">'memory/group_rpl/memory_gr'</span>
<span class="token keyword">WHEN</span> EVENT_NAME <span class="token operator">=</span> <span class="token string">'memory/group_rpl/transaction_data'</span>
<span class="token keyword">THEN</span> <span class="token string">'memory/group_rpl/memory_gr'</span>
<span class="token keyword">ELSE</span> <span class="token string">'memory_gr_rest'</span>
<span class="token keyword">END</span><span class="token punctuation">)</span> <span class="token keyword">AS</span> EVENT_NAME<span class="token punctuation">,</span>
<span class="token function">SUM</span><span class="token punctuation">(</span>COUNT_ALLOC<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token function">SUM</span><span class="token punctuation">(</span>COUNT_FREE<span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token function">SUM</span><span class="token punctuation">(</span>SUM_NUMBER_OF_BYTES_ALLOC<span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token function">SUM</span><span class="token punctuation">(</span>SUM_NUMBER_OF_BYTES_FREE<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token function">SUM</span><span class="token punctuation">(</span>LOW_COUNT_USED<span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token function">SUM</span><span class="token punctuation">(</span>CURRENT_COUNT_USED<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token function">SUM</span><span class="token punctuation">(</span>HIGH_COUNT_USED<span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token function">SUM</span><span class="token punctuation">(</span>LOW_NUMBER_OF_BYTES_USED<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token function">SUM</span><span class="token punctuation">(</span>CURRENT_NUMBER_OF_BYTES_USED<span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token function">SUM</span><span class="token punctuation">(</span>HIGH_NUMBER_OF_BYTES_USED<span class="token punctuation">)</span>
<span class="token keyword">FROM</span> performance_schema<span class="token punctuation">.</span>memory_summary_global_by_event_name
<span class="token keyword">GROUP</span> <span class="token keyword">BY</span> <span class="token punctuation">(</span><span class="token operator">CASE</span>
<span class="token keyword">WHEN</span> EVENT_NAME <span class="token operator">=</span> <span class="token string">'memory/group_rpl/Gcs_message_data::m_buffer'</span>
<span class="token keyword">THEN</span> <span class="token string">'memory/group_rpl/memory_gr'</span>
<span class="token keyword">WHEN</span> EVENT_NAME <span class="token operator">=</span> <span class="token string">'memory/group_rpl/GCS_XCom::xcom_cache'</span>
<span class="token keyword">THEN</span> <span class="token string">'memory/group_rpl/memory_gr'</span>
<span class="token keyword">WHEN</span> EVENT_NAME <span class="token operator">=</span> <span class="token string">'memory/group_rpl/transaction_data'</span>
<span class="token keyword">THEN</span> <span class="token string">'memory/group_rpl/memory_gr'</span>
<span class="token keyword">ELSE</span> <span class="token string">'memory_gr_rest'</span>
<span class="token keyword">END</span><span class="token punctuation">)</span>
<span class="token punctuation">)</span> f
<span class="token keyword">WHERE</span> f<span class="token punctuation">.</span>EVENT_NAME <span class="token operator">!=</span> <span class="token string">'memory_gr_rest'</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>
EVENT_NAME<span class="token punctuation">:</span> memory/group_rpl/memory_gr
SUM(COUNT_ALLOC)<span class="token punctuation">:</span> 84
SUM(COUNT_FREE)<span class="token punctuation">:</span> 31
SUM(SUM_NUMBER_OF_BYTES_ALLOC)<span class="token punctuation">:</span> 1072324
SUM(SUM_NUMBER_OF_BYTES_FREE)<span class="token punctuation">:</span> 7149
SUM(LOW_COUNT_USED)<span class="token punctuation">:</span> 0
SUM(CURRENT_COUNT_USED)<span class="token punctuation">:</span> 53
SUM(HIGH_COUNT_USED)<span class="token punctuation">:</span> 59
SUM(LOW_NUMBER_OF_BYTES_USED)<span class="token punctuation">:</span> 0
SUM(CURRENT_NUMBER_OF_BYTES_USED)<span class="token punctuation">:</span> 1065175
SUM(HIGH_NUMBER_OF_BYTES_USED)<span class="token punctuation">:</span> 1065809</span></code></pre>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="mysql-gr-memory-monitoring-ps-sample-queries-total-memory">
</a>
Total Memory Used in Group Replication
</h5>
</div>
</div>
</div>
<p>
The memory allocation to sending and receiving transactions,
certification, and all other major processes. It is calculated
by querying all the events of the
<code class="literal">
memory/group_rpl/
</code>
group. For example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa98828963"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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">SELECT</span>
<span class="token punctuation">(</span><span class="token operator">CASE</span>
<span class="token keyword">WHEN</span> EVENT_NAME <span class="token operator">LIKE</span> <span class="token string">'memory/group_rpl/%'</span>
<span class="token keyword">THEN</span> <span class="token string">'memory/group_rpl/memory_gr'</span>
<span class="token keyword">ELSE</span> <span class="token string">'memory_gr_rest'</span>
<span class="token keyword">END</span><span class="token punctuation">)</span> <span class="token keyword">AS</span> EVENT_NAME<span class="token punctuation">,</span>
<span class="token function">SUM</span><span class="token punctuation">(</span>COUNT_ALLOC<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token function">SUM</span><span class="token punctuation">(</span>COUNT_FREE<span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token function">SUM</span><span class="token punctuation">(</span>SUM_NUMBER_OF_BYTES_ALLOC<span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token function">SUM</span><span class="token punctuation">(</span>SUM_NUMBER_OF_BYTES_FREE<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token function">SUM</span><span class="token punctuation">(</span>LOW_COUNT_USED<span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token function">SUM</span><span class="token punctuation">(</span>CURRENT_COUNT_USED<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token function">SUM</span><span class="token punctuation">(</span>HIGH_COUNT_USED<span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token function">SUM</span><span class="token punctuation">(</span>LOW_NUMBER_OF_BYTES_USED<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token function">SUM</span><span class="token punctuation">(</span>CURRENT_NUMBER_OF_BYTES_USED<span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token function">SUM</span><span class="token punctuation">(</span>HIGH_NUMBER_OF_BYTES_USED<span class="token punctuation">)</span>
<span class="token keyword">FROM</span> performance_schema<span class="token punctuation">.</span>memory_summary_global_by_event_name
<span class="token keyword">GROUP</span> <span class="token keyword">BY</span> <span class="token punctuation">(</span><span class="token operator">CASE</span>
<span class="token keyword">WHEN</span> EVENT_NAME <span class="token operator">LIKE</span> <span class="token string">'memory/group_rpl/%'</span>
<span class="token keyword">THEN</span> <span class="token string">'memory/group_rpl/memory_gr'</span>
<span class="token keyword">ELSE</span> <span class="token string">'memory_gr_rest'</span>
<span class="token keyword">END</span><span class="token punctuation">)</span>
<span class="token punctuation">)</span> f
<span class="token keyword">WHERE</span> f<span class="token punctuation">.</span>EVENT_NAME <span class="token operator">!=</span> <span class="token string">'memory_gr_rest'</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>
EVENT_NAME<span class="token punctuation">:</span> memory/group_rpl/memory_gr
SUM(COUNT_ALLOC)<span class="token punctuation">:</span> 190
SUM(COUNT_FREE)<span class="token punctuation">:</span> 127
SUM(SUM_NUMBER_OF_BYTES_ALLOC)<span class="token punctuation">:</span> 1096370
SUM(SUM_NUMBER_OF_BYTES_FREE)<span class="token punctuation">:</span> 28675
SUM(LOW_COUNT_USED)<span class="token punctuation">:</span> 0
SUM(CURRENT_COUNT_USED)<span class="token punctuation">:</span> 63
SUM(HIGH_COUNT_USED)<span class="token punctuation">:</span> 77
SUM(LOW_NUMBER_OF_BYTES_USED)<span class="token punctuation">:</span> 0
SUM(CURRENT_NUMBER_OF_BYTES_USED)<span class="token punctuation">:</span> 1067695
SUM(HIGH_NUMBER_OF_BYTES_USED)<span class="token punctuation">:</span> 1069255</span></code></pre>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="mysql-gr-memory-monitoring-ps-sample-queries-certification-memory">
</a>
Memory Used in Certification
</h5>
</div>
</div>
</div>
<p>
The memory allocation in the certification process is a sum of
the
<code class="literal">
certification_data
</code>
,
<code class="literal">
certification_data_gc
</code>
, and
<code class="literal">
certification_info
</code>
event values. For
example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa40029251"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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">SELECT</span>
<span class="token punctuation">(</span><span class="token operator">CASE</span>
<span class="token keyword">WHEN</span> EVENT_NAME <span class="token operator">=</span> <span class="token string">'memory/group_rpl/certification_data'</span>
<span class="token keyword">THEN</span> <span class="token string">'memory/group_rpl/certification'</span>
<span class="token keyword">WHEN</span> EVENT_NAME <span class="token operator">=</span> <span class="token string">'memory/group_rpl/certification_data_gc'</span>
<span class="token keyword">THEN</span> <span class="token string">'memory/group_rpl/certification'</span>
<span class="token keyword">WHEN</span> EVENT_NAME <span class="token operator">=</span> <span class="token string">'memory/group_rpl/certification_info'</span>
<span class="token keyword">THEN</span> <span class="token string">'memory/group_rpl/certification'</span>
<span class="token keyword">ELSE</span> <span class="token string">'memory_gr_rest'</span>
<span class="token keyword">END</span><span class="token punctuation">)</span> <span class="token keyword">AS</span> EVENT_NAME<span class="token punctuation">,</span> <span class="token function">SUM</span><span class="token punctuation">(</span>COUNT_ALLOC<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token function">SUM</span><span class="token punctuation">(</span>COUNT_FREE<span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token function">SUM</span><span class="token punctuation">(</span>SUM_NUMBER_OF_BYTES_ALLOC<span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token function">SUM</span><span class="token punctuation">(</span>SUM_NUMBER_OF_BYTES_FREE<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token function">SUM</span><span class="token punctuation">(</span>LOW_COUNT_USED<span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token function">SUM</span><span class="token punctuation">(</span>CURRENT_COUNT_USED<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token function">SUM</span><span class="token punctuation">(</span>HIGH_COUNT_USED<span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token function">SUM</span><span class="token punctuation">(</span>LOW_NUMBER_OF_BYTES_USED<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token function">SUM</span><span class="token punctuation">(</span>CURRENT_NUMBER_OF_BYTES_USED<span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token function">SUM</span><span class="token punctuation">(</span>HIGH_NUMBER_OF_BYTES_USED<span class="token punctuation">)</span>
<span class="token keyword">FROM</span> performance_schema<span class="token punctuation">.</span>memory_summary_global_by_event_name
<span class="token keyword">GROUP</span> <span class="token keyword">BY</span> <span class="token punctuation">(</span><span class="token operator">CASE</span>
<span class="token keyword">WHEN</span> EVENT_NAME <span class="token operator">=</span> <span class="token string">'memory/group_rpl/certification_data'</span>
<span class="token keyword">THEN</span> <span class="token string">'memory/group_rpl/certification'</span>
<span class="token keyword">WHEN</span> EVENT_NAME <span class="token operator">=</span> <span class="token string">'memory/group_rpl/certification_data_gc'</span>
<span class="token keyword">THEN</span> <span class="token string">'memory/group_rpl/certification'</span>
<span class="token keyword">WHEN</span> EVENT_NAME <span class="token operator">=</span> <span class="token string">'memory/group_rpl/certification_info'</span>
<span class="token keyword">THEN</span> <span class="token string">'memory/group_rpl/certification'</span>
<span class="token keyword">ELSE</span> <span class="token string">'memory_gr_rest'</span>
<span class="token keyword">END</span><span class="token punctuation">)</span>
<span class="token punctuation">)</span> f
<span class="token keyword">WHERE</span> f<span class="token punctuation">.</span>EVENT_NAME <span class="token operator">!=</span> <span class="token string">'memory_gr_rest'</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>
EVENT_NAME<span class="token punctuation">:</span> memory/group_rpl/certification
SUM(COUNT_ALLOC)<span class="token punctuation">:</span> 80
SUM(COUNT_FREE)<span class="token punctuation">:</span> 80
SUM(SUM_NUMBER_OF_BYTES_ALLOC)<span class="token punctuation">:</span> 9442
SUM(SUM_NUMBER_OF_BYTES_FREE)<span class="token punctuation">:</span> 9442
SUM(LOW_COUNT_USED)<span class="token punctuation">:</span> 0
SUM(CURRENT_COUNT_USED)<span class="token punctuation">:</span> 0
SUM(HIGH_COUNT_USED)<span class="token punctuation">:</span> 66
SUM(LOW_NUMBER_OF_BYTES_USED)<span class="token punctuation">:</span> 0
SUM(CURRENT_NUMBER_OF_BYTES_USED)<span class="token punctuation">:</span> 0
SUM(HIGH_NUMBER_OF_BYTES_USED)<span class="token punctuation">:</span> 6561</span></code></pre>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="mysql-gr-memory-monitoring-ps-sample-queries-pipeline-memory">
</a>
Memory Used in Replication Pipeline
</h5>
</div>
</div>
</div>
<p>
The memory allocation of the replication pipeline is the sum
of the
<code class="literal">
certification_data
</code>
and
<code class="literal">
transaction_data
</code>
event values. For example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa8610148"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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">SELECT</span>
<span class="token punctuation">(</span><span class="token operator">CASE</span>
<span class="token keyword">WHEN</span> EVENT_NAME <span class="token operator">LIKE</span> <span class="token string">'memory/group_rpl/certification_data'</span>
<span class="token keyword">THEN</span> <span class="token string">'memory/group_rpl/pipeline'</span>
<span class="token keyword">WHEN</span> EVENT_NAME <span class="token operator">LIKE</span> <span class="token string">'memory/group_rpl/transaction_data'</span>
<span class="token keyword">THEN</span> <span class="token string">'memory/group_rpl/pipeline'</span>
<span class="token keyword">ELSE</span> <span class="token string">'memory_gr_rest'</span>
<span class="token keyword">END</span><span class="token punctuation">)</span> <span class="token keyword">AS</span> EVENT_NAME<span class="token punctuation">,</span> <span class="token function">SUM</span><span class="token punctuation">(</span>COUNT_ALLOC<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token function">SUM</span><span class="token punctuation">(</span>COUNT_FREE<span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token function">SUM</span><span class="token punctuation">(</span>SUM_NUMBER_OF_BYTES_ALLOC<span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token function">SUM</span><span class="token punctuation">(</span>SUM_NUMBER_OF_BYTES_FREE<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token function">SUM</span><span class="token punctuation">(</span>LOW_COUNT_USED<span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token function">SUM</span><span class="token punctuation">(</span>CURRENT_COUNT_USED<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token function">SUM</span><span class="token punctuation">(</span>HIGH_COUNT_USED<span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token function">SUM</span><span class="token punctuation">(</span>LOW_NUMBER_OF_BYTES_USED<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token function">SUM</span><span class="token punctuation">(</span>CURRENT_NUMBER_OF_BYTES_USED<span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token function">SUM</span><span class="token punctuation">(</span>HIGH_NUMBER_OF_BYTES_USED<span class="token punctuation">)</span>
<span class="token keyword">FROM</span> performance_schema<span class="token punctuation">.</span>memory_summary_global_by_event_name
<span class="token keyword">GROUP</span> <span class="token keyword">BY</span> <span class="token punctuation">(</span><span class="token operator">CASE</span>
<span class="token keyword">WHEN</span> EVENT_NAME <span class="token operator">LIKE</span> <span class="token string">'memory/group_rpl/certification_data'</span>
<span class="token keyword">THEN</span> <span class="token string">'memory/group_rpl/pipeline'</span>
<span class="token keyword">WHEN</span> EVENT_NAME <span class="token operator">LIKE</span> <span class="token string">'memory/group_rpl/transaction_data'</span>
<span class="token keyword">THEN</span> <span class="token string">'memory/group_rpl/pipeline'</span>
<span class="token keyword">ELSE</span> <span class="token string">'memory_gr_rest'</span>
<span class="token keyword">END</span><span class="token punctuation">)</span>
<span class="token punctuation">)</span> f
<span class="token keyword">WHERE</span> f<span class="token punctuation">.</span>EVENT_NAME <span class="token operator">!=</span> <span class="token string">'memory_gr_rest'</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>
EVENT_NAME<span class="token punctuation">:</span> memory/group_rpl/pipeline
COUNT_ALLOC<span class="token punctuation">:</span> 17
COUNT_FREE<span class="token punctuation">:</span> 13
SUM_NUMBER_OF_BYTES_ALLOC<span class="token punctuation">:</span> 2483
SUM_NUMBER_OF_BYTES_FREE<span class="token punctuation">:</span> 1668
LOW_COUNT_USED<span class="token punctuation">:</span> 0
CURRENT_COUNT_USED<span class="token punctuation">:</span> 4
HIGH_COUNT_USED<span class="token punctuation">:</span> 4
LOW_NUMBER_OF_BYTES_USED<span class="token punctuation">:</span> 0
CURRENT_NUMBER_OF_BYTES_USED<span class="token punctuation">:</span> 815
HIGH_NUMBER_OF_BYTES_USED<span class="token punctuation">:</span> 815</span></code></pre>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="mysql-gr-memory-monitoring-ps-sample-queries-consistency-memory">
</a>
Memory Used in Consistency
</h5>
</div>
</div>
</div>
<p>
The memory allocation for transaction consistency guarantees
is the sum of the
<code class="literal">
consistent_members_that_must_prepare_transaction
</code>
,
<code class="literal">
consistent_transactions
</code>
,
<code class="literal">
consistent_transactions_prepared
</code>
,
<code class="literal">
consistent_transactions_waiting
</code>
, and
<code class="literal">
consistent_transactions_delayed_view_change
</code>
event values. For example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa90565248"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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">SELECT</span>
<span class="token punctuation">(</span><span class="token operator">CASE</span>
<span class="token keyword">WHEN</span> EVENT_NAME <span class="token operator">=</span> <span class="token string">'memory/group_rpl/consistent_members_that_must_prepare_transaction'</span>
<span class="token keyword">THEN</span> <span class="token string">'memory/group_rpl/consistency'</span>
<span class="token keyword">WHEN</span> EVENT_NAME <span class="token operator">=</span> <span class="token string">'memory/group_rpl/consistent_transactions'</span>
<span class="token keyword">THEN</span> <span class="token string">'memory/group_rpl/consistency'</span>
<span class="token keyword">WHEN</span> EVENT_NAME <span class="token operator">=</span> <span class="token string">'memory/group_rpl/consistent_transactions_prepared'</span>
<span class="token keyword">THEN</span> <span class="token string">'memory/group_rpl/consistency'</span>
<span class="token keyword">WHEN</span> EVENT_NAME <span class="token operator">=</span> <span class="token string">'memory/group_rpl/consistent_transactions_waiting'</span>
<span class="token keyword">THEN</span> <span class="token string">'memory/group_rpl/consistency'</span>
<span class="token keyword">WHEN</span> EVENT_NAME <span class="token operator">=</span> <span class="token string">'memory/group_rpl/consistent_transactions_delayed_view_change'</span>
<span class="token keyword">THEN</span> <span class="token string">'memory/group_rpl/consistency'</span>
<span class="token keyword">ELSE</span> <span class="token string">'memory_gr_rest'</span>
<span class="token keyword">END</span><span class="token punctuation">)</span> <span class="token keyword">AS</span> EVENT_NAME<span class="token punctuation">,</span> <span class="token function">SUM</span><span class="token punctuation">(</span>COUNT_ALLOC<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token function">SUM</span><span class="token punctuation">(</span>COUNT_FREE<span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token function">SUM</span><span class="token punctuation">(</span>SUM_NUMBER_OF_BYTES_ALLOC<span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token function">SUM</span><span class="token punctuation">(</span>SUM_NUMBER_OF_BYTES_FREE<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token function">SUM</span><span class="token punctuation">(</span>LOW_COUNT_USED<span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token function">SUM</span><span class="token punctuation">(</span>CURRENT_COUNT_USED<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token function">SUM</span><span class="token punctuation">(</span>HIGH_COUNT_USED<span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token function">SUM</span><span class="token punctuation">(</span>LOW_NUMBER_OF_BYTES_USED<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token function">SUM</span><span class="token punctuation">(</span>CURRENT_NUMBER_OF_BYTES_USED<span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token function">SUM</span><span class="token punctuation">(</span>HIGH_NUMBER_OF_BYTES_USED<span class="token punctuation">)</span>
<span class="token keyword">FROM</span> performance_schema<span class="token punctuation">.</span>memory_summary_global_by_event_name
<span class="token keyword">GROUP</span> <span class="token keyword">BY</span> <span class="token punctuation">(</span><span class="token operator">CASE</span>
<span class="token keyword">WHEN</span> EVENT_NAME <span class="token operator">=</span> <span class="token string">'memory/group_rpl/consistent_members_that_must_prepare_transaction'</span>
<span class="token keyword">THEN</span> <span class="token string">'memory/group_rpl/consistency'</span>
<span class="token keyword">WHEN</span> EVENT_NAME <span class="token operator">=</span> <span class="token string">'memory/group_rpl/consistent_transactions'</span>
<span class="token keyword">THEN</span> <span class="token string">'memory/group_rpl/consistency'</span>
<span class="token keyword">WHEN</span> EVENT_NAME <span class="token operator">=</span> <span class="token string">'memory/group_rpl/consistent_transactions_prepared'</span>
<span class="token keyword">THEN</span> <span class="token string">'memory/group_rpl/consistency'</span>
<span class="token keyword">WHEN</span> EVENT_NAME <span class="token operator">=</span> <span class="token string">'memory/group_rpl/consistent_transactions_waiting'</span>
<span class="token keyword">THEN</span> <span class="token string">'memory/group_rpl/consistency'</span>
<span class="token keyword">WHEN</span> EVENT_NAME <span class="token operator">=</span> <span class="token string">'memory/group_rpl/consistent_transactions_delayed_view_change'</span>
<span class="token keyword">THEN</span> <span class="token string">'memory/group_rpl/consistency'</span>
<span class="token keyword">ELSE</span> <span class="token string">'memory_gr_rest'</span>
<span class="token keyword">END</span><span class="token punctuation">)</span>
<span class="token punctuation">)</span> f
<span class="token keyword">WHERE</span> f<span class="token punctuation">.</span>EVENT_NAME <span class="token operator">!=</span> <span class="token string">'memory_gr_rest'</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>
EVENT_NAME<span class="token punctuation">:</span> memory/group_rpl/consistency
COUNT_ALLOC<span class="token punctuation">:</span> 16
COUNT_FREE<span class="token punctuation">:</span> 6
SUM_NUMBER_OF_BYTES_ALLOC<span class="token punctuation">:</span> 1464
SUM_NUMBER_OF_BYTES_FREE<span class="token punctuation">:</span> 528
LOW_COUNT_USED<span class="token punctuation">:</span> 0
CURRENT_COUNT_USED<span class="token punctuation">:</span> 10
HIGH_COUNT_USED<span class="token punctuation">:</span> 11
LOW_NUMBER_OF_BYTES_USED<span class="token punctuation">:</span> 0
CURRENT_NUMBER_OF_BYTES_USED<span class="token punctuation">:</span> 936
HIGH_NUMBER_OF_BYTES_USED<span class="token punctuation">:</span> 1024</span></code></pre>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="mysql-gr-memory-monitoring-ps-sample-queries-message-memory">
</a>
Memory Used in Delivery Message Service
</h5>
</div>
</div>
</div>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
This instrumentation applies only to data received, not data
sent.
</p>
</div>
<p>
The memory allocation for the Group Replication delivery
message service is the sum of the
<code class="literal">
message_service_received_message
</code>
and
<code class="literal">
message_service_queue
</code>
event values. For
example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa26083931"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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">SELECT</span>
<span class="token punctuation">(</span><span class="token operator">CASE</span>
<span class="token keyword">WHEN</span> EVENT_NAME <span class="token operator">=</span> <span class="token string">'memory/group_rpl/message_service_received_message'</span>
<span class="token keyword">THEN</span> <span class="token string">'memory/group_rpl/message_service'</span>
<span class="token keyword">WHEN</span> EVENT_NAME <span class="token operator">=</span> <span class="token string">'memory/group_rpl/message_service_queue'</span>
<span class="token keyword">THEN</span> <span class="token string">'memory/group_rpl/message_service'</span>
<span class="token keyword">ELSE</span> <span class="token string">'memory_gr_rest'</span>
<span class="token keyword">END</span><span class="token punctuation">)</span> <span class="token keyword">AS</span> EVENT_NAME<span class="token punctuation">,</span>
<span class="token function">SUM</span><span class="token punctuation">(</span>COUNT_ALLOC<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token function">SUM</span><span class="token punctuation">(</span>COUNT_FREE<span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token function">SUM</span><span class="token punctuation">(</span>SUM_NUMBER_OF_BYTES_ALLOC<span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token function">SUM</span><span class="token punctuation">(</span>SUM_NUMBER_OF_BYTES_FREE<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token function">SUM</span><span class="token punctuation">(</span>LOW_COUNT_USED<span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token function">SUM</span><span class="token punctuation">(</span>CURRENT_COUNT_USED<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token function">SUM</span><span class="token punctuation">(</span>HIGH_COUNT_USED<span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token function">SUM</span><span class="token punctuation">(</span>LOW_NUMBER_OF_BYTES_USED<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token function">SUM</span><span class="token punctuation">(</span>CURRENT_NUMBER_OF_BYTES_USED<span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token function">SUM</span><span class="token punctuation">(</span>HIGH_NUMBER_OF_BYTES_USED<span class="token punctuation">)</span>
<span class="token keyword">FROM</span> performance_schema<span class="token punctuation">.</span>memory_summary_global_by_event_name
<span class="token keyword">GROUP</span> <span class="token keyword">BY</span> <span class="token punctuation">(</span><span class="token operator">CASE</span>
<span class="token keyword">WHEN</span> EVENT_NAME <span class="token operator">=</span> <span class="token string">'memory/group_rpl/message_service_received_message'</span>
<span class="token keyword">THEN</span> <span class="token string">'memory/group_rpl/message_service'</span>
<span class="token keyword">WHEN</span> EVENT_NAME <span class="token operator">=</span> <span class="token string">'memory/group_rpl/message_service_queue'</span>
<span class="token keyword">THEN</span> <span class="token string">'memory/group_rpl/message_service'</span>
<span class="token keyword">ELSE</span> <span class="token string">'memory_gr_rest'</span>
<span class="token keyword">END</span><span class="token punctuation">)</span>
<span class="token punctuation">)</span> f
<span class="token keyword">WHERE</span> f<span class="token punctuation">.</span>EVENT_NAME <span class="token operator">!=</span> <span class="token string">'memory_gr_rest'</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>
EVENT_NAME<span class="token punctuation">:</span> memory/group_rpl/message_service
COUNT_ALLOC<span class="token punctuation">:</span> 2
COUNT_FREE<span class="token punctuation">:</span> 0
SUM_NUMBER_OF_BYTES_ALLOC<span class="token punctuation">:</span> 1048664
SUM_NUMBER_OF_BYTES_FREE<span class="token punctuation">:</span> 0
LOW_COUNT_USED<span class="token punctuation">:</span> 0
CURRENT_COUNT_USED<span class="token punctuation">:</span> 2
HIGH_COUNT_USED<span class="token punctuation">:</span> 2
LOW_NUMBER_OF_BYTES_USED<span class="token punctuation">:</span> 0
CURRENT_NUMBER_OF_BYTES_USED<span class="token punctuation">:</span> 1048664
HIGH_NUMBER_OF_BYTES_USED<span class="token punctuation">:</span> 1048664</span></code></pre>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="mysql-gr-memory-monitoring-ps-sample-queries-send-receive-transaction">
</a>
Memory Used to Broadcast and Receive Transactions
</h5>
</div>
</div>
</div>
<p>
The memory allocation for the broadcasting and receiving
transactions to and from the network is the sum of the
<code class="literal">
wGcs_message_data::m_buffer
</code>
and
<code class="literal">
GCS_XCom::xcom_cache
</code>
event values. For
example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa96936672"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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">SELECT</span>
<span class="token punctuation">(</span><span class="token operator">CASE</span>
<span class="token keyword">WHEN</span> EVENT_NAME <span class="token operator">=</span> <span class="token string">'memory/group_rpl/Gcs_message_data::m_buffer'</span>
<span class="token keyword">THEN</span> <span class="token string">'memory/group_rpl/memory_gr'</span>
<span class="token keyword">WHEN</span> EVENT_NAME <span class="token operator">=</span> <span class="token string">'memory/group_rpl/GCS_XCom::xcom_cache'</span>
<span class="token keyword">THEN</span> <span class="token string">'memory/group_rpl/memory_gr'</span>
<span class="token keyword">ELSE</span> <span class="token string">'memory_gr_rest'</span>
<span class="token keyword">END</span><span class="token punctuation">)</span> <span class="token keyword">AS</span> EVENT_NAME<span class="token punctuation">,</span>
<span class="token function">SUM</span><span class="token punctuation">(</span>COUNT_ALLOC<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token function">SUM</span><span class="token punctuation">(</span>COUNT_FREE<span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token function">SUM</span><span class="token punctuation">(</span>SUM_NUMBER_OF_BYTES_ALLOC<span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token function">SUM</span><span class="token punctuation">(</span>SUM_NUMBER_OF_BYTES_FREE<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token function">SUM</span><span class="token punctuation">(</span>LOW_COUNT_USED<span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token function">SUM</span><span class="token punctuation">(</span>CURRENT_COUNT_USED<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token function">SUM</span><span class="token punctuation">(</span>HIGH_COUNT_USED<span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token function">SUM</span><span class="token punctuation">(</span>LOW_NUMBER_OF_BYTES_USED<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token function">SUM</span><span class="token punctuation">(</span>CURRENT_NUMBER_OF_BYTES_USED<span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token function">SUM</span><span class="token punctuation">(</span>HIGH_NUMBER_OF_BYTES_USED<span class="token punctuation">)</span>
<span class="token keyword">FROM</span> performance_schema<span class="token punctuation">.</span>memory_summary_global_by_event_name
<span class="token keyword">GROUP</span> <span class="token keyword">BY</span> <span class="token punctuation">(</span><span class="token operator">CASE</span>
<span class="token keyword">WHEN</span> EVENT_NAME <span class="token operator">=</span> <span class="token string">'memory/group_rpl/Gcs_message_data::m_buffer'</span>
<span class="token keyword">THEN</span> <span class="token string">'memory/group_rpl/memory_gr'</span>
<span class="token keyword">WHEN</span> EVENT_NAME <span class="token operator">=</span> <span class="token string">'memory/group_rpl/GCS_XCom::xcom_cache'</span>
<span class="token keyword">THEN</span> <span class="token string">'memory/group_rpl/memory_gr'</span>
<span class="token keyword">ELSE</span> <span class="token string">'memory_gr_rest'</span>
<span class="token keyword">END</span><span class="token punctuation">)</span>
<span class="token punctuation">)</span> f
<span class="token keyword">WHERE</span> f<span class="token punctuation">.</span>EVENT_NAME <span class="token operator">!=</span> <span class="token string">'memory_gr_rest'</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>
EVENT_NAME<span class="token punctuation">:</span> memory/group_rpl/memory_gr
SUM(COUNT_ALLOC)<span class="token punctuation">:</span> 73
SUM(COUNT_FREE)<span class="token punctuation">:</span> 20
SUM(SUM_NUMBER_OF_BYTES_ALLOC)<span class="token punctuation">:</span> 1070845
SUM(SUM_NUMBER_OF_BYTES_FREE)<span class="token punctuation">:</span> 5670
SUM(LOW_COUNT_USED)<span class="token punctuation">:</span> 0
SUM(CURRENT_COUNT_USED)<span class="token punctuation">:</span> 53
SUM(HIGH_COUNT_USED)<span class="token punctuation">:</span> 56
SUM(LOW_NUMBER_OF_BYTES_USED)<span class="token punctuation">:</span> 0
SUM(CURRENT_NUMBER_OF_BYTES_USED)<span class="token punctuation">:</span> 1065175
SUM(HIGH_NUMBER_OF_BYTES_USED)<span class="token punctuation">:</span> 1065175</span></code></pre>
</div>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/mysql-cluster-ndbinfo-backup-id.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="mysql-cluster-ndbinfo-backup-id">
</a>
25.6.17.3 The ndbinfo backup_id Table
</h4>
</div>
</div>
</div>
<p>
This table provides a way to find the ID of the backup started
most recently for this cluster.
</p>
<p>
The
<code class="literal">
backup_id
</code>
table contains a single column
<code class="literal">
id
</code>
, which corresponds to a backup ID taken
using 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
<a class="link" href="mysql-cluster-backup-using-management-client.html" title="25.6.8.2 Using The NDB Cluster Management Client to Create a Backup">
<code class="literal">
START BACKUP
</code>
</a>
command. This
table contains a single row.
</p>
<p>
<span class="emphasis">
<em>
Example
</em>
</span>
: Assume the following sequence of
<code class="literal">
START BACKUP
</code>
commands issued in the NDB
management client, with no other backups taken since the cluster
was first started:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-ndbmgm"><div class="docs-select-all right" id="sa56227189"><div class="copy-help left">Press ⌘+C to 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">START BACKUP</span>
Waiting for completed<span class="token punctuation">,</span> this may take several minutes
<span class="token selector">Node 5:</span> Backup 1 started from node 50
<span class="token selector">Node 5:</span> Backup 1 started from node 50 completed
StartGCP<span class="token operator">:</span> 27894 StopGCP<span class="token operator">:</span> 27897
#Records<span class="token operator">:</span> 2057 #LogRecords<span class="token operator">:</span> 0
Data<span class="token operator">:</span> 51580 bytes Log<span class="token operator">:</span> 0 bytes
<span class="token prompt">ndb_mgm></span> <span class="token keyword">START BACKUP</span> 5
Waiting for completed<span class="token punctuation">,</span> this may take several minutes
<span class="token selector">Node 5:</span> Backup 5 started from node 50
<span class="token selector">Node 5:</span> Backup 5 started from node 50 completed
StartGCP<span class="token operator">:</span> 27905 StopGCP<span class="token operator">:</span> 27908
#Records<span class="token operator">:</span> 2057 #LogRecords<span class="token operator">:</span> 0
Data<span class="token operator">:</span> 51580 bytes Log<span class="token operator">:</span> 0 bytes
<span class="token prompt">ndb_mgm></span> <span class="token keyword">START BACKUP</span>
Waiting for completed<span class="token punctuation">,</span> this may take several minutes
<span class="token selector">Node 5:</span> Backup 6 started from node 50
<span class="token selector">Node 5:</span> Backup 6 started from node 50 completed
StartGCP<span class="token operator">:</span> 27912 StopGCP<span class="token operator">:</span> 27915
#Records<span class="token operator">:</span> 2057 #LogRecords<span class="token operator">:</span> 0
Data<span class="token operator">:</span> 51580 bytes Log<span class="token operator">:</span> 0 bytes
<span class="token prompt">ndb_mgm></span> <span class="token keyword">START BACKUP</span> 3
Connected to Management Server at<span class="token operator">:</span> localhost<span class="token operator">:</span>1186 <span class="token punctuation">(</span>using cleartext<span class="token punctuation">)</span>
Waiting for completed<span class="token punctuation">,</span> this may take several minutes
<span class="token selector">Node 5:</span> Backup 3 started from node 50
<span class="token selector">Node 5:</span> Backup 3 started from node 50 completed
StartGCP<span class="token operator">:</span> 28149 StopGCP<span class="token operator">:</span> 28152
#Records<span class="token operator">:</span> 2057 #LogRecords<span class="token operator">:</span> 0
Data<span class="token operator">:</span> 51580 bytes Log<span class="token operator">:</span> 0 bytes
<span class="token prompt">ndb_mgm></span></code></pre>
</div>
<p>
After this, the
<code class="literal">
backup_id
</code>
table contains the
single row shown here, 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:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa43685603"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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> ndbinfo<span class="token punctuation">;</span>
<span class="token keyword">Database</span> <span class="token keyword">changed</span>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> backup_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>
<span class="token output"><span class="token punctuation">|</span> 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>
<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 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>
If no backups can be found, the table contains a single row with
<code class="literal">
0
</code>
as the
<code class="literal">
id
</code>
value.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/mysql-cluster-ndbinfo-cpuinfo.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="mysql-cluster-ndbinfo-cpuinfo">
</a>
25.6.17.18 The ndbinfo cpuinfo Table
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045089957488">
</a>
<p>
The
<code class="literal">
cpuinfo
</code>
table provides information about
the CPU on which a given data node executes.
</p>
<p>
The
<code class="literal">
cpuinfo
</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 online, otherwise 0
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
core_id
</code>
</p>
<p>
CPU core ID
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
socket_id
</code>
</p>
<p>
CPU socket ID
</p>
</li>
</ul>
</div>
<h5>
<a name="idm46045089943760">
</a>
Notes
</h5>
<p>
The
<code class="literal">
cpuinfo
</code>
table is available on all
operating systems supported by
<code class="literal">
NDB
</code>
, with the
exception of MacOS and FreeBSD.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/charset-collation-information-schema.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="charset-collation-information-schema">
</a>
12.8.7 Using Collation in INFORMATION_SCHEMA Searches
</h3>
</div>
</div>
</div>
<a class="indexterm" name="idm46045216846736">
</a>
<a class="indexterm" name="idm46045216845248">
</a>
<p>
String columns in
<code class="literal">
INFORMATION_SCHEMA
</code>
tables
have a collation of
<code class="literal">
utf8mb3_general_ci
</code>
, which
is case-insensitive. However, for values that correspond to
objects that are represented in the file system, such as
databases and tables, searches in
<code class="literal">
INFORMATION_SCHEMA
</code>
string columns can be
case-sensitive or case-insensitive, depending on the
characteristics of the underlying file system 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 setting. For example, searches may be case-sensitive if
the file system is case-sensitive. This section describes this
behavior and how to modify it if necessary.
</p>
<p>
Suppose that a query searches the
<code class="literal">
SCHEMATA.SCHEMA_NAME
</code>
column for the
<code class="literal">
test
</code>
database. On Linux, file systems are
case-sensitive, so comparisons of
<code class="literal">
SCHEMATA.SCHEMA_NAME
</code>
with
<code class="literal">
'test'
</code>
match, but comparisons with
<code class="literal">
'TEST'
</code>
do not:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa8111627"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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">SCHEMA_NAME</span> <span class="token keyword">FROM</span> INFORMATION_SCHEMA<span class="token punctuation">.</span>SCHEMATA
<span class="token keyword">WHERE</span> <span class="token keyword">SCHEMA_NAME</span> <span class="token operator">=</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>
<span class="token output"><span class="token punctuation">|</span> SCHEMA_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>
<span class="token output"><span class="token punctuation">|</span> test <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 prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token keyword">SCHEMA_NAME</span> <span class="token keyword">FROM</span> INFORMATION_SCHEMA<span class="token punctuation">.</span>SCHEMATA
<span class="token keyword">WHERE</span> <span class="token keyword">SCHEMA_NAME</span> <span class="token operator">=</span> <span class="token string">'TEST'</span><span class="token punctuation">;</span>
<span class="token output">Empty set (0.00 sec)</span></code></pre>
</div>
<p>
These results occur with 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 set to 0. A
<a class="link" href="server-system-variables.html#sysvar_lower_case_table_names">
<code class="literal">
lower_case_table_names
</code>
</a>
setting
of 1 or 2 causes the second query to return the same (nonempty)
result as the first query.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
It is prohibited to start the server with a
<a class="link" href="server-system-variables.html#sysvar_lower_case_table_names">
<code class="literal">
lower_case_table_names
</code>
</a>
setting that is different from the setting used when the
server was initialized.
</p>
</div>
<p>
On Windows or macOS, file systems are not case-sensitive, so
comparisons match both
<code class="literal">
'test'
</code>
and
<code class="literal">
'TEST'
</code>
:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa30911596"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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">SCHEMA_NAME</span> <span class="token keyword">FROM</span> INFORMATION_SCHEMA<span class="token punctuation">.</span>SCHEMATA
<span class="token keyword">WHERE</span> <span class="token keyword">SCHEMA_NAME</span> <span class="token operator">=</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>
<span class="token output"><span class="token punctuation">|</span> SCHEMA_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>
<span class="token output"><span class="token punctuation">|</span> test <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 prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token keyword">SCHEMA_NAME</span> <span class="token keyword">FROM</span> INFORMATION_SCHEMA<span class="token punctuation">.</span>SCHEMATA
<span class="token keyword">WHERE</span> <span class="token keyword">SCHEMA_NAME</span> <span class="token operator">=</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>
<span class="token output"><span class="token punctuation">|</span> SCHEMA_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>
<span class="token output"><span class="token punctuation">|</span> TEST <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></code></pre>
</div>
<p>
The value of
<a class="link" href="server-system-variables.html#sysvar_lower_case_table_names">
<code class="literal">
lower_case_table_names
</code>
</a>
makes no
difference in this context.
</p>
<p>
The preceding behavior occurs because the
<code class="literal">
utf8mb3_general_ci
</code>
collation is not used for
<code class="literal">
INFORMATION_SCHEMA
</code>
queries when searching for
values that correspond to objects represented in the file
system.
</p>
<p>
If the result of a string operation on an
<code class="literal">
INFORMATION_SCHEMA
</code>
column differs from
expectations, a workaround is to use an explicit
<code class="literal">
COLLATE
</code>
clause to force a suitable collation
(see
<a class="xref" href="charset-collate.html" title="12.8.1 Using COLLATE in SQL Statements">
Section 12.8.1, “Using COLLATE in SQL Statements”
</a>
). For example, to perform
a case-insensitive search, use
<code class="literal">
COLLATE
</code>
with
the
<code class="literal">
INFORMATION_SCHEMA
</code>
column name:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa15646189"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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">SCHEMA_NAME</span> <span class="token keyword">FROM</span> INFORMATION_SCHEMA<span class="token punctuation">.</span>SCHEMATA
<span class="token keyword">WHERE</span> <span class="token keyword">SCHEMA_NAME</span> <span class="token keyword">COLLATE</span> utf8mb3_general_ci <span class="token operator">=</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>
<span class="token output"><span class="token punctuation">|</span> SCHEMA_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>
<span class="token output"><span class="token punctuation">|</span> test <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 prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token keyword">SCHEMA_NAME</span> <span class="token keyword">FROM</span> INFORMATION_SCHEMA<span class="token punctuation">.</span>SCHEMATA
<span class="token keyword">WHERE</span> <span class="token keyword">SCHEMA_NAME</span> <span class="token keyword">COLLATE</span> utf8mb3_general_ci <span class="token operator">=</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>
<span class="token output"><span class="token punctuation">|</span> SCHEMA_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>
<span class="token output"><span class="token punctuation">|</span> test <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></code></pre>
</div>
<p>
You can also use the
<a class="link" href="string-functions.html#function_upper">
<code class="literal">
UPPER()
</code>
</a>
or
<a class="link" href="string-functions.html#function_lower">
<code class="literal">
LOWER()
</code>
</a>
function:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa90684862"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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">WHERE</span> <span class="token function">UPPER</span><span class="token punctuation">(</span><span class="token keyword">SCHEMA_NAME</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token string">'TEST'</span>
<span class="token keyword">WHERE</span> <span class="token function">LOWER</span><span class="token punctuation">(</span><span class="token keyword">SCHEMA_NAME</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token string">'test'</span></code></pre>
</div>
<p>
Although a case-insensitive comparison can be performed even on
platforms with case-sensitive file systems, as just shown, it is
not necessarily always the right thing to do. On such platforms,
it is possible to have multiple objects with names that differ
only in lettercase. For example, tables named
<code class="literal">
city
</code>
,
<code class="literal">
CITY
</code>
, and
<code class="literal">
City
</code>
can all exist simultaneously. Consider
whether a search should match all such names or just one and
write queries accordingly. The first of the following
comparisons (with
<code class="literal">
utf8mb3_bin
</code>
) is
case-sensitive; the others are not:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa48842666"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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">WHERE</span> <span class="token keyword">TABLE_NAME</span> <span class="token keyword">COLLATE</span> utf8mb3_bin <span class="token operator">=</span> <span class="token string">'City'</span>
<span class="token keyword">WHERE</span> <span class="token keyword">TABLE_NAME</span> <span class="token keyword">COLLATE</span> utf8mb3_general_ci <span class="token operator">=</span> <span class="token string">'city'</span>
<span class="token keyword">WHERE</span> <span class="token function">UPPER</span><span class="token punctuation">(</span><span class="token keyword">TABLE_NAME</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token string">'CITY'</span>
<span class="token keyword">WHERE</span> <span class="token function">LOWER</span><span class="token punctuation">(</span><span class="token keyword">TABLE_NAME</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token string">'city'</span></code></pre>
</div>
<p>
Searches in
<code class="literal">
INFORMATION_SCHEMA
</code>
string columns
for values that refer to
<code class="literal">
INFORMATION_SCHEMA
</code>
itself do use the
<code class="literal">
utf8mb3_general_ci
</code>
collation because
<code class="literal">
INFORMATION_SCHEMA
</code>
is a
<span class="quote">
“
<span class="quote">
virtual
</span>
”
</span>
database not represented in the file
system. For example, comparisons with
<code class="literal">
SCHEMATA.SCHEMA_NAME
</code>
match
<code class="literal">
'information_schema'
</code>
or
<code class="literal">
'INFORMATION_SCHEMA'
</code>
regardless of platform:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa96207528"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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">SCHEMA_NAME</span> <span class="token keyword">FROM</span> INFORMATION_SCHEMA<span class="token punctuation">.</span>SCHEMATA
<span class="token keyword">WHERE</span> <span class="token keyword">SCHEMA_NAME</span> <span class="token operator">=</span> <span class="token string">'information_schema'</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> SCHEMA_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>
<span class="token output"><span class="token punctuation">|</span> information_schema <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> <span class="token keyword">SCHEMA_NAME</span> <span class="token keyword">FROM</span> INFORMATION_SCHEMA<span class="token punctuation">.</span>SCHEMATA
<span class="token keyword">WHERE</span> <span class="token keyword">SCHEMA_NAME</span> <span class="token operator">=</span> <span class="token string">'INFORMATION_SCHEMA'</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> SCHEMA_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>
<span class="token output"><span class="token punctuation">|</span> information_schema <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></code></pre>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/docker-mysql-getting-started.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="docker-mysql-getting-started">
</a>
2.5.6.1 Basic Steps for MySQL Server Deployment with Docker
</h4>
</div>
</div>
</div>
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Warning
</div>
<p>
The MySQL Docker images maintained by the MySQL team are built
specifically for Linux platforms. Other platforms are not
supported, and users using these MySQL Docker images on them
are doing so at their own risk. See
<a class="link" href="deploy-mysql-nonlinux-docker.html" title="2.5.6.3 Deploying MySQL on Windows and Other Non-Linux Platforms with Docker">
the discussion
here
</a>
for some known limitations for running these
containers on non-Linux operating systems.
</p>
</div>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="xref" href="docker-mysql-getting-started.html#docker-download-image" title="Downloading a MySQL Server Docker Image">
Downloading a MySQL Server Docker Image
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="docker-mysql-getting-started.html#docker-starting-mysql-server" title="Starting a MySQL Server Instance">
Starting a MySQL Server Instance
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="docker-mysql-getting-started.html#docker-connecting-within-container" title="Connecting to MySQL Server from within the Container">
Connecting to MySQL Server from within the Container
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="docker-mysql-getting-started.html#docker-shell-access" title="Container Shell Access">
Container Shell Access
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="docker-mysql-getting-started.html#docker-stopping-deleting" title="Stopping and Deleting a MySQL Container">
Stopping and Deleting a MySQL Container
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="docker-mysql-getting-started.html#docker-upgrading" title="Upgrading a MySQL Server Container">
Upgrading a MySQL Server Container
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="docker-mysql-getting-started.html#docker-more-topics" title="More Topics on Deploying MySQL Server with Docker">
More Topics on Deploying MySQL Server with Docker
</a>
</p>
</li>
</ul>
</div>
<h5>
<a name="docker-download-image">
</a>
Downloading a MySQL Server Docker Image
</h5>
<div class="important" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Important
</div>
<p>
<span class="emphasis">
<em>
For users of MySQL Enterprise Edition
</em>
</span>
: A subscription is
required to use the Docker images for MySQL Enterprise Edition. Subscriptions
work by a Bring Your Own License model; see
<a class="ulink" href="https://www.mysql.com/buy-mysql/" target="_blank">
How to Buy MySQL
Products and Services
</a>
for details.
</p>
</div>
<p>
Downloading the server image in a separate step is not strictly
necessary; however, performing this step before you create your
Docker container ensures your local image is up to date. To
download the MySQL Community Edition image from the
<a class="ulink" href="https://container-registry.oracle.com/" target="_blank">
Oracle
Container Registry (OCR)
</a>
, run this command:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa76241207"><div class="copy-help left">Press ⌘+C to 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">docker pull container-registry<span class="token punctuation">.</span>oracle<span class="token punctuation">.</span>com/mysql/community-server<span class="token punctuation">:</span><em class="replaceable">tag</em></code></pre>
</div>
<p>
The
<em class="replaceable">
<code>
tag
</code>
</em>
is the label for the image
version you want to pull (for example,
<code class="literal">
8.4
</code>
, or
<code class="literal">
9.1
</code>
, or
<code class="literal">
latest
</code>
). If
<strong class="userinput">
<code>
:
<em class="replaceable">
<code>
tag
</code>
</em>
</code>
</strong>
is
omitted, the
<code class="literal">
latest
</code>
label is used, and the
image for the latest GA release (which is the latest innovation
release) of MySQL Community Server is downloaded.
</p>
<p>
To download the MySQL Enterprise Edition image from the OCR, you need to first
accept the license agreement on the OCR and log in to the
container repository with your Docker client. Follow these
steps:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Visit the OCR at
<a class="ulink" href="https://container-registry.oracle.com/" target="_blank">
https://container-registry.oracle.com/
</a>
and
choose
<span class="guiicon">
MySQL
</span>
.
</p>
</li>
<li class="listitem">
<p>
Under the list of MySQL repositories, choose
<code class="literal">
enterprise-server
</code>
.
</p>
</li>
<li class="listitem">
<p>
If you have not signed in to the OCR yet, click the
<span class="guibutton">
Sign in
</span>
button on the right of the
page, and then enter your Oracle account credentials when
prompted to.
</p>
</li>
<li class="listitem">
<p>
Follow the instructions on the right of the page to accept
the license agreement.
</p>
</li>
<li class="listitem">
<p>
Log in to the OCR with your container client using, for
example, the
<code class="literal">
docker login
</code>
command:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa48494576"><div class="copy-help left">Press ⌘+C to 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 comment" spellcheck="true"># docker login container-registry.oracle.com </span>
Username<span class="token punctuation">:</span> <em class="replaceable">Oracle-Account-ID</em>
Password<span class="token punctuation">:</span> <em class="replaceable">password</em>
Login successful<span class="token punctuation">.</span></code></pre>
</div>
</li>
</ul>
</div>
<p>
Download the Docker image for MySQL Enterprise Edition from the OCR with this
command:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa30168128"><div class="copy-help left">Press ⌘+C to 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">docker pull container-registry<span class="token punctuation">.</span>oracle<span class="token punctuation">.</span>com/mysql/enterprise-server<span class="token punctuation">:</span><em class="replaceable">tag</em></code></pre>
</div>
<p>
To download the MySQL Enterprise Edition image from
<a class="ulink" href="https://support.oracle.com/" target="_blank">
My Oracle
Support
</a>
website, go onto the website, sign in to your
Oracle account, and perform these steps once you are on the
landing page:
</p>
<p>
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Select the
<span class="guimenu">
Patches and Updates
</span>
tab.
</p>
</li>
<li class="listitem">
<p>
Go to the
<span class="guilabel">
Patch Search
</span>
region and, on
the
<span class="guilabel">
Search
</span>
tab, switch to the
<span class="guilabel">
Product or Family (Advanced)
</span>
subtab.
</p>
</li>
<li class="listitem">
<p>
Enter
<span class="quote">
“
<span class="quote">
MySQL Server
</span>
”
</span>
for the
<span class="guimenuitem">
Product
</span>
field, and the desired
version number in the
<span class="guimenuitem">
Release
</span>
field.
</p>
</li>
<li class="listitem">
<p>
Use the dropdowns for additional filters to select
<span class="guimenuitem">
Description
</span>
—
<span class="guimenuitem">
contains
</span>
,
and enter
<span class="quote">
“
<span class="quote">
Docker
</span>
”
</span>
in the text field.
</p>
<p>
The following figure shows the search settings for the
MySQL Enterprise Edition image for MySQL Server 8.0:
</p>
<div class="mediaobject">
<img alt="Diagram showing search settings for MySQL Enterprise image" src="images/docker-search2.png" style="width: 100%; max-width: 922px;"/>
</div>
</li>
<li class="listitem">
<p>
Click the
<span class="guibutton">
Search
</span>
button and, from
the result list, select the version you want, and click
the
<span class="guibutton">
Download
</span>
button.
</p>
</li>
<li class="listitem">
<p>
In the
<span class="guilabel">
File Download
</span>
dialogue box
that appears, click and download the
<code class="filename">
.zip
</code>
file for the Docker image.
</p>
</li>
</ul>
</div>
<p>
Unzip the downloaded
<code class="filename">
.zip
</code>
archive to obtain
the tarball inside
(
<code class="filename">
mysql-enterprise-server-
<em class="replaceable">
<code>
version
</code>
</em>
.tar
</code>
),
and then load the image by running this command:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-simple"><div class="docs-select-all right" id="sa45468036"><div class="copy-help left">Press ⌘+C to 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">docker load <span class="token operator">-</span>i mysql<span class="token operator">-</span>enterprise<span class="token operator">-</span>server<span class="token operator">-</span><em class="replaceable">version</em><span class="token punctuation">.</span>tar</code></pre>
</div>
<p>
You can list downloaded Docker images with this command:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa52281985"><div class="copy-help left">Press ⌘+C to 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">docker</span> images
REPOSITORY TAG IMAGE ID CREATED SIZE
container-registry<span class="token punctuation">.</span>oracle<span class="token punctuation">.</span>com/mysql/community-server latest 1d9c2219ff69 2 months ago 496MB</code></pre>
</div>
<h5>
<a name="docker-starting-mysql-server">
</a>
Starting a MySQL Server Instance
</h5>
<p>
To start a new Docker container for a MySQL Server, use the
following command:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa12619065"><div class="copy-help left">Press ⌘+C to 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">docker run <span class="token constant">--name</span><span class="token attr-value"><span class="token punctuation">=</span><em class="replaceable">container_name</em></span> <span class="token property">--restart</span> on-failure <span class="token property">-d</span> <em class="replaceable">image_name</em><span class="token punctuation">:</span><em class="replaceable">tag</em></code></pre>
</div>
<p>
<em class="replaceable">
<code>
image_name
</code>
</em>
is the name of the image
to be used to start the container; see
<a class="xref" href="docker-mysql-getting-started.html#docker-download-image" title="Downloading a MySQL Server Docker Image">
Downloading a MySQL Server Docker Image
</a>
for more information.
</p>
<p>
The
<code class="option">
--name
</code>
option, for supplying a custom name
for your server container, is optional; if no container name is
supplied, a random one is generated.
</p>
<p>
The
<code class="option">
--restart
</code>
option is for configuring the
<a class="ulink" href="https://docs.docker.com/config/containers/start-containers-automatically/" target="_blank">
restart
policy
</a>
for your container; it should be set to the value
<code class="literal">
on-failure
</code>
, to enable support for server
restart within a client session (which happens, for example,
when the
<a class="link" href="restart.html" title="15.7.8.8 RESTART Statement">
RESTART
</a>
statement is
executed by a client or during the configuration of an
InnoDB Cluster instance). With the support for restart
enabled, issuing a restart within a client session causes the
server and the container to stop and then restart.
</p>
<p>
For example, to start a new Docker container for the MySQL
Community Server, use this command:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa7920167"><div class="copy-help left">Press ⌘+C to 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">docker run <span class="token constant">--name</span><span class="token attr-value"><span class="token punctuation">=</span>mysql1</span> <span class="token property">--restart</span> on-failure <span class="token property">-d</span> container-registry<span class="token punctuation">.</span>oracle<span class="token punctuation">.</span>com/mysql/community-server<span class="token punctuation">:</span>latest</code></pre>
</div>
<p>
To start a new Docker container for the MySQL Enterprise Server
with a Docker image downloaded from the OCR, use this command:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa42016940"><div class="copy-help left">Press ⌘+C to 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">docker run <span class="token constant">--name</span><span class="token attr-value"><span class="token punctuation">=</span>mysql1</span> <span class="token property">--restart</span> on-failure <span class="token property">-d</span> container-registry<span class="token punctuation">.</span>oracle<span class="token punctuation">.</span>com/mysql/enterprise-server<span class="token punctuation">:</span>latest</code></pre>
</div>
<p>
To start a new Docker container for the MySQL Enterprise Server
with a Docker image downloaded from My Oracle Support, use this
command:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa77559957"><div class="copy-help left">Press ⌘+C to 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">docker run <span class="token constant">--name</span><span class="token attr-value"><span class="token punctuation">=</span>mysql1</span> <span class="token property">--restart</span> on-failure <span class="token property">-d</span> mysql/enterprise-server<span class="token punctuation">:</span>latest</code></pre>
</div>
<p>
If the Docker image of the specified name and tag has not been
downloaded by an earlier
<span class="command">
<strong>
docker pull
</strong>
</span>
or
<span class="command">
<strong>
docker run
</strong>
</span>
command, the image is now
downloaded. Initialization for the container begins, and the
container appears in the list of running containers when you run
the
<span class="command">
<strong>
docker ps
</strong>
</span>
command. For example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa79282230"><div class="copy-help left">Press ⌘+C to 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">docker</span> ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4cd4129b3211 container-registry<span class="token punctuation">.</span>oracle<span class="token punctuation">.</span>com/mysql/community-server<span class="token punctuation">:</span>latest <span class="token atrule">"/entrypoint.sh mysq…"</span> 8 seconds ago Up 7 seconds <span class="token punctuation">(</span>health<span class="token punctuation">:</span> starting<span class="token punctuation">)</span> 3306/tcp<span class="token punctuation">,</span> 33060-33061/tcp mysql1</code></pre>
</div>
<p>
The container initialization might take some time. When the
server is ready for use, the
<code class="literal">
STATUS
</code>
of the
container in the output of the
<span class="command">
<strong>
docker ps
</strong>
</span>
command changes from
<code class="literal">
(health: starting)
</code>
to
<code class="literal">
(healthy)
</code>
.
</p>
<p>
The
<code class="option">
-d
</code>
option used in the
<span class="command">
<strong>
docker
run
</strong>
</span>
command above makes the container run in the
background. Use this command to monitor the output from the
container:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa55600268"><div class="copy-help left">Press ⌘+C to 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">docker logs mysql1</code></pre>
</div>
<p>
</p>
<p>
Once initialization is finished, the command's output is going
to contain the random password generated for the root user;
check the password with, for example, this command:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa3591565"><div class="copy-help left">Press ⌘+C to 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">docker</span> logs mysql1 2>&1 | grep GENERATED
GENERATED ROOT PASSWORD<span class="token punctuation">:</span> Axegh3kAJyDLaRuBemecis&EShOs</code></pre>
</div>
<p>
</p>
<h5>
<a name="docker-connecting-within-container">
</a>
Connecting to MySQL Server from within the Container
</h5>
<p>
Once the server is ready, you can run 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 within the MySQL Server
container you just started, and connect it to the MySQL Server.
Use the
<span class="command">
<strong>
docker exec -it
</strong>
</span>
command to start a
<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 inside the Docker container you
have started, like the following:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa80830888"><div class="copy-help left">Press ⌘+C to 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">docker exec <span class="token property">-it</span> mysql1 mysql <span class="token property">-uroot</span> <span class="token property">-p</span></code></pre>
</div>
<p>
When asked, enter the generated root password (see the last step
in
<a class="xref" href="docker-mysql-getting-started.html#docker-starting-mysql-server" title="Starting a MySQL Server Instance">
Starting a MySQL Server Instance
</a>
above on how to find the password). Because the
<a class="link" href="docker-mysql-more-topics.html#docker_var_mysql_onetime_password">
<code class="option">
MYSQL_ONETIME_PASSWORD
</code>
</a>
option is true by default, after you have connected a
<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 the server, you must reset
the server root password by issuing this statement:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa8560179"><div class="copy-help left">Press ⌘+C to 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">mysql></span><span class="token command"> ALTER</span> USER <span class="token atrule">'root'</span>@<span class="token atrule">'localhost'</span> IDENTIFIED BY <span class="token atrule">'<em class="replaceable">password</em>'</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
Substitute
<em class="replaceable">
<code>
password
</code>
</em>
with the password
of your choice. Once the password is reset, the server is ready
for use.
</p>
<h5>
<a name="docker-shell-access">
</a>
Container Shell Access
</h5>
<p>
To have shell access to your MySQL Server container, use the
<span class="command">
<strong>
docker exec -it
</strong>
</span>
command to start a bash shell
inside the container:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa7660649"><div class="copy-help left">Press ⌘+C to 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">docker</span> exec <span class="token property">-it</span> mysql1 bash
bash-4<span class="token punctuation">.</span>2<span class="token comment" spellcheck="true">#</span></code></pre>
</div>
<p>
You can then run Linux commands inside the container. For
example, to view contents in the server's data directory inside
the container, use this command:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa98929954"><div class="copy-help left">Press ⌘+C to 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">bash-4<span class="token punctuation">.</span>2<span class="token comment" spellcheck="true"># ls /var/lib/mysql</span>
auto<span class="token punctuation">.</span>cnf ca<span class="token punctuation">.</span>pem client-key<span class="token punctuation">.</span>pem ib_logfile0 ibdata1 mysql mysql<span class="token punctuation">.</span>sock<span class="token punctuation">.</span>lock private_key<span class="token punctuation">.</span>pem server-cert<span class="token punctuation">.</span>pem sys
ca-key<span class="token punctuation">.</span>pem client-cert<span class="token punctuation">.</span>pem ib_buffer_pool ib_logfile1 ibtmp1 mysql<span class="token punctuation">.</span>sock performance_schema public_key<span class="token punctuation">.</span>pem server-key<span class="token punctuation">.</span>pem</code></pre>
</div>
<h5>
<a name="docker-stopping-deleting">
</a>
Stopping and Deleting a MySQL Container
</h5>
<p>
To stop the MySQL Server container we have created, use this
command:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa80749013"><div class="copy-help left">Press ⌘+C to 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">docker stop mysql1</code></pre>
</div>
<p>
<span class="command">
<strong>
docker stop
</strong>
</span>
sends a SIGTERM signal to the
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
process, so that the server is shut
down gracefully.
</p>
<p>
Also notice that when the main process of a container
(
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
in the case of a MySQL Server
container) is stopped, the Docker container stops automatically.
</p>
<p>
To start the MySQL Server container again:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa99871467"><div class="copy-help left">Press ⌘+C to 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">docker start mysql1</code></pre>
</div>
<p>
To stop and start again the MySQL Server container with a single
command:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa76469827"><div class="copy-help left">Press ⌘+C to 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">docker restart mysql1</code></pre>
</div>
<p>
To delete the MySQL container, stop it first, and then use the
<span class="command">
<strong>
docker rm
</strong>
</span>
command:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa73820979"><div class="copy-help left">Press ⌘+C to 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">docker stop mysql1</code></pre>
</div>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa78341922"><div class="copy-help left">Press ⌘+C to 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">docker rm mysql1</code></pre>
</div>
<p>
If you want the
<a class="link" href="docker-mysql-more-topics.html#docker-persisting-data-configuration" title="Persisting Data and Configuration Changes">
Docker
volume for the server's data directory
</a>
to be deleted at
the same time, add the
<code class="literal">
-v
</code>
option to the
<span class="command">
<strong>
docker rm
</strong>
</span>
command.
</p>
<h5>
<a name="docker-upgrading">
</a>
Upgrading a MySQL Server Container
</h5>
<div class="important" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Important
</div>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Before performing any upgrade to MySQL, follow carefully
the instructions in
<a class="xref" href="upgrading.html" title="Chapter 3 Upgrading MySQL">
Chapter 3,
<i>
Upgrading MySQL
</i>
</a>
. Among
other instructions discussed there, it is especially
important to back up your database before the upgrade.
</p>
</li>
<li class="listitem">
<p>
The instructions in this section require that the server's
data and configuration have been persisted on the host.
See
<a class="xref" href="docker-mysql-more-topics.html#docker-persisting-data-configuration" title="Persisting Data and Configuration Changes">
Persisting Data and Configuration Changes
</a>
for details.
</p>
</li>
</ul>
</div>
</div>
<p>
Follow these steps to upgrade a Docker installation of MySQL
8.4 to 9.1:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Stop the MySQL 8.4 server (container name
is
<code class="literal">
mysql84
</code>
in
this example):
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa70900139"><div class="copy-help left">Press ⌘+C to 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">docker stop mysql84</code></pre>
</div>
</li>
<li class="listitem">
<p>
Download the MySQL 9.1 Server Docker
image. See instructions in
<a class="xref" href="docker-mysql-getting-started.html#docker-download-image" title="Downloading a MySQL Server Docker Image">
Downloading a MySQL Server Docker Image
</a>
. Make sure you use
the right tag for MySQL 9.1.
</p>
</li>
<li class="listitem">
<p>
Start a new MySQL 9.1 Docker
container (named
<code class="literal">
mysql91
</code>
in
this example) with the old server data and configuration
(with proper modifications if needed—see
<a class="xref" href="upgrading.html" title="Chapter 3 Upgrading MySQL">
Chapter 3,
<i>
Upgrading MySQL
</i>
</a>
) that have been
persisted on the host (by
<a class="ulink" href="https://docs.docker.com/engine/reference/commandline/service_create/#add-bind-mounts-or-volumes" target="_blank">
bind-mounting
</a>
in this example). For the MySQL Community Server, run this
command:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa2812172"><div class="copy-help left">Press ⌘+C to 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">docker run <span class="token constant">--name</span><span class="token attr-value"><span class="token punctuation">=</span>mysql84</span> \
<span class="token property">--mount</span> type<span class="token attr-value"><span class="token punctuation">=</span>bind,src=/path</span><span class="token constant">-on-host-machine/my.cnf,dst</span><span class="token attr-value"><span class="token punctuation">=</span>/etc/my.cnf</span> \
<span class="token property">--mount</span> type<span class="token attr-value"><span class="token punctuation">=</span>bind,src=/path</span><span class="token constant">-on-host-machine/datadir,dst</span><span class="token attr-value"><span class="token punctuation">=</span>/var/lib/mysql</span> \
<span class="token property">-d</span> container-registry<span class="token punctuation">.</span>oracle<span class="token punctuation">.</span>com/mysql/community-server<span class="token punctuation">:</span>9<span class="token punctuation">.</span>1</code></pre>
</div>
<p>
If needed, adjust
<code class="literal">
container-registry.oracle.com/mysql/community-server
</code>
to the correct image name—for example, replace it with
<code class="literal">
container-registry.oracle.com/mysql/enterprise-server
</code>
for MySQL Enterprise Edition images downloaded from the OCR, or
<code class="literal">
mysql/enterprise-server
</code>
for MySQL Enterprise Edition images
downloaded from My Oracle Support.
</p>
</li>
<li class="listitem">
<p>
Wait for the server to finish startup. You can check the
status of the server using the
<span class="command">
<strong>
docker ps
</strong>
</span>
command (see
<a class="xref" href="docker-mysql-getting-started.html#docker-starting-mysql-server" title="Starting a MySQL Server Instance">
Starting a MySQL Server Instance
</a>
for how to do that).
</p>
</li>
</ul>
</div>
<p>
Follow the same steps for upgrading within the
9.1 series (that is, from release
9.1.
<em class="replaceable">
<code>
x
</code>
</em>
to
9.1.
<em class="replaceable">
<code>
y
</code>
</em>
): stop
the original container, and start a new one with a newer image
on the old server data and configuration. If you used the
9.1 or the
<code class="literal">
latest
</code>
tag
when starting your original container and there is now a new
MySQL 9.1 release you want to upgrade to
it, you must first pull the image for the new release with the
command:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-simple"><div class="docs-select-all right" id="sa2580187"><div class="copy-help left">Press ⌘+C to 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">docker pull container<span class="token operator">-</span>registry<span class="token punctuation">.</span>oracle<span class="token punctuation">.</span>com<span class="token operator">/</span>mysql<span class="token operator">/</span>community<span class="token operator">-</span>server<span class="token operator">:</span>9<span class="token punctuation">.</span>1</code></pre>
</div>
<p>
You can then upgrade by starting a
<span class="emphasis">
<em>
new
</em>
</span>
container with the same tag on the old data and configuration
(adjust the image name if you are using the MySQL Enterprise Edition; see
<a class="xref" href="docker-mysql-getting-started.html#docker-download-image" title="Downloading a MySQL Server Docker Image">
Downloading a MySQL Server Docker Image
</a>
):
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa77906451"><div class="copy-help left">Press ⌘+C to 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">docker run <span class="token constant">--name</span><span class="token attr-value"><span class="token punctuation">=</span>mysql84new</span> \
<span class="token property">--mount</span> type<span class="token attr-value"><span class="token punctuation">=</span>bind,src=/path</span><span class="token constant">-on-host-machine/my.cnf,dst</span><span class="token attr-value"><span class="token punctuation">=</span>/etc/my.cnf</span> \
<span class="token property">--mount</span> type<span class="token attr-value"><span class="token punctuation">=</span>bind,src=/path</span><span class="token constant">-on-host-machine/datadir,dst</span><span class="token attr-value"><span class="token punctuation">=</span>/var/lib/mysql</span> \
<span class="token property">-d</span> container-registry<span class="token punctuation">.</span>oracle<span class="token punctuation">.</span>com/mysql/community-server<span class="token punctuation">:</span>9<span class="token punctuation">.</span>1</code></pre>
</div>
<h5>
<a name="docker-more-topics">
</a>
More Topics on Deploying MySQL Server with Docker
</h5>
<p>
For more topics on deploying MySQL Server with Docker like
server configuration, persisting data and configuration, server
error log, and container environment variables, see
<a class="xref" href="docker-mysql-more-topics.html" title="2.5.6.2 More Topics on Deploying MySQL Server with Docker">
Section 2.5.6.2, “More Topics on Deploying MySQL Server with Docker”
</a>
.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/sys-user-summary-by-file-io.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="sys-user-summary-by-file-io">
</a>
30.4.3.42 The user_summary_by_file_io and x$user_summary_by_file_io Views
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045061942672">
</a>
<a class="indexterm" name="idm46045061941216">
</a>
<a class="indexterm" name="idm46045061939712">
</a>
<a class="indexterm" name="idm46045061938208">
</a>
<p>
These views summarize file I/O, grouped by user. By default,
rows are sorted by descending total file I/O latency.
</p>
<p>
The
<a class="link" href="sys-user-summary-by-file-io.html" title="30.4.3.42 The user_summary_by_file_io and x$user_summary_by_file_io Views">
<code class="literal">
user_summary_by_file_io
</code>
</a>
and
<a class="link" href="sys-user-summary-by-file-io.html" title="30.4.3.42 The user_summary_by_file_io and x$user_summary_by_file_io Views">
<code class="literal">
x$user_summary_by_file_io
</code>
</a>
views
have these columns:
</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. Rows for which the
<code class="literal">
USER
</code>
column in the underlying
Performance Schema table is
<code class="literal">
NULL
</code>
are
assumed to be for background threads and are reported with
a host name of
<code class="literal">
background
</code>
.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ios
</code>
</p>
<p>
The total number of file I/O events for the user.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
io_latency
</code>
</p>
<p>
The total wait time of timed file I/O events for the user.
</p>
</li>
</ul>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/mysql-cluster-ndbinfo-table-replicas.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="mysql-cluster-ndbinfo-table-replicas">
</a>
25.6.17.60 The ndbinfo table_replicas Table
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045087665184">
</a>
<p>
The
<code class="literal">
table_replicas
</code>
table provides information
about the copying, distribution, and checkpointing of
<code class="literal">
NDB
</code>
table fragments and fragment replicas.
</p>
<p>
The
<code class="literal">
table_replicas
</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>
ID of the node from which data is fetched
(
<a class="ulink" href="/doc/ndb-internals/en/ndb-internals-kernel-blocks-dbdih.html" target="_top">
<code class="literal">
DIH
</code>
</a>
master)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
table_id
</code>
</p>
<p>
Table ID
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
fragment_id
</code>
</p>
<p>
Fragment ID
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
initial_gci
</code>
</p>
<p>
Initial GCI for table
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
replica_node_id
</code>
</p>
<p>
ID of node where fragment replica is stored
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
is_lcp_ongoing
</code>
</p>
<p>
Is 1 if LCP is ongoing on this fragment, 0 otherwise
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
num_crashed_replicas
</code>
</p>
<p>
Number of crashed fragment replica instances
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
last_max_gci_started
</code>
</p>
<p>
Highest GCI started in most recent LCP
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
last_max_gci_completed
</code>
</p>
<p>
Highest GCI completed in most recent LCP
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
last_lcp_id
</code>
</p>
<p>
ID of most recent LCP
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
prev_lcp_id
</code>
</p>
<p>
ID of previous LCP
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
prev_max_gci_started
</code>
</p>
<p>
Highest GCI started in previous LCP
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
prev_max_gci_completed
</code>
</p>
<p>
Highest GCI completed in previous LCP
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
last_create_gci
</code>
</p>
<p>
Last Create GCI of last crashed fragment replica instance
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
last_replica_gci
</code>
</p>
<p>
Last GCI of last crashed fragment replica instance
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
is_replica_alive
</code>
</p>
<p>
1 if this fragment replica is alive, 0 otherwise
</p>
</li>
</ul>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/innodb-information-schema-innodb_cmp.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="innodb-information-schema-innodb_cmp">
</a>
17.15.1.1 INNODB_CMP and INNODB_CMP_RESET
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045151401648">
</a>
<a class="indexterm" name="idm46045151400256">
</a>
<p>
The
<a class="link" href="information-schema-innodb-cmp-table.html" title="28.4.6 The INFORMATION_SCHEMA INNODB_CMP and INNODB_CMP_RESET Tables">
<code class="literal">
INNODB_CMP
</code>
</a>
and
<a class="link" href="information-schema-innodb-cmp-table.html" title="28.4.6 The INFORMATION_SCHEMA INNODB_CMP and INNODB_CMP_RESET Tables">
<code class="literal">
INNODB_CMP_RESET
</code>
</a>
tables provide
status information about operations related to compressed
tables, which are described in
<a class="xref" href="innodb-compression.html" title="17.9 InnoDB Table and Page Compression">
Section 17.9, “InnoDB Table and Page Compression”
</a>
. The
<code class="literal">
PAGE_SIZE
</code>
column reports the compressed
<a class="link" href="glossary.html#glos_page_size" title="page size">
page size
</a>
.
</p>
<p>
These two tables have identical contents, but reading from
<a class="link" href="information-schema-innodb-cmp-table.html" title="28.4.6 The INFORMATION_SCHEMA INNODB_CMP and INNODB_CMP_RESET Tables">
<code class="literal">
INNODB_CMP_RESET
</code>
</a>
resets the
statistics on compression and uncompression operations. For
example, if you archive the output of
<a class="link" href="information-schema-innodb-cmp-table.html" title="28.4.6 The INFORMATION_SCHEMA INNODB_CMP and INNODB_CMP_RESET Tables">
<code class="literal">
INNODB_CMP_RESET
</code>
</a>
every 60 minutes,
you see the statistics for each hourly period. If you monitor
the output of
<a class="link" href="information-schema-innodb-cmp-table.html" title="28.4.6 The INFORMATION_SCHEMA INNODB_CMP and INNODB_CMP_RESET Tables">
<code class="literal">
INNODB_CMP
</code>
</a>
(making
sure never to read
<a class="link" href="information-schema-innodb-cmp-table.html" title="28.4.6 The INFORMATION_SCHEMA INNODB_CMP and INNODB_CMP_RESET Tables">
<code class="literal">
INNODB_CMP_RESET
</code>
</a>
), you see the
cumulative statistics since InnoDB was started.
</p>
<p>
For the table definition, see
<a class="xref" href="information-schema-innodb-cmp-table.html" title="28.4.6 The INFORMATION_SCHEMA INNODB_CMP and INNODB_CMP_RESET Tables">
Section 28.4.6, “The INFORMATION_SCHEMA INNODB_CMP and INNODB_CMP_RESET Tables”
</a>
.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/charset.html | <div id="docs-body">
<div class="chapter">
<div class="titlepage">
<div>
<div>
<h1 class="title">
<a name="charset">
</a>
Chapter 12 Character Sets, Collations, Unicode
</h1>
</div>
</div>
</div>
<div class="toc">
<p>
<b>
Table of Contents
</b>
</p>
<dl class="toc">
<dt>
<span class="section">
<a href="charset-general.html">
12.1 Character Sets and Collations in General
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="charset-mysql.html">
12.2 Character Sets and Collations in MySQL
</a>
</span>
</dt>
<dd>
<dl>
<dt>
<span class="section">
<a href="charset-repertoire.html">
12.2.1 Character Set Repertoire
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="charset-metadata.html">
12.2.2 UTF-8 for Metadata
</a>
</span>
</dt>
</dl>
</dd>
<dt>
<span class="section">
<a href="charset-syntax.html">
12.3 Specifying Character Sets and Collations
</a>
</span>
</dt>
<dd>
<dl>
<dt>
<span class="section">
<a href="charset-collation-names.html">
12.3.1 Collation Naming Conventions
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="charset-server.html">
12.3.2 Server Character Set and Collation
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="charset-database.html">
12.3.3 Database Character Set and Collation
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="charset-table.html">
12.3.4 Table Character Set and Collation
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="charset-column.html">
12.3.5 Column Character Set and Collation
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="charset-literal.html">
12.3.6 Character String Literal Character Set and Collation
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="charset-national.html">
12.3.7 The National Character Set
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="charset-introducer.html">
12.3.8 Character Set Introducers
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="charset-examples.html">
12.3.9 Examples of Character Set and Collation Assignment
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="charset-compatibility.html">
12.3.10 Compatibility with Other DBMSs
</a>
</span>
</dt>
</dl>
</dd>
<dt>
<span class="section">
<a href="charset-connection.html">
12.4 Connection Character Sets and Collations
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="charset-applications.html">
12.5 Configuring Application Character Set and Collation
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="charset-errors.html">
12.6 Error Message Character Set
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="charset-conversion.html">
12.7 Column Character Set Conversion
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="charset-collations.html">
12.8 Collation Issues
</a>
</span>
</dt>
<dd>
<dl>
<dt>
<span class="section">
<a href="charset-collate.html">
12.8.1 Using COLLATE in SQL Statements
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="charset-collate-precedence.html">
12.8.2 COLLATE Clause Precedence
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="charset-collation-compatibility.html">
12.8.3 Character Set and Collation Compatibility
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="charset-collation-coercibility.html">
12.8.4 Collation Coercibility in Expressions
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="charset-binary-collations.html">
12.8.5 The binary Collation Compared to _bin Collations
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="charset-collation-effect.html">
12.8.6 Examples of the Effect of Collation
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="charset-collation-information-schema.html">
12.8.7 Using Collation in INFORMATION_SCHEMA Searches
</a>
</span>
</dt>
</dl>
</dd>
<dt>
<span class="section">
<a href="charset-unicode.html">
12.9 Unicode Support
</a>
</span>
</dt>
<dd>
<dl>
<dt>
<span class="section">
<a href="charset-unicode-utf8mb4.html">
12.9.1 The utf8mb4 Character Set (4-Byte UTF-8 Unicode Encoding)
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="charset-unicode-utf8mb3.html">
12.9.2 The utf8mb3 Character Set (3-Byte UTF-8 Unicode Encoding)
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="charset-unicode-utf8.html">
12.9.3 The utf8 Character Set (Deprecated alias for utf8mb3)
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="charset-unicode-ucs2.html">
12.9.4 The ucs2 Character Set (UCS-2 Unicode Encoding)
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="charset-unicode-utf16.html">
12.9.5 The utf16 Character Set (UTF-16 Unicode Encoding)
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="charset-unicode-utf16le.html">
12.9.6 The utf16le Character Set (UTF-16LE Unicode Encoding)
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="charset-unicode-utf32.html">
12.9.7 The utf32 Character Set (UTF-32 Unicode Encoding)
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="charset-unicode-conversion.html">
12.9.8 Converting Between 3-Byte and 4-Byte Unicode Character Sets
</a>
</span>
</dt>
</dl>
</dd>
<dt>
<span class="section">
<a href="charset-charsets.html">
12.10 Supported Character Sets and Collations
</a>
</span>
</dt>
<dd>
<dl>
<dt>
<span class="section">
<a href="charset-unicode-sets.html">
12.10.1 Unicode Character Sets
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="charset-we-sets.html">
12.10.2 West European Character Sets
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="charset-ce-sets.html">
12.10.3 Central European Character Sets
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="charset-se-me-sets.html">
12.10.4 South European and Middle East Character Sets
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="charset-baltic-sets.html">
12.10.5 Baltic Character Sets
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="charset-cyrillic-sets.html">
12.10.6 Cyrillic Character Sets
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="charset-asian-sets.html">
12.10.7 Asian Character Sets
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="charset-binary-set.html">
12.10.8 The Binary Character Set
</a>
</span>
</dt>
</dl>
</dd>
<dt>
<span class="section">
<a href="charset-restrictions.html">
12.11 Restrictions on Character Sets
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="error-message-language.html">
12.12 Setting the Error Message Language
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="adding-character-set.html">
12.13 Adding a Character Set
</a>
</span>
</dt>
<dd>
<dl>
<dt>
<span class="section">
<a href="character-arrays.html">
12.13.1 Character Definition Arrays
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="string-collating.html">
12.13.2 String Collating Support for Complex Character Sets
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="multibyte-characters.html">
12.13.3 Multi-Byte Character Support for Complex Character Sets
</a>
</span>
</dt>
</dl>
</dd>
<dt>
<span class="section">
<a href="adding-collation.html">
12.14 Adding a Collation to a Character Set
</a>
</span>
</dt>
<dd>
<dl>
<dt>
<span class="section">
<a href="charset-collation-implementations.html">
12.14.1 Collation Implementation Types
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="adding-collation-choosing-id.html">
12.14.2 Choosing a Collation ID
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="adding-collation-simple-8bit.html">
12.14.3 Adding a Simple Collation to an 8-Bit Character Set
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="adding-collation-unicode-uca.html">
12.14.4 Adding a UCA Collation to a Unicode Character Set
</a>
</span>
</dt>
</dl>
</dd>
<dt>
<span class="section">
<a href="charset-configuration.html">
12.15 Character Set Configuration
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="locale-support.html">
12.16 MySQL Server Locale Support
</a>
</span>
</dt>
</dl>
</div>
<a class="indexterm" name="idm46045218193024">
</a>
<a class="indexterm" name="idm46045218191952">
</a>
<a class="indexterm" name="idm46045218190880">
</a>
<a class="indexterm" name="idm46045218189808">
</a>
<a class="indexterm" name="idm46045218188736">
</a>
<a class="indexterm" name="idm46045218187664">
</a>
<p>
MySQL includes character set support that enables you to store data
using a variety of character sets and perform comparisons according
to a variety of collations. The default MySQL server character set
and collation are
<code class="literal">
utf8mb4
</code>
and
<code class="literal">
utf8mb4_0900_ai_ci
</code>
, but you can specify character
sets at the server, database, table, column, and string literal
levels. To maximize interoperability and future-proofing of your
data and applications, we recommend that you use the
<code class="literal">
utf8mb4
</code>
character set whenever possible.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
<code class="literal">
UTF8
</code>
is a deprecated synonym for
<code class="literal">
utf8mb3
</code>
, and you should expect it to be removed
in a future version of MySQL. Specify
<code class="literal">
utfmb3
</code>
or
(preferably)
<code class="literal">
utfmb4
</code>
instead.
</p>
</div>
<p>
This chapter discusses the following topics:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
What are character sets and collations?
</p>
</li>
<li class="listitem">
<p>
The multiple-level default system for character set assignment.
</p>
</li>
<li class="listitem">
<p>
Syntax for specifying character sets and collations.
</p>
</li>
<li class="listitem">
<p>
Affected functions and operations.
</p>
</li>
<li class="listitem">
<p>
Unicode support.
</p>
</li>
<li class="listitem">
<p>
The character sets and collations that are available, with
notes.
</p>
</li>
<li class="listitem">
<p>
Selecting the language for error messages.
</p>
</li>
<li class="listitem">
<p>
Selecting the locale for day and month names.
</p>
</li>
</ul>
</div>
<p>
Character set issues affect not only data storage, but also
communication between client programs and the MySQL server. If you
want the client program to communicate with the server using a
character set different from the default, you need to indicate which
one. For example, to use the
<code class="literal">
latin1
</code>
Unicode
character set, issue this statement after connecting to the server:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa47419321"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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">'latin1'</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
For more information about configuring character sets for
application use and character set-related issues in client/server
communication, see
<a class="xref" href="charset-applications.html" title="12.5 Configuring Application Character Set and Collation">
Section 12.5, “Configuring Application Character Set and Collation”
</a>
, and
<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>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/performance-schema-connection-attribute-tables.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="performance-schema-connection-attribute-tables">
</a>
29.12.9 Performance Schema Connection Attribute Tables
</h3>
</div>
</div>
</div>
<div class="toc">
<dl class="toc">
<dt>
<span class="section">
<a href="performance-schema-session-account-connect-attrs-table.html">
29.12.9.1 The session_account_connect_attrs Table
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="performance-schema-session-connect-attrs-table.html">
29.12.9.2 The session_connect_attrs Table
</a>
</span>
</dt>
</dl>
</div>
<p>
Connection attributes are key-value pairs that application
programs can pass to the server at connect time. For
applications based on the C API implemented by the
<code class="literal">
libmysqlclient
</code>
client library, the
<a class="ulink" href="/doc/c-api/8.4/en/mysql-options.html" target="_top">
<code class="literal">
mysql_options()
</code>
</a>
and
<a class="ulink" href="/doc/c-api/8.4/en/mysql-options4.html" target="_top">
<code class="literal">
mysql_options4()
</code>
</a>
functions
define the connection attribute set. Other MySQL Connectors may
provide their own attribute-definition methods.
</p>
<p>
These Performance Schema tables expose attribute information:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="link" href="performance-schema-session-account-connect-attrs-table.html" title="29.12.9.1 The session_account_connect_attrs Table">
<code class="literal">
session_account_connect_attrs
</code>
</a>
:
Connection attributes for the current session, and other
sessions associated with the session account
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="performance-schema-session-connect-attrs-table.html" title="29.12.9.2 The session_connect_attrs Table">
<code class="literal">
session_connect_attrs
</code>
</a>
:
Connection attributes for all sessions
</p>
</li>
</ul>
</div>
<p>
In addition, connect events written to the audit log may include
connection attributes. See
<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>
.
</p>
<p>
Attribute names that begin with an underscore
(
<code class="literal">
_
</code>
) are reserved for internal use and should
not be created by application programs. This convention permits
new attributes to be introduced by MySQL without colliding with
application attributes, and enables application programs to
define their own attributes that do not collide with internal
attributes.
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="xref" href="performance-schema-connection-attribute-tables.html#performance-schema-connection-attributes-available" title="Available Connection Attributes">
Available Connection Attributes
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="performance-schema-connection-attribute-tables.html#performance-schema-connection-attribute-limits" title="Connection Attribute Limits">
Connection Attribute Limits
</a>
</p>
</li>
</ul>
</div>
<h4>
<a name="performance-schema-connection-attributes-available">
</a>
Available Connection Attributes
</h4>
<p>
The set of connection attributes visible within a given
connection varies depending on factors such as your platform,
MySQL Connector used to establish the connection, or client
program.
</p>
<p>
The
<code class="literal">
libmysqlclient
</code>
client library sets these
attributes:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
_client_name
</code>
: The client name
(
<code class="literal">
libmysql
</code>
for the client library).
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
_client_version
</code>
: The client library
version.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
_os
</code>
: The operating system (for example,
<code class="literal">
Linux
</code>
,
<code class="literal">
Win64
</code>
).
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
_pid
</code>
: The client process ID.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
_platform
</code>
: The machine platform (for
example,
<code class="literal">
x86_64
</code>
).
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
_thread
</code>
: The client thread ID (Windows
only).
</p>
</li>
</ul>
</div>
<p>
Other MySQL Connectors may define their own connection
attributes.
</p>
<p>
MySQL Connector/C++ defines these attributes for applications that use
X DevAPI or X DevAPI for C:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
_client_license
</code>
: The connector license
(for example
<code class="literal">
GPL-2.0
</code>
).
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
_client_name
</code>
: The connector name
(
<code class="literal">
mysql-connector-cpp
</code>
).
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
_client_version
</code>
: The connector version.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
_os
</code>
: The operating system (for example,
<code class="literal">
Linux
</code>
,
<code class="literal">
Win64
</code>
).
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
_pid
</code>
: The client process ID.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
_platform
</code>
: The machine platform (for
example,
<code class="literal">
x86_64
</code>
).
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
_source_host
</code>
: The host name of the
machine on which the client is running.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
_thread
</code>
: The client thread ID (Windows
only).
</p>
</li>
</ul>
</div>
<p>
<a name="performance-schema-connection-attributes-cj">
</a>
MySQL Connector/J defines these attributes:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
_client_name
</code>
: The client name
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
_client_version
</code>
: The client library
version
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
_os
</code>
: The operating system (for example,
<code class="literal">
Linux
</code>
,
<code class="literal">
Win64
</code>
)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
_client_license
</code>
: The connector license
type
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
_platform
</code>
: The machine platform (for
example,
<code class="literal">
x86_64
</code>
)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
_runtime_vendor
</code>
: The Java runtime
environment (JRE) vendor
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
_runtime_version
</code>
: The Java runtime
environment (JRE) version
</p>
</li>
</ul>
</div>
<p>
MySQL Connector/NET defines these attributes:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
_client_version
</code>
: The client library
version.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
_os
</code>
: The operating system (for example,
<code class="literal">
Linux
</code>
,
<code class="literal">
Win64
</code>
).
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
_pid
</code>
: The client process ID.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
_platform
</code>
: The machine platform (for
example,
<code class="literal">
x86_64
</code>
).
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
_program_name
</code>
: The client name.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
_thread
</code>
: The client thread ID (Windows
only).
</p>
</li>
</ul>
</div>
<p>
The Connector/Python implementation defines these attributes; some values
and attributes depend on the Connector/Python implementation (pure python
or c-ext):
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
_client_license
</code>
: The license type of the
connector;
<code class="literal">
GPL-2.0
</code>
or
<code class="literal">
Commercial
</code>
. (pure python only)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
_client_name
</code>
: Set to
<code class="literal">
mysql-connector-python
</code>
(pure python) or
<code class="literal">
libmysql
</code>
(c-ext)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
_client_version
</code>
: The connector version
(pure python) or mysqlclient library version (c-ext).
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
_os
</code>
: The operating system with the
connector (for example,
<code class="literal">
Linux
</code>
,
<code class="literal">
Win64
</code>
).
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
_pid
</code>
: The process identifier on the
source machine (for example,
<code class="literal">
26955
</code>
)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
_platform
</code>
: The machine platform (for
example,
<code class="literal">
x86_64
</code>
).
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
_source_host
</code>
: The host name of the
machine on which the connector is connecting from.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
_connector_version
</code>
: The connector version
(for example,
<code class="literal">
8.4.3
</code>
) (c-ext
only).
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
_connector_license
</code>
: The license type of
the connector;
<code class="literal">
GPL-2.0
</code>
or
<code class="literal">
Commercial
</code>
(c-ext only).
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
_connector_name
</code>
: Always set to
<code class="literal">
mysql-connector-python
</code>
(c-ext only).
</p>
</li>
</ul>
</div>
<p>
PHP defines attributes that depend on how it was compiled:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Compiled using
<code class="literal">
libmysqlclient
</code>
: The
standard
<code class="literal">
libmysqlclient
</code>
attributes,
described previously.
</p>
</li>
<li class="listitem">
<p>
Compiled using
<code class="literal">
mysqlnd
</code>
: Only the
<code class="literal">
_client_name
</code>
attribute, with a value of
<code class="literal">
mysqlnd
</code>
.
</p>
</li>
</ul>
</div>
<p>
Many MySQL client programs set a
<code class="literal">
program_name
</code>
attribute with a value equal to the client name. For example,
<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
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
set
<code class="literal">
program_name
</code>
to
<code class="literal">
mysqladmin
</code>
and
<code class="literal">
mysqldump
</code>
,
respectively. MySQL Shell sets
<code class="literal">
program_name
</code>
to
<code class="literal">
mysqlsh
</code>
.
</p>
<p>
Some MySQL client programs define additional attributes:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<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>
:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
<code class="literal">
os_user
</code>
: The name of the operating
system user running the program. Available on Unix and
Unix-like systems and Windows.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
os_sudouser
</code>
: The value of the
<code class="literal">
SUDO_USER
</code>
environment variable.
Available on Unix and Unix-like systems.
</p>
<a class="indexterm" name="idm46045071898832">
</a>
<a class="indexterm" name="idm46045071897744">
</a>
</li>
</ul>
</div>
<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>
connection attributes for which the
value is empty are not sent.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="mysqlbinlog.html" title="6.6.9 mysqlbinlog — Utility for Processing Binary Log Files">
<span class="command">
<strong>
mysqlbinlog
</strong>
</span>
</a>
:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
<code class="literal">
_client_role
</code>
:
<code class="literal">
binary_log_listener
</code>
</p>
</li>
</ul>
</div>
</li>
<li class="listitem">
<p>
Replica connections:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
<code class="literal">
program_name
</code>
:
<code class="literal">
mysqld
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
_client_role
</code>
:
<code class="literal">
binary_log_listener
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
_client_replication_channel_name
</code>
: The
channel name.
</p>
</li>
</ul>
</div>
</li>
<li class="listitem">
<p>
<a class="link" href="federated-storage-engine.html" title="18.8 The FEDERATED Storage Engine">
<code class="literal">
FEDERATED
</code>
</a>
storage engine
connections:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
<code class="literal">
program_name
</code>
:
<code class="literal">
mysqld
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
_client_role
</code>
:
<code class="literal">
federated_storage
</code>
</p>
</li>
</ul>
</div>
</li>
</ul>
</div>
<h4>
<a name="performance-schema-connection-attribute-limits">
</a>
Connection Attribute Limits
</h4>
<p>
There are limits on the amount of connection attribute data
transmitted from client to server:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
A fixed limit imposed by the client prior to connect time.
</p>
</li>
<li class="listitem">
<p>
A fixed limit imposed by the server at connect time.
</p>
</li>
<li class="listitem">
<p>
A configurable limit imposed by the Performance Schema at
connect time.
</p>
</li>
</ul>
</div>
<p>
For connections initiated using the C API, the
<code class="literal">
libmysqlclient
</code>
library imposes a limit of
64KB on the aggregate size of connection attribute data on the
client side: Calls to
<a class="ulink" href="/doc/c-api/8.4/en/mysql-options.html" target="_top">
<code class="literal">
mysql_options()
</code>
</a>
that cause this
limit to be exceeded produce a
<a class="ulink" href="/doc/mysql-errors/8.4/en/client-error-reference.html#error_cr_invalid_parameter_no" target="_top">
<code class="literal">
CR_INVALID_PARAMETER_NO
</code>
</a>
error.
Other MySQL Connectors may impose their own client-side limits
on how much connection attribute data can be transmitted to the
server.
</p>
<p>
On the server side, these size checks on connection attribute
data occur:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
The server imposes a limit of 64KB on the aggregate size of
connection attribute data it accepts. If a client attempts
to send more than 64KB of attribute data, the server rejects
the connection. Otherwise, the server considers the
attribute buffer valid and tracks the size of the longest
such buffer in the
<a class="link" href="performance-schema-status-variables.html#statvar_Performance_schema_session_connect_attrs_longest_seen">
<code class="literal">
Performance_schema_session_connect_attrs_longest_seen
</code>
</a>
status variable.
</p>
</li>
<li class="listitem">
<p>
For accepted connections, the Performance Schema checks
aggregate attribute size against the value of the
<a class="link" href="performance-schema-system-variables.html#sysvar_performance_schema_session_connect_attrs_size">
<code class="literal">
performance_schema_session_connect_attrs_size
</code>
</a>
system variable. If attribute size exceeds this value, these
actions take place:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
The Performance Schema truncates the attribute data and
increments the
<a class="link" href="performance-schema-status-variables.html#statvar_Performance_schema_session_connect_attrs_lost">
<code class="literal">
Performance_schema_session_connect_attrs_lost
</code>
</a>
status variable, which indicates the number of
connections for which attribute truncation occurred.
</p>
</li>
<li class="listitem">
<p>
The Performance Schema writes a message to the error log
if the
<a class="link" href="server-system-variables.html#sysvar_log_error_verbosity">
<code class="literal">
log_error_verbosity
</code>
</a>
system variable is greater than 1:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-none"><div class="docs-select-all right" id="sa48004860"><div class="copy-help left">Press ⌘+C to 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">Connection attributes of length <em class="replaceable">N</em> were truncated
(<em class="replaceable">N</em> bytes lost)
for connection <em class="replaceable">N</em>, user <em class="replaceable">user_name</em>@<em class="replaceable">host_name</em>
(as <em class="replaceable">user_name</em>), auth: {yes|no}</code></pre>
</div>
<p>
The information in the warning message is intended to
help DBAs identify clients for which attribute
truncation occurred.
</p>
</li>
<li class="listitem">
<p>
A
<code class="literal">
_truncated
</code>
attribute is added to
the session attributes with a value indicating how many
bytes were lost, if the attribute buffer has sufficient
space. This enables the Performance Schema to expose
per-connection truncation information in the connection
attribute tables. This information can be examined
without having to check the error log.
</p>
</li>
</ul>
</div>
</li>
</ul>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/show-errors.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="show-errors">
</a>
15.7.7.18 SHOW ERRORS Statement
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045170471424">
</a>
<a class="indexterm" name="idm46045170470352">
</a>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa83674474"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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">ERRORS</span> <span class="token punctuation">[</span><span class="token keyword">LIMIT</span> <span class="token punctuation">[</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">row_count</em></span><span class="token punctuation">]</span>
<span class="token keyword">SHOW</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">ERRORS</span></code></pre>
</div>
<p>
<a class="link" href="show-errors.html" title="15.7.7.18 SHOW ERRORS Statement">
<code class="literal">
SHOW ERRORS
</code>
</a>
is a diagnostic
statement that is similar to
<a class="link" href="show-warnings.html" title="15.7.7.42 SHOW WARNINGS Statement">
<code class="literal">
SHOW
WARNINGS
</code>
</a>
, except that it displays information only for
errors, rather than for errors, warnings, and notes.
</p>
<p>
The
<code class="literal">
LIMIT
</code>
clause has the same syntax as for
the
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
statement. See
<a class="xref" href="select.html" title="15.2.13 SELECT Statement">
Section 15.2.13, “SELECT Statement”
</a>
.
</p>
<p>
The
<a class="link" href="show-errors.html" title="15.7.7.18 SHOW ERRORS Statement">
<code class="literal">
SHOW COUNT(*)
ERRORS
</code>
</a>
statement displays the number of errors. You
can also retrieve this number from the
<a class="link" href="server-system-variables.html#sysvar_error_count">
<code class="literal">
error_count
</code>
</a>
variable:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa40189957"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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 function">COUNT</span><span class="token punctuation">(</span><span class="token operator">*</span><span class="token punctuation">)</span> <span class="token keyword">ERRORS</span><span class="token punctuation">;</span>
<span class="token keyword">SELECT</span> <span class="token variable">@@error_count</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
<a class="link" href="show-errors.html" title="15.7.7.18 SHOW ERRORS Statement">
<code class="literal">
SHOW ERRORS
</code>
</a>
and
<a class="link" href="server-system-variables.html#sysvar_error_count">
<code class="literal">
error_count
</code>
</a>
apply only to
errors, not warnings or notes. In other respects, they are
similar to
<a class="link" href="show-warnings.html" title="15.7.7.42 SHOW WARNINGS Statement">
<code class="literal">
SHOW WARNINGS
</code>
</a>
and
<a class="link" href="server-system-variables.html#sysvar_warning_count">
<code class="literal">
warning_count
</code>
</a>
. In particular,
<a class="link" href="show-errors.html" title="15.7.7.18 SHOW ERRORS Statement">
<code class="literal">
SHOW ERRORS
</code>
</a>
cannot display
information for more than
<a class="link" href="server-system-variables.html#sysvar_max_error_count">
<code class="literal">
max_error_count
</code>
</a>
messages, and
<a class="link" href="server-system-variables.html#sysvar_error_count">
<code class="literal">
error_count
</code>
</a>
can exceed the
value of
<a class="link" href="server-system-variables.html#sysvar_max_error_count">
<code class="literal">
max_error_count
</code>
</a>
if the
number of errors exceeds
<a class="link" href="server-system-variables.html#sysvar_max_error_count">
<code class="literal">
max_error_count
</code>
</a>
.
</p>
<p>
For more information, see
<a class="xref" href="show-warnings.html" title="15.7.7.42 SHOW WARNINGS Statement">
Section 15.7.7.42, “SHOW WARNINGS Statement”
</a>
.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/mysql-cluster-params-api.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="mysql-cluster-params-api">
</a>
25.4.2.3 NDB Cluster SQL Node and API Node Configuration Parameters
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045121455760">
</a>
<a class="indexterm" name="idm46045121454304">
</a>
<a class="indexterm" name="idm46045121453232">
</a>
<p>
The listing in this section provides information about
parameters used in the
<code class="literal">
[mysqld]
</code>
and
<code class="literal">
[api]
</code>
sections of a
<code class="filename">
config.ini
</code>
file for configuring NDB Cluster
SQL nodes and API nodes. For detailed descriptions and other
additional information about each of these parameters, see
<a class="xref" href="mysql-cluster-api-definition.html" title="25.4.3.7 Defining SQL and Other API Nodes in an NDB Cluster">
Section 25.4.3.7, “Defining SQL and Other API Nodes in an NDB Cluster”
</a>
.
</p>
<div class="itemizedlist">
<a name="ndbparam-summary-list-api">
</a>
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-api-definition.html#ndbparam-api-apiverbose" title="API Node Debugging Parameters">
ApiVerbose
</a>
</code>
:
Enable NDB API debugging; for NDB development.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-api-definition.html#ndbparam-api-arbitrationdelay">
ArbitrationDelay
</a>
</code>
:
When asked to arbitrate, arbitrator waits this many
milliseconds before voting.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-api-definition.html#ndbparam-api-arbitrationrank">
ArbitrationRank
</a>
</code>
:
If 0, then API node is not arbitrator. Kernel selects
arbitrators in order 1, 2.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-api-definition.html#ndbparam-api-autoreconnect">
AutoReconnect
</a>
</code>
:
Specifies whether an API node should reconnect fully when
disconnected from cluster.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-api-definition.html#ndbparam-api-batchbytesize">
BatchByteSize
</a>
</code>
:
Default batch size in bytes.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-api-definition.html#ndbparam-api-batchsize">
BatchSize
</a>
</code>
:
Default batch size in number of records.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-api-definition.html#ndbparam-api-connectbackoffmaxtime">
ConnectBackoffMaxTime
</a>
</code>
:
Specifies longest time in milliseconds (~100ms resolution)
to allow between connection attempts to any given data node
by this API node. Excludes time elapsed while connection
attempts are ongoing, which in worst case can take several
seconds. Disable by setting to 0. If no data nodes are
currently connected to this API node,
StartConnectBackoffMaxTime is used instead.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-api-definition.html#ndbparam-api-connectionmap">
ConnectionMap
</a>
</code>
:
Specifies which data nodes to connect.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-api-definition.html#ndbparam-api-defaulthashmapsize">
DefaultHashMapSize
</a>
</code>
:
Set size (in buckets) to use for table hash maps. Three
values are supported: 0, 240, and 3840.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-api-definition.html#ndbparam-api-defaultoperationredoproblemaction">
DefaultOperationRedoProblemAction
</a>
</code>
:
How operations are handled in event that
RedoOverCommitCounter is exceeded.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-api-definition.html#ndbparam-api-executeoncomputer">
ExecuteOnComputer
</a>
</code>
:
String referencing earlier defined COMPUTER.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-api-definition.html#ndbparam-api-extrasendbuffermemory">
ExtraSendBufferMemory
</a>
</code>
:
Memory to use for send buffers in addition to any allocated
by TotalSendBufferMemory or SendBufferMemory. Default (0)
allows up to 16MB.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-api-definition.html#ndbparam-api-heartbeatthreadpriority">
HeartbeatThreadPriority
</a>
</code>
:
Set heartbeat thread policy and priority for API nodes; see
manual for allowed values.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-api-definition.html#ndbparam-api-hostname">
HostName
</a>
</code>
:
Host name or IP address for this SQL or API node.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-api-definition.html#ndbparam-api-id">
Id
</a>
</code>
:
Number identifying MySQL server or API node (Id). Now
deprecated; use NodeId instead.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-api-definition.html#ndbparam-api-locationdomainid">
LocationDomainId
</a>
</code>
:
Assign this API node to specific availability domain or
zone. 0 (default) leaves this unset.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-api-definition.html#ndbparam-api-maxscanbatchsize">
MaxScanBatchSize
</a>
</code>
:
Maximum collective batch size for one scan.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-api-definition.html#ndbparam-api-nodeid">
NodeId
</a>
</code>
:
Number uniquely identifying SQL node or API node among all
nodes in cluster.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-api-definition.html#ndbparam-api-startconnectbackoffmaxtime">
StartConnectBackoffMaxTime
</a>
</code>
:
Same as ConnectBackoffMaxTime except that this parameter is
used in its place if no data nodes are connected to this API
node.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-api-definition.html#ndbparam-api-totalsendbuffermemory">
TotalSendBufferMemory
</a>
</code>
:
Total memory to use for all transporter send buffers.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-api-definition.html#ndbparam-api-wan">
wan
</a>
</code>
:
Use WAN TCP setting as default.
</p>
</li>
</ul>
</div>
<p>
For a discussion of MySQL server options for NDB Cluster, see
<a class="xref" href="mysql-cluster-options-variables.html#mysql-cluster-program-options-mysqld" title="25.4.3.9.1 MySQL Server Options for NDB Cluster">
Section 25.4.3.9.1, “MySQL Server Options for NDB Cluster”
</a>
. For
information about MySQL server system variables relating to NDB
Cluster, see
<a class="xref" href="mysql-cluster-options-variables.html#mysql-cluster-system-variables" title="25.4.3.9.2 NDB Cluster System Variables">
Section 25.4.3.9.2, “NDB Cluster System Variables”
</a>
.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
To add new SQL or API nodes to the configuration of a running
NDB Cluster, it is necessary to perform a rolling restart of
all cluster nodes after adding new
<code class="literal">
[mysqld]
</code>
or
<code class="literal">
[api]
</code>
sections to the
<code class="filename">
config.ini
</code>
file (or files, if you are
using more than one management server). This must be done
before the new SQL or API nodes can connect to the cluster.
</p>
<p>
It is
<span class="emphasis">
<em>
not
</em>
</span>
necessary to perform any
restart of the cluster if new SQL or API nodes can employ
previously unused API slots in the cluster configuration to
connect to the cluster.
</p>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/performance-schema-replication-connection-configuration-table.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="performance-schema-replication-connection-configuration-table">
</a>
29.12.11.11 The replication_connection_configuration Table
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045071112016">
</a>
<a class="indexterm" name="idm46045071110512">
</a>
<p>
This table shows the configuration parameters used by the
replica for connecting to the source. Parameters stored in the
table can be changed at runtime with 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.
</p>
<p>
Compared to the
<a class="link" href="performance-schema-replication-connection-status-table.html" title="29.12.11.13 The replication_connection_status Table">
<code class="literal">
replication_connection_status
</code>
</a>
table,
<a class="link" href="performance-schema-replication-connection-configuration-table.html" title="29.12.11.11 The replication_connection_configuration Table">
<code class="literal">
replication_connection_configuration
</code>
</a>
changes less frequently. It contains values that define how
the replica connects to the source and that remain constant
during the connection, whereas
<a class="link" href="performance-schema-replication-connection-status-table.html" title="29.12.11.13 The replication_connection_status Table">
<code class="literal">
replication_connection_status
</code>
</a>
contains values that change during the connection.
</p>
<p>
The
<a class="link" href="performance-schema-replication-connection-configuration-table.html" title="29.12.11.11 The replication_connection_configuration Table">
<code class="literal">
replication_connection_configuration
</code>
</a>
table has the following columns. The column descriptions
indicate the corresponding
<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>
options from which the column
values are taken, and the table given later in this section
shows the correspondence between
<a class="link" href="performance-schema-replication-connection-configuration-table.html" title="29.12.11.11 The replication_connection_configuration Table">
<code class="literal">
replication_connection_configuration
</code>
</a>
columns and
<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>
columns.
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
CHANNEL_NAME
</code>
</p>
<p>
The replication channel which this row is displaying.
There is always a default replication channel, and more
replication channels can be added. See
<a class="xref" href="replication-channels.html" title="19.2.2 Replication Channels">
Section 19.2.2, “Replication Channels”
</a>
for more
information. (
<code class="literal">
CHANGE REPLICATION SOURCE
TO
</code>
option:
<code class="literal">
FOR CHANNEL
</code>
)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
HOST
</code>
</p>
<p>
The host name of the source that the replica is connected
to. (
<code class="literal">
CHANGE REPLICATION SOURCE TO
</code>
option:
<code class="literal">
SOURCE_HOST
</code>
)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
PORT
</code>
</p>
<p>
The port used to connect to the source. (
<code class="literal">
CHANGE
REPLICATION SOURCE TO
</code>
option:
<code class="literal">
SOURCE_PORT
</code>
)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
USER
</code>
</p>
<p>
The user name of the replication user account used to
connect to the source. (
<code class="literal">
CHANGE REPLICATION SOURCE
TO
</code>
option:
<code class="literal">
SOURCE_USER
</code>
)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
NETWORK_INTERFACE
</code>
</p>
<p>
The network interface that the replica is bound to, if
any. (
<code class="literal">
CHANGE REPLICATION SOURCE TO
</code>
option:
<code class="literal">
SOURCE_BIND
</code>
)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
AUTO_POSITION
</code>
</p>
<p>
1 if GTID auto-positioning is in use; otherwise 0.
(
<code class="literal">
CHANGE REPLICATION SOURCE TO
</code>
option:
<code class="literal">
SOURCE_AUTO_POSITION
</code>
)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SSL_ALLOWED
</code>
,
<code class="literal">
SSL_CA_FILE
</code>
,
<code class="literal">
SSL_CA_PATH
</code>
,
<code class="literal">
SSL_CERTIFICATE
</code>
,
<code class="literal">
SSL_CIPHER
</code>
,
<code class="literal">
SSL_KEY
</code>
,
<code class="literal">
SSL_VERIFY_SERVER_CERTIFICATE
</code>
,
<code class="literal">
SSL_CRL_FILE
</code>
,
<code class="literal">
SSL_CRL_PATH
</code>
</p>
<p>
These columns show the SSL parameters used by the replica
to connect to the source, if any.
</p>
<p>
<code class="literal">
SSL_ALLOWED
</code>
has these values:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
<code class="literal">
Yes
</code>
if an SSL connection to the
source is permitted
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
No
</code>
if an SSL connection to the
source is not permitted
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
Ignored
</code>
if an SSL connection is
permitted but the replica does not have SSL support
enabled
</p>
</li>
</ul>
</div>
<p>
(
<code class="literal">
CHANGE REPLICATION SOURCE TO
</code>
options
for the other SSL columns:
<code class="literal">
SOURCE_SSL_CA
</code>
,
<code class="literal">
SOURCE_SSL_CAPATH
</code>
,
<code class="literal">
SOURCE_SSL_CERT
</code>
,
<code class="literal">
SOURCE_SSL_CIPHER
</code>
,
<code class="literal">
SOURCE_SSL_CRL
</code>
,
<code class="literal">
SOURCE_SSL_CRLPATH
</code>
,
<code class="literal">
SOURCE_SSL_KEY
</code>
,
<code class="literal">
SOURCE_SSL_VERIFY_SERVER_CERT
</code>
)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
CONNECTION_RETRY_INTERVAL
</code>
</p>
<p>
The number of seconds between connect retries.
(
<code class="literal">
CHANGE REPLICATION SOURCE TO
</code>
option:
<code class="literal">
SOURCE_CONNECT_RETRY
</code>
)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
CONNECTION_RETRY_COUNT
</code>
</p>
<p>
The number of times the replica can attempt to reconnect
to the source in the event of a lost connection.
(
<code class="literal">
CHANGE REPLICATION SOURCE TO
</code>
option:
<code class="literal">
SOURCE_RETRY_COUNT
</code>
)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
HEARTBEAT_INTERVAL
</code>
</p>
<p>
The replication heartbeat interval on a replica, measured
in seconds. (
<code class="literal">
CHANGE REPLICATION SOURCE
TO
</code>
option:
<code class="literal">
SOURCE_HEARTBEAT_PERIOD
</code>
)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
TLS_VERSION
</code>
</p>
<p>
The list of TLS protocol versions that are permitted by
the replica for the replication connection. For TLS
version information, 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>
.
(
<code class="literal">
CHANGE REPLICATION SOURCE TO
</code>
option:
<code class="literal">
SOURCE_TLS_VERSION
</code>
)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
TLS_CIPHERSUITES
</code>
</p>
<p>
The list of ciphersuites that are permitted by the replica
for the replication connection. For TLS ciphersuite
information, 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>
.
(
<code class="literal">
CHANGE REPLICATION SOURCE TO
</code>
option:
<code class="literal">
SOURCE_TLS_CIPHERSUITES
</code>
)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
PUBLIC_KEY_PATH
</code>
</p>
<p>
The path name to a file containing a replica-side copy of
the public key required by the source for RSA key
pair-based password exchange. The file must be in PEM
format. This column applies to replicas that authenticate
with the
<code class="literal">
sha256_password
</code>
(deprecated)
or
<code class="literal">
caching_sha2_password
</code>
authentication
plugin. (
<code class="literal">
CHANGE REPLICATION SOURCE TO
</code>
option:
<code class="literal">
SOURCE_PUBLIC_KEY_PATH
</code>
)
</p>
<p>
If
<code class="literal">
PUBLIC_KEY_PATH
</code>
is given and
specifies a valid public key file, it takes precedence
over
<code class="literal">
GET_PUBLIC_KEY
</code>
.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
GET_PUBLIC_KEY
</code>
</p>
<p>
Whether to request from the source the public key required
for RSA key pair-based password exchange. This column
applies to replicas that authenticate with the
<code class="literal">
caching_sha2_password
</code>
authentication
plugin. For that plugin, the source does not send the
public key unless requested. (
<code class="literal">
CHANGE REPLICATION
SOURCE TO
</code>
option:
<code class="literal">
GET_SOURCE_PUBLIC_KEY
</code>
)
</p>
<p>
If
<code class="literal">
PUBLIC_KEY_PATH
</code>
is given and
specifies a valid public key file, it takes precedence
over
<code class="literal">
GET_PUBLIC_KEY
</code>
.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
NETWORK_NAMESPACE
</code>
</p>
<p>
The network namespace name; empty if the connection uses
the default (global) namespace. For information about
network namespaces, see
<a class="xref" href="network-namespace-support.html" title="7.1.14 Network Namespace Support">
Section 7.1.14, “Network Namespace Support”
</a>
.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
COMPRESSION_ALGORITHM
</code>
</p>
<p>
The permitted compression algorithms for connections to
the source. (
<code class="literal">
CHANGE REPLICATION SOURCE
TO
</code>
option:
<code class="literal">
SOURCE_COMPRESSION_ALGORITHMS
</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>
<code class="literal">
ZSTD_COMPRESSION_LEVEL
</code>
</p>
<p>
The compression level to use for connections to the source
that use the
<code class="literal">
zstd
</code>
compression
algorithm. (
<code class="literal">
CHANGE REPLICATION SOURCE
TO
</code>
option:
<code class="literal">
SOURCE_ZSTD_COMPRESSION_LEVEL
</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>
<code class="literal">
SOURCE_CONNECTION_AUTO_FAILOVER
</code>
</p>
<p>
Whether the asynchronous connection failover mechanism is
activated for this replication channel. (
<code class="literal">
CHANGE
REPLICATION SOURCE TO
</code>
option:
<code class="literal">
SOURCE_CONNECTION_AUTO_FAILOVER
</code>
)
</p>
<p>
For more information, see
<a class="xref" href="replication-asynchronous-connection-failover.html" title="19.4.9 Switching Sources and Replicas with Asynchronous Connection Failover">
Section 19.4.9, “Switching Sources and Replicas with Asynchronous Connection Failover”
</a>
.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
GTID_ONLY
</code>
</p>
<p>
Indicates if this channel only uses GTIDs for the
transaction queueing and application process and for
recovery, and does not persist binary log and relay log
file names and file positions in the replication metadata
repositories. (
<code class="literal">
CHANGE REPLICATION SOURCE
TO
</code>
option:
<code class="literal">
GTID_ONLY
</code>
)
</p>
<p>
For more information, see
<a class="xref" href="group-replication-gtids.html" title="20.4.1 GTIDs and Group Replication">
Section 20.4.1, “GTIDs and Group Replication”
</a>
.
</p>
</li>
</ul>
</div>
<p>
The
<a class="link" href="performance-schema-replication-connection-configuration-table.html" title="29.12.11.11 The replication_connection_configuration Table">
<code class="literal">
replication_connection_configuration
</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">
CHANNEL_NAME
</code>
)
</p>
</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 not permitted
for the
<a class="link" href="performance-schema-replication-connection-configuration-table.html" title="29.12.11.11 The replication_connection_configuration Table">
<code class="literal">
replication_connection_configuration
</code>
</a>
table.
</p>
<p>
The following table shows the correspondence between
<a class="link" href="performance-schema-replication-connection-configuration-table.html" title="29.12.11.11 The replication_connection_configuration Table">
<code class="literal">
replication_connection_configuration
</code>
</a>
columns and
<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>
columns.
</p>
<div class="informaltable">
<table summary="Correspondence between replication_connection_configuration columns and SHOW REPLICA STATUS columns">
<colgroup>
<col style="width: 60%"/>
<col style="width: 40%"/>
</colgroup>
<thead>
<tr>
<th>
<code class="literal">
replication_connection_configuration
</code>
Column
</th>
<th>
<code class="literal">
SHOW REPLICA STATUS
</code>
Column
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<code class="literal">
CHANNEL_NAME
</code>
</td>
<td>
<code class="literal">
Channel_name
</code>
</td>
</tr>
<tr>
<td>
<code class="literal">
HOST
</code>
</td>
<td>
<code class="literal">
Source_Host
</code>
</td>
</tr>
<tr>
<td>
<code class="literal">
PORT
</code>
</td>
<td>
<code class="literal">
Source_Port
</code>
</td>
</tr>
<tr>
<td>
<code class="literal">
USER
</code>
</td>
<td>
<code class="literal">
Source_User
</code>
</td>
</tr>
<tr>
<td>
<code class="literal">
NETWORK_INTERFACE
</code>
</td>
<td>
<code class="literal">
Source_Bind
</code>
</td>
</tr>
<tr>
<td>
<code class="literal">
AUTO_POSITION
</code>
</td>
<td>
<code class="literal">
Auto_Position
</code>
</td>
</tr>
<tr>
<td>
<code class="literal">
SSL_ALLOWED
</code>
</td>
<td>
<code class="literal">
Source_SSL_Allowed
</code>
</td>
</tr>
<tr>
<td>
<code class="literal">
SSL_CA_FILE
</code>
</td>
<td>
<code class="literal">
Source_SSL_CA_File
</code>
</td>
</tr>
<tr>
<td>
<code class="literal">
SSL_CA_PATH
</code>
</td>
<td>
<code class="literal">
Source_SSL_CA_Path
</code>
</td>
</tr>
<tr>
<td>
<code class="literal">
SSL_CERTIFICATE
</code>
</td>
<td>
<code class="literal">
Source_SSL_Cert
</code>
</td>
</tr>
<tr>
<td>
<code class="literal">
SSL_CIPHER
</code>
</td>
<td>
<code class="literal">
Source_SSL_Cipher
</code>
</td>
</tr>
<tr>
<td>
<code class="literal">
SSL_KEY
</code>
</td>
<td>
<code class="literal">
Source_SSL_Key
</code>
</td>
</tr>
<tr>
<td>
<code class="literal">
SSL_VERIFY_SERVER_CERTIFICATE
</code>
</td>
<td>
<code class="literal">
Source_SSL_Verify_Server_Cert
</code>
</td>
</tr>
<tr>
<td>
<code class="literal">
SSL_CRL_FILE
</code>
</td>
<td>
<code class="literal">
Source_SSL_Crl
</code>
</td>
</tr>
<tr>
<td>
<code class="literal">
SSL_CRL_PATH
</code>
</td>
<td>
<code class="literal">
Source_SSL_Crlpath
</code>
</td>
</tr>
<tr>
<td>
<code class="literal">
CONNECTION_RETRY_INTERVAL
</code>
</td>
<td>
<code class="literal">
Source_Connect_Retry
</code>
</td>
</tr>
<tr>
<td>
<code class="literal">
CONNECTION_RETRY_COUNT
</code>
</td>
<td>
<code class="literal">
Source_Retry_Count
</code>
</td>
</tr>
<tr>
<td>
<code class="literal">
HEARTBEAT_INTERVAL
</code>
</td>
<td>
None
</td>
</tr>
<tr>
<td>
<code class="literal">
TLS_VERSION
</code>
</td>
<td>
<code class="literal">
Source_TLS_Version
</code>
</td>
</tr>
<tr>
<td>
<code class="literal">
PUBLIC_KEY_PATH
</code>
</td>
<td>
<code class="literal">
Source_public_key_path
</code>
</td>
</tr>
<tr>
<td>
<code class="literal">
GET_PUBLIC_KEY
</code>
</td>
<td>
<code class="literal">
Get_source_public_key
</code>
</td>
</tr>
<tr>
<td>
<code class="literal">
NETWORK_NAMESPACE
</code>
</td>
<td>
<code class="literal">
Network_Namespace
</code>
</td>
</tr>
<tr>
<td>
<code class="literal">
COMPRESSION_ALGORITHM
</code>
</td>
<td>
[None]
</td>
</tr>
<tr>
<td>
<code class="literal">
ZSTD_COMPRESSION_LEVEL
</code>
</td>
<td>
[None]
</td>
</tr>
<tr>
<td>
<code class="literal">
GTID_ONLY
</code>
</td>
<td>
[None]
</td>
</tr>
</tbody>
</table>
</div>
<div class="informaltable">
<table cellpadding="0" cellspacing="0" style="position: fixed; top: 0px; display: none; left: 401px; width: 608px;">
<thead>
<tr>
<th style="width: 363.953px;">
<code class="literal">
replication_connection_configuration
</code>
Column
</th>
<th style="width: 242.641px;">
<code class="literal">
SHOW REPLICA STATUS
</code>
Column
</th>
</tr>
</thead>
</table>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/mysql-cluster-ndbinfo-diskstat.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="mysql-cluster-ndbinfo-diskstat">
</a>
25.6.17.32 The ndbinfo diskstat Table
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045089402848">
</a>
<p>
The
<code class="literal">
diskstat
</code>
table provides information about
writes to Disk Data tablespaces during the past 1 second.
</p>
<p>
The
<code class="literal">
diskstat
</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 of this node
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
block_instance
</code>
</p>
<p>
ID of reporting instance of
<a class="ulink" href="/doc/ndb-internals/en/ndb-internals-kernel-blocks-pgman.html" target="_top">
<code class="literal">
PGMAN
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
pages_made_dirty
</code>
</p>
<p>
Number of pages made dirty during the past second
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
reads_issued
</code>
</p>
<p>
Reads issued during the past second
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
reads_completed
</code>
</p>
<p>
Reads completed during the past second
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
writes_issued
</code>
</p>
<p>
Writes issued during the past second
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
writes_completed
</code>
</p>
<p>
Writes completed during the past second
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
log_writes_issued
</code>
</p>
<p>
Number of times a page write has required a log write during
the past second
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
log_writes_completed
</code>
</p>
<p>
Number of log writes completed during the last second
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
get_page_calls_issued
</code>
</p>
<p>
Number of
<code class="literal">
get_page()
</code>
calls issued during
the past second
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
get_page_reqs_issued
</code>
</p>
<p>
Number of times that a
<code class="literal">
get_page()
</code>
call
has resulted in a wait for I/O or completion of I/O already
begun during the past second
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
get_page_reqs_completed
</code>
</p>
<p>
Number of
<code class="literal">
get_page()
</code>
calls waiting for
I/O or I/O completion that have completed during the past
second
</p>
</li>
</ul>
</div>
<h5>
<a name="idm46045089372048">
</a>
Notes
</h5>
<p>
Each row in this table corresponds to an instance of
<a class="ulink" href="/doc/ndb-internals/en/ndb-internals-kernel-blocks-pgman.html" target="_top">
<code class="literal">
PGMAN
</code>
</a>
; there is one such
instance per LDM thread plus an additional instance for each
data node.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/semijoins-antijoins.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="semijoins-antijoins">
</a>
10.2.2.1 Optimizing IN and EXISTS Subquery Predicates with Semijoin and Antijoin
Transformations
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045228378128">
</a>
<a class="indexterm" name="idm46045228377088">
</a>
<p>
A semijoin is a preparation-time transformation that enables
multiple execution strategies such as table pullout, duplicate
weedout, first match, loose scan, and materialization. The
optimizer uses semijoin strategies to improve subquery
execution, as described in this section.
</p>
<p>
For an inner join between two tables, the join returns a row
from one table as many times as there are matches in the other
table. But for some questions, the only information that
matters is whether there is a match, not the number of
matches. Suppose that there are tables named
<code class="literal">
class
</code>
and
<code class="literal">
roster
</code>
that
list classes in a course curriculum and class rosters
(students enrolled in each class), respectively. To list the
classes that actually have students enrolled, you could use
this join:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa14733357"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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> class<span class="token punctuation">.</span>class_num<span class="token punctuation">,</span> class<span class="token punctuation">.</span>class_name
<span class="token keyword">FROM</span> class
<span class="token keyword">INNER</span> <span class="token keyword">JOIN</span> roster
<span class="token keyword">WHERE</span> class<span class="token punctuation">.</span>class_num <span class="token operator">=</span> roster<span class="token punctuation">.</span>class_num<span class="token punctuation">;</span></code></pre>
</div>
<p>
However, the result lists each class once for each enrolled
student. For the question being asked, this is unnecessary
duplication of information.
</p>
<p>
Assuming that
<code class="literal">
class_num
</code>
is a primary key in
the
<code class="literal">
class
</code>
table, duplicate suppression is
possible by using
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
DISTINCT
</code>
</a>
, but it is inefficient to generate all
matching rows first only to eliminate duplicates later.
</p>
<p>
The same duplicate-free result can be obtained by using a
subquery:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa45993254"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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> class_num<span class="token punctuation">,</span> class_name
<span class="token keyword">FROM</span> class
<span class="token keyword">WHERE</span> class_num <span class="token keyword">IN</span>
<span class="token punctuation">(</span><span class="token keyword">SELECT</span> class_num <span class="token keyword">FROM</span> roster<span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
Here, the optimizer can recognize that the
<a class="link" href="comparison-operators.html#operator_in">
<code class="literal">
IN
</code>
</a>
clause requires the subquery
to return only one instance of each class number from the
<code class="literal">
roster
</code>
table. In this case, the query can
use a
<span class="firstterm">
semijoin
</span>
; that is,
an operation that returns only one instance of each row in
<code class="literal">
class
</code>
that is matched by rows in
<code class="literal">
roster
</code>
.
</p>
<p>
The following statement, which contains an
<a class="link" href="comparison-operators.html#operator_exists">
<code class="literal">
EXISTS
</code>
</a>
subquery predicate, is
equivalent to the previous statement containing an
<code class="literal">
IN
</code>
subquery predicate:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa34333635"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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> class_num<span class="token punctuation">,</span> class_name
<span class="token keyword">FROM</span> class
<span class="token keyword">WHERE</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> roster <span class="token keyword">WHERE</span> class<span class="token punctuation">.</span>class_num <span class="token operator">=</span> roster<span class="token punctuation">.</span>class_num<span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
Any statement with an
<code class="literal">
EXISTS
</code>
subquery
predicate is subject to the same semijoin transforms as a
statement with an equivalent
<code class="literal">
IN
</code>
subquery
predicate.
</p>
<p>
The following subqueries are transformed into antijoins:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
NOT IN (SELECT ... FROM ...)
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
NOT EXISTS (SELECT ... FROM ...)
</code>
.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
IN (SELECT ... FROM ...) IS NOT TRUE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
EXISTS (SELECT ... FROM ...) IS NOT
TRUE
</code>
.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
IN (SELECT ... FROM ...) IS FALSE
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
EXISTS (SELECT ... FROM ...) IS FALSE
</code>
.
</p>
</li>
</ul>
</div>
<p>
In short, any negation of a subquery of the form
<code class="literal">
IN
(SELECT ... FROM ...)
</code>
or
<code class="literal">
EXISTS (SELECT ...
FROM ...)
</code>
is transformed into an antijoin.
</p>
<p>
An antijoin is an operation that returns only rows for which
there is no match. Consider the query shown here:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa42969386"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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> class_num<span class="token punctuation">,</span> class_name
<span class="token keyword">FROM</span> class
<span class="token keyword">WHERE</span> class_num <span class="token operator">NOT</span> <span class="token keyword">IN</span>
<span class="token punctuation">(</span><span class="token keyword">SELECT</span> class_num <span class="token keyword">FROM</span> roster<span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
This query is rewritten internally as the antijoin
<code class="literal">
SELECT class_num, class_name FROM class ANTIJOIN
roster ON class_num
</code>
, which returns one instance of
each row in
<code class="literal">
class
</code>
that is
<span class="emphasis">
<em>
not
</em>
</span>
matched by any rows in
<code class="literal">
roster
</code>
. This means that, for each row in
<code class="literal">
class
</code>
, as soon as a match is found in
<code class="literal">
roster
</code>
, the row in
<code class="literal">
class
</code>
can be discarded.
</p>
<p>
Antijoin transformations cannot in most cases be applied if
the expressions being compared are nullable. An exception to
this rule is that
<code class="literal">
(... NOT IN (SELECT ...)) IS NOT
FALSE
</code>
and its equivalent
<code class="literal">
(... IN (SELECT
...)) IS NOT TRUE
</code>
can be transformed into antijoins.
</p>
<p>
Outer join and inner join syntax is permitted in the outer
query specification, and table references may be base tables,
derived tables, view references, or common table expressions.
</p>
<p>
In MySQL, a subquery must satisfy these criteria to be handled
as a semijoin (or an antijoin, if
<code class="literal">
NOT
</code>
modifies the subquery):
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
It must be part of an
<code class="literal">
IN
</code>
,
<code class="literal">
=
ANY
</code>
, or
<code class="literal">
EXISTS
</code>
predicate that
appears at the top level of the
<code class="literal">
WHERE
</code>
or
<code class="literal">
ON
</code>
clause, possibly as a term in an
<code class="literal">
AND
</code>
expression. For example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa16960074"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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> ot1<span class="token punctuation">,</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
<span class="token keyword">WHERE</span> <span class="token punctuation">(</span>oe1<span class="token punctuation">,</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">IN</span>
<span class="token punctuation">(</span><span class="token keyword">SELECT</span> ie1<span class="token punctuation">,</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span> <span class="token keyword">FROM</span> it1<span class="token punctuation">,</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span> <span class="token keyword">WHERE</span> <span 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>
Here,
<code class="literal">
ot_
<em class="replaceable">
<code>
i
</code>
</em>
</code>
and
<code class="literal">
it_
<em class="replaceable">
<code>
i
</code>
</em>
</code>
represent tables in the outer and inner parts of the
query, and
<code class="literal">
oe_
<em class="replaceable">
<code>
i
</code>
</em>
</code>
and
<code class="literal">
ie_
<em class="replaceable">
<code>
i
</code>
</em>
</code>
represent expressions that refer to columns in the outer
and inner tables.
</p>
<p>
The subquery can also be the argument to an expression
modified by
<code class="literal">
NOT
</code>
,
<code class="literal">
IS [NOT]
TRUE
</code>
, or
<code class="literal">
IS [NOT] FALSE
</code>
.
</p>
</li>
<li class="listitem">
<p>
It must be a single
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
without
<a class="link" href="union.html" title="15.2.18 UNION Clause">
<code class="literal">
UNION
</code>
</a>
constructs.
</p>
</li>
<li class="listitem">
<p>
It must not contain a
<code class="literal">
HAVING
</code>
clause.
</p>
</li>
<li class="listitem">
<p>
It must not contain any aggregate functions (whether it is
explicitly or implicitly grouped).
</p>
</li>
<li class="listitem">
<p>
It must not have a
<code class="literal">
LIMIT
</code>
clause.
</p>
</li>
<li class="listitem">
<p>
The statement must not use the
<code class="literal">
STRAIGHT_JOIN
</code>
join type in the outer
query.
</p>
<a class="indexterm" name="idm46045228310624">
</a>
</li>
<li class="listitem">
<p>
The
<code class="literal">
STRAIGHT_JOIN
</code>
modifier must not be
present.
</p>
<a class="indexterm" name="idm46045228307568">
</a>
</li>
<li class="listitem">
<p>
The number of outer and inner tables together must be less
than the maximum number of tables permitted in a join.
</p>
</li>
<li class="listitem">
<p>
The subquery may be correlated or uncorrelated.
Decorrelation looks at trivially correlated predicates in
the
<code class="literal">
WHERE
</code>
clause of a subquery used as
the argument to
<code class="literal">
EXISTS
</code>
, and makes it
possible to optimize it as if it was used within
<code class="literal">
IN (SELECT b FROM ...)
</code>
. The term
<span class="emphasis">
<em>
trivially correlated
</em>
</span>
means that the
predicate is an equality predicate, that it is the sole
predicate in the
<code class="literal">
WHERE
</code>
clause (or is
combined with
<code class="literal">
AND
</code>
), and that one
operand is from a table referenced in the subquery and the
other operand is from the outer query block.
</p>
</li>
<li class="listitem">
<p>
The
<code class="literal">
DISTINCT
</code>
keyword is permitted but
ignored. Semijoin strategies automatically handle
duplicate removal.
</p>
</li>
<li class="listitem">
<p>
A
<code class="literal">
GROUP BY
</code>
clause is permitted but
ignored, unless the subquery also contains one or more
aggregate functions.
</p>
</li>
<li class="listitem">
<p>
An
<code class="literal">
ORDER BY
</code>
clause is permitted but
ignored, since ordering is irrelevant to the evaluation of
semijoin strategies.
</p>
</li>
</ul>
</div>
<p>
If a subquery meets the preceding criteria, MySQL converts it
to a semijoin (or to an antijoin if applicable) and makes a
cost-based choice from these strategies:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Convert the subquery to a join, or use table pullout and
run the query as an inner join between subquery tables and
outer tables. Table pullout pulls a table out from the
subquery to the outer query.
</p>
<a class="indexterm" name="idm46045228292784">
</a>
</li>
<li class="listitem">
<p>
<span class="emphasis">
<em>
Duplicate Weedout
</em>
</span>
: Run the semijoin
as if it was a join and remove duplicate records using a
temporary table.
</p>
<a class="indexterm" name="idm46045228289968">
</a>
</li>
<li class="listitem">
<p>
<span class="emphasis">
<em>
FirstMatch
</em>
</span>
: When scanning the inner
tables for row combinations and there are multiple
instances of a given value group, choose one rather than
returning them all. This "shortcuts" scanning and
eliminates production of unnecessary rows.
</p>
<a class="indexterm" name="idm46045228286992">
</a>
</li>
<li class="listitem">
<p>
<span class="emphasis">
<em>
LooseScan
</em>
</span>
: Scan a subquery table
using an index that enables a single value to be chosen
from each subquery's value group.
</p>
<a class="indexterm" name="idm46045228284144">
</a>
</li>
<li class="listitem">
<p>
Materialize the subquery into an indexed temporary table
that is used to perform a join, where the index is used to
remove duplicates. The index might also be used later for
lookups when joining the temporary table with the outer
tables; if not, the table is scanned. For more information
about materialization, see
<a class="xref" href="subquery-materialization.html" title="10.2.2.2 Optimizing Subqueries with Materialization">
Section 10.2.2.2, “Optimizing Subqueries with Materialization”
</a>
.
</p>
<a class="indexterm" name="idm46045228280528">
</a>
</li>
</ul>
</div>
<p>
Each of these strategies can be enabled or disabled using the
following
<a class="link" href="server-system-variables.html#sysvar_optimizer_switch">
<code class="literal">
optimizer_switch
</code>
</a>
system variable flags:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
The
<a class="link" href="switchable-optimizations.html#optflag_semijoin">
<code class="literal">
semijoin
</code>
</a>
flag
controls whether semijoins and antijoins are used.
</p>
</li>
<li class="listitem">
<p>
If
<a class="link" href="switchable-optimizations.html#optflag_semijoin">
<code class="literal">
semijoin
</code>
</a>
is enabled,
the
<a class="link" href="switchable-optimizations.html#optflag_firstmatch">
<code class="literal">
firstmatch
</code>
</a>
,
<a class="link" href="switchable-optimizations.html#optflag_loosescan">
<code class="literal">
loosescan
</code>
</a>
,
<a class="link" href="switchable-optimizations.html#optflag_duplicateweedout">
<code class="literal">
duplicateweedout
</code>
</a>
, and
<a class="link" href="switchable-optimizations.html#optflag_materialization">
<code class="literal">
materialization
</code>
</a>
flags
enable finer control over the permitted semijoin
strategies.
</p>
</li>
<li class="listitem">
<p>
If the
<a class="link" href="switchable-optimizations.html#optflag_duplicateweedout">
<code class="literal">
duplicateweedout
</code>
</a>
semijoin strategy is disabled, it is not used unless all
other applicable strategies are also disabled.
</p>
</li>
<li class="listitem">
<p>
If
<a class="link" href="switchable-optimizations.html#optflag_duplicateweedout">
<code class="literal">
duplicateweedout
</code>
</a>
is
disabled, on occasion the optimizer may generate a query
plan that is far from optimal. This occurs due to
heuristic pruning during greedy search, which can be
avoided by setting
<a class="link" href="server-system-variables.html#sysvar_optimizer_prune_level">
<code class="literal">
optimizer_prune_level=0
</code>
</a>
.
</p>
</li>
</ul>
</div>
<p>
These flags are enabled by default. See
<a class="xref" href="switchable-optimizations.html" title="10.9.2 Switchable Optimizations">
Section 10.9.2, “Switchable Optimizations”
</a>
.
</p>
<p>
The optimizer minimizes differences in handling of views and
derived tables. This affects queries that use the
<code class="literal">
STRAIGHT_JOIN
</code>
modifier and a view with an
<code class="literal">
IN
</code>
subquery that can be converted to a
semijoin. The following query illustrates this because the
change in processing causes a change in transformation, and
thus a different execution strategy:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa4832796"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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> v <span class="token keyword">AS</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> a <span class="token keyword">IN</span> <span class="token punctuation">(</span><span class="token keyword">SELECT</span> b
<span class="token keyword">FROM</span> t2<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">SELECT</span> <span class="token keyword">STRAIGHT_JOIN</span> <span class="token operator">*</span>
<span class="token keyword">FROM</span> t3 <span class="token keyword">JOIN</span> v <span class="token keyword">ON</span> t3<span class="token punctuation">.</span>x <span class="token operator">=</span> v<span class="token punctuation">.</span>a<span class="token punctuation">;</span></code></pre>
</div>
<p>
The optimizer first looks at the view and converts the
<code class="literal">
IN
</code>
subquery to a semijoin, then checks
whether it is possible to merge the view into the outer query.
Because the
<code class="literal">
STRAIGHT_JOIN
</code>
modifier in the
outer query prevents semijoin, the optimizer refuses the
merge, causing derived table evaluation using a materialized
table.
</p>
<p>
<a class="link" href="explain.html" title="15.8.2 EXPLAIN Statement">
<code class="literal">
EXPLAIN
</code>
</a>
output indicates the
use of semijoin strategies as follows:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
For extended
<a class="link" href="explain.html" title="15.8.2 EXPLAIN Statement">
<code class="literal">
EXPLAIN
</code>
</a>
output, the text displayed by a following
<a class="link" href="show-warnings.html" title="15.7.7.42 SHOW WARNINGS Statement">
<code class="literal">
SHOW WARNINGS
</code>
</a>
shows the
rewritten query, which displays the semijoin structure.
(See
<a class="xref" href="explain-extended.html" title="10.8.3 Extended EXPLAIN Output Format">
Section 10.8.3, “Extended EXPLAIN Output Format”
</a>
.) From this you
can get an idea about which tables were pulled out of the
semijoin. If a subquery was converted to a semijoin, you
should see that the subquery predicate is gone and its
tables and
<code class="literal">
WHERE
</code>
clause were merged
into the outer query join list and
<code class="literal">
WHERE
</code>
clause.
</p>
</li>
<li class="listitem">
<p>
Temporary table use for Duplicate Weedout is indicated by
<code class="literal">
Start temporary
</code>
and
<code class="literal">
End
temporary
</code>
in the
<code class="literal">
Extra
</code>
column. Tables that were not pulled out and are in the
range of
<a class="link" href="explain.html" title="15.8.2 EXPLAIN Statement">
<code class="literal">
EXPLAIN
</code>
</a>
output
rows covered by
<code class="literal">
Start temporary
</code>
and
<code class="literal">
End temporary
</code>
have their
<code class="literal">
rowid
</code>
in the temporary table.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
FirstMatch(
<em class="replaceable">
<code>
tbl_name
</code>
</em>
)
</code>
in the
<code class="literal">
Extra
</code>
column indicates join
shortcutting.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
LooseScan(
<em class="replaceable">
<code>
m
</code>
</em>
..
<em class="replaceable">
<code>
n
</code>
</em>
)
</code>
in the
<code class="literal">
Extra
</code>
column indicates use of
the LooseScan strategy.
<em class="replaceable">
<code>
m
</code>
</em>
and
<em class="replaceable">
<code>
n
</code>
</em>
are key part numbers.
</p>
</li>
<li class="listitem">
<p>
Temporary table use for materialization is indicated by
rows with a
<code class="literal">
select_type
</code>
value of
<code class="literal">
MATERIALIZED
</code>
and rows with a
<code class="literal">
table
</code>
value of
<code class="literal">
<subquery
<em class="replaceable">
<code>
N
</code>
</em>
>
</code>
.
</p>
</li>
</ul>
</div>
<p>
A semijoin transformation can also be applied to a
single-table
<a class="link" href="update.html" title="15.2.17 UPDATE Statement">
<code class="literal">
UPDATE
</code>
</a>
or
<a class="link" href="delete.html" title="15.2.2 DELETE Statement">
<code class="literal">
DELETE
</code>
</a>
statement that uses a
<code class="literal">
[NOT] IN
</code>
or
<code class="literal">
[NOT] EXISTS
</code>
subquery predicate, provided that the statement does not use
<code class="literal">
ORDER BY
</code>
or
<code class="literal">
LIMIT
</code>
, and
that semijoin transformations are allowed by an optimizer hint
or by the
<a class="link" href="server-system-variables.html#sysvar_optimizer_switch">
<code class="literal">
optimizer_switch
</code>
</a>
setting.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/declare.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="declare">
</a>
15.6.3 DECLARE Statement
</h3>
</div>
</div>
</div>
<a class="indexterm" name="idm46045176441760">
</a>
<p>
The
<a class="link" href="declare.html" title="15.6.3 DECLARE Statement">
<code class="literal">
DECLARE
</code>
</a>
statement is used to
define various items local to a program:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Local variables. See
<a class="xref" href="stored-program-variables.html" title="15.6.4 Variables in Stored Programs">
Section 15.6.4, “Variables in Stored Programs”
</a>
.
</p>
</li>
<li class="listitem">
<p>
Conditions and handlers. See
<a class="xref" href="condition-handling.html" title="15.6.7 Condition Handling">
Section 15.6.7, “Condition Handling”
</a>
.
</p>
</li>
<li class="listitem">
<p>
Cursors. See
<a class="xref" href="cursors.html" title="15.6.6 Cursors">
Section 15.6.6, “Cursors”
</a>
.
</p>
</li>
</ul>
</div>
<p>
<a class="link" href="declare.html" title="15.6.3 DECLARE Statement">
<code class="literal">
DECLARE
</code>
</a>
is permitted only inside a
<a class="link" href="begin-end.html" title="15.6.1 BEGIN ... END Compound Statement">
<code class="literal">
BEGIN ... END
</code>
</a>
compound statement and must be at its start, before any other
statements.
</p>
<p>
Declarations must follow a certain order. Cursor declarations must
appear before handler declarations. Variable and condition
declarations must appear before cursor or handler declarations.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/performance-schema-statement-digests.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h2 class="title">
<a name="performance-schema-statement-digests">
</a>
29.10 Performance Schema Statement Digests and Sampling
</h2>
</div>
</div>
</div>
<p>
The MySQL server is capable of maintaining statement digest
information. The digesting process converts each SQL statement to
normalized form (the statement digest) and computes a SHA-256 hash
value (the digest hash value) from the normalized result.
Normalization permits statements that are similar to be grouped
and summarized to expose information about the types of statements
the server is executing and how often they occur. For each digest,
a representative statement that produces the digest is stored as a
sample. This section describes how statement digesting and
sampling occur and how they can be useful.
</p>
<p>
Digesting occurs in the parser regardless of whether the
Performance Schema is available, so that other features such as
MySQL Enterprise Firewall and query rewrite plugins have access to statement digests.
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="xref" href="performance-schema-statement-digests.html#statement-digests-general" title="Statement Digest General Concepts">
Statement Digest General Concepts
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="performance-schema-statement-digests.html#statement-digests-performance-schema" title="Statement Digests in the Performance Schema">
Statement Digests in the Performance Schema
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="performance-schema-statement-digests.html#statement-digests-memory-use" title="Statement Digest Memory Use">
Statement Digest Memory Use
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="performance-schema-statement-digests.html#statement-digests-sampling" title="Statement Sampling">
Statement Sampling
</a>
</p>
</li>
</ul>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h3 class="title">
<a name="statement-digests-general">
</a>
Statement Digest General Concepts
</h3>
</div>
</div>
</div>
<p>
When the parser receives an SQL statement, it computes a
statement digest if that digest is needed, which is true if any
of the following conditions are true:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Performance Schema digest instrumentation is enabled
</p>
</li>
<li class="listitem">
<p>
MySQL Enterprise Firewall is enabled
</p>
</li>
<li class="listitem">
<p>
A query rewrite plugin is enabled
</p>
</li>
</ul>
</div>
<p>
The parser is also used by the
<a class="link" href="encryption-functions.html#function_statement-digest-text">
<code class="literal">
STATEMENT_DIGEST_TEXT()
</code>
</a>
and
<a class="link" href="encryption-functions.html#function_statement-digest">
<code class="literal">
STATEMENT_DIGEST()
</code>
</a>
functions,
which applications can call to compute a normalized statement
digest and a digest hash value, respectively, from an SQL
statement.
</p>
<p>
The
<a class="link" href="server-system-variables.html#sysvar_max_digest_length">
<code class="literal">
max_digest_length
</code>
</a>
system
variable value determines the maximum number of bytes available
per session for computation of normalized statement digests.
Once that amount of space is used during digest computation,
truncation occurs: no further tokens from a parsed statement are
collected or figure into its digest value. Statements that
differ only after that many bytes of parsed tokens produce the
same normalized statement digest and are considered identical if
compared or if aggregated for digest statistics.
</p>
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Warning
</div>
<p>
Setting the
<a class="link" href="server-system-variables.html#sysvar_max_digest_length">
<code class="literal">
max_digest_length
</code>
</a>
system variable to zero disables digest production, which also
disables server functionality that requires digests.
</p>
</div>
<p>
After the normalized statement has been computed, a SHA-256 hash
value is computed from it. In addition:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
If MySQL Enterprise Firewall is enabled, it is called and the digest as
computed is available to it.
</p>
</li>
<li class="listitem">
<p>
If any query rewrite plugin is enabled, it is called and the
statement digest and digest value are available to it.
</p>
</li>
<li class="listitem">
<p>
If the Performance Schema has digest instrumentation
enabled, it makes a copy of the normalized statement digest,
allocating a maximum of
<a class="link" href="performance-schema-system-variables.html#sysvar_performance_schema_max_digest_length">
<code class="literal">
performance_schema_max_digest_length
</code>
</a>
bytes for it. Consequently, if
<a class="link" href="performance-schema-system-variables.html#sysvar_performance_schema_max_digest_length">
<code class="literal">
performance_schema_max_digest_length
</code>
</a>
is less than
<a class="link" href="server-system-variables.html#sysvar_max_digest_length">
<code class="literal">
max_digest_length
</code>
</a>
, the copy
is truncated relative to the original. The copy of the
normalized statement digest is stored in the appropriate
Performance Schema tables, along with the SHA-256 hash value
computed from the original normalized statement. (If the
Performance Schema truncates its copy of the normalized
statement digest relative to the original, it does not
recompute the SHA-256 hash value.)
</p>
</li>
</ul>
</div>
<p>
Statement normalization transforms the statement text to a more
standardized digest string representation that preserves the
general statement structure while removing information not
essential to the structure:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Object identifiers such as database and table names are
preserved.
</p>
</li>
<li class="listitem">
<p>
Literal values are converted to parameter markers. A
normalized statement does not retain information such as
names, passwords, dates, and so forth.
</p>
</li>
<li class="listitem">
<p>
Comments are removed and whitespace is adjusted.
</p>
</li>
</ul>
</div>
<p>
Consider these statements:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa34891305"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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> orders <span class="token keyword">WHERE</span> customer_id<span class="token operator">=</span><span class="token number">10</span> <span class="token operator">AND</span> quantity<span class="token operator">></span><span class="token number">20</span>
<span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> orders <span class="token keyword">WHERE</span> customer_id <span class="token operator">=</span> <span class="token number">20</span> <span class="token operator">AND</span> quantity <span class="token operator">></span> <span class="token number">100</span></code></pre>
</div>
<p>
To normalize these statements, the parser replaces data values
by
<code class="literal">
?
</code>
and adjusts whitespace. Both statements
yield the same normalized form and thus are considered
<span class="quote">
“
<span class="quote">
the same
</span>
”
</span>
:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa79125345"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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> orders <span class="token keyword">WHERE</span> customer_id <span class="token operator">=</span> ? <span class="token operator">AND</span> quantity <span class="token operator">></span> ?</code></pre>
</div>
<p>
The normalized statement contains less information but is still
representative of the original statement. Other similar
statements that have different data values have the same
normalized form.
</p>
<p>
Now consider these statements:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa79193203"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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> customers <span class="token keyword">WHERE</span> customer_id <span class="token operator">=</span> <span class="token number">1000</span>
<span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> orders <span class="token keyword">WHERE</span> customer_id <span class="token operator">=</span> <span class="token number">1000</span></code></pre>
</div>
<p>
In this case, the normalized statements differ because the
object identifiers differ:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa43694561"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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> customers <span class="token keyword">WHERE</span> customer_id <span class="token operator">=</span> ?
<span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> orders <span class="token keyword">WHERE</span> customer_id <span class="token operator">=</span> ?</code></pre>
</div>
<p>
If normalization produces a statement that exceeds the space
available in the digest buffer (as determined by
<a class="link" href="server-system-variables.html#sysvar_max_digest_length">
<code class="literal">
max_digest_length
</code>
</a>
), truncation
occurs and the text ends with
<span class="quote">
“
<span class="quote">
...
</span>
”
</span>
. Long
normalized statements that differ only in the part that occurs
following the
<span class="quote">
“
<span class="quote">
...
</span>
”
</span>
are considered the same.
Consider these statements:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa88018111"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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> mytable <span class="token keyword">WHERE</span> cola <span class="token operator">=</span> <span class="token number">10</span> <span class="token operator">AND</span> colb <span class="token operator">=</span> <span class="token number">20</span>
<span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> mytable <span class="token keyword">WHERE</span> cola <span class="token operator">=</span> <span class="token number">10</span> <span class="token operator">AND</span> colc <span class="token operator">=</span> <span class="token number">20</span></code></pre>
</div>
<p>
If the cutoff happens to be right after the
<code class="literal">
AND
</code>
, both statements have this normalized
form:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa36378966"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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> mytable <span class="token keyword">WHERE</span> cola <span class="token operator">=</span> ? <span class="token operator">AND</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span></code></pre>
</div>
<p>
In this case, the difference in the second column name is lost
and both statements are considered the same.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h3 class="title">
<a name="statement-digests-performance-schema">
</a>
Statement Digests in the Performance Schema
</h3>
</div>
</div>
</div>
<p>
In the Performance Schema, statement digesting involves these
elements:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
A
<code class="literal">
statements_digest
</code>
consumer 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 controls
whether the Performance Schema maintains digest information.
See
<a class="xref" href="performance-schema-consumer-filtering.html#performance-schema-consumer-filtering-statement-digest" title="Statement Digest Consumer">
Statement Digest Consumer
</a>
.
</p>
</li>
<li class="listitem">
<p>
The statement event tables
(
<a class="link" href="performance-schema-events-statements-current-table.html" title="29.12.6.1 The events_statements_current Table">
<code class="literal">
events_statements_current
</code>
</a>
,
<a class="link" href="performance-schema-events-statements-history-table.html" title="29.12.6.2 The events_statements_history Table">
<code class="literal">
events_statements_history
</code>
</a>
, and
<a class="link" href="performance-schema-events-statements-history-long-table.html" title="29.12.6.3 The events_statements_history_long Table">
<code class="literal">
events_statements_history_long
</code>
</a>
)
have columns for storing normalized statement digests and
the corresponding digest SHA-256 hash values:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
<code class="literal">
DIGEST_TEXT
</code>
is the text of the
normalized statement digest. This is a copy of the
original normalized statement that was computed to a
maximum of
<a class="link" href="server-system-variables.html#sysvar_max_digest_length">
<code class="literal">
max_digest_length
</code>
</a>
bytes, further truncated as necessary to
<a class="link" href="performance-schema-system-variables.html#sysvar_performance_schema_max_digest_length">
<code class="literal">
performance_schema_max_digest_length
</code>
</a>
bytes.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
DIGEST
</code>
is the digest SHA-256 hash
value computed from the original normalized statement.
</p>
</li>
</ul>
</div>
<p>
See
<a class="xref" href="performance-schema-statement-tables.html" title="29.12.6 Performance Schema Statement Event Tables">
Section 29.12.6, “Performance Schema Statement Event Tables”
</a>
.
</p>
</li>
<li class="listitem">
<p>
The
<a class="link" href="performance-schema-statement-summary-tables.html" title="29.12.20.3 Statement Summary Tables">
<code class="literal">
events_statements_summary_by_digest
</code>
</a>
summary table provides aggregated statement digest
information. This table aggregates information for
statements per
<code class="literal">
SCHEMA_NAME
</code>
and
<code class="literal">
DIGEST
</code>
combination. The Performance
Schema uses SHA-256 hash values for aggregation because they
are fast to compute and have a favorable statistical
distribution that minimizes collisions. See
<a class="xref" href="performance-schema-statement-summary-tables.html" title="29.12.20.3 Statement Summary Tables">
Section 29.12.20.3, “Statement Summary Tables”
</a>
.
</p>
</li>
</ul>
</div>
<p>
Some Performance Tables have a column that stores original SQL
statements from which digests are computed:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
The
<code class="literal">
SQL_TEXT
</code>
column of the
<a class="link" href="performance-schema-events-statements-current-table.html" title="29.12.6.1 The events_statements_current Table">
<code class="literal">
events_statements_current
</code>
</a>
,
<a class="link" href="performance-schema-events-statements-history-table.html" title="29.12.6.2 The events_statements_history Table">
<code class="literal">
events_statements_history
</code>
</a>
, and
<a class="link" href="performance-schema-events-statements-history-long-table.html" title="29.12.6.3 The events_statements_history_long Table">
<code class="literal">
events_statements_history_long
</code>
</a>
statement event tables.
</p>
</li>
<li class="listitem">
<p>
The
<code class="literal">
QUERY_SAMPLE_TEXT
</code>
column of the
<a class="link" href="performance-schema-statement-summary-tables.html" title="29.12.20.3 Statement Summary Tables">
<code class="literal">
events_statements_summary_by_digest
</code>
</a>
summary table.
</p>
</li>
</ul>
</div>
<p>
The maximum space available for statement display is 1024 bytes
by default. To change this value, set the
<a class="link" href="performance-schema-system-variables.html#sysvar_performance_schema_max_sql_text_length">
<code class="literal">
performance_schema_max_sql_text_length
</code>
</a>
system variable at server startup. Changes affect the storage
required for all the columns just named.
</p>
<p>
The
<a class="link" href="performance-schema-system-variables.html#sysvar_performance_schema_max_digest_length">
<code class="literal">
performance_schema_max_digest_length
</code>
</a>
system variable determines the maximum number of bytes available
per statement for digest value storage in the Performance
Schema. However, the display length of statement digests may be
longer than the available buffer size due to internal encoding
of statement elements such as keywords and literal values.
Consequently, values selected from the
<code class="literal">
DIGEST_TEXT
</code>
column of statement event tables
may appear to exceed the
<a class="link" href="performance-schema-system-variables.html#sysvar_performance_schema_max_digest_length">
<code class="literal">
performance_schema_max_digest_length
</code>
</a>
value.
</p>
<p>
The
<a class="link" href="performance-schema-statement-summary-tables.html" title="29.12.20.3 Statement Summary Tables">
<code class="literal">
events_statements_summary_by_digest
</code>
</a>
summary table provides a profile of the statements executed by
the server. It shows what kinds of statements an application is
executing and how often. An application developer can use this
information together with other information in the table to
assess the application's performance characteristics. For
example, table columns that show wait times, lock times, or
index use may highlight types of queries that are inefficient.
This gives the developer insight into which parts of the
application need attention.
</p>
<p>
The
<a class="link" href="performance-schema-statement-summary-tables.html" title="29.12.20.3 Statement Summary Tables">
<code class="literal">
events_statements_summary_by_digest
</code>
</a>
summary table has a fixed size. By default the Performance
Schema estimates the size to use at startup. To specify the
table size explicitly, set the
<a class="link" href="performance-schema-system-variables.html#sysvar_performance_schema_digests_size">
<code class="literal">
performance_schema_digests_size
</code>
</a>
system variable at server startup. If the table becomes full,
the Performance Schema groups statements that have
<code class="literal">
SCHEMA_NAME
</code>
and
<code class="literal">
DIGEST
</code>
values not matching existing values in the table in a special
row with
<code class="literal">
SCHEMA_NAME
</code>
and
<code class="literal">
DIGEST
</code>
set to
<code class="literal">
NULL
</code>
. This
permits all statements to be counted. However, if the special
row accounts for a significant percentage of the statements
executed, it might be desirable to increase the summary table
size by increasing
<a class="link" href="performance-schema-system-variables.html#sysvar_performance_schema_digests_size">
<code class="literal">
performance_schema_digests_size
</code>
</a>
.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h3 class="title">
<a name="statement-digests-memory-use">
</a>
Statement Digest Memory Use
</h3>
</div>
</div>
</div>
<p>
For applications that generate very long statements that differ
only at the end, increasing
<a class="link" href="server-system-variables.html#sysvar_max_digest_length">
<code class="literal">
max_digest_length
</code>
</a>
enables
computation of digests that distinguish statements that would
otherwise aggregate to the same digest. Conversely, decreasing
<a class="link" href="server-system-variables.html#sysvar_max_digest_length">
<code class="literal">
max_digest_length
</code>
</a>
causes the
server to devote less memory to digest storage but increases the
likelihood of longer statements aggregating to the same digest.
Administrators should keep in mind that larger values result in
correspondingly increased memory requirements, particularly for
workloads that involve large numbers of simultaneous sessions
(the server allocates
<a class="link" href="server-system-variables.html#sysvar_max_digest_length">
<code class="literal">
max_digest_length
</code>
</a>
bytes per
session).
</p>
<p>
As described previously, normalized statement digests as
computed by the parser are constrained to a maximum of
<a class="link" href="server-system-variables.html#sysvar_max_digest_length">
<code class="literal">
max_digest_length
</code>
</a>
bytes,
whereas normalized statement digests stored in the Performance
Schema use
<a class="link" href="performance-schema-system-variables.html#sysvar_performance_schema_max_digest_length">
<code class="literal">
performance_schema_max_digest_length
</code>
</a>
bytes. The following memory-use considerations apply regarding
the relative values of
<a class="link" href="server-system-variables.html#sysvar_max_digest_length">
<code class="literal">
max_digest_length
</code>
</a>
and
<a class="link" href="performance-schema-system-variables.html#sysvar_performance_schema_max_digest_length">
<code class="literal">
performance_schema_max_digest_length
</code>
</a>
:
</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_max_digest_length">
<code class="literal">
max_digest_length
</code>
</a>
is
less than
<a class="link" href="performance-schema-system-variables.html#sysvar_performance_schema_max_digest_length">
<code class="literal">
performance_schema_max_digest_length
</code>
</a>
:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
Server features other than the Performance Schema use
normalized statement digests that take up to
<a class="link" href="server-system-variables.html#sysvar_max_digest_length">
<code class="literal">
max_digest_length
</code>
</a>
bytes.
</p>
</li>
<li class="listitem">
<p>
The Performance Schema does not further truncate
normalized statement digests that it stores, but
allocates more memory than
<a class="link" href="server-system-variables.html#sysvar_max_digest_length">
<code class="literal">
max_digest_length
</code>
</a>
bytes
per digest, which is unnecessary.
</p>
</li>
</ul>
</div>
</li>
<li class="listitem">
<p>
If
<a class="link" href="server-system-variables.html#sysvar_max_digest_length">
<code class="literal">
max_digest_length
</code>
</a>
equals
<a class="link" href="performance-schema-system-variables.html#sysvar_performance_schema_max_digest_length">
<code class="literal">
performance_schema_max_digest_length
</code>
</a>
:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
Server features other than the Performance Schema use
normalized statement digests that take up to
<a class="link" href="server-system-variables.html#sysvar_max_digest_length">
<code class="literal">
max_digest_length
</code>
</a>
bytes.
</p>
</li>
<li class="listitem">
<p>
The Performance Schema does not further truncate
normalized statement digests that it stores, and
allocates the same amount of memory as
<a class="link" href="server-system-variables.html#sysvar_max_digest_length">
<code class="literal">
max_digest_length
</code>
</a>
bytes
per digest.
</p>
</li>
</ul>
</div>
</li>
<li class="listitem">
<p>
If
<a class="link" href="server-system-variables.html#sysvar_max_digest_length">
<code class="literal">
max_digest_length
</code>
</a>
is
greater than
<a class="link" href="performance-schema-system-variables.html#sysvar_performance_schema_max_digest_length">
<code class="literal">
performance_schema_max_digest_length
</code>
</a>
:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
Server features other than the Performance Schema use
normalized statement digests that take up to
<a class="link" href="server-system-variables.html#sysvar_max_digest_length">
<code class="literal">
max_digest_length
</code>
</a>
bytes.
</p>
</li>
<li class="listitem">
<p>
The Performance Schema further truncates normalized
statement digests that it stores, and allocates less
memory than
<a class="link" href="server-system-variables.html#sysvar_max_digest_length">
<code class="literal">
max_digest_length
</code>
</a>
bytes
per digest.
</p>
</li>
</ul>
</div>
</li>
</ul>
</div>
<p>
Because the Performance Schema statement event tables might
store many digests, setting
<a class="link" href="performance-schema-system-variables.html#sysvar_performance_schema_max_digest_length">
<code class="literal">
performance_schema_max_digest_length
</code>
</a>
smaller than
<a class="link" href="server-system-variables.html#sysvar_max_digest_length">
<code class="literal">
max_digest_length
</code>
</a>
enables administrators to balance these factors:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
The need to have long normalized statement digests available
to server features outside the Performance Schema
</p>
</li>
<li class="listitem">
<p>
Many concurrent sessions, each of which allocates
digest-computation memory
</p>
</li>
<li class="listitem">
<p>
The need to limit memory consumption by the Performance
Schema statement event tables when storing many statement
digests
</p>
</li>
</ul>
</div>
<p>
The
<a class="link" href="performance-schema-system-variables.html#sysvar_performance_schema_max_digest_length">
<code class="literal">
performance_schema_max_digest_length
</code>
</a>
setting is not per session, it is per statement, and a session
can store multiple statements in the
<a class="link" href="performance-schema-events-statements-history-table.html" title="29.12.6.2 The events_statements_history Table">
<code class="literal">
events_statements_history
</code>
</a>
table. A
typical number of statements in this table is 10 per session, so
each session consumes 10 times the memory indicated by the
<a class="link" href="performance-schema-system-variables.html#sysvar_performance_schema_max_digest_length">
<code class="literal">
performance_schema_max_digest_length
</code>
</a>
value, for this table alone.
</p>
<p>
Also, there are many statements (and digests) collected
globally, most notably in the
<a class="link" href="performance-schema-events-statements-history-long-table.html" title="29.12.6.3 The events_statements_history_long Table">
<code class="literal">
events_statements_history_long
</code>
</a>
table. Here, too,
<em class="replaceable">
<code>
N
</code>
</em>
statements stored
consumes
<em class="replaceable">
<code>
N
</code>
</em>
times the memory indicated
by the
<a class="link" href="performance-schema-system-variables.html#sysvar_performance_schema_max_digest_length">
<code class="literal">
performance_schema_max_digest_length
</code>
</a>
value.
</p>
<p>
To assess the amount of memory used for SQL statement storage
and digest computation, use the
<a class="link" href="show-engine.html" title="15.7.7.16 SHOW ENGINE Statement">
<code class="literal">
SHOW ENGINE
PERFORMANCE_SCHEMA STATUS
</code>
</a>
statement, or monitor these
instruments:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa37515854"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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">'%.sqltext'</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>
<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 class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="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> memory/performance_schema/events_statements_history.sqltext <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> memory/performance_schema/events_statements_current.sqltext <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> memory/performance_schema/events_statements_history_long.sqltext <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>
<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">'memory/performance_schema/%.tokens'</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></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> memory/performance_schema/events_statements_history.tokens <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> memory/performance_schema/events_statements_current.tokens <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> memory/performance_schema/events_statements_summary_by_digest.tokens <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> memory/performance_schema/events_statements_history_long.tokens <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>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h3 class="title">
<a name="statement-digests-sampling">
</a>
Statement Sampling
</h3>
</div>
</div>
</div>
<p>
The Performance Schema uses statement sampling to collect
representative statements that produce each digest value in the
<a class="link" href="performance-schema-statement-summary-tables.html" title="29.12.20.3 Statement Summary Tables">
<code class="literal">
events_statements_summary_by_digest
</code>
</a>
table. These columns store sample statement information:
<code class="literal">
QUERY_SAMPLE_TEXT
</code>
(the text of the
statement),
<code class="literal">
QUERY_SAMPLE_SEEN
</code>
(when the
statement was seen), and
<code class="literal">
QUERY_SAMPLE_TIMER_WAIT
</code>
(the statement wait
or execution time). The Performance Schema updates all three
columns each time it chooses a sample statement.
</p>
<p>
When a new table row is inserted, the statement that produced
the row digest value is stored as the current sample statement
associated with the digest. Thereafter, when the server sees
other statements with the same digest value, it determines
whether to use the new statement to replace the current sample
statement (that is, whether to resample). Resampling policy is
based on the comparative wait times of the current sample
statement and new statement and, optionally, the age of the
current sample statement:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Resampling based on wait times: If the new statement wait
time has a wait time greater than that of the current sample
statement, it becomes the current sample statement.
</p>
</li>
<li class="listitem">
<p>
Resampling based on age: If the
<a class="link" href="performance-schema-system-variables.html#sysvar_performance_schema_max_digest_sample_age">
<code class="literal">
performance_schema_max_digest_sample_age
</code>
</a>
system variable has a value greater than zero and the
current sample statement is more than that many seconds old,
the current statement is considered
<span class="quote">
“
<span class="quote">
too old
</span>
”
</span>
and the new statement replaces it. This occurs even if the
new statement wait time is less than that of the current
sample statement.
</p>
</li>
</ul>
</div>
<p>
By default,
<a class="link" href="performance-schema-system-variables.html#sysvar_performance_schema_max_digest_sample_age">
<code class="literal">
performance_schema_max_digest_sample_age
</code>
</a>
is 60 seconds (1 minute). To change how quickly sample
statements
<span class="quote">
“
<span class="quote">
expire
</span>
”
</span>
due to age, increase or
decrease the value. To disable the age-based part of the
resampling policy, set
<a class="link" href="performance-schema-system-variables.html#sysvar_performance_schema_max_digest_sample_age">
<code class="literal">
performance_schema_max_digest_sample_age
</code>
</a>
to 0.
</p>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/mysql-cluster-programs-ndb-print-backup-file.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="mysql-cluster-programs-ndb-print-backup-file">
</a>
25.5.17 ndb_print_backup_file — Print NDB Backup File Contents
</h3>
</div>
</div>
</div>
<a class="indexterm" name="idm46045100548304">
</a>
<p>
<a class="link" href="mysql-cluster-programs-ndb-print-backup-file.html" title="25.5.17 ndb_print_backup_file — Print NDB Backup File Contents">
<span class="command">
<strong>
ndb_print_backup_file
</strong>
</span>
</a>
obtains diagnostic
information from a cluster backup file.
</p>
<p>
</p>
<h4>
<a name="idm46045100544928">
</a>
Usage
</h4>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa34189170"><div class="copy-help left">Press ⌘+C to 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">ndb_print_backup_file <span class="token punctuation">[</span><span class="token property">-P</span> <em class="replaceable">password</em><span class="token punctuation">]</span> <em class="replaceable">file_name</em></code></pre>
</div>
<p>
<em class="replaceable">
<code>
file_name
</code>
</em>
is the name of a cluster
backup file. This can be any of the files
(
<code class="filename">
.Data
</code>
,
<code class="filename">
.ctl
</code>
, or
<code class="filename">
.log
</code>
file) found in a cluster backup
directory. These files are found in the data node's backup
directory under the subdirectory
<code class="filename">
BACKUP-
<em class="replaceable">
<code>
#
</code>
</em>
</code>
, where
<em class="replaceable">
<code>
#
</code>
</em>
is the sequence number for the
backup. For more information about cluster backup files and
their contents, see
<a class="xref" href="mysql-cluster-backup-concepts.html" title="25.6.8.1 NDB Cluster Backup Concepts">
Section 25.6.8.1, “NDB Cluster Backup Concepts”
</a>
.
</p>
<p>
Like
<a class="link" href="mysql-cluster-programs-ndb-print-schema-file.html" title="25.5.20 ndb_print_schema_file — Print NDB Schema File Contents">
<span class="command">
<strong>
ndb_print_schema_file
</strong>
</span>
</a>
and
<a class="link" href="mysql-cluster-programs-ndb-print-sys-file.html" title="25.5.21 ndb_print_sys_file — Print NDB System File Contents">
<span class="command">
<strong>
ndb_print_sys_file
</strong>
</span>
</a>
(and unlike most of the
other
<a class="link" href="mysql-cluster.html" title="Chapter 25 MySQL NDB Cluster 8.4">
<code class="literal">
NDB
</code>
</a>
utilities that are
intended to be run on a management server host or to connect to
a management server)
<a class="link" href="mysql-cluster-programs-ndb-print-backup-file.html" title="25.5.17 ndb_print_backup_file — Print NDB Backup File Contents">
<span class="command">
<strong>
ndb_print_backup_file
</strong>
</span>
</a>
must be run on a cluster data node, since it accesses the data
node file system directly. Because it does not make use of the
management server, this utility can be used when the management
server is not running, and even when the cluster has been
completely shut down.
</p>
<p>
This program can also be used to read undo log files.
</p>
<h4>
<a name="mysql-cluster-programs-ndb-print-backup-file-options">
</a>
Options
</h4>
<p>
<a class="link" href="mysql-cluster-programs-ndb-print-backup-file.html" title="25.5.17 ndb_print_backup_file — Print NDB Backup File Contents">
<span class="command">
<strong>
ndb_print_backup_file
</strong>
</span>
</a>
supports the options
described in the following list.
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a name="option_ndb_print_backup_file_backup-key">
</a>
<a class="link" href="mysql-cluster-programs-ndb-print-backup-file.html#option_ndb_print_backup_file_backup-key">
<code class="option">
--backup-key
</code>
</a>
,
<code class="option">
-K
</code>
</p>
<a class="indexterm" name="idm46045100524464">
</a>
<a class="indexterm" name="idm46045100522976">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for backup-key">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--backup-key=key
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Specify the key needed to decrypt an encrypted backup.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_print_backup_file_backup-key-from-stdin">
</a>
<a class="link" href="mysql-cluster-programs-ndb-print-backup-file.html#option_ndb_print_backup_file_backup-key-from-stdin">
<code class="option">
--backup-key-from-stdin
</code>
</a>
</p>
<a class="indexterm" name="idm46045100513168">
</a>
<a class="indexterm" name="idm46045100511664">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for backup-key-from-stdin">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--backup-key-from-stdin
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Allow input of the decryption key from standard input,
similar to entering a password after invoking
<a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
<span class="command">
<strong>
mysql
</strong>
</span>
</a>
<a class="link" href="mysql-command-options.html#option_mysql_password">
<code class="option">
--password
</code>
</a>
with no password
supplied.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_print_backup_file_backup-password">
</a>
<a class="link" href="mysql-cluster-programs-ndb-print-backup-file.html#option_ndb_print_backup_file_backup-password">
<code class="option">
--backup-password
</code>
</a>
</p>
<a class="indexterm" name="idm46045100499600">
</a>
<a class="indexterm" name="idm46045100498112">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for backup-password">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--backup-password=password
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
String
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
[none]
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Specify the password needed to decrypt an encrypted backup.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_print_backup_file_backup-password-from-stdin">
</a>
<a class="link" href="mysql-cluster-programs-ndb-print-backup-file.html#option_ndb_print_backup_file_backup-password-from-stdin">
<code class="option">
--backup-password-from-stdin
</code>
</a>
</p>
<a class="indexterm" name="idm46045100483728">
</a>
<a class="indexterm" name="idm46045100482224">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for backup-password-from-stdin">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--backup-password-from-stdin
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Allow input of the password from standard input, similar to
entering a password after invoking
<a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
<span class="command">
<strong>
mysql
</strong>
</span>
</a>
<a class="link" href="mysql-command-options.html#option_mysql_password">
<code class="option">
--password
</code>
</a>
with no password
supplied.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_print_backup_file_control-directory-number">
</a>
<a class="link" href="mysql-cluster-programs-ndb-print-backup-file.html#option_ndb_print_backup_file_control-directory-number">
<code class="option">
--control-directory-number
</code>
</a>
</p>
<a class="indexterm" name="idm46045100470128">
</a>
<a class="indexterm" name="idm46045100468624">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for control-directory-number">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--control-directory-number=#
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
Integer
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
0
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Control file directory number. Used together with
<a class="link" href="mysql-cluster-programs-ndb-print-backup-file.html#option_ndb_print_backup_file_print-restored-rows">
<code class="option">
--print-restored-rows
</code>
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_print_backup_file_defaults-extra-file">
</a>
<a class="link" href="mysql-cluster-programs-ndb-print-backup-file.html#option_ndb_print_backup_file_defaults-extra-file">
<code class="option">
--defaults-extra-file
</code>
</a>
</p>
<a class="indexterm" name="idm46045100453200">
</a>
<a class="indexterm" name="idm46045100451696">
</a>
<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=path
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
String
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
[none]
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Read given file after global files are read.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_print_backup_file_defaults-file">
</a>
<a class="link" href="mysql-cluster-programs-ndb-print-backup-file.html#option_ndb_print_backup_file_defaults-file">
<code class="option">
--defaults-file
</code>
</a>
</p>
<a class="indexterm" name="idm46045100437328">
</a>
<a class="indexterm" name="idm46045100435840">
</a>
<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=path
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
String
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
[none]
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Read default options from given file only.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_print_backup_file_defaults-group-suffix">
</a>
<a class="link" href="mysql-cluster-programs-ndb-print-backup-file.html#option_ndb_print_backup_file_defaults-group-suffix">
<code class="option">
--defaults-group-suffix
</code>
</a>
</p>
<a class="indexterm" name="idm46045100421568">
</a>
<a class="indexterm" name="idm46045100420064">
</a>
<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=string
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
String
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
[none]
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Also read groups with concat(group, suffix).
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_print_backup_file_fragment-id">
</a>
<a class="link" href="mysql-cluster-programs-ndb-print-backup-file.html#option_ndb_print_backup_file_fragment-id">
<code class="option">
--fragment-id
</code>
</a>
</p>
<a class="indexterm" name="idm46045100405632">
</a>
<a class="indexterm" name="idm46045100404144">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for fragment-id">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--fragment-id=#
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
Integer
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
0
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Fragment ID. Used together with
<a class="link" href="mysql-cluster-programs-ndb-print-backup-file.html#option_ndb_print_backup_file_print-restored-rows">
<code class="option">
--print-restored-rows
</code>
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_print_backup_file_help">
</a>
<a class="link" href="mysql-cluster-programs-ndb-print-backup-file.html#option_ndb_print_backup_file_help">
<code class="option">
--help
</code>
</a>
</p>
<a class="indexterm" name="idm46045100388896">
</a>
<a class="indexterm" name="idm46045100387408">
</a>
<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>
<p class="valid-value">
<code class="literal">
--help
</code>
</p>
<p class="valid-value">
<code class="literal">
--usage
</code>
</p>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Print program usage information.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_print_backup_file_login-path">
</a>
<a class="link" href="mysql-cluster-programs-ndb-print-backup-file.html#option_ndb_print_backup_file_login-path">
<code class="option">
--login-path
</code>
</a>
</p>
<a class="indexterm" name="idm46045100376336">
</a>
<a class="indexterm" name="idm46045100374848">
</a>
<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=path
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
String
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
[none]
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Read given path from login file.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_print_backup_file_no-login-paths">
</a>
<a class="link" href="mysql-cluster-programs-ndb-print-backup-file.html#option_ndb_print_backup_file_no-login-paths">
<code class="option">
--no-login-paths
</code>
</a>
</p>
<a class="indexterm" name="idm46045100360432">
</a>
<a class="indexterm" name="idm46045100358944">
</a>
<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>
<p>
Skips reading options from the login path file.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_print_backup_file_no-defaults">
</a>
<a class="link" href="mysql-cluster-programs-ndb-print-backup-file.html#option_ndb_print_backup_file_no-defaults">
<code class="option">
--no-defaults
</code>
</a>
</p>
<a class="indexterm" name="idm46045100349168">
</a>
<a class="indexterm" name="idm46045100347680">
</a>
<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>
<p>
Do not read default options from any option file other than
login file.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_print_backup_file_no-print-rows">
</a>
<a class="link" href="mysql-cluster-programs-ndb-print-backup-file.html#option_ndb_print_backup_file_no-print-rows">
<code class="option">
--no-print-rows
</code>
</a>
</p>
<a class="indexterm" name="idm46045100337856">
</a>
<a class="indexterm" name="idm46045100336368">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for no-print-rows">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--no-print-rows
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Do not include rows in output.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_print_backup_file_print-defaults">
</a>
<a class="link" href="mysql-cluster-programs-ndb-print-backup-file.html#option_ndb_print_backup_file_print-defaults">
<code class="option">
--print-defaults
</code>
</a>
</p>
<a class="indexterm" name="idm46045100326608">
</a>
<a class="indexterm" name="idm46045100325120">
</a>
<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>
<p>
Print program argument list and exit.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_print_backup_file_print-header-words">
</a>
<a class="link" href="mysql-cluster-programs-ndb-print-backup-file.html#option_ndb_print_backup_file_print-header-words">
<code class="option">
--print-header-words
</code>
</a>
</p>
<a class="indexterm" name="idm46045100315280">
</a>
<a class="indexterm" name="idm46045100313776">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for print-header-words">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--print-header-words
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Include header words in output.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_print_backup_file_print-restored-rows">
</a>
<a class="link" href="mysql-cluster-programs-ndb-print-backup-file.html#option_ndb_print_backup_file_print-restored-rows">
<code class="option">
--print-restored-rows
</code>
</a>
</p>
<a class="indexterm" name="idm46045100304048">
</a>
<a class="indexterm" name="idm46045100302544">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for print-restored-rows">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--print-restored-rows
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Include restored rows in output, using the file
<code class="filename">
LCP/
<em class="replaceable">
<code>
c
</code>
</em>
/T
<em class="replaceable">
<code>
t
</code>
</em>
F
<em class="replaceable">
<code>
f
</code>
</em>
.ctl
</code>
,
for which the values are set as follows:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
<em class="replaceable">
<code>
c
</code>
</em>
is the control file number
set using
<a class="link" href="mysql-cluster-programs-ndb-print-backup-file.html#option_ndb_print_backup_file_control-directory-number">
<code class="option">
--control-directory-number
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<em class="replaceable">
<code>
t
</code>
</em>
is the table ID set using
<a class="link" href="mysql-cluster-programs-ndb-print-backup-file.html#option_ndb_print_backup_file_table-id">
<code class="option">
--table-id
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<em class="replaceable">
<code>
f
</code>
</em>
is the fragment ID set
using
<a class="link" href="mysql-cluster-programs-ndb-print-backup-file.html#option_ndb_print_backup_file_fragment-id">
<code class="option">
--fragment-id
</code>
</a>
</p>
</li>
</ul>
</div>
</li>
<li class="listitem">
<p>
<a name="option_ndb_print_backup_file_print-rows">
</a>
<a class="link" href="mysql-cluster-programs-ndb-print-backup-file.html#option_ndb_print_backup_file_print-rows">
<code class="option">
--print-rows
</code>
</a>
</p>
<a class="indexterm" name="idm46045100283728">
</a>
<a class="indexterm" name="idm46045100282240">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for print-rows">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--print-rows
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Print rows. This option is enabled by default; to disable
it, use
<a class="link" href="mysql-cluster-programs-ndb-print-backup-file.html#option_ndb_print_backup_file_no-print-rows">
<code class="option">
--no-print-rows
</code>
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_print_backup_file_print-rows-per-page">
</a>
<a class="link" href="mysql-cluster-programs-ndb-print-backup-file.html#option_ndb_print_backup_file_print-rows-per-page">
<code class="option">
--print-rows-per-page
</code>
</a>
</p>
<a class="indexterm" name="idm46045100271328">
</a>
<a class="indexterm" name="idm46045100269824">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for print-rows-per-page">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--print-rows-per-page
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Print rows per page.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_print_backup_file_rowid-file">
</a>
<a class="link" href="mysql-cluster-programs-ndb-print-backup-file.html#option_ndb_print_backup_file_rowid-file">
<code class="option">
--rowid-file
</code>
</a>
</p>
<a class="indexterm" name="idm46045100260064">
</a>
<a class="indexterm" name="idm46045100258576">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for rowid-file">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--rowid-file=path
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
File name
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
[none]
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
File to check for row ID.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_print_backup_file_show-ignored-rows">
</a>
<a class="link" href="mysql-cluster-programs-ndb-print-backup-file.html#option_ndb_print_backup_file_show-ignored-rows">
<code class="option">
--show-ignored-rows
</code>
</a>
</p>
<a class="indexterm" name="idm46045100244304">
</a>
<a class="indexterm" name="idm46045100242800">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for show-ignored-rows">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--show-ignored-rows
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Show ignored rows.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_print_backup_file_table-id">
</a>
<a class="link" href="mysql-cluster-programs-ndb-print-backup-file.html#option_ndb_print_backup_file_table-id">
<code class="option">
--table-id
</code>
</a>
</p>
<a class="indexterm" name="idm46045100233152">
</a>
<a class="indexterm" name="idm46045100231664">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for table-id">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--table-id=#
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
Integer
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
[none]
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Table ID. Used together with
<a class="link" href="mysql-cluster-programs-ndb-print-backup-file.html#option_ndb_print_backup_file_print-restored-rows">
<code class="option">
--print-restored-rows
</code>
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_print_backup_file_usage">
</a>
<a class="link" href="mysql-cluster-programs-ndb-print-backup-file.html#option_ndb_print_backup_file_usage">
<code class="option">
--usage
</code>
</a>
</p>
<a class="indexterm" name="idm46045100216384">
</a>
<a class="indexterm" name="idm46045100214896">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for usage">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--usage
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Display help text and exit; same as
<a class="link" href="mysql-cluster-programs-ndb-print-backup-file.html#option_ndb_print_backup_file_help">
<code class="option">
--help
</code>
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_print_backup_file_verbose">
</a>
<a class="link" href="mysql-cluster-programs-ndb-print-backup-file.html#option_ndb_print_backup_file_verbose">
<code class="option">
--verbose
</code>
</a>
</p>
<a class="indexterm" name="idm46045100204080">
</a>
<a class="indexterm" name="idm46045100202592">
</a>
<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>
<tr>
<th>
Type
</th>
<td>
Integer
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
0
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Verbosity level of output. A greater value indicates
increased verbosity.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_print_backup_file_version">
</a>
<a class="link" href="mysql-cluster-programs-ndb-print-backup-file.html#option_ndb_print_backup_file_version">
<code class="option">
--version
</code>
</a>
</p>
<a class="indexterm" name="idm46045100188384">
</a>
<a class="indexterm" name="idm46045100186896">
</a>
<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>
<p>
Display version information and exit.
</p>
</li>
</ul>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/solaris-installation.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h2 class="title">
<a name="solaris-installation">
</a>
2.7 Installing MySQL on Solaris
</h2>
</div>
</div>
</div>
<div class="toc">
<dl class="toc">
<dt>
<span class="section">
<a href="solaris-installation-pkg.html">
2.7.1 Installing MySQL on Solaris Using a Solaris PKG
</a>
</span>
</dt>
</dl>
</div>
<a class="indexterm" name="idm46045329794880">
</a>
<a class="indexterm" name="idm46045329793424">
</a>
<a class="indexterm" name="idm46045329791968">
</a>
<a class="indexterm" name="idm46045329790480">
</a>
<a class="indexterm" name="idm46045329789392">
</a>
<a class="indexterm" name="idm46045329787904">
</a>
<a class="indexterm" name="idm46045329786448">
</a>
<a class="indexterm" name="idm46045329784960">
</a>
<a class="indexterm" name="idm46045329783888">
</a>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
MySQL 8.4 supports Solaris 11.4 and higher
</p>
</div>
<p>
MySQL on Solaris is available in a number of different formats.
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
For information on installing using the native Solaris PKG
format, see
<a class="xref" href="solaris-installation-pkg.html" title="2.7.1 Installing MySQL on Solaris Using a Solaris PKG">
Section 2.7.1, “Installing MySQL on Solaris Using a Solaris PKG”
</a>
.
</p>
</li>
<li class="listitem">
<p>
To use a standard
<code class="literal">
tar
</code>
binary installation,
use the notes provided in
<a class="xref" href="binary-installation.html" title="2.2 Installing MySQL on Unix/Linux Using Generic Binaries">
Section 2.2, “Installing MySQL on Unix/Linux Using Generic Binaries”
</a>
.
Check the notes and hints at the end of this section for Solaris
specific notes that you may need before or after installation.
</p>
</li>
</ul>
</div>
<p>
To obtain a binary MySQL distribution for Solaris in tarball or PKG
format,
<a class="ulink" href="https://dev.mysql.com/downloads/mysql/8.4.html" target="_top">
https://dev.mysql.com/downloads/mysql/8.4.html
</a>
.
</p>
<p>
Additional notes to be aware of when installing and using MySQL on
Solaris:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
If you want to use MySQL with the
<code class="literal">
mysql
</code>
user
and group, use the
<span class="command">
<strong>
groupadd
</strong>
</span>
and
<span class="command">
<strong>
useradd
</strong>
</span>
commands:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa85607113"><div class="copy-help left">Press ⌘+C to 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">groupadd mysql
useradd <span class="token property">-g</span> mysql <span class="token property">-s</span> /bin/false mysql</code></pre>
</div>
</li>
<li class="listitem">
<p>
If you install MySQL using a binary tarball distribution on
Solaris, because the Solaris
<span class="command">
<strong>
tar
</strong>
</span>
cannot
handle long file names, use GNU
<span class="command">
<strong>
tar
</strong>
</span>
(
<span class="command">
<strong>
gtar
</strong>
</span>
) to unpack the distribution. If you do
not have GNU
<span class="command">
<strong>
tar
</strong>
</span>
on your system, install it
with the following command:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa62231147"><div class="copy-help left">Press ⌘+C to 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">pkg install archiver/gnu-tar</code></pre>
</div>
</li>
<li class="listitem">
<p>
You should mount any file systems on which you intend to store
<code class="literal">
InnoDB
</code>
files with the
<code class="literal">
forcedirectio
</code>
option. (By default mounting is
done without this option.) Failing to do so causes a significant
drop in performance when using the
<code class="literal">
InnoDB
</code>
storage engine on this platform.
</p>
</li>
<li class="listitem">
<p>
If you would like MySQL to start automatically, you can copy
<code class="filename">
support-files/mysql.server
</code>
to
<code class="filename">
/etc/init.d
</code>
and create a symbolic link to
it named
<code class="filename">
/etc/rc3.d/S99mysql.server
</code>
.
</p>
</li>
<li class="listitem">
<p>
If too many processes try to connect very rapidly to
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
, you should see this error in the
MySQL log:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-simple"><div class="docs-select-all right" id="sa73902142"><div class="copy-help left">Press ⌘+C to 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">Error in accept<span class="token operator">:</span> Protocol error</code></pre>
</div>
<p>
You might try starting the server with the
<a class="link" href="server-system-variables.html#sysvar_back_log">
<code class="option">
--back_log=50
</code>
</a>
option as a
workaround for this.
</p>
</li>
<li class="listitem">
<p>
To configure the generation of core files on Solaris you should
use the
<span class="command">
<strong>
coreadm
</strong>
</span>
command. Because of the
security implications of generating a core on a
<code class="literal">
setuid()
</code>
application, by default, Solaris
does not support core files on
<code class="literal">
setuid()
</code>
programs. However, you can modify this behavior using
<span class="command">
<strong>
coreadm
</strong>
</span>
. If you enable
<code class="literal">
setuid()
</code>
core files for the current user,
they are generated using mode 600 and are owned by the
superuser.
</p>
</li>
</ul>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/mysql-shell-tutorial-javascript-documents-remove.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="mysql-shell-tutorial-javascript-documents-remove">
</a>
22.3.3.5 Remove Documents
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045127732800">
</a>
<p>
You can use the
<code class="literal">
remove()
</code>
method to delete
some or all documents from a collection in a schema. The
X DevAPI provides additional methods for use with the
<code class="literal">
remove()
</code>
method to filter and sort the
documents to be removed.
</p>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="mysql-shell-tutorial-javascript-remove-documents-by-condition">
</a>
Remove Documents Using Conditions
</h5>
</div>
</div>
</div>
<a class="indexterm" name="idm46045127728016">
</a>
<p>
The following example passes a search condition to the
<code class="literal">
remove()
</code>
method. All documents matching the
condition are removed from the
<code class="literal">
countryinfo
</code>
collection. In this example, one document matches the
condition.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-mysqlsh"><div class="docs-select-all right" id="sa91605443"><div class="copy-help left">Press ⌘+C to 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>countryinfo<span class="token punctuation">.</span><span class="token function">remove</span><span class="token punctuation">(</span><span class="token string">"Code = 'SEA'"</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-remove-first-document">
</a>
Remove the First Document
</h5>
</div>
</div>
</div>
<a class="indexterm" name="idm46045127721408">
</a>
<p>
To remove the first document in the
<code class="literal">
countryinfo
</code>
collection, use the
<code class="literal">
limit()
</code>
method with a value of 1.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-mysqlsh"><div class="docs-select-all right" id="sa22437864"><div class="copy-help left">Press ⌘+C to 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>countryinfo<span class="token punctuation">.</span><span class="token function">remove</span><span class="token punctuation">(</span><span class="token string">"true"</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">limit</span><span class="token punctuation">(</span><span class="token number">1</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-remove-last-document">
</a>
Remove the Last Document in an Order
</h5>
</div>
</div>
</div>
<a class="indexterm" name="idm46045127715088">
</a>
<p>
The following example removes the last document in the
<code class="literal">
countryinfo
</code>
collection by country name.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-mysqlsh"><div class="docs-select-all right" id="sa75294115"><div class="copy-help left">Press ⌘+C to 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>countryinfo<span class="token punctuation">.</span><span class="token function">remove</span><span class="token punctuation">(</span><span class="token string">"true"</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">sort</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token string">"Name desc"</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">limit</span><span class="token punctuation">(</span><span class="token number">1</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-remove-all-documents">
</a>
Remove All Documents in a Collection
</h5>
</div>
</div>
</div>
<a class="indexterm" name="idm46045127709312">
</a>
<p>
You can remove all documents in a collection. To do so, use
the
<code class="literal">
remove("true")
</code>
method without
specifying a search condition.
</p>
<div class="caution" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Caution
</div>
<p>
Use care when you remove documents without specifying a
search condition. This action deletes all documents from the
collection.
</p>
</div>
<p>
Alternatively, use the
<code class="literal">
db.drop_collection('countryinfo')
</code>
operation
to delete the
<code class="literal">
countryinfo
</code>
collection.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="idm46045127703616">
</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/crud-ebnf-collection-crud-functions.html#crud-ebnf-collectionremovefunction" target="_top">
CollectionRemoveFunction
</a>
for the full syntax definition.
</p>
</li>
<li class="listitem">
<p>
See
<a class="xref" href="mysql-shell-tutorial-javascript-download.html" title="22.3.2 Download and Import world_x Database">
Section 22.3.2, “Download and Import world_x Database”
</a>
for instructions to recreate the
<code class="literal">
world_x
</code>
schema.
</p>
</li>
</ul>
</div>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/sys-schema-table-statistics.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="sys-schema-table-statistics">
</a>
30.4.3.29 The schema_table_statistics and x$schema_table_statistics Views
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045062404224">
</a>
<a class="indexterm" name="idm46045062402768">
</a>
<a class="indexterm" name="idm46045062401264">
</a>
<a class="indexterm" name="idm46045062399760">
</a>
<p>
These views summarize table statistics. By default, rows are
sorted by descending total wait time (tables with most
contention first).
</p>
<p>
These views user a helper view,
<code class="literal">
x$ps_schema_table_statistics_io
</code>
.
</p>
<p>
The
<a class="link" href="sys-schema-table-statistics.html" title="30.4.3.29 The schema_table_statistics and x$schema_table_statistics Views">
<code class="literal">
schema_table_statistics
</code>
</a>
and
<a class="link" href="sys-schema-table-statistics.html" title="30.4.3.29 The schema_table_statistics and x$schema_table_statistics Views">
<code class="literal">
x$schema_table_statistics
</code>
</a>
views
have these columns:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
table_schema
</code>
</p>
<p>
The schema that contains the table.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
table_name
</code>
</p>
<p>
The table name.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
total_latency
</code>
</p>
<p>
The total wait time of timed I/O events for the table.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
rows_fetched
</code>
</p>
<p>
The total number of rows read from the table.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
fetch_latency
</code>
</p>
<p>
The total wait time of timed read I/O events for the
table.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
rows_inserted
</code>
</p>
<p>
The total number of rows inserted into the table.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
insert_latency
</code>
</p>
<p>
The total wait time of timed insert I/O events for the
table.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
rows_updated
</code>
</p>
<p>
The total number of rows updated in the table.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
update_latency
</code>
</p>
<p>
The total wait time of timed update I/O events for the
table.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
rows_deleted
</code>
</p>
<p>
The total number of rows deleted from the table.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
delete_latency
</code>
</p>
<p>
The total wait time of timed delete I/O events for the
table.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
io_read_requests
</code>
</p>
<p>
The total number of read requests for the table.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
io_read
</code>
</p>
<p>
The total number of bytes read from the table.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
io_read_latency
</code>
</p>
<p>
The total wait time of reads from the table.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
io_write_requests
</code>
</p>
<p>
The total number of write requests for the table.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
io_write
</code>
</p>
<p>
The total number of bytes written to the table.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
io_write_latency
</code>
</p>
<p>
The total wait time of writes to the table.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
io_misc_requests
</code>
</p>
<p>
The total number of miscellaneous I/O requests for the
table.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
io_misc_latency
</code>
</p>
<p>
The total wait time of miscellaneous I/O requests for the
table.
</p>
</li>
</ul>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/audit-log-disabling.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="audit-log-disabling">
</a>
8.4.5.9 Disabling Audit Logging
</h4>
</div>
</div>
</div>
<p>
The
<a class="link" href="audit-log-reference.html#sysvar_audit_log_disable">
<code class="literal">
audit_log_disable
</code>
</a>
variable
permits disabling audit logging for all connecting and connected
sessions. The
<a class="link" href="audit-log-reference.html#sysvar_audit_log_disable">
<code class="literal">
audit_log_disable
</code>
</a>
variable can be set in a MySQL Server option file, in a
command-line startup string, or at runtime using a
<a class="link" href="set-variable.html" title="15.7.6.1 SET Syntax for Variable Assignment">
<code class="literal">
SET
</code>
</a>
statement; for example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa9310449"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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> audit_log_disable <span class="token operator">=</span> <span class="token boolean">true</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
Setting
<a class="link" href="audit-log-reference.html#sysvar_audit_log_disable">
<code class="literal">
audit_log_disable
</code>
</a>
to
true disables the audit log plugin. The plugin is re-enabled
when
<a class="link" href="audit-log-reference.html#sysvar_audit_log_disable">
<code class="literal">
audit_log_disable
</code>
</a>
is set
back to
<code class="literal">
false
</code>
, which is the default setting.
</p>
<p>
Starting the audit log plugin with
<a class="link" href="audit-log-reference.html#sysvar_audit_log_disable">
<code class="literal">
audit_log_disable = true
</code>
</a>
generates a warning
(
<a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html#error_er_warn_audit_log_disabled" target="_top">
<code class="literal">
ER_WARN_AUDIT_LOG_DISABLED
</code>
</a>
)
with the following message:
<span class="errortext">
Audit Log is disabled.
Enable it with audit_log_disable = false
</span>
. Setting
<a class="link" href="audit-log-reference.html#sysvar_audit_log_disable">
<code class="literal">
audit_log_disable
</code>
</a>
to false also
generates warning. When
<a class="link" href="audit-log-reference.html#sysvar_audit_log_disable">
<code class="literal">
audit_log_disable
</code>
</a>
is set to
true, audit log function calls and variable changes generate a
session warning.
</p>
<p>
Setting the runtime value of
<a class="link" href="audit-log-reference.html#sysvar_audit_log_disable">
<code class="literal">
audit_log_disable
</code>
</a>
requires the
<a class="link" href="privileges-provided.html#priv_audit-admin">
<code class="literal">
AUDIT_ADMIN
</code>
</a>
privilege, in
addition to 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) normally required to set a global system variable
runtime value.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/optimizing-innodb-bulk-data-loading.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="optimizing-innodb-bulk-data-loading">
</a>
10.5.5 Bulk Data Loading for InnoDB Tables
</h3>
</div>
</div>
</div>
<a class="indexterm" name="idm46045226128160">
</a>
<p>
These performance tips supplement the general guidelines for
fast inserts in
<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>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
When importing data into
<code class="literal">
InnoDB
</code>
, turn off
autocommit mode, because it performs a log flush to disk for
every insert. To disable autocommit during your import
operation, surround it with
<a class="link" href="commit.html" title="15.3.1 START TRANSACTION, COMMIT, and ROLLBACK Statements">
<code class="literal">
SET
autocommit
</code>
</a>
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>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa69948751"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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> autocommit<span class="token operator">=</span><span class="token number">0</span><span class="token punctuation">;</span>
<span class="token punctuation"></span><em class="replaceable"><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span> <span class="token keyword">SQL</span> <span class="token keyword">import</span> statements <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span></em><span class="token punctuation"></span>
<span class="token keyword">COMMIT</span><span class="token punctuation">;</span></code></pre>
</div>
<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>
option
<a class="link" href="mysqldump.html#option_mysqldump_opt">
<code class="option">
--opt
</code>
</a>
creates dump files
that are fast to import into an
<code class="literal">
InnoDB
</code>
table, even without wrapping them with the
<a class="link" href="commit.html" title="15.3.1 START TRANSACTION, COMMIT, and ROLLBACK Statements">
<code class="literal">
SET
autocommit
</code>
</a>
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>
If you have
<code class="literal">
UNIQUE
</code>
constraints on
secondary keys, you can speed up table imports by
temporarily turning off the uniqueness checks during the
import session:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa31027233"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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> unique_checks<span class="token operator">=</span><span class="token number">0</span><span class="token punctuation">;</span>
<span class="token punctuation"></span><em class="replaceable"><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span> <span class="token keyword">SQL</span> <span class="token keyword">import</span> statements <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span></em><span class="token punctuation"></span>
<span class="token keyword">SET</span> unique_checks<span class="token operator">=</span><span class="token number">1</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
For big tables, this saves a lot of disk I/O because
<code class="literal">
InnoDB
</code>
can use its change buffer to write
secondary index records in a batch. Be certain that the data
contains no duplicate keys.
</p>
</li>
<li class="listitem">
<p>
If you have
<code class="literal">
FOREIGN KEY
</code>
constraints in
your tables, you can speed up table imports by turning off
the foreign key checks for the duration of the import
session:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa55907017"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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> foreign_key_checks<span class="token operator">=</span><span class="token number">0</span><span class="token punctuation">;</span>
<span class="token punctuation"></span><em class="replaceable"><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span> <span class="token keyword">SQL</span> <span class="token keyword">import</span> statements <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span></em><span class="token punctuation"></span>
<span class="token keyword">SET</span> foreign_key_checks<span class="token operator">=</span><span class="token number">1</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
For big tables, this can save a lot of disk I/O.
</p>
</li>
<li class="listitem">
<p>
Use the multiple-row
<a class="link" href="insert.html" title="15.2.7 INSERT Statement">
<code class="literal">
INSERT
</code>
</a>
syntax to reduce communication overhead between the client
and the server if you need to insert many rows:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa43964097"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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">INSERT</span> <span class="token keyword">INTO</span> yourtable <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 number">2</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token punctuation">(</span><span class="token number">5</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 punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
This tip is valid for inserts into any table, not just
<code class="literal">
InnoDB
</code>
tables.
</p>
</li>
<li class="listitem">
<p>
When doing bulk inserts into tables with auto-increment
columns, set
<a class="link" href="innodb-parameters.html#sysvar_innodb_autoinc_lock_mode">
<code class="literal">
innodb_autoinc_lock_mode
</code>
</a>
to
2 (interleaved) instead of 1 (consecutive). See
<a class="xref" href="innodb-auto-increment-handling.html" title="17.6.1.6 AUTO_INCREMENT Handling in InnoDB">
Section 17.6.1.6, “AUTO_INCREMENT Handling in InnoDB”
</a>
for
details.
</p>
</li>
<li class="listitem">
<p>
When performing bulk inserts, it is faster to insert rows in
<code class="literal">
PRIMARY KEY
</code>
order.
<code class="literal">
InnoDB
</code>
tables use a
<a class="link" href="glossary.html#glos_clustered_index" title="clustered index">
clustered index
</a>
,
which makes it relatively fast to use data in the order of
the
<code class="literal">
PRIMARY KEY
</code>
. Performing bulk inserts
in
<code class="literal">
PRIMARY KEY
</code>
order is particularly
important for tables that do not fit entirely within the
buffer pool.
</p>
</li>
<li class="listitem">
<p>
For optimal performance when loading data into an
<code class="literal">
InnoDB
</code>
<code class="literal">
FULLTEXT
</code>
index,
follow this set of steps:
</p>
<div class="orderedlist">
<ol class="orderedlist" type="1">
<li class="listitem">
<p>
Define a column
<code class="literal">
FTS_DOC_ID
</code>
at table
creation time, of type
<code class="literal">
BIGINT UNSIGNED NOT
NULL
</code>
, with a unique index named
<code class="literal">
FTS_DOC_ID_INDEX
</code>
. For example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa64000468"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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>
FTS_DOC_ID <span class="token datatype">BIGINT</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>
title <span class="token datatype">varchar</span><span class="token punctuation">(</span><span class="token number">255</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>
<span class="token datatype">text</span> <span class="token datatype">mediumtext</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span><span class="token punctuation">,</span>
<span class="token keyword">PRIMARY</span> <span class="token keyword">KEY</span> <span class="token punctuation">(</span><span class="token punctuation">`</span>FTS_DOC_ID<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">DEFAULT</span> <span class="token keyword">CHARSET</span><span class="token operator">=</span>utf8mb4<span class="token punctuation">;</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> t1<span class="token punctuation">(</span>FTS_DOC_ID<span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
Load the data into the table.
</p>
</li>
<li class="listitem">
<p>
Create the
<code class="literal">
FULLTEXT
</code>
index after the
data is loaded.
</p>
</li>
</ol>
</div>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
When adding
<code class="literal">
FTS_DOC_ID
</code>
column at table
creation time, ensure that the
<code class="literal">
FTS_DOC_ID
</code>
column is updated when the
<code class="literal">
FULLTEXT
</code>
indexed column is updated, as
the
<code class="literal">
FTS_DOC_ID
</code>
must increase
monotonically with each
<a class="link" href="insert.html" title="15.2.7 INSERT Statement">
<code class="literal">
INSERT
</code>
</a>
or
<a class="link" href="update.html" title="15.2.17 UPDATE Statement">
<code class="literal">
UPDATE
</code>
</a>
. If you choose not
to add the
<code class="literal">
FTS_DOC_ID
</code>
at table creation
time and have
<code class="literal">
InnoDB
</code>
manage DOC IDs for
you,
<code class="literal">
InnoDB
</code>
adds the
<code class="literal">
FTS_DOC_ID
</code>
as a hidden column with the
next
<a class="link" href="create-index.html" title="15.1.15 CREATE INDEX Statement">
<code class="literal">
CREATE
FULLTEXT INDEX
</code>
</a>
call. This approach, however,
requires a table rebuild which can impact performance.
</p>
</div>
</li>
<li class="listitem">
<p>
If loading data into a
<span class="emphasis">
<em>
new
</em>
</span>
MySQL
instance, consider disabling redo logging using
<a class="link" href="alter-instance.html" title="15.1.5 ALTER INSTANCE Statement">
<code class="literal">
ALTER
INSTANCE {ENABLE|DISABLE} INNODB REDO_LOG
</code>
</a>
syntax.
Disabling redo logging helps speed up data loading by
avoiding redo log writes. For more information, see
<a class="xref" href="innodb-redo-log.html#innodb-disable-redo-logging" title="Disabling Redo Logging">
Disabling Redo Logging
</a>
.
</p>
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Warning
</div>
<p>
This feature is intended only for loading data into a new
MySQL instance.
<span class="emphasis">
<em>
Do not disable redo logging on a
production system.
</em>
</span>
It is permitted to shutdown
and restart the server while redo logging is disabled, but
an unexpected server stoppage while redo logging is
disabled can cause data loss and instance corruption.
</p>
</div>
</li>
<li class="listitem">
<p>
Use MySQL Shell to import data. MySQL Shell's parallel
table import utility
<code class="literal">
util.importTable()
</code>
provides rapid data import to a MySQL relational table for
large data files. MySQL Shell's dump loading utility
<code class="literal">
util.loadDump()
</code>
also offers parallel load
capabilities. See
<a class="ulink" href="/doc/mysql-shell/8.4/en/mysql-shell-utilities.html" target="_top">
MySQL Shell Utilities
</a>
.
</p>
</li>
</ul>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/innodb-buffer-pool-in-core-file.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="innodb-buffer-pool-in-core-file">
</a>
17.8.3.7 Excluding or Including Buffer Pool Pages from Core Files
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045162873840">
</a>
<a class="indexterm" name="idm46045162872352">
</a>
<a class="indexterm" name="idm46045162871280">
</a>
<a class="indexterm" name="idm46045162870240">
</a>
<p>
A core file records the status and memory image of a running
process. Because the buffer pool resides in main memory, and the
memory image of a running process is dumped to the core file,
systems with large buffer pools can produce large core files
when the
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
process dies.
</p>
<p>
Large core files can be problematic for a number of reasons
including the time it takes to write them, the amount of disk
space they consume, and the challenges associated with
transferring large files.
</p>
<p>
Excluding buffer pool pages may also be desirable from a
security perspective if you have concerns about dumping database
pages to core files that may be shared inside or outside of your
organization for debugging purposes.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
Access to the data present in buffer pool pages at the time
the
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
process died may be beneficial
in some debugging scenarios. If in doubt whether to include or
exclude buffer pool pages, consult MySQL Support.
</p>
</div>
<p>
The
<a class="link" href="innodb-parameters.html#sysvar_innodb_buffer_pool_in_core_file">
<code class="literal">
innodb_buffer_pool_in_core_file
</code>
</a>
option is only relevant if the
<a class="link" href="server-system-variables.html#sysvar_core_file">
<code class="literal">
core_file
</code>
</a>
variable is enabled
and the operating system supports the
<code class="literal">
MADV_DONTDUMP
</code>
non-POSIX extension to the
<a class="ulink" href="http://man7.org/linux/man-pages/man2/madvise.2.html" target="_blank">
madvise()
</a>
system call, which is supported in Linux 3.4 and later. The
<code class="literal">
MADV_DONTDUMP
</code>
extension causes pages in a
specified range to be excluded from core dumps. The
<a class="link" href="innodb-parameters.html#sysvar_innodb_buffer_pool_in_core_file">
<code class="literal">
innodb_buffer_pool_in_core_file
</code>
</a>
option is disabled by default on systems that support
MADV_DONTDUMP, otherwise it defaults to ON.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
Before MySQL 8.4,
<a class="link" href="innodb-parameters.html#sysvar_innodb_buffer_pool_in_core_file">
<code class="literal">
innodb_buffer_pool_in_core_file
</code>
</a>
was enabled by default instead of disabled.
</p>
</div>
<p>
To generate core files with buffer pool pages, start the server
with the
<a class="link" href="server-options.html#option_mysqld_core-file">
<code class="option">
--core-file
</code>
</a>
and
<a class="link" href="innodb-parameters.html#sysvar_innodb_buffer_pool_in_core_file">
<code class="literal">
--innodb-buffer-pool-in-core-file=ON
</code>
</a>
options.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa52196881"><div class="copy-help left">Press ⌘+C to 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 property">--core-file</span> <span class="token constant">--innodb-buffer-pool-in-core-file</span><span class="token attr-value"><span class="token punctuation">=</span>ON</span></code></pre>
</div>
<p>
The
<a class="link" href="server-system-variables.html#sysvar_core_file">
<code class="literal">
core_file
</code>
</a>
variable is
read-only and disabled by default. It is enabled by specifying
the
<a class="link" href="server-options.html#option_mysqld_core-file">
<code class="option">
--core-file
</code>
</a>
option at
startup. The
<a class="link" href="innodb-parameters.html#sysvar_innodb_buffer_pool_in_core_file">
<code class="literal">
innodb_buffer_pool_in_core_file
</code>
</a>
variable is dynamic. It can be specified at startup or
configured at runtime using a
<a class="link" href="set-variable.html" title="15.7.6.1 SET Syntax for Variable Assignment">
<code class="literal">
SET
</code>
</a>
statement.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa35446095"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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> innodb_buffer_pool_in_core_file<span class="token operator">=</span><span class="token keyword">OFF</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
If the
<a class="link" href="innodb-parameters.html#sysvar_innodb_buffer_pool_in_core_file">
<code class="literal">
innodb_buffer_pool_in_core_file
</code>
</a>
variable is disabled but
<code class="literal">
MADV_DONTDUMP
</code>
is not
supported by the operating system, or an
<code class="literal">
madvise()
</code>
failure occurs, a warning is
written to the MySQL server error log and the
<a class="link" href="server-system-variables.html#sysvar_core_file">
<code class="literal">
core_file
</code>
</a>
variable is disabled
to prevent writing core files that unintentionally include
buffer pool pages. If the read-only
<a class="link" href="server-system-variables.html#sysvar_core_file">
<code class="literal">
core_file
</code>
</a>
variable becomes
disabled, the server must be restarted to enable it again.
</p>
<p>
The following table shows configuration and
<code class="literal">
MADV_DONTDUMP
</code>
support scenarios that
determine whether core files are generated and whether they
include buffer pool pages.
</p>
<div class="table">
<a name="innodb-buffer-pool-in-core-file-configuration-scenarios">
</a>
<p class="title">
<b>
Table 17.4 Core File Configuration Scenarios
</b>
</p>
<div class="table-contents">
<table summary="Core file configuration and MADV_DONTDUMP support scenarios.">
<colgroup>
<col style="width: 20%"/>
<col style="width: 20%"/>
<col style="width: 20%"/>
<col style="width: 40%"/>
</colgroup>
<thead>
<tr>
<th scope="col">
<a class="link" href="server-system-variables.html#sysvar_core_file">
<code class="literal">
core_file
</code>
</a>
variable
</th>
<th scope="col">
<a class="link" href="innodb-parameters.html#sysvar_innodb_buffer_pool_in_core_file">
<code class="literal">
innodb_buffer_pool_in_core_file
</code>
</a>
variable
</th>
<th scope="col">
madvise() MADV_DONTDUMP Support
</th>
<th scope="col">
Outcome
</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">
OFF (default)
</th>
<td>
Not relevant to outcome
</td>
<td>
Not relevant to outcome
</td>
<td>
Core file is not generated
</td>
</tr>
<tr>
<th scope="row">
ON
</th>
<td>
ON (default on systems without
<code class="literal">
MADV_DONTDUMP
</code>
support)
</td>
<td>
Not relevant to outcome
</td>
<td>
Core file is generated with buffer pool pages
</td>
</tr>
<tr>
<th scope="row">
ON
</th>
<td>
OFF (default on systems with
<code class="literal">
MADV_DONTDUMP
</code>
support)
</td>
<td>
Yes
</td>
<td>
Core file is generated without buffer pool pages
</td>
</tr>
<tr>
<th scope="row">
ON
</th>
<td>
OFF
</td>
<td>
No
</td>
<td>
Core file is not generated,
<a class="link" href="server-system-variables.html#sysvar_core_file">
<code class="literal">
core_file
</code>
</a>
is disabled, and a warning is written to the server error
log
</td>
</tr>
</tbody>
</table>
</div>
</div>
<br class="table-break"/>
<p>
The reduction in core file size achieved by disabling the
<a class="link" href="innodb-parameters.html#sysvar_innodb_buffer_pool_in_core_file">
<code class="literal">
innodb_buffer_pool_in_core_file
</code>
</a>
variable depends on the size of the buffer pool, but it is also
affected by the
<code class="literal">
InnoDB
</code>
page size. A smaller
page size means more pages are required for the same amount of
data, and more pages means more page metadata. The following
table provides size reduction examples that you might see for a
1GB buffer pool with different pages sizes.
</p>
<div class="table">
<a name="innodb-buffer-pool-in-core-file-size-examples">
</a>
<p class="title">
<b>
Table 17.5 Core File Size with Buffer Pool Pages Included and Excluded
</b>
</p>
<div class="table-contents">
<table summary="Core file size reduction examples for different pages sizes.">
<colgroup>
<col style="width: 20%"/>
<col style="width: 20%"/>
<col style="width: 20%"/>
</colgroup>
<thead>
<tr>
<th scope="col">
<a class="link" href="innodb-parameters.html#sysvar_innodb_page_size">
<code class="literal">
innodb_page_size
</code>
</a>
Setting
</th>
<th scope="col">
Buffer Pool Pages Included
(
<a class="link" href="innodb-parameters.html#sysvar_innodb_buffer_pool_in_core_file">
<code class="literal">
innodb_buffer_pool_in_core_file=ON
</code>
</a>
)
</th>
<th scope="col">
Buffer Pool Pages Excluded
(
<a class="link" href="innodb-parameters.html#sysvar_innodb_buffer_pool_in_core_file">
<code class="literal">
innodb_buffer_pool_in_core_file=OFF
</code>
</a>
)
</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">
4KB
</th>
<td>
2.1GB
</td>
<td>
0.9GB
</td>
</tr>
<tr>
<th scope="row">
64KB
</th>
<td>
1.7GB
</td>
<td>
0.7GB
</td>
</tr>
</tbody>
</table>
</div>
</div>
<br class="table-break"/>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/charset-unicode-sets.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="charset-unicode-sets">
</a>
12.10.1 Unicode Character Sets
</h3>
</div>
</div>
</div>
<a class="indexterm" name="idm46045216397808">
</a>
<a class="indexterm" name="idm46045216396320">
</a>
<p>
This section describes the collations available for Unicode
character sets and their differentiating properties. For general
information about Unicode, see
<a class="xref" href="charset-unicode.html" title="12.9 Unicode Support">
Section 12.9, “Unicode Support”
</a>
.
</p>
<p>
MySQL supports multiple Unicode character sets:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
utf8mb4
</code>
: A UTF-8 encoding of the Unicode
character set using one to four bytes per character.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
utf8mb3
</code>
: A UTF-8 encoding of the Unicode
character set using one to three bytes per character. This
character set is deprecated; please use
<code class="literal">
utf8mb4
</code>
instead.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
utf8
</code>
: A deprecated alias for
<code class="literal">
utf8mb3
</code>
. Use
<code class="literal">
utf8mb4
</code>
instead.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
<code class="literal">
utf8
</code>
is expected in a future release to
become an alias for
<code class="literal">
utf8mb4
</code>
.
</p>
</div>
</li>
<li class="listitem">
<p>
<code class="literal">
ucs2
</code>
: The UCS-2 encoding of the Unicode
character set using two bytes per character. Deprecated;
expect support for this character set to be removed in a
future version of MySQL.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
utf16
</code>
: The UTF-16 encoding for the
Unicode character set using two or four bytes per character.
Like
<code class="literal">
ucs2
</code>
but with an extension for
supplementary characters.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
utf16le
</code>
: The UTF-16LE encoding for the
Unicode character set. Like
<code class="literal">
utf16
</code>
but
little-endian rather than big-endian.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
utf32
</code>
: The UTF-32 encoding for the
Unicode character set using four bytes per character.
</p>
</li>
</ul>
</div>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
The
<code class="literal">
utf8mb3
</code>
character set is deprecated and
you should expect it to be removed in a future MySQL release.
Please use
<code class="literal">
utf8mb4
</code>
instead.
<code class="literal">
utf8
</code>
is currently an alias for
<code class="literal">
utf8mb3
</code>
, but it is now deprecated as such,
and
<code class="literal">
utf8
</code>
is expected subsequently to become
a reference to
<code class="literal">
utf8mb4
</code>
.
<code class="literal">
utf8mb3
</code>
is also displayed in place of
<code class="literal">
utf8
</code>
in columns of Information Schema
tables, and in the output of SQL
<code class="literal">
SHOW
</code>
statements.
</p>
<p>
To avoid ambiguity about the meaning of
<code class="literal">
utf8
</code>
, consider specifying
<code class="literal">
utf8mb4
</code>
explicitly for character set
references.
</p>
</div>
<p>
<code class="literal">
utf8mb4
</code>
,
<code class="literal">
utf16
</code>
,
<code class="literal">
utf16le
</code>
, and
<code class="literal">
utf32
</code>
support
Basic Multilingual Plane (BMP) characters and supplementary
characters that lie outside the BMP.
<code class="literal">
utf8mb3
</code>
and
<code class="literal">
ucs2
</code>
support only BMP characters.
</p>
<p>
Most Unicode character sets have a general collation (indicated
by
<code class="literal">
_general
</code>
in the name or by the absence of
a language specifier), a binary collation (indicated by
<code class="literal">
_bin
</code>
in the name), and several
language-specific collations (indicated by language specifiers).
For example, for
<code class="literal">
utf8mb4
</code>
,
<code class="literal">
utf8mb4_general_ci
</code>
and
<code class="literal">
utf8mb4_bin
</code>
are its general and binary
collations, and
<code class="literal">
utf8mb4_danish_ci
</code>
is one of
its language-specific collations.
</p>
<a class="indexterm" name="idm46045216355328">
</a>
<a class="indexterm" name="idm46045216353840">
</a>
<p>
Most character sets have a single binary collation.
<code class="literal">
utf8mb4
</code>
is an exception that has two:
<code class="literal">
utf8mb4_bin
</code>
and
<code class="literal">
utf8mb4_0900_bin
</code>
. These two binary collations
have the same sort order but are distinguished by their pad
attribute and collating weight characteristics. See
<a class="xref" href="charset-unicode-sets.html#charset-unicode-sets-pad-attributes" title="Collation Pad Attributes">
Collation Pad Attributes
</a>
, and
<a class="xref" href="charset-unicode-sets.html#charset-unicode-sets-collating-weights" title="Character Collating Weights">
Character Collating Weights
</a>
.
</p>
<p>
Collation support for
<code class="literal">
utf16le
</code>
is limited. The
only collations available are
<code class="literal">
utf16le_general_ci
</code>
and
<code class="literal">
utf16le_bin
</code>
. These are similar to
<code class="literal">
utf16_general_ci
</code>
and
<code class="literal">
utf16_bin
</code>
.
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="xref" href="charset-unicode-sets.html#charset-unicode-sets-uca" title="Unicode Collation Algorithm (UCA) Versions">
Unicode Collation Algorithm (UCA) Versions
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="charset-unicode-sets.html#charset-unicode-sets-pad-attributes" title="Collation Pad Attributes">
Collation Pad Attributes
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="charset-unicode-sets.html#charset-unicode-sets-language-specific-collations" title="Language-Specific Collations">
Language-Specific Collations
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="charset-unicode-sets.html#charset-unicode-sets-general-versus-unicode" title="_general_ci Versus _unicode_ci Collations">
_general_ci Versus _unicode_ci Collations
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="charset-unicode-sets.html#charset-unicode-sets-collating-weights" title="Character Collating Weights">
Character Collating Weights
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="charset-unicode-sets.html#charset-unicode-sets-miscellaneous" title="Miscellaneous Information">
Miscellaneous Information
</a>
</p>
</li>
</ul>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h4 class="title">
<a name="charset-unicode-sets-uca">
</a>
Unicode Collation Algorithm (UCA) Versions
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045216336032">
</a>
<p>
MySQL implements the
<code class="literal">
<em class="replaceable">
<code>
xxx
</code>
</em>
_unicode_ci
</code>
collations according to the Unicode Collation Algorithm (UCA)
described at
<a class="ulink" href="http://www.unicode.org/reports/tr10/" target="_blank">
http://www.unicode.org/reports/tr10/
</a>
. The
collation uses the version-4.0.0 UCA weight keys:
<a class="ulink" href="http://www.unicode.org/Public/UCA/4.0.0/allkeys-4.0.0.txt" target="_blank">
http://www.unicode.org/Public/UCA/4.0.0/allkeys-4.0.0.txt
</a>
.
The
<code class="literal">
<em class="replaceable">
<code>
xxx
</code>
</em>
_unicode_ci
</code>
collations have only partial support for the Unicode Collation
Algorithm. Some characters are not supported, and combining
marks are not fully supported. This affects languages such as
Vietnamese, Yoruba, and Navajo. A combined character is
considered different from the same character written with a
single unicode character in string comparisons, and the two
characters are considered to have a different length (for
example, as returned by the
<a class="link" href="string-functions.html#function_char-length">
<code class="literal">
CHAR_LENGTH()
</code>
</a>
function or in
result set metadata).
</p>
<p>
Unicode collations based on UCA versions higher than 4.0.0
include the version in the collation name. Examples:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
utf8mb4_unicode_520_ci
</code>
is based on UCA
5.2.0 weight keys
(
<a class="ulink" href="http://www.unicode.org/Public/UCA/5.2.0/allkeys.txt" target="_blank">
http://www.unicode.org/Public/UCA/5.2.0/allkeys.txt
</a>
),
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
utf8mb4_0900_ai_ci
</code>
is based on UCA
9.0.0 weight keys
(
<a class="ulink" href="http://www.unicode.org/Public/UCA/9.0.0/allkeys.txt" target="_blank">
http://www.unicode.org/Public/UCA/9.0.0/allkeys.txt
</a>
).
</p>
</li>
</ul>
</div>
<p>
The
<a class="link" href="string-functions.html#function_lower">
<code class="literal">
LOWER()
</code>
</a>
and
<a class="link" href="string-functions.html#function_upper">
<code class="literal">
UPPER()
</code>
</a>
functions perform case
folding according to the collation of their argument. A
character that has uppercase and lowercase versions only in a
Unicode version higher than 4.0.0 is converted by these
functions only if the argument collation uses a high enough
UCA version.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h4 class="title">
<a name="charset-unicode-sets-pad-attributes">
</a>
Collation Pad Attributes
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045216319584">
</a>
<a class="indexterm" name="idm46045216318096">
</a>
<a class="indexterm" name="idm46045216317024">
</a>
<a class="indexterm" name="idm46045216315536">
</a>
<p>
Collations based on UCA 9.0.0 and higher are faster than
collations based on UCA versions prior to 9.0.0. They also
have a pad attribute of
<code class="literal">
NO PAD
</code>
, in contrast
to
<code class="literal">
PAD SPACE
</code>
as used in collations based on
UCA versions prior to 9.0.0. For comparison of nonbinary
strings,
<code class="literal">
NO PAD
</code>
collations treat spaces at
the end of strings like any other character (see
<a class="xref" href="charset-binary-collations.html#charset-binary-collations-trailing-space-comparisons" title="Trailing Space Handling in Comparisons">
Trailing Space Handling in Comparisons
</a>
).
</p>
<p>
To determine the pad attribute for a collation, use the
<code class="literal">
INFORMATION_SCHEMA
</code>
<a class="link" href="information-schema-collations-table.html" title="28.3.6 The INFORMATION_SCHEMA COLLATIONS Table">
<code class="literal">
COLLATIONS
</code>
</a>
table, which has a
<code class="literal">
PAD_ATTRIBUTE
</code>
column. For example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa84975734"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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> COLLATION_NAME<span class="token punctuation">,</span> PAD_ATTRIBUTE
<span class="token keyword">FROM</span> INFORMATION_SCHEMA<span class="token punctuation">.</span>COLLATIONS
<span class="token keyword">WHERE</span> CHARACTER_SET_NAME <span class="token operator">=</span> <span class="token string">'utf8mb4'</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>
<span class="token output"><span class="token punctuation">|</span> COLLATION_NAME <span class="token punctuation">|</span> PAD_ATTRIBUTE <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> utf8mb4_general_ci <span class="token punctuation">|</span> PAD SPACE <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> utf8mb4_bin <span class="token punctuation">|</span> PAD SPACE <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> utf8mb4_unicode_ci <span class="token punctuation">|</span> PAD SPACE <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> utf8mb4_icelandic_ci <span class="token punctuation">|</span> PAD SPACE <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> utf8mb4_0900_ai_ci <span class="token punctuation">|</span> NO PAD <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> utf8mb4_de_pb_0900_ai_ci <span class="token punctuation">|</span> NO PAD <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> utf8mb4_is_0900_ai_ci <span class="token punctuation">|</span> NO PAD <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> utf8mb4_ja_0900_as_cs <span class="token punctuation">|</span> NO PAD <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> utf8mb4_ja_0900_as_cs_ks <span class="token punctuation">|</span> NO PAD <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> utf8mb4_0900_as_ci <span class="token punctuation">|</span> NO PAD <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> utf8mb4_ru_0900_ai_ci <span class="token punctuation">|</span> NO PAD <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> utf8mb4_ru_0900_as_cs <span class="token punctuation">|</span> NO PAD <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> utf8mb4_zh_0900_as_cs <span class="token punctuation">|</span> NO PAD <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> utf8mb4_0900_bin <span class="token punctuation">|</span> NO PAD <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></code></pre>
</div>
<p>
Comparison of nonbinary string values
(
<code class="literal">
CHAR
</code>
,
<code class="literal">
VARCHAR
</code>
, and
<code class="literal">
TEXT
</code>
) that have a
<code class="literal">
NO PAD
</code>
collation differ from other collations with respect to
trailing spaces. For example,
<code class="literal">
'a'
</code>
and
<code class="literal">
'a '
</code>
compare as different strings, not
the same string. This can be seen using the binary collations
for
<code class="literal">
utf8mb4
</code>
. The pad attribute for
<code class="literal">
utf8mb4_bin
</code>
is
<code class="literal">
PAD
SPACE
</code>
, whereas for
<code class="literal">
utf8mb4_0900_bin
</code>
it is
<code class="literal">
NO
PAD
</code>
. Consequently, operations involving
<code class="literal">
utf8mb4_0900_bin
</code>
do not add trailing
spaces, and comparisons involving strings with trailing spaces
may differ for the two collations:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa33434406"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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> t1 <span class="token punctuation">(</span>c <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">COLLATE</span> utf8mb4_bin<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected (0.03 sec)</span>
<span class="token prompt">mysql></span> <span class="token keyword">INSERT</span> <span class="token keyword">INTO</span> t1 <span class="token keyword">VALUES</span><span class="token punctuation">(</span><span class="token string">'a'</span><span class="token punctuation">)</span><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">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t1 <span class="token keyword">WHERE</span> c <span class="token operator">=</span> <span class="token string">'a '</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>
<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> a <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">ALTER</span> <span class="token keyword">TABLE</span> t1 <span class="token keyword">MODIFY</span> c <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">COLLATE</span> utf8mb4_0900_bin<span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected (0.02 sec)</span>
<span class="token output">Records: 0 Duplicates: 0 Warnings: 0</span>
<span class="token prompt">mysql></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> c <span class="token operator">=</span> <span class="token string">'a '</span><span class="token punctuation">;</span>
<span class="token output">Empty set (0.00 sec)</span></code></pre>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h4 class="title">
<a name="charset-unicode-sets-language-specific-collations">
</a>
Language-Specific Collations
</h4>
</div>
</div>
</div>
<p>
MySQL implements language-specific Unicode collations if the
ordering based only on the Unicode Collation Algorithm (UCA)
does not work well for a language. Language-specific
collations are UCA-based, with additional language tailoring
rules. Examples of such rules appear later in this section.
For questions about particular language orderings,
<a class="ulink" href="http://unicode.org" target="_blank">
http://unicode.org
</a>
provides Common Locale Data
Repository (CLDR) collation charts at
<a class="ulink" href="http://www.unicode.org/cldr/charts/30/collation/index.html" target="_blank">
http://www.unicode.org/cldr/charts/30/collation/index.html
</a>
.
</p>
<a class="indexterm" name="idm46045216286608">
</a>
<p>
For example, the nonlanguage-specific
<code class="literal">
utf8mb4_0900_ai_ci
</code>
and language-specific
<code class="literal">
utf8mb4_
<em class="replaceable">
<code>
LOCALE
</code>
</em>
_0900_ai_ci
</code>
Unicode collations each have these characteristics:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
The collation is based on UCA 9.0.0 and CLDR v30, is
accent-insensitive and case-insensitive. These
characteristics are indicated by
<code class="literal">
_0900
</code>
,
<code class="literal">
_ai
</code>
, and
<code class="literal">
_ci
</code>
in the
collation name. Exception:
<code class="literal">
utf8mb4_la_0900_ai_ci
</code>
is not based on
CLDR because Classical Latin is not defined in CLDR.
</p>
</li>
<li class="listitem">
<p>
The collation works for all characters in the range [U+0,
U+10FFFF].
</p>
</li>
<li class="listitem">
<p>
If the collation is not language specific, it sorts all
characters, including supplementary characters, in default
order (described following). If the collation is language
specific, it sorts characters of the language correctly
according to language-specific rules, and characters not
in the language in default order.
</p>
</li>
<li class="listitem">
<p>
By default, the collation sorts characters having a code
point listed in the DUCET table (Default Unicode Collation
Element Table) according to the weight value assigned in
the table. The collation sorts characters not having a
code point listed in the DUCET table using their implicit
weight value, which is constructed according to the UCA.
</p>
</li>
<li class="listitem">
<p>
For non-language-specific collations, characters in
contraction sequences are treated as separate characters.
For language-specific collations, contractions might
change character sorting order.
</p>
</li>
</ul>
</div>
<p>
A collation name that includes a locale code or language name
shown in the following table is a language-specific collation.
Unicode character sets may include collations for one or more
of these languages.
</p>
<div class="table">
<a name="charset-unicode-collation-language-specifiers">
</a>
<p class="title">
<b>
Table 12.3 Unicode Collation Language Specifiers
</b>
</p>
<div class="table-contents">
<table summary="Language specifiers for Unicode character set collations.">
<colgroup>
<col style="width: 40%"/>
<col style="width: 60%"/>
</colgroup>
<thead>
<tr>
<th>
Language
</th>
<th>
Language Specifier
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
Bosnian
</td>
<td>
<code class="literal">
bs
</code>
</td>
</tr>
<tr>
<td>
Bulgarian
</td>
<td>
<code class="literal">
bg
</code>
</td>
</tr>
<tr>
<td>
Chinese
</td>
<td>
<code class="literal">
zh
</code>
</td>
</tr>
<tr>
<td>
Classical Latin
</td>
<td>
<code class="literal">
la
</code>
or
<code class="literal">
roman
</code>
</td>
</tr>
<tr>
<td>
Croatian
</td>
<td>
<code class="literal">
hr
</code>
or
<code class="literal">
croatian
</code>
</td>
</tr>
<tr>
<td>
Czech
</td>
<td>
<code class="literal">
cs
</code>
or
<code class="literal">
czech
</code>
</td>
</tr>
<tr>
<td>
Danish
</td>
<td>
<code class="literal">
da
</code>
or
<code class="literal">
danish
</code>
</td>
</tr>
<tr>
<td>
Esperanto
</td>
<td>
<code class="literal">
eo
</code>
or
<code class="literal">
esperanto
</code>
</td>
</tr>
<tr>
<td>
Estonian
</td>
<td>
<code class="literal">
et
</code>
or
<code class="literal">
estonian
</code>
</td>
</tr>
<tr>
<td>
Galician
</td>
<td>
<code class="literal">
gl
</code>
</td>
</tr>
<tr>
<td>
German phone book order
</td>
<td>
<code class="literal">
de_pb
</code>
or
<code class="literal">
german2
</code>
</td>
</tr>
<tr>
<td>
Hungarian
</td>
<td>
<code class="literal">
hu
</code>
or
<code class="literal">
hungarian
</code>
</td>
</tr>
<tr>
<td>
Icelandic
</td>
<td>
<code class="literal">
is
</code>
or
<code class="literal">
icelandic
</code>
</td>
</tr>
<tr>
<td>
Japanese
</td>
<td>
<code class="literal">
ja
</code>
</td>
</tr>
<tr>
<td>
Latvian
</td>
<td>
<code class="literal">
lv
</code>
or
<code class="literal">
latvian
</code>
</td>
</tr>
<tr>
<td>
Lithuanian
</td>
<td>
<code class="literal">
lt
</code>
or
<code class="literal">
lithuanian
</code>
</td>
</tr>
<tr>
<td>
Mongolian
</td>
<td>
<code class="literal">
mn
</code>
</td>
</tr>
<tr>
<td>
Norwegian / Bokmål
</td>
<td>
<code class="literal">
nb
</code>
</td>
</tr>
<tr>
<td>
Norwegian / Nynorsk
</td>
<td>
<code class="literal">
nn
</code>
</td>
</tr>
<tr>
<td>
Persian
</td>
<td>
<code class="literal">
persian
</code>
</td>
</tr>
<tr>
<td>
Polish
</td>
<td>
<code class="literal">
pl
</code>
or
<code class="literal">
polish
</code>
</td>
</tr>
<tr>
<td>
Romanian
</td>
<td>
<code class="literal">
ro
</code>
or
<code class="literal">
romanian
</code>
</td>
</tr>
<tr>
<td>
Russian
</td>
<td>
<code class="literal">
ru
</code>
</td>
</tr>
<tr>
<td>
Serbian
</td>
<td>
<code class="literal">
sr
</code>
</td>
</tr>
<tr>
<td>
Sinhala
</td>
<td>
<code class="literal">
sinhala
</code>
</td>
</tr>
<tr>
<td>
Slovak
</td>
<td>
<code class="literal">
sk
</code>
or
<code class="literal">
slovak
</code>
</td>
</tr>
<tr>
<td>
Slovenian
</td>
<td>
<code class="literal">
sl
</code>
or
<code class="literal">
slovenian
</code>
</td>
</tr>
<tr>
<td>
Modern Spanish
</td>
<td>
<code class="literal">
es
</code>
or
<code class="literal">
spanish
</code>
</td>
</tr>
<tr>
<td>
Traditional Spanish
</td>
<td>
<code class="literal">
es_trad
</code>
or
<code class="literal">
spanish2
</code>
</td>
</tr>
<tr>
<td>
Swedish
</td>
<td>
<code class="literal">
sv
</code>
or
<code class="literal">
swedish
</code>
</td>
</tr>
<tr>
<td>
Turkish
</td>
<td>
<code class="literal">
tr
</code>
or
<code class="literal">
turkish
</code>
</td>
</tr>
<tr>
<td>
Vietnamese
</td>
<td>
<code class="literal">
vi
</code>
or
<code class="literal">
vietnamese
</code>
</td>
</tr>
</tbody>
</table>
</div>
<div class="table-contents">
<table cellpadding="0" cellspacing="0" style="position: fixed; top: 0px; display: none; left: 401px; width: 442px;">
<thead>
<tr>
<th style="width: 176.281px;">
Language
</th>
<th style="width: 264.422px;">
Language Specifier
</th>
</tr>
</thead>
</table>
</div>
</div>
<br class="table-break"/>
<p>
MySQL provides the Bulgarian collations
<code class="literal">
utf8mb4_bg_0900_ai_ci
</code>
and
<code class="literal">
utf8mb4_bg_0900_as_cs
</code>
.
</p>
<p>
Croatian collations are tailored for these Croatian letters:
<code class="literal">
Č
</code>
,
<code class="literal">
Ć
</code>
,
<code class="literal">
Dž
</code>
,
<code class="literal">
Đ
</code>
,
<code class="literal">
Lj
</code>
,
<code class="literal">
Nj
</code>
,
<code class="literal">
Š
</code>
,
<code class="literal">
Ž
</code>
.
</p>
<p>
MySQL provides the
<code class="literal">
utf8mb4_sr_latn_0900_ai_ci
</code>
and
<code class="literal">
utf8mb4_sr_latn_0900_as_cs
</code>
collations for
Serbian and the
<code class="literal">
utf8mb4_bs_0900_ai_ci
</code>
and
<code class="literal">
utf8mb4_bs_0900_as_cs
</code>
collations for
Bosnian, when these languages are written with the Latin
alphabet.
</p>
<p>
MySQL provides collations for both major varieties of
Norwegian: for Bokmål, you can use
<code class="literal">
utf8mb4_nb_0900_ai_ci
</code>
and
<code class="literal">
utf8mb4_nb_0900_as_cs
</code>
; for Nynorsk, MySQL
now provides
<code class="literal">
utf8mb4_nn_0900_ai_ci
</code>
and
<code class="literal">
utf8mb4_nn_0900_as_cs
</code>
.
</p>
<p>
For Japanese, the
<code class="literal">
utf8mb4
</code>
character set
includes
<code class="literal">
utf8mb4_ja_0900_as_cs
</code>
and
<code class="literal">
utf8mb4_ja_0900_as_cs_ks
</code>
collations. Both
collations are accent-sensitive and case-sensitive.
<code class="literal">
utf8mb4_ja_0900_as_cs_ks
</code>
is also
kana-sensitive and distinguishes Katakana characters from
Hiragana characters, whereas
<code class="literal">
utf8mb4_ja_0900_as_cs
</code>
treats Katakana and
Hiragana characters as equal for sorting. Applications that
require a Japanese collation but not kana sensitivity may use
<code class="literal">
utf8mb4_ja_0900_as_cs
</code>
for better sort
performance.
<code class="literal">
utf8mb4_ja_0900_as_cs
</code>
uses
three weight levels for sorting;
<code class="literal">
utf8mb4_ja_0900_as_cs_ks
</code>
uses four.
</p>
<p>
For Classical Latin collations that are accent-insensitive,
<code class="literal">
I
</code>
and
<code class="literal">
J
</code>
compare as
equal, and
<code class="literal">
U
</code>
and
<code class="literal">
V
</code>
compare as equal.
<code class="literal">
I
</code>
and
<code class="literal">
J
</code>
, and
<code class="literal">
U
</code>
and
<code class="literal">
V
</code>
compare as equal on the base letter
level. In other words,
<code class="literal">
J
</code>
is regarded as an
accented
<code class="literal">
I
</code>
, and
<code class="literal">
U
</code>
is
regarded as an accented
<code class="literal">
V
</code>
.
</p>
<p>
MySQL provides collations for the Mongolian language when
written with Cyrillic characters,
<code class="literal">
utf8mb4_mn_cyrl_0900_ai_ci
</code>
and
<code class="literal">
utf8mb4_mn_cyrl_0900_as_cs
</code>
.
</p>
<p>
Spanish collations are available for modern and traditional
Spanish. For both,
<code class="literal">
ñ
</code>
(n-tilde) is a
separate letter between
<code class="literal">
n
</code>
and
<code class="literal">
o
</code>
. In addition, for traditional Spanish,
<code class="literal">
ch
</code>
is a separate letter between
<code class="literal">
c
</code>
and
<code class="literal">
d
</code>
, and
<code class="literal">
ll
</code>
is a separate letter between
<code class="literal">
l
</code>
and
<code class="literal">
m
</code>
.
</p>
<p>
Traditional Spanish collations may also be used for Asturian
and Galician. MySQL also provides
<code class="literal">
utf8mb4_gl_0900_ai_ci
</code>
and
<code class="literal">
utf8mb4_gl_0900_as_cs
</code>
collations for
Galician. (These are the same collations as
<code class="literal">
utf8mb4_es_0900_ai_ci
</code>
and
<code class="literal">
utf8mb4_es_0900_as_cs
</code>
, respectively.)
</p>
<p>
Swedish collations include Swedish rules. For example, in
Swedish, the following relationship holds, which is not
something expected by a German or French speaker:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-none"><div class="docs-select-all right" id="sa25434254"><div class="copy-help left">Press ⌘+C to 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">Ü = Y < Ö</code></pre>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h4 class="title">
<a name="charset-unicode-sets-general-versus-unicode">
</a>
_general_ci Versus _unicode_ci Collations
</h4>
</div>
</div>
</div>
<p>
For any Unicode character set, operations performed using the
<code class="literal">
<em class="replaceable">
<code>
xxx
</code>
</em>
_general_ci
</code>
collation are faster than those for the
<code class="literal">
<em class="replaceable">
<code>
xxx
</code>
</em>
_unicode_ci
</code>
collation. For example, comparisons for the
<code class="literal">
utf8mb4_general_ci
</code>
collation are faster,
but slightly less correct, than comparisons for
<code class="literal">
utf8mb4_unicode_ci
</code>
. The reason is that
<code class="literal">
utf8mb4_unicode_ci
</code>
supports mappings such
as expansions; that is, when one character compares as equal
to combinations of other characters. For example,
<code class="literal">
ß
</code>
is equal to
<code class="literal">
ss
</code>
in
German and some other languages.
<code class="literal">
utf8mb4_unicode_ci
</code>
also supports
contractions and ignorable characters.
<code class="literal">
utf8mb4_general_ci
</code>
is a legacy collation
that does not support expansions, contractions, or ignorable
characters. It can make only one-to-one comparisons between
characters.
</p>
<p>
To further illustrate, the following equalities hold in both
<code class="literal">
utf8mb4_general_ci
</code>
and
<code class="literal">
utf8mb4_unicode_ci
</code>
(for the effect of this
in comparisons or searches, see
<a class="xref" href="charset-collation-effect.html" title="12.8.6 Examples of the Effect of Collation">
Section 12.8.6, “Examples of the Effect of Collation”
</a>
):
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-none"><div class="docs-select-all right" id="sa90673352"><div class="copy-help left">Press ⌘+C to 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">Ä = A
Ö = O
Ü = U</code></pre>
</div>
<p>
A difference between the collations is that this is true for
<code class="literal">
utf8mb4_general_ci
</code>
:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-none"><div class="docs-select-all right" id="sa77981180"><div class="copy-help left">Press ⌘+C to 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">ß = s</code></pre>
</div>
<p>
Whereas this is true for
<code class="literal">
utf8mb4_unicode_ci
</code>
, which supports the
German DIN-1 ordering (also known as dictionary order):
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-none"><div class="docs-select-all right" id="sa81299890"><div class="copy-help left">Press ⌘+C to 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">ß = ss</code></pre>
</div>
<p>
MySQL implements language-specific Unicode collations if the
ordering with
<code class="literal">
utf8mb4_unicode_ci
</code>
does not
work well for a language. For example,
<code class="literal">
utf8mb4_unicode_ci
</code>
works fine for German
dictionary order and French, so there is no need to create
special
<code class="literal">
utf8mb4
</code>
collations.
</p>
<p>
<code class="literal">
utf8mb4_general_ci
</code>
also is satisfactory for
both German and French, except that
<code class="literal">
ß
</code>
is
equal to
<code class="literal">
s
</code>
, and not to
<code class="literal">
ss
</code>
. If this is acceptable for your
application, you should use
<code class="literal">
utf8mb4_general_ci
</code>
because it is faster. If
this is not acceptable (for example, if you require German
dictionary order), use
<code class="literal">
utf8mb4_unicode_ci
</code>
because it is more accurate.
</p>
<p>
If you require German DIN-2 (phone book) ordering, use the
<code class="literal">
utf8mb4_german2_ci
</code>
collation, which
compares the following sets of characters equal:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-none"><div class="docs-select-all right" id="sa14616409"><div class="copy-help left">Press ⌘+C to 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">Ä = Æ = AE
Ö = Œ = OE
Ü = UE
ß = ss</code></pre>
</div>
<p>
<code class="literal">
utf8mb4_german2_ci
</code>
is similar to
<code class="literal">
latin1_german2_ci
</code>
, but the latter does not
compare
<code class="literal">
Æ
</code>
equal to
<code class="literal">
AE
</code>
or
<code class="literal">
Œ
</code>
equal to
<code class="literal">
OE
</code>
. There
is no
<code class="literal">
utf8mb4_german_ci
</code>
corresponding to
<code class="literal">
latin1_german_ci
</code>
for German dictionary
order because
<code class="literal">
utf8mb4_general_ci
</code>
suffices.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h4 class="title">
<a name="charset-unicode-sets-collating-weights">
</a>
Character Collating Weights
</h4>
</div>
</div>
</div>
<p>
A character's collating weight is determined as follows:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
For all Unicode collations except the
<code class="literal">
_bin
</code>
(binary) collations, MySQL
performs a table lookup to find a character's collating
weight.
</p>
</li>
<li class="listitem">
<p>
For
<code class="literal">
_bin
</code>
collations except
<code class="literal">
utf8mb4_0900_bin
</code>
, the weight is based
on the code point, possibly with leading zero bytes added.
</p>
</li>
<li class="listitem">
<p>
For
<code class="literal">
utf8mb4_0900_bin
</code>
, the weight is the
<code class="literal">
utf8mb4
</code>
encoding bytes. The sort order
is the same as for
<code class="literal">
utf8mb4_bin
</code>
, but
much faster.
</p>
</li>
</ul>
</div>
<p>
Collating weights can be displayed using the
<a class="link" href="string-functions.html#function_weight-string">
<code class="literal">
WEIGHT_STRING()
</code>
</a>
function. (See
<a class="xref" href="string-functions.html" title="14.8 String Functions and Operators">
Section 14.8, “String Functions and Operators”
</a>
.) If a collation uses a
weight lookup table, but a character is not in the table (for
example, because it is a
<span class="quote">
“
<span class="quote">
new
</span>
”
</span>
character),
collating weight determination becomes more complex:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
For BMP characters in general collations
(
<code class="literal">
<em class="replaceable">
<code>
xxx
</code>
</em>
_general_ci
</code>
),
the weight is the code point.
</p>
</li>
<li class="listitem">
<p>
For BMP characters in UCA collations (for example,
<code class="literal">
<em class="replaceable">
<code>
xxx
</code>
</em>
_unicode_ci
</code>
and language-specific collations), the following algorithm
applies:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-clike"><div class="docs-select-all right" id="sa25616583"><div class="copy-help left">Press ⌘+C to 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 keyword">if</span> <span class="token punctuation">(</span>code <span class="token operator">>=</span> <span class="token number">0x3400</span> <span class="token operator">&&</span> code <span class="token operator"><=</span> <span class="token number">0x4DB5</span><span class="token punctuation">)</span>
base<span class="token operator">=</span> <span class="token number">0xFB80</span><span class="token punctuation">;</span> <span class="token comment" spellcheck="true">/* CJK Ideograph Extension */</span>
<span class="token keyword">else</span> <span class="token keyword">if</span> <span class="token punctuation">(</span>code <span class="token operator">>=</span> <span class="token number">0x4E00</span> <span class="token operator">&&</span> code <span class="token operator"><=</span> <span class="token number">0x9FA5</span><span class="token punctuation">)</span>
base<span class="token operator">=</span> <span class="token number">0xFB40</span><span class="token punctuation">;</span> <span class="token comment" spellcheck="true">/* CJK Ideograph */</span>
<span class="token keyword">else</span>
base<span class="token operator">=</span> <span class="token number">0xFBC0</span><span class="token punctuation">;</span> <span class="token comment" spellcheck="true">/* All other characters */</span>
aaaa<span class="token operator">=</span> base <span class="token operator">+</span> <span class="token punctuation">(</span>code <span class="token operator">></span><span class="token operator">></span> <span class="token number">15</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
bbbb<span class="token operator">=</span> <span class="token punctuation">(</span>code <span class="token operator">&</span> <span class="token number">0x7FFF</span><span class="token punctuation">)</span> <span class="token operator">|</span> <span class="token number">0x8000</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
The result is a sequence of two collating elements,
<code class="literal">
aaaa
</code>
followed by
<code class="literal">
bbbb
</code>
. For example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa52462613"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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">HEX</span><span class="token punctuation">(</span><span class="token function">WEIGHT_STRING</span><span class="token punctuation">(</span>_ucs2 <span class="token number">0x04CF</span> <span class="token keyword">COLLATE</span> ucs2_unicode_ci<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>
<span class="token output"><span class="token punctuation">|</span> HEX(WEIGHT_STRING(_ucs2 0x04CF COLLATE ucs2_unicode_ci)) <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> FBC084CF <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>
Thus,
<code class="literal">
U+04cf CYRILLIC SMALL LETTER
PALOCHKA
</code>
(
<code class="literal">
ӏ
</code>
) is, with all
UCA 4.0.0 collations, greater than
<code class="literal">
U+04c0
CYRILLIC LETTER PALOCHKA
</code>
(
<code class="literal">
Ӏ
</code>
). With UCA 5.2.0 collations, all
palochkas sort together.
</p>
</li>
<li class="listitem">
<p>
For supplementary characters in general collations, the
weight is the weight for
<code class="literal">
0xfffd REPLACEMENT
CHARACTER
</code>
. For supplementary characters in UCA
4.0.0 collations, their collating weight is
<code class="literal">
0xfffd
</code>
. That is, to MySQL, all
supplementary characters are equal to each other, and
greater than almost all BMP characters.
</p>
<p>
An example with Deseret characters and
<code class="literal">
COUNT(DISTINCT)
</code>
:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa40565749"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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">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> utf32 <span class="token keyword">COLLATE</span> utf32_unicode_ci<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">INSERT</span> <span class="token keyword">INTO</span> t <span class="token keyword">VALUES</span> <span class="token punctuation">(</span>0xfffd<span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment" spellcheck="true">/* REPLACEMENT CHARACTER */</span>
<span class="token keyword">INSERT</span> <span class="token keyword">INTO</span> t <span class="token keyword">VALUES</span> <span class="token punctuation">(</span><span class="token number">0x010412</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment" spellcheck="true">/* DESERET CAPITAL LETTER BEE */</span>
<span class="token keyword">INSERT</span> <span class="token keyword">INTO</span> t <span class="token keyword">VALUES</span> <span class="token punctuation">(</span><span class="token number">0x010413</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment" spellcheck="true">/* DESERET CAPITAL LETTER TEE */</span>
<span class="token keyword">SELECT</span> <span class="token function">COUNT</span><span class="token punctuation">(</span><span class="token keyword">DISTINCT</span> s1<span class="token punctuation">)</span> <span class="token keyword">FROM</span> t<span class="token punctuation">;</span></code></pre>
</div>
<p>
The result is 2 because in the MySQL
<code class="literal">
<em class="replaceable">
<code>
xxx
</code>
</em>
_unicode_ci
</code>
collations, the replacement character has a weight of
<code class="literal">
0x0dc6
</code>
, whereas Deseret Bee and Deseret
Tee both have a weight of
<code class="literal">
0xfffd
</code>
. (Were
the
<code class="literal">
utf32_general_ci
</code>
collation used
instead, the result is 1 because all three characters have
a weight of
<code class="literal">
0xfffd
</code>
in that collation.)
</p>
<p>
An example with cuneiform characters and
<a class="link" href="string-functions.html#function_weight-string">
<code class="literal">
WEIGHT_STRING()
</code>
</a>
:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa89447726"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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">/*
The four characters in the INSERT string are
00000041 # LATIN CAPITAL LETTER A
0001218F # CUNEIFORM SIGN KAB
000121A7 # CUNEIFORM SIGN KISH
00000042 # LATIN CAPITAL LETTER B
*/</span>
<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">4</span><span class="token punctuation">)</span> <span class="token keyword">CHARACTER</span> <span class="token keyword">SET</span> utf32 <span class="token keyword">COLLATE</span> utf32_unicode_ci<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">INSERT</span> <span class="token keyword">INTO</span> t <span class="token keyword">VALUES</span> <span class="token punctuation">(</span><span class="token number">0x000000410001218f000121a700000042</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">SELECT</span> <span class="token function">HEX</span><span class="token punctuation">(</span><span class="token function">WEIGHT_STRING</span><span class="token punctuation">(</span>s1<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token keyword">FROM</span> t<span class="token punctuation">;</span></code></pre>
</div>
<p>
The result is:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-none"><div class="docs-select-all right" id="sa50695193"><div class="copy-help left">Press ⌘+C to 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">0E33 FFFD FFFD 0E4A</code></pre>
</div>
<p>
<code class="literal">
0E33
</code>
and
<code class="literal">
0E4A
</code>
are
primary weights as in
<a class="ulink" href="ftp://www.unicode.org/Public/UCA/4.0.0/allkeys-4.0.0.txt" target="_top">
UCA
4.0.0
</a>
.
<code class="literal">
FFFD
</code>
is the weight for
KAB and also for KISH.
</p>
<p>
The rule that all supplementary characters are equal to
each other is nonoptimal but is not expected to cause
trouble. These characters are very rare, so it is very
rare that a multi-character string consists entirely of
supplementary characters. In Japan, since the
supplementary characters are obscure Kanji ideographs, the
typical user does not care what order they are in, anyway.
If you really want rows sorted by the MySQL rule and
secondarily by code point value, it is easy:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa56729984"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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">ORDER</span> <span class="token keyword">BY</span> s1 <span class="token keyword">COLLATE</span> utf32_unicode_ci<span class="token punctuation">,</span> s1 <span class="token keyword">COLLATE</span> utf32_bin</code></pre>
</div>
</li>
<li class="listitem">
<p>
For supplementary characters based on UCA versions higher
than 4.0.0 (for example,
<code class="literal">
<em class="replaceable">
<code>
xxx
</code>
</em>
_unicode_520_ci
</code>
),
supplementary characters do not necessarily all have the
same collating weight. Some have explicit weights from the
UCA
<code class="filename">
allkeys.txt
</code>
file. Others have
weights calculated from this algorithm:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-clike"><div class="docs-select-all right" id="sa3934039"><div class="copy-help left">Press ⌘+C to 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">aaaa<span class="token operator">=</span> base <span class="token operator">+</span> <span class="token punctuation">(</span>code <span class="token operator">></span><span class="token operator">></span> <span class="token number">15</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
bbbb<span class="token operator">=</span> <span class="token punctuation">(</span>code <span class="token operator">&</span> <span class="token number">0x7FFF</span><span class="token punctuation">)</span> <span class="token operator">|</span> <span class="token number">0x8000</span><span class="token punctuation">;</span></code></pre>
</div>
</li>
</ul>
</div>
<a class="indexterm" name="idm46045216043008">
</a>
<p>
There is a difference between
<span class="quote">
“
<span class="quote">
ordering by the
character's code value
</span>
”
</span>
and
<span class="quote">
“
<span class="quote">
ordering by the
character's binary representation,
</span>
”
</span>
a difference that
appears only with
<code class="literal">
utf16_bin
</code>
, because of
surrogates.
</p>
<p>
Suppose that
<code class="literal">
utf16_bin
</code>
(the binary
collation for
<code class="literal">
utf16
</code>
) was a binary
comparison
<span class="quote">
“
<span class="quote">
byte by byte
</span>
”
</span>
rather than
<span class="quote">
“
<span class="quote">
character by character.
</span>
”
</span>
If that were so, the
order of characters in
<code class="literal">
utf16_bin
</code>
would
differ from the order in
<code class="literal">
utf8mb4_bin
</code>
. For
example, the following chart shows two rare characters. The
first character is in the range
<code class="literal">
E000
</code>
-
<code class="literal">
FFFF
</code>
, so it is
greater than a surrogate but less than a supplementary. The
second character is a supplementary.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-none"><div class="docs-select-all right" id="sa83409278"><div class="copy-help left">Press ⌘+C to 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">Code point Character utf8mb4 utf16
---------- --------- ------- -----
0FF9D HALFWIDTH KATAKANA LETTER N EF BE 9D FF 9D
10384 UGARITIC LETTER DELTA F0 90 8E 84 D8 00 DF 84</code></pre>
</div>
<p>
The two characters in the chart are in order by code point
value because
<code class="literal">
0xff9d
</code>
<
<code class="literal">
0x10384
</code>
. And they are in order by
<code class="literal">
utf8mb4
</code>
value because
<code class="literal">
0xef
</code>
<
<code class="literal">
0xf0
</code>
. But they
are not in order by
<code class="literal">
utf16
</code>
value, if we use
byte-by-byte comparison, because
<code class="literal">
0xff
</code>
>
<code class="literal">
0xd8
</code>
.
</p>
<p>
So MySQL's
<code class="literal">
utf16_bin
</code>
collation is not
<span class="quote">
“
<span class="quote">
byte by byte.
</span>
”
</span>
It is
<span class="quote">
“
<span class="quote">
by code
point.
</span>
”
</span>
When MySQL sees a supplementary-character
encoding in
<code class="literal">
utf16
</code>
, it converts to the
character's code-point value, and then compares. Therefore,
<code class="literal">
utf8mb4_bin
</code>
and
<code class="literal">
utf16_bin
</code>
are the same ordering. This is
consistent with the SQL:2008 standard requirement for a
UCS_BASIC collation:
<span class="quote">
“
<span class="quote">
UCS_BASIC is a collation in which
the ordering is determined entirely by the Unicode scalar
values of the characters in the strings being sorted. It is
applicable to the UCS character repertoire. Since every
character repertoire is a subset of the UCS repertoire, the
UCS_BASIC collation is potentially applicable to every
character set. NOTE 11: The Unicode scalar value of a
character is its code point treated as an unsigned
integer.
</span>
”
</span>
</p>
<p>
If the character set is
<code class="literal">
ucs2
</code>
, comparison is
byte-by-byte, but
<code class="literal">
ucs2
</code>
strings should not
contain surrogates, anyway.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h4 class="title">
<a name="charset-unicode-sets-miscellaneous">
</a>
Miscellaneous Information
</h4>
</div>
</div>
</div>
<p>
The
<code class="literal">
<em class="replaceable">
<code>
xxx
</code>
</em>
_general_mysql500_ci
</code>
collations preserve the pre-5.1.24 ordering of the original
<code class="literal">
<em class="replaceable">
<code>
xxx
</code>
</em>
_general_ci
</code>
collations and permit upgrades for tables created before MySQL
5.1.24 (Bug #27877).
</p>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/binary-log-mixed.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="binary-log-mixed">
</a>
7.4.4.3 Mixed Binary Logging Format
</h4>
</div>
</div>
</div>
<p>
When running in
<code class="literal">
MIXED
</code>
logging format, the
server automatically switches from statement-based to row-based
logging under the following conditions:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
When a function contains
<a class="link" href="miscellaneous-functions.html#function_uuid">
<code class="literal">
UUID()
</code>
</a>
.
</p>
</li>
<li class="listitem">
<p>
When one or more tables with
<code class="literal">
AUTO_INCREMENT
</code>
columns are updated and a
trigger or stored function is invoked. Like all other unsafe
statements, this generates a warning if
<a class="link" href="replication-options-binary-log.html#sysvar_binlog_format">
<code class="literal">
binlog_format = STATEMENT
</code>
</a>
.
</p>
<p>
For more information, see
<a class="xref" href="replication-features-auto-increment.html" title="19.5.1.1 Replication and AUTO_INCREMENT">
Section 19.5.1.1, “Replication and AUTO_INCREMENT”
</a>
.
</p>
</li>
<li class="listitem">
<p>
When the body of a view requires row-based replication, the
statement creating the view also uses it. For example, this
occurs when the statement creating a view uses the
<a class="link" href="miscellaneous-functions.html#function_uuid">
<code class="literal">
UUID()
</code>
</a>
function.
</p>
</li>
<li class="listitem">
<p>
When a call to a loadable function is involved.
</p>
</li>
<li class="listitem">
<p>
When
<a class="link" href="information-functions.html#function_found-rows">
<code class="literal">
FOUND_ROWS()
</code>
</a>
or
<a class="link" href="information-functions.html#function_row-count">
<code class="literal">
ROW_COUNT()
</code>
</a>
is used. (Bug
#12092, Bug #30244)
</p>
</li>
<li class="listitem">
<p>
When
<a class="link" href="information-functions.html#function_user">
<code class="literal">
USER()
</code>
</a>
,
<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>
is used. (Bug
#28086)
</p>
</li>
<li class="listitem">
<p>
When one of the tables involved is a log table in the
<code class="literal">
mysql
</code>
database.
</p>
</li>
<li class="listitem">
<p>
When the
<a class="link" href="string-functions.html#function_load-file">
<code class="literal">
LOAD_FILE()
</code>
</a>
function
is used. (Bug #39701)
</p>
</li>
<li class="listitem">
<p>
When a statement refers to one or more system variables.
(Bug #31168)
</p>
<p>
<b>
Exception.
</b>
The following system variables, when used with session
scope (only), do not cause the logging format to switch:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
<a class="link" href="replication-options-source.html#sysvar_auto_increment_increment">
<code class="literal">
auto_increment_increment
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="replication-options-source.html#sysvar_auto_increment_offset">
<code class="literal">
auto_increment_offset
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="server-system-variables.html#sysvar_character_set_client">
<code class="literal">
character_set_client
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="server-system-variables.html#sysvar_character_set_connection">
<code class="literal">
character_set_connection
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="server-system-variables.html#sysvar_character_set_database">
<code class="literal">
character_set_database
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="server-system-variables.html#sysvar_character_set_server">
<code class="literal">
character_set_server
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="server-system-variables.html#sysvar_collation_connection">
<code class="literal">
collation_connection
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="server-system-variables.html#sysvar_collation_database">
<code class="literal">
collation_database
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="server-system-variables.html#sysvar_collation_server">
<code class="literal">
collation_server
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="server-system-variables.html#sysvar_foreign_key_checks">
<code class="literal">
foreign_key_checks
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="server-system-variables.html#sysvar_identity">
<code class="literal">
identity
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="server-system-variables.html#sysvar_last_insert_id">
<code class="literal">
last_insert_id
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="server-system-variables.html#sysvar_lc_time_names">
<code class="literal">
lc_time_names
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="server-system-variables.html#sysvar_pseudo_thread_id">
<code class="literal">
pseudo_thread_id
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="server-system-variables.html#sysvar_sql_auto_is_null">
<code class="literal">
sql_auto_is_null
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="server-system-variables.html#sysvar_time_zone">
<code class="literal">
time_zone
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="server-system-variables.html#sysvar_timestamp">
<code class="literal">
timestamp
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="server-system-variables.html#sysvar_unique_checks">
<code class="literal">
unique_checks
</code>
</a>
</p>
</li>
</ul>
</div>
<p>
For information about determining system variable scope, see
<a class="xref" href="using-system-variables.html" title="7.1.9 Using System Variables">
Section 7.1.9, “Using System Variables”
</a>
.
</p>
<p>
For information about how replication treats
<a class="link" href="server-system-variables.html#sysvar_sql_mode">
<code class="literal">
sql_mode
</code>
</a>
, see
<a class="xref" href="replication-features-variables.html" title="19.5.1.39 Replication and Variables">
Section 19.5.1.39, “Replication and Variables”
</a>
.
</p>
</li>
</ul>
</div>
<p>
In releases prior to MySQL 8.0, when mixed binary logging format
was in use, if a statement was logged by row and the session
that executed the statement had any temporary tables, all
subsequent statements were treated as unsafe and logged in
row-based format until all temporary tables in use by that
session were dropped. In MySQL 8.4, operations on
temporary tables are not logged in mixed binary logging format,
and the presence of temporary tables in the session has no
impact on the logging mode used for each statement.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
A warning is generated if you try to execute a statement using
statement-based logging that should be written using row-based
logging. The warning is shown both in the client (in the
output of
<a class="link" href="show-warnings.html" title="15.7.7.42 SHOW WARNINGS Statement">
<code class="literal">
SHOW WARNINGS
</code>
</a>
) and
through the
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
error log. A warning is
added to the
<a class="link" href="show-warnings.html" title="15.7.7.42 SHOW WARNINGS Statement">
<code class="literal">
SHOW WARNINGS
</code>
</a>
table each time such a statement is executed. However, only
the first statement that generated the warning for each client
session is written to the error log to prevent flooding the
log.
</p>
</div>
<p>
In addition to the decisions above, individual engines can also
determine the logging format used when information in a table is
updated. The logging capabilities of an individual engine can be
defined as follows:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
If an engine supports row-based logging, the engine is said
to be
<span class="firstterm">
row-logging
capable
</span>
.
</p>
</li>
<li class="listitem">
<p>
If an engine supports statement-based logging, the engine is
said to be
<span class="firstterm">
statement-logging
capable
</span>
.
</p>
</li>
</ul>
</div>
<p>
A given storage engine can support either or both logging
formats. The following table lists the formats supported by each
engine.
</p>
<div class="informaltable">
<a name="storage-engine-logging-format-support">
</a>
<table summary="Logging formats supported by each storage engine.">
<colgroup>
<col style="width: 50%"/>
<col style="width: 25%"/>
<col style="width: 25%"/>
</colgroup>
<thead>
<tr>
<th scope="col">
Storage Engine
</th>
<th scope="col">
Row Logging Supported
</th>
<th scope="col">
Statement Logging Supported
</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">
<code class="literal">
ARCHIVE
</code>
</th>
<td>
Yes
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
BLACKHOLE
</code>
</th>
<td>
Yes
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
CSV
</code>
</th>
<td>
Yes
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
EXAMPLE
</code>
</th>
<td>
Yes
</td>
<td>
No
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
FEDERATED
</code>
</th>
<td>
Yes
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
HEAP
</code>
</th>
<td>
Yes
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
InnoDB
</code>
</th>
<td>
Yes
</td>
<td>
Yes when the transaction isolation level is
<a class="link" href="innodb-transaction-isolation-levels.html#isolevel_repeatable-read">
<code class="literal">
REPEATABLE READ
</code>
</a>
or
<a class="link" href="innodb-transaction-isolation-levels.html#isolevel_serializable">
<code class="literal">
SERIALIZABLE
</code>
</a>
; No
otherwise.
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
MyISAM
</code>
</th>
<td>
Yes
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
MERGE
</code>
</th>
<td>
Yes
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="mysql-cluster.html" title="Chapter 25 MySQL NDB Cluster 8.4">
<code class="literal">
NDB
</code>
</a>
</th>
<td>
Yes
</td>
<td>
No
</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 scope="col" style="width: 369px;">
Storage Engine
</th>
<th scope="col" style="width: 184.5px;">
Row Logging Supported
</th>
<th scope="col" style="width: 184.5px;">
Statement Logging Supported
</th>
</tr>
</thead>
</table>
</div>
<p>
Whether a statement is to be logged and the logging mode to be
used is determined according to the type of statement (safe,
unsafe, or binary injected), the binary logging format
(
<code class="literal">
STATEMENT
</code>
,
<code class="literal">
ROW
</code>
, or
<code class="literal">
MIXED
</code>
), and the logging capabilities of the
storage engine (statement capable, row capable, both, or
neither). (Binary injection refers to logging a change that must
be logged using
<code class="literal">
ROW
</code>
format.)
</p>
<p>
Statements may be logged with or without a warning; failed
statements are not logged, but generate errors in the log. This
is shown in the following decision table.
<span class="bold">
<strong>
Type
</strong>
</span>
,
<span class="bold">
<strong>
binlog_format
</strong>
</span>
,
<span class="bold">
<strong>
SLC
</strong>
</span>
, and
<span class="bold">
<strong>
RLC
</strong>
</span>
columns outline the
conditions, and
<span class="bold">
<strong>
Error / Warning
</strong>
</span>
and
<span class="bold">
<strong>
Logged as
</strong>
</span>
columns represent
the corresponding actions.
<span class="bold">
<strong>
SLC
</strong>
</span>
stands for
<span class="quote">
“
<span class="quote">
statement-logging capable
</span>
”
</span>
, and
<span class="bold">
<strong>
RLC
</strong>
</span>
stands for
<span class="quote">
“
<span class="quote">
row-logging capable
</span>
”
</span>
.
</p>
<div class="informaltable">
<table summary="The information in this table is used to determine if a statement is to be logged and the logging mode to be used. The table outlines conditions (Safe/unsafe, binlog_format, SLC, RLR) and corresponding actions.">
<colgroup>
<col style="width: 10%"/>
<col style="width: 25%"/>
<col style="width: 10%"/>
<col style="width: 10%"/>
<col style="width: 20%"/>
<col style="width: 25%"/>
</colgroup>
<thead>
<tr>
<th scope="col">
Type
</th>
<th scope="col">
<a class="link" href="replication-options-binary-log.html#sysvar_binlog_format">
<code class="literal">
binlog_format
</code>
</a>
</th>
<th scope="col">
SLC
</th>
<th scope="col">
RLC
</th>
<th scope="col">
Error / Warning
</th>
<th scope="col">
Logged as
</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">
*
</th>
<td>
<code class="literal">
*
</code>
</td>
<td>
No
</td>
<td>
No
</td>
<td>
<span class="errortext">
Error: Cannot execute statement
</span>
: Binary logging
is impossible since at least one engine is involved that
is both row-incapable and statement-incapable.
</td>
<td>
<code class="literal">
-
</code>
</td>
</tr>
<tr>
<th scope="row">
Safe
</th>
<td>
<code class="literal">
STATEMENT
</code>
</td>
<td>
Yes
</td>
<td>
No
</td>
<td>
-
</td>
<td>
<code class="literal">
STATEMENT
</code>
</td>
</tr>
<tr>
<th scope="row">
Safe
</th>
<td>
<code class="literal">
MIXED
</code>
</td>
<td>
Yes
</td>
<td>
No
</td>
<td>
-
</td>
<td>
<code class="literal">
STATEMENT
</code>
</td>
</tr>
<tr>
<th scope="row">
Safe
</th>
<td>
<code class="literal">
ROW
</code>
</td>
<td>
Yes
</td>
<td>
No
</td>
<td>
<span class="errortext">
Error: Cannot execute statement
</span>
: Binary logging
is impossible since
<code class="literal">
BINLOG_FORMAT = ROW
</code>
and at least one table uses a storage engine that is not
capable of row-based logging.
</td>
<td>
<code class="literal">
-
</code>
</td>
</tr>
<tr>
<th scope="row">
Unsafe
</th>
<td>
<code class="literal">
STATEMENT
</code>
</td>
<td>
Yes
</td>
<td>
No
</td>
<td>
<span class="errortext">
Warning: Unsafe statement binlogged in statement
format
</span>
, since
<code class="literal">
BINLOG_FORMAT =
STATEMENT
</code>
</td>
<td>
<code class="literal">
STATEMENT
</code>
</td>
</tr>
<tr>
<th scope="row">
Unsafe
</th>
<td>
<code class="literal">
MIXED
</code>
</td>
<td>
Yes
</td>
<td>
No
</td>
<td>
<span class="errortext">
Error: Cannot execute statement
</span>
: Binary logging
of an unsafe statement is impossible when the storage
engine is limited to statement-based logging, even if
<code class="literal">
BINLOG_FORMAT = MIXED
</code>
.
</td>
<td>
<code class="literal">
-
</code>
</td>
</tr>
<tr>
<th scope="row">
Unsafe
</th>
<td>
<code class="literal">
ROW
</code>
</td>
<td>
Yes
</td>
<td>
No
</td>
<td>
<span class="errortext">
Error: Cannot execute statement
</span>
: Binary logging
is impossible since
<code class="literal">
BINLOG_FORMAT = ROW
</code>
and at least one table uses a storage engine that is not
capable of row-based logging.
</td>
<td>
-
</td>
</tr>
<tr>
<th scope="row">
Row Injection
</th>
<td>
<code class="literal">
STATEMENT
</code>
</td>
<td>
Yes
</td>
<td>
No
</td>
<td>
<span class="errortext">
Error: Cannot execute row injection
</span>
: Binary
logging is not possible since at least one table uses a
storage engine that is not capable of row-based logging.
</td>
<td>
-
</td>
</tr>
<tr>
<th scope="row">
Row Injection
</th>
<td>
<code class="literal">
MIXED
</code>
</td>
<td>
Yes
</td>
<td>
No
</td>
<td>
<span class="errortext">
Error: Cannot execute row injection
</span>
: Binary
logging is not possible since at least one table uses a
storage engine that is not capable of row-based logging.
</td>
<td>
-
</td>
</tr>
<tr>
<th scope="row">
Row Injection
</th>
<td>
<code class="literal">
ROW
</code>
</td>
<td>
Yes
</td>
<td>
No
</td>
<td>
<span class="errortext">
Error: Cannot execute row injection
</span>
: Binary
logging is not possible since at least one table uses a
storage engine that is not capable of row-based logging.
</td>
<td>
-
</td>
</tr>
<tr>
<th scope="row">
Safe
</th>
<td>
<code class="literal">
STATEMENT
</code>
</td>
<td>
No
</td>
<td>
Yes
</td>
<td>
<span class="errortext">
Error: Cannot execute statement
</span>
: Binary logging
is impossible since
<code class="literal">
BINLOG_FORMAT =
STATEMENT
</code>
and at least one table uses a storage
engine that is not capable of statement-based logging.
</td>
<td>
<code class="literal">
-
</code>
</td>
</tr>
<tr>
<th scope="row">
Safe
</th>
<td>
<code class="literal">
MIXED
</code>
</td>
<td>
No
</td>
<td>
Yes
</td>
<td>
-
</td>
<td>
<code class="literal">
ROW
</code>
</td>
</tr>
<tr>
<th scope="row">
Safe
</th>
<td>
<code class="literal">
ROW
</code>
</td>
<td>
No
</td>
<td>
Yes
</td>
<td>
-
</td>
<td>
<code class="literal">
ROW
</code>
</td>
</tr>
<tr>
<th scope="row">
Unsafe
</th>
<td>
<code class="literal">
STATEMENT
</code>
</td>
<td>
No
</td>
<td>
Yes
</td>
<td>
<span class="errortext">
Error: Cannot execute statement
</span>
: Binary logging
is impossible since
<code class="literal">
BINLOG_FORMAT =
STATEMENT
</code>
and at least one table uses a storage
engine that is not capable of statement-based logging.
</td>
<td>
-
</td>
</tr>
<tr>
<th scope="row">
Unsafe
</th>
<td>
<code class="literal">
MIXED
</code>
</td>
<td>
No
</td>
<td>
Yes
</td>
<td>
-
</td>
<td>
<code class="literal">
ROW
</code>
</td>
</tr>
<tr>
<th scope="row">
Unsafe
</th>
<td>
<code class="literal">
ROW
</code>
</td>
<td>
No
</td>
<td>
Yes
</td>
<td>
-
</td>
<td>
<code class="literal">
ROW
</code>
</td>
</tr>
<tr>
<th scope="row">
Row Injection
</th>
<td>
<code class="literal">
STATEMENT
</code>
</td>
<td>
No
</td>
<td>
Yes
</td>
<td>
<span class="errortext">
Error: Cannot execute row injection
</span>
: Binary
logging is not possible since
<code class="literal">
BINLOG_FORMAT =
STATEMENT
</code>
.
</td>
<td>
<code class="literal">
-
</code>
</td>
</tr>
<tr>
<th scope="row">
Row Injection
</th>
<td>
<code class="literal">
MIXED
</code>
</td>
<td>
No
</td>
<td>
Yes
</td>
<td>
-
</td>
<td>
<code class="literal">
ROW
</code>
</td>
</tr>
<tr>
<th scope="row">
Row Injection
</th>
<td>
<code class="literal">
ROW
</code>
</td>
<td>
No
</td>
<td>
Yes
</td>
<td>
-
</td>
<td>
<code class="literal">
ROW
</code>
</td>
</tr>
<tr>
<th scope="row">
Safe
</th>
<td>
<code class="literal">
STATEMENT
</code>
</td>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
-
</td>
<td>
<code class="literal">
STATEMENT
</code>
</td>
</tr>
<tr>
<th scope="row">
Safe
</th>
<td>
<code class="literal">
MIXED
</code>
</td>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
-
</td>
<td>
<code class="literal">
STATEMENT
</code>
</td>
</tr>
<tr>
<th scope="row">
Safe
</th>
<td>
<code class="literal">
ROW
</code>
</td>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
-
</td>
<td>
<code class="literal">
ROW
</code>
</td>
</tr>
<tr>
<th scope="row">
Unsafe
</th>
<td>
<code class="literal">
STATEMENT
</code>
</td>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
<span class="errortext">
Warning: Unsafe statement binlogged in statement
format
</span>
since
<code class="literal">
BINLOG_FORMAT =
STATEMENT
</code>
.
</td>
<td>
<code class="literal">
STATEMENT
</code>
</td>
</tr>
<tr>
<th scope="row">
Unsafe
</th>
<td>
<code class="literal">
MIXED
</code>
</td>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
-
</td>
<td>
<code class="literal">
ROW
</code>
</td>
</tr>
<tr>
<th scope="row">
Unsafe
</th>
<td>
<code class="literal">
ROW
</code>
</td>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
-
</td>
<td>
<code class="literal">
ROW
</code>
</td>
</tr>
<tr>
<th scope="row">
Row Injection
</th>
<td>
<code class="literal">
STATEMENT
</code>
</td>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
<span class="errortext">
Error: Cannot execute row injection
</span>
: Binary
logging is not possible because
<code class="literal">
BINLOG_FORMAT =
STATEMENT
</code>
.
</td>
<td>
-
</td>
</tr>
<tr>
<th scope="row">
Row Injection
</th>
<td>
<code class="literal">
MIXED
</code>
</td>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
-
</td>
<td>
<code class="literal">
ROW
</code>
</td>
</tr>
<tr>
<th scope="row">
Row Injection
</th>
<td>
<code class="literal">
ROW
</code>
</td>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
-
</td>
<td>
<code class="literal">
ROW
</code>
</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 scope="col" style="width: 73.7969px;">
Type
</th>
<th scope="col" style="width: 184.5px;">
<a class="link" href="replication-options-binary-log.html#sysvar_binlog_format">
<code class="literal">
binlog_format
</code>
</a>
</th>
<th scope="col" style="width: 73.7969px;">
SLC
</th>
<th scope="col" style="width: 73.7969px;">
RLC
</th>
<th scope="col" style="width: 147.594px;">
Error / Warning
</th>
<th scope="col" style="width: 184.516px;">
Logged as
</th>
</tr>
</thead>
</table>
</div>
<p>
When a warning is produced by the determination, a standard
MySQL warning is produced (and is available using
<a class="link" href="show-warnings.html" title="15.7.7.42 SHOW WARNINGS Statement">
<code class="literal">
SHOW WARNINGS
</code>
</a>
). The information
is also written to the
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
error log. Only
one error for each error instance per client connection is
logged to prevent flooding the log. The log message includes the
SQL statement that was attempted.
</p>
<p>
If a replica has
<a class="link" href="server-system-variables.html#sysvar_log_error_verbosity">
<code class="literal">
log_error_verbosity
</code>
</a>
set to
display warnings, the replica prints messages to the error log
to provide information about its status, such as the binary log
and relay log coordinates where it starts its job, when it is
switching to another relay log, when it reconnects after a
disconnect, statements that are unsafe for statement-based
logging, and so forth.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/trigger-syntax.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="trigger-syntax">
</a>
27.3.1 Trigger Syntax and Examples
</h3>
</div>
</div>
</div>
<p>
To create a trigger or drop a trigger, use the
<a class="link" href="create-trigger.html" title="15.1.22 CREATE TRIGGER Statement">
<code class="literal">
CREATE TRIGGER
</code>
</a>
or
<a class="link" href="drop-trigger.html" title="15.1.34 DROP TRIGGER Statement">
<code class="literal">
DROP TRIGGER
</code>
</a>
statement, described
in
<a class="xref" href="create-trigger.html" title="15.1.22 CREATE TRIGGER Statement">
Section 15.1.22, “CREATE TRIGGER Statement”
</a>
, and
<a class="xref" href="drop-trigger.html" title="15.1.34 DROP TRIGGER Statement">
Section 15.1.34, “DROP TRIGGER Statement”
</a>
.
</p>
<p>
Here is a simple example that associates a trigger with a table,
to activate for
<a class="link" href="insert.html" title="15.2.7 INSERT Statement">
<code class="literal">
INSERT
</code>
</a>
operations.
The trigger acts as an accumulator, summing the values inserted
into one of the columns of the table.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa47771600"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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">account</span> <span class="token punctuation">(</span>acct_num <span class="token datatype">INT</span><span class="token punctuation">,</span> amount <span class="token datatype">DECIMAL</span><span class="token punctuation">(</span><span class="token number">10</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 output">Query OK, 0 rows affected (0.03 sec)</span>
<span class="token prompt">mysql></span> <span class="token keyword">CREATE</span> <span class="token keyword">TRIGGER</span> ins_sum <span class="token keyword">BEFORE</span> <span class="token keyword">INSERT</span> <span class="token keyword">ON</span> <span class="token keyword">account</span>
<span class="token keyword">FOR</span> <span class="token keyword">EACH</span> <span class="token keyword">ROW</span> <span class="token keyword">SET</span> <span class="token variable">@sum</span> <span class="token operator">=</span> <span class="token variable">@sum</span> <span class="token operator">+</span> <span class="token keyword">NEW</span><span class="token punctuation">.</span>amount<span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected (0.01 sec)</span></code></pre>
</div>
<p>
The
<a class="link" href="create-trigger.html" title="15.1.22 CREATE TRIGGER Statement">
<code class="literal">
CREATE TRIGGER
</code>
</a>
statement
creates a trigger named
<code class="literal">
ins_sum
</code>
that is
associated with the
<code class="literal">
account
</code>
table. It also
includes clauses that specify the trigger action time, the
triggering event, and what to do when the trigger activates:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
The keyword
<code class="literal">
BEFORE
</code>
indicates the trigger
action time. In this case, the trigger activates before each
row inserted into the table. The other permitted keyword here
is
<code class="literal">
AFTER
</code>
.
</p>
</li>
<li class="listitem">
<p>
The keyword
<code class="literal">
INSERT
</code>
indicates the trigger
event; that is, the type of operation that activates the
trigger. In the example,
<a class="link" href="insert.html" title="15.2.7 INSERT Statement">
<code class="literal">
INSERT
</code>
</a>
operations cause trigger activation. You can also create
triggers for
<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>
operations.
</p>
</li>
<li class="listitem">
<p>
The statement following
<code class="literal">
FOR EACH ROW
</code>
defines the trigger body; that is, the statement to execute
each time the trigger activates, which occurs once for each
row affected by the triggering event. In the example, the
trigger body is a simple
<a class="link" href="set-variable.html" title="15.7.6.1 SET Syntax for Variable Assignment">
<code class="literal">
SET
</code>
</a>
that accumulates into a user variable the values inserted into
the
<code class="literal">
amount
</code>
column. The statement refers to
the column as
<code class="literal">
NEW.amount
</code>
which means
<span class="quote">
“
<span class="quote">
the value of the
<code class="literal">
amount
</code>
column to be
inserted into the new row.
</span>
”
</span>
</p>
</li>
</ul>
</div>
<p>
To use the trigger, set the accumulator variable to zero, execute
an
<a class="link" href="insert.html" title="15.2.7 INSERT Statement">
<code class="literal">
INSERT
</code>
</a>
statement, and then see
what value the variable has afterward:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa66151861"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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">@sum</span> <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">INSERT</span> <span class="token keyword">INTO</span> <span class="token keyword">account</span> <span class="token keyword">VALUES</span><span class="token punctuation">(</span><span class="token number">137</span><span class="token punctuation">,</span><span class="token number">14.98</span><span class="token punctuation">)</span><span class="token punctuation">,</span><span class="token punctuation">(</span><span class="token number">141</span><span class="token punctuation">,</span><span class="token number">1937.50</span><span class="token punctuation">)</span><span class="token punctuation">,</span><span class="token punctuation">(</span><span class="token number">97</span><span class="token punctuation">,</span><span class="token operator">-</span><span class="token number">100.00</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 variable">@sum</span> <span class="token keyword">AS</span> <span class="token string">'Total amount inserted'</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>
<span class="token output"><span class="token punctuation">|</span> Total amount inserted <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>
<span class="token output"><span class="token punctuation">|</span> 1852.48 <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></code></pre>
</div>
<p>
In this case, the value of
<code class="literal">
@sum
</code>
after the
<a class="link" href="insert.html" title="15.2.7 INSERT Statement">
<code class="literal">
INSERT
</code>
</a>
statement has executed is
<code class="literal">
14.98 + 1937.50 - 100
</code>
, or
<code class="literal">
1852.48
</code>
.
</p>
<p>
To destroy the trigger, use a
<a class="link" href="drop-trigger.html" title="15.1.34 DROP TRIGGER Statement">
<code class="literal">
DROP
TRIGGER
</code>
</a>
statement. You must specify the schema name if
the trigger is not in the default schema:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa55382018"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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">DROP</span> <span class="token keyword">TRIGGER</span> test<span class="token punctuation">.</span>ins_sum<span class="token punctuation">;</span></code></pre>
</div>
<p>
If you drop a table, any triggers for the table are also dropped.
</p>
<p>
Trigger names exist in the schema namespace, meaning that all
triggers must have unique names within a schema. Triggers in
different schemas can have the same name.
</p>
<p>
It is possible to define multiple triggers for a given table that
have the same trigger event and action time. For example, you can
have two
<code class="literal">
BEFORE UPDATE
</code>
triggers for a table. By
default, triggers that have the same trigger event and action time
activate in the order they were created. To affect trigger order,
specify a clause after
<code class="literal">
FOR EACH ROW
</code>
that
indicates
<code class="literal">
FOLLOWS
</code>
or
<code class="literal">
PRECEDES
</code>
and the name of an existing trigger
that also has the same trigger event and action time. With
<code class="literal">
FOLLOWS
</code>
, the new trigger activates after the
existing trigger. With
<code class="literal">
PRECEDES
</code>
, the new
trigger activates before the existing trigger.
</p>
<p>
For example, the following trigger definition defines another
<code class="literal">
BEFORE INSERT
</code>
trigger for the
<code class="literal">
account
</code>
table:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa14983965"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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">TRIGGER</span> ins_transaction <span class="token keyword">BEFORE</span> <span class="token keyword">INSERT</span> <span class="token keyword">ON</span> <span class="token keyword">account</span>
<span class="token keyword">FOR</span> <span class="token keyword">EACH</span> <span class="token keyword">ROW</span> <span class="token keyword">PRECEDES</span> ins_sum
<span class="token keyword">SET</span>
<span class="token variable">@deposits</span> <span class="token operator">=</span> <span class="token variable">@deposits</span> <span class="token operator">+</span> <span class="token function">IF</span><span class="token punctuation">(</span><span class="token keyword">NEW</span><span class="token punctuation">.</span>amount<span class="token operator">></span><span class="token number">0</span><span class="token punctuation">,</span><span class="token keyword">NEW</span><span class="token punctuation">.</span>amount<span class="token punctuation">,</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token variable">@withdrawals</span> <span class="token operator">=</span> <span class="token variable">@withdrawals</span> <span class="token operator">+</span> <span class="token function">IF</span><span class="token punctuation">(</span><span class="token keyword">NEW</span><span class="token punctuation">.</span>amount<span class="token operator"><</span><span class="token number">0</span><span class="token punctuation">,</span><span class="token operator">-</span><span class="token keyword">NEW</span><span class="token punctuation">.</span>amount<span class="token punctuation">,</span><span class="token number">0</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>
This trigger,
<code class="literal">
ins_transaction
</code>
, is similar to
<code class="literal">
ins_sum
</code>
but accumulates deposits and
withdrawals separately. It has a
<code class="literal">
PRECEDES
</code>
clause that causes it to activate before
<code class="literal">
ins_sum
</code>
; without that clause, it would activate
after
<code class="literal">
ins_sum
</code>
because it is created after
<code class="literal">
ins_sum
</code>
.
</p>
<p>
Within the trigger body, the
<code class="literal">
OLD
</code>
and
<code class="literal">
NEW
</code>
keywords enable you to access columns in
the rows affected by a trigger.
<code class="literal">
OLD
</code>
and
<code class="literal">
NEW
</code>
are MySQL extensions to triggers; they are
not case-sensitive.
</p>
<p>
In an
<code class="literal">
INSERT
</code>
trigger, only
<code class="literal">
NEW.
<em class="replaceable">
<code>
col_name
</code>
</em>
</code>
can be
used; there is no old row. In a
<code class="literal">
DELETE
</code>
trigger,
only
<code class="literal">
OLD.
<em class="replaceable">
<code>
col_name
</code>
</em>
</code>
can be used; there is no new row. In an
<code class="literal">
UPDATE
</code>
trigger, you can use
<code class="literal">
OLD.
<em class="replaceable">
<code>
col_name
</code>
</em>
</code>
to
refer to the columns of a row before it is updated and
<code class="literal">
NEW.
<em class="replaceable">
<code>
col_name
</code>
</em>
</code>
to
refer to the columns of the row after it is updated.
</p>
<p>
A column named with
<code class="literal">
OLD
</code>
is read only. You can
refer to it (if you have the
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
privilege), but not modify it. You can refer to a column named
with
<code class="literal">
NEW
</code>
if you have the
<a class="link" href="privileges-provided.html#priv_select">
<code class="literal">
SELECT
</code>
</a>
privilege for it. In a
<code class="literal">
BEFORE
</code>
trigger, you can also change its value
with
<code class="literal">
SET NEW.
<em class="replaceable">
<code>
col_name
</code>
</em>
=
<em class="replaceable">
<code>
value
</code>
</em>
</code>
if you have the
<a class="link" href="privileges-provided.html#priv_update">
<code class="literal">
UPDATE
</code>
</a>
privilege for it. This means
you can use a trigger to modify the values to be inserted into a
new row or used to update a row. (Such a
<code class="literal">
SET
</code>
statement has no effect in an
<code class="literal">
AFTER
</code>
trigger
because the row change has already occurred.)
</p>
<p>
In a
<code class="literal">
BEFORE
</code>
trigger, the
<code class="literal">
NEW
</code>
value for an
<code class="literal">
AUTO_INCREMENT
</code>
column is 0, not
the sequence number that is generated automatically when the new
row actually is inserted.
</p>
<p>
By using the
<a class="link" href="begin-end.html" title="15.6.1 BEGIN ... END Compound Statement">
<code class="literal">
BEGIN ...
END
</code>
</a>
construct, you can define a trigger that executes
multiple statements. Within the
<code class="literal">
BEGIN
</code>
block,
you also can use other syntax that is permitted within stored
routines such as conditionals and loops. However, just as for
stored routines, if you use 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
to define a trigger that executes multiple statements, it is
necessary to redefine 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>
statement
delimiter so that you can use the
<code class="literal">
;
</code>
statement
delimiter within the trigger definition. The following example
illustrates these points. It defines an
<code class="literal">
UPDATE
</code>
trigger that checks the new value to be used for updating each
row, and modifies the value to be within the range from 0 to 100.
This must be a
<code class="literal">
BEFORE
</code>
trigger because the value
must be checked before it is used to update the row:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa44554125"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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">delimiter</span> <span class="token comment" spellcheck="true">//</span>
<span class="token prompt">mysql></span> <span class="token keyword">CREATE</span> <span class="token keyword">TRIGGER</span> upd_check <span class="token keyword">BEFORE</span> <span class="token keyword">UPDATE</span> <span class="token keyword">ON</span> <span class="token keyword">account</span>
<span class="token keyword">FOR</span> <span class="token keyword">EACH</span> <span class="token keyword">ROW</span>
<span class="token keyword">BEGIN</span>
<span class="token keyword">IF</span> <span class="token keyword">NEW</span><span class="token punctuation">.</span>amount <span class="token operator"><</span> <span class="token number">0</span> <span class="token keyword">THEN</span>
<span class="token keyword">SET</span> <span class="token keyword">NEW</span><span class="token punctuation">.</span>amount <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>
<span class="token keyword">ELSEIF</span> <span class="token keyword">NEW</span><span class="token punctuation">.</span>amount <span class="token operator">></span> <span class="token number">100</span> <span class="token keyword">THEN</span>
<span class="token keyword">SET</span> <span class="token keyword">NEW</span><span class="token punctuation">.</span>amount <span class="token operator">=</span> <span class="token number">100</span><span class="token punctuation">;</span>
<span class="token keyword">END</span> <span class="token keyword">IF</span><span class="token punctuation">;</span>
<span class="token keyword">END</span><span class="token punctuation">;</span><span class="token comment" spellcheck="true">//</span>
<span class="token prompt">mysql></span> <span class="token keyword">delimiter</span> <span class="token punctuation">;</span></code></pre>
</div>
<p>
It can be easier to define a stored procedure separately and then
invoke it from the trigger using a simple
<a class="link" href="call.html" title="15.2.1 CALL Statement">
<code class="literal">
CALL
</code>
</a>
statement. This is also
advantageous if you want to execute the same code from within
several triggers.
</p>
<p>
There are limitations on what can appear in statements that a
trigger executes when activated:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
The trigger cannot use the
<a class="link" href="call.html" title="15.2.1 CALL Statement">
<code class="literal">
CALL
</code>
</a>
statement to invoke stored procedures that return data to the
client or that use dynamic SQL. (Stored procedures are
permitted to return data to the trigger through
<code class="literal">
OUT
</code>
or
<code class="literal">
INOUT
</code>
parameters.)
</p>
</li>
<li class="listitem">
<p>
The trigger cannot use statements that explicitly or
implicitly begin or end a transaction, such as
<a class="link" href="commit.html" title="15.3.1 START TRANSACTION, COMMIT, and ROLLBACK Statements">
<code class="literal">
START
TRANSACTION
</code>
</a>
,
<a class="link" href="commit.html" title="15.3.1 START TRANSACTION, COMMIT, and ROLLBACK Statements">
<code class="literal">
COMMIT
</code>
</a>
,
or
<a class="link" href="commit.html" title="15.3.1 START TRANSACTION, COMMIT, and ROLLBACK Statements">
<code class="literal">
ROLLBACK
</code>
</a>
.
(
<a class="link" href="commit.html" title="15.3.1 START TRANSACTION, COMMIT, and ROLLBACK Statements">
<code class="literal">
ROLLBACK to
SAVEPOINT
</code>
</a>
is permitted because it does not end a
transaction.).
</p>
</li>
</ul>
</div>
<p>
See also
<a class="xref" href="stored-program-restrictions.html" title="27.8 Restrictions on Stored Programs">
Section 27.8, “Restrictions on Stored Programs”
</a>
.
</p>
<p>
MySQL handles errors during trigger execution as follows:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
If a
<code class="literal">
BEFORE
</code>
trigger fails, the operation on
the corresponding row is not performed.
</p>
</li>
<li class="listitem">
<p>
A
<code class="literal">
BEFORE
</code>
trigger is activated by the
<span class="emphasis">
<em>
attempt
</em>
</span>
to insert or modify the row,
regardless of whether the attempt subsequently succeeds.
</p>
</li>
<li class="listitem">
<p>
An
<code class="literal">
AFTER
</code>
trigger is executed only if any
<code class="literal">
BEFORE
</code>
triggers and the row operation
execute successfully.
</p>
</li>
<li class="listitem">
<p>
An error during either a
<code class="literal">
BEFORE
</code>
or
<code class="literal">
AFTER
</code>
trigger results in failure of the
entire statement that caused trigger invocation.
</p>
</li>
<li class="listitem">
<p>
For transactional tables, failure of a statement should cause
rollback of all changes performed by the statement. Failure of
a trigger causes the statement to fail, so trigger failure
also causes rollback. For nontransactional tables, such
rollback cannot be done, so although the statement fails, any
changes performed prior to the point of the error remain in
effect.
</p>
</li>
</ul>
</div>
<p>
Triggers can contain direct references to tables by name, such as
the trigger named
<code class="literal">
testref
</code>
shown in this
example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa11355583"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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> test1<span class="token punctuation">(</span>a1 <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> test2<span class="token punctuation">(</span>a2 <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> test3<span class="token punctuation">(</span>a3 <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 punctuation">;</span>
<span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> test4<span class="token punctuation">(</span>
a4 <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>
b4 <span class="token datatype">INT</span> <span class="token keyword">DEFAULT</span> <span class="token number">0</span>
<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">delimiter</span> <span class="token operator">|</span>
<span class="token keyword">CREATE</span> <span class="token keyword">TRIGGER</span> testref <span class="token keyword">BEFORE</span> <span class="token keyword">INSERT</span> <span class="token keyword">ON</span> test1
<span class="token keyword">FOR</span> <span class="token keyword">EACH</span> <span class="token keyword">ROW</span>
<span class="token keyword">BEGIN</span>
<span class="token keyword">INSERT</span> <span class="token keyword">INTO</span> test2 <span class="token keyword">SET</span> a2 <span class="token operator">=</span> <span class="token keyword">NEW</span><span class="token punctuation">.</span>a1<span class="token punctuation">;</span>
<span class="token keyword">DELETE</span> <span class="token keyword">FROM</span> test3 <span class="token keyword">WHERE</span> a3 <span class="token operator">=</span> <span class="token keyword">NEW</span><span class="token punctuation">.</span>a1<span class="token punctuation">;</span>
<span class="token keyword">UPDATE</span> test4 <span class="token keyword">SET</span> b4 <span class="token operator">=</span> b4 <span class="token operator">+</span> <span class="token number">1</span> <span class="token keyword">WHERE</span> a4 <span class="token operator">=</span> <span class="token keyword">NEW</span><span class="token punctuation">.</span>a1<span class="token punctuation">;</span>
<span class="token keyword">END</span><span class="token punctuation">;</span>
<span class="token operator">|</span>
<span class="token keyword">delimiter</span> <span class="token punctuation">;</span>
<span class="token keyword">INSERT</span> <span class="token keyword">INTO</span> test3 <span class="token punctuation">(</span>a3<span class="token punctuation">)</span> <span class="token keyword">VALUES</span>
<span class="token punctuation">(</span><span class="token boolean">NULL</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token punctuation">(</span><span class="token boolean">NULL</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token punctuation">(</span><span class="token boolean">NULL</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token punctuation">(</span><span class="token boolean">NULL</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token punctuation">(</span><span class="token boolean">NULL</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token punctuation">(</span><span class="token boolean">NULL</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token punctuation">(</span><span class="token boolean">NULL</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token punctuation">(</span><span class="token boolean">NULL</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token punctuation">(</span><span class="token boolean">NULL</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token punctuation">(</span><span class="token boolean">NULL</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">INSERT</span> <span class="token keyword">INTO</span> test4 <span class="token punctuation">(</span>a4<span class="token punctuation">)</span> <span class="token keyword">VALUES</span>
<span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
Suppose that you insert the following values into table
<code class="literal">
test1
</code>
as shown here:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa7642037"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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> test1 <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">3</span><span class="token punctuation">)</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 number">7</span><span class="token punctuation">)</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 number">8</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token punctuation">(</span><span class="token number">4</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token punctuation">(</span><span class="token number">4</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 8 rows affected (0.01 sec)</span>
<span class="token output">Records: 8 Duplicates: 0 Warnings: 0</span></code></pre>
</div>
<p>
As a result, the four tables contain the following data:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa26003281"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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> test1<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> a1 <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> 3 <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> 7 <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> 8 <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> 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>
<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> 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>
<span class="token output"><span class="token punctuation">|</span> a2 <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> 3 <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> 7 <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> 8 <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> 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>
<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> test3<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>
<span class="token output"><span class="token punctuation">|</span> a3 <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>
<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> 5 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 6 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 9 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 10 <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>
<span class="token output">5 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> test4<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>
<span class="token output"><span class="token punctuation">|</span> a4 <span class="token punctuation">|</span> b4 <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>
<span class="token output"><span class="token punctuation">|</span> 1 <span class="token punctuation">|</span> 3 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 2 <span class="token punctuation">|</span> 0 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 3 <span class="token punctuation">|</span> 1 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 4 <span class="token punctuation">|</span> 2 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 5 <span class="token punctuation">|</span> 0 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 6 <span class="token punctuation">|</span> 0 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 7 <span class="token punctuation">|</span> 1 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 8 <span class="token punctuation">|</span> 1 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 9 <span class="token punctuation">|</span> 0 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 10 <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>
<span class="token output">10 rows in set (0.00 sec)</span></code></pre>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/partitioning-columns.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="partitioning-columns">
</a>
26.2.3 COLUMNS Partitioning
</h3>
</div>
</div>
</div>
<div class="toc">
<dl class="toc">
<dt>
<span class="section">
<a href="partitioning-columns-range.html">
26.2.3.1 RANGE COLUMNS partitioning
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="partitioning-columns-list.html">
26.2.3.2 LIST COLUMNS partitioning
</a>
</span>
</dt>
</dl>
</div>
<a class="indexterm" name="idm46045084599280">
</a>
<a class="indexterm" name="idm46045084597792">
</a>
<a class="indexterm" name="idm46045084596720">
</a>
<a class="indexterm" name="idm46045084595632">
</a>
<a class="indexterm" name="idm46045084594544">
</a>
<a class="indexterm" name="idm46045084593472">
</a>
<p>
The next two sections discuss
<span class="firstterm">
<code class="literal">
COLUMNS
</code>
partitioning
</span>
, which are variants on
<code class="literal">
RANGE
</code>
and
<code class="literal">
LIST
</code>
partitioning.
<code class="literal">
COLUMNS
</code>
partitioning enables
the use of multiple columns in partitioning keys. All of these
columns are taken into account both for the purpose of placing
rows in partitions and for the determination of which partitions
are to be checked for matching rows in partition pruning.
</p>
<p>
In addition, both
<code class="literal">
RANGE COLUMNS
</code>
partitioning
and
<code class="literal">
LIST COLUMNS
</code>
partitioning support the use
of non-integer columns for defining value ranges or list
members. The permitted data types are shown in the following
list:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
All integer types:
<a class="link" href="integer-types.html" title="13.1.2 Integer Types (Exact Value) - INTEGER, INT, SMALLINT, TINYINT, MEDIUMINT, BIGINT">
<code class="literal">
TINYINT
</code>
</a>
,
<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>
,
<a class="link" href="integer-types.html" title="13.1.2 Integer Types (Exact Value) - INTEGER, INT, SMALLINT, TINYINT, MEDIUMINT, BIGINT">
<code class="literal">
MEDIUMINT
</code>
</a>
,
<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>
(
<a class="link" href="integer-types.html" title="13.1.2 Integer Types (Exact Value) - INTEGER, INT, SMALLINT, TINYINT, MEDIUMINT, BIGINT">
<code class="literal">
INTEGER
</code>
</a>
), and
<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>
. (This is the same as
with partitioning by
<code class="literal">
RANGE
</code>
and
<code class="literal">
LIST
</code>
.)
</p>
<p>
Other numeric data types (such as
<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>
or
<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>
) are not supported as
partitioning columns.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="datetime.html" title="13.2.2 The DATE, DATETIME, and TIMESTAMP Types">
<code class="literal">
DATE
</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>
.
</p>
<p>
Columns using other data types relating to dates or times
are not supported as partitioning columns.
</p>
</li>
<li class="listitem">
<p>
The following 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="binary-varbinary.html" title="13.3.3 The BINARY and VARBINARY Types">
<code class="literal">
BINARY
</code>
</a>
, and
<a class="link" href="binary-varbinary.html" title="13.3.3 The BINARY and VARBINARY Types">
<code class="literal">
VARBINARY
</code>
</a>
.
</p>
<p>
<a class="link" href="blob.html" title="13.3.4 The BLOB and TEXT Types">
<code class="literal">
TEXT
</code>
</a>
and
<a class="link" href="blob.html" title="13.3.4 The BLOB and TEXT Types">
<code class="literal">
BLOB
</code>
</a>
columns are not
supported as partitioning columns.
</p>
</li>
</ul>
</div>
<p>
The discussions of
<code class="literal">
RANGE COLUMNS
</code>
and
<code class="literal">
LIST COLUMNS
</code>
partitioning in the next two
sections assume that you are already familiar with partitioning
based on ranges and lists as supported in MySQL 5.1 and later;
for more information about these, see
<a class="xref" href="partitioning-range.html" title="26.2.1 RANGE Partitioning">
Section 26.2.1, “RANGE Partitioning”
</a>
, and
<a class="xref" href="partitioning-list.html" title="26.2.2 LIST Partitioning">
Section 26.2.2, “LIST Partitioning”
</a>
, respectively.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/recovery-from-backups.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="recovery-from-backups">
</a>
9.3.2 Using Backups for Recovery
</h3>
</div>
</div>
</div>
<p>
Now, suppose that we have a catastrophic unexpected exit on
Wednesday at 8 a.m. that requires recovery from backups. To
recover, first we restore the last full backup we have (the one
from Sunday 1 p.m.). The full backup file is just a set of SQL
statements, so restoring it is very easy:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa49948296"><div class="copy-help left">Press ⌘+C to 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> < backup_sunday_1_PM<span class="token punctuation">.</span>sql</code></pre>
</div>
<p>
At this point, the data is restored to its state as of Sunday 1
p.m.. To restore the changes made since then, we must use the
incremental backups; that is, the
<code class="filename">
gbichot2-bin.000007
</code>
and
<code class="filename">
gbichot2-bin.000008
</code>
binary log files. Fetch
the files if necessary from where they were backed up, and then
process their contents like this:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa2398624"><div class="copy-help left">Press ⌘+C to 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">mysqlbinlog</span> gbichot2-bin<span class="token punctuation">.</span>000007 gbichot2-bin<span class="token punctuation">.</span>000008 | mysql</code></pre>
</div>
<p>
We now have recovered the data to its state as of Tuesday 1
p.m., but still are missing the changes from that date to the
date of the crash. To not lose them, we would have needed to
have the MySQL server store its MySQL binary logs into a safe
location (RAID disks, SAN, ...) different from the place where
it stores its data files, so that these logs were not on the
destroyed disk. (That is, we can start the server with a
<a class="link" href="replication-options-binary-log.html#option_mysqld_log-bin">
<code class="option">
--log-bin
</code>
</a>
option that specifies a
location on a different physical device from the one on which
the data directory resides. That way, the logs are safe even if
the device containing the directory is lost.) If we had done
this, we would have the
<code class="filename">
gbichot2-bin.000009
</code>
file (and any subsequent files) at hand, and we could apply them
using
<a class="link" href="mysqlbinlog.html" title="6.6.9 mysqlbinlog — Utility for Processing Binary Log Files">
<span class="command">
<strong>
mysqlbinlog
</strong>
</span>
</a>
and
<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 restore the most recent data changes
with no loss up to the moment of the crash:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa7954365"><div class="copy-help left">Press ⌘+C to 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">mysqlbinlog</span> gbichot2-bin<span class="token punctuation">.</span>000009 <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span> | mysql</code></pre>
</div>
<p>
For more information about using
<a class="link" href="mysqlbinlog.html" title="6.6.9 mysqlbinlog — Utility for Processing Binary Log Files">
<span class="command">
<strong>
mysqlbinlog
</strong>
</span>
</a>
to process binary log files, see
<a class="xref" href="point-in-time-recovery.html" title="9.5 Point-in-Time (Incremental) Recovery">
Section 9.5, “Point-in-Time (Incremental) Recovery”
</a>
.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/document-store-concepts.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h2 class="title">
<a name="document-store-concepts">
</a>
22.2 Document Store Concepts
</h2>
</div>
</div>
</div>
<p>
This section explains the concepts introduced as part of using
MySQL as a document store.
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="xref" href="document-store-concepts.html#document-store-concepts-json-document" title="JSON Document">
JSON Document
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="document-store-concepts.html#document-store-concepts-collection" title="Collection">
Collection
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="document-store-concepts.html#document-store-concepts-crud-operation" title="CRUD Operations">
CRUD Operations
</a>
</p>
</li>
</ul>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h3 class="title">
<a name="document-store-concepts-json-document">
</a>
JSON Document
</h3>
</div>
</div>
</div>
<p>
A JSON document is a data structure composed of key-value pairs
and is the fundamental structure for using MySQL as document
store. For example, the world_x schema (installed later in this
chapter) contains this document:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-json"><div class="docs-select-all right" id="sa41173062"><div class="copy-help left">Press ⌘+C to 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">"GNP"</span><span class="token operator">:</span> <span class="token number">4834</span><span class="token punctuation">,</span>
<span class="token property">"_id"</span><span class="token operator">:</span> <span class="token string">"00005de917d80000000000000023"</span><span class="token punctuation">,</span>
<span class="token property">"Code"</span><span class="token operator">:</span> <span class="token string">"BWA"</span><span class="token punctuation">,</span>
<span class="token property">"Name"</span><span class="token operator">:</span> <span class="token string">"Botswana"</span><span class="token punctuation">,</span>
<span class="token property">"IndepYear"</span><span class="token operator">:</span> <span class="token number">1966</span><span class="token punctuation">,</span>
<span class="token property">"geography"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"Region"</span><span class="token operator">:</span> <span class="token string">"Southern Africa"</span><span class="token punctuation">,</span>
<span class="token property">"Continent"</span><span class="token operator">:</span> <span class="token string">"Africa"</span><span class="token punctuation">,</span>
<span class="token property">"SurfaceArea"</span><span class="token operator">:</span> <span class="token number">581730</span>
<span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token property">"government"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"HeadOfState"</span><span class="token operator">:</span> <span class="token string">"Festus G. Mogae"</span><span class="token punctuation">,</span>
<span class="token property">"GovernmentForm"</span><span class="token operator">:</span> <span class="token string">"Republic"</span>
<span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token property">"demographics"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"Population"</span><span class="token operator">:</span> <span class="token number">1622000</span><span class="token punctuation">,</span>
<span class="token property">"LifeExpectancy"</span><span class="token operator">:</span> <span class="token number">39.29999923706055</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span></code></pre>
</div>
<p>
This document shows that the values of keys can be simple data
types, such as integers or strings, but can also contain other
documents, arrays, and lists of documents. For example, the
<code class="literal">
geography
</code>
key's value consists of multiple
key-value pairs. A JSON document is represented internally using
the MySQL binary JSON object, through the
<a class="link" href="json.html" title="13.5 The JSON Data Type">
<code class="literal">
JSON
</code>
</a>
MySQL datatype.
</p>
<p>
The most important differences between a document and the tables
known from traditional relational databases are that the
structure of a document does not have to be defined in advance,
and a collection can contain multiple documents with different
structures. Relational tables on the other hand require that
their structure be defined, and all rows in the table must
contain the same columns.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h3 class="title">
<a name="document-store-concepts-collection">
</a>
Collection
</h3>
</div>
</div>
</div>
<p>
A collection is a container that is used to store JSON documents
in a MySQL database. Applications usually run operations against
a collection of documents, for example to find a specific
document.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h3 class="title">
<a name="document-store-concepts-crud-operation">
</a>
CRUD Operations
</h3>
</div>
</div>
</div>
<p>
The four basic operations that can be issued against a
collection are Create, Read, Update and Delete (CRUD). In terms
of MySQL this means:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Create a new document (insertion or addition)
</p>
</li>
<li class="listitem">
<p>
Read one or more documents (queries)
</p>
</li>
<li class="listitem">
<p>
Update one or more documents
</p>
</li>
<li class="listitem">
<p>
Delete one or more documents
</p>
</li>
</ul>
</div>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/string-literals.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="string-literals">
</a>
11.1.1 String Literals
</h3>
</div>
</div>
</div>
<a class="indexterm" name="idm46045220637808">
</a>
<a class="indexterm" name="idm46045220636320">
</a>
<a class="indexterm" name="idm46045220635248">
</a>
<a class="indexterm" name="idm46045220633760">
</a>
<a class="indexterm" name="idm46045220632272">
</a>
<a class="indexterm" name="idm46045220630784">
</a>
<p>
A string is a sequence of bytes or characters, enclosed within
either single quote (
<code class="literal">
'
</code>
) or double quote
(
<code class="literal">
"
</code>
) characters. Examples:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa29223045"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token string">'a string'</span>
<span class="token string">"another string"</span></code></pre>
</div>
<a class="indexterm" name="idm46045220626448">
</a>
<a class="indexterm" name="idm46045220625376">
</a>
<p>
Quoted strings placed next to each other are concatenated to a
single string. The following lines are equivalent:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa62397403"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token string">'a string'</span>
<span class="token string">'a'</span> <span class="token string">' '</span> <span class="token string">'string'</span></code></pre>
</div>
<p>
If the
<a class="link" href="sql-mode.html#sqlmode_ansi_quotes">
<code class="literal">
ANSI_QUOTES
</code>
</a>
SQL mode is
enabled, string literals can be quoted only within single
quotation marks because a string quoted within double quotation
marks is interpreted as an identifier.
</p>
<p>
A
<span class="firstterm">
binary string
</span>
is a
string of bytes. Every binary string has a character set and
collation named
<code class="literal">
binary
</code>
. A
<span class="firstterm">
nonbinary string
</span>
is a
string of characters. It has a character set other than
<code class="literal">
binary
</code>
and a collation that is compatible
with the character set.
</p>
<p>
For both types of strings, comparisons are based on the numeric
values of the string unit. For binary strings, the unit is the
byte; comparisons use numeric byte values. For nonbinary
strings, the unit is the character and some character sets
support multibyte characters; comparisons use numeric character
code values. Character code ordering is a function of the string
collation. (For more information, see
<a class="xref" href="charset-binary-collations.html" title="12.8.5 The binary Collation Compared to _bin Collations">
Section 12.8.5, “The binary Collation Compared to _bin Collations”
</a>
.)
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
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, binary strings
display using hexadecimal notation, depending on the value of
the
<a class="link" href="mysql-command-options.html#option_mysql_binary-as-hex">
<code class="option">
--binary-as-hex
</code>
</a>
. For more
information about that option, see
<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>
.
</p>
</div>
<p>
A character string literal may have an optional character set
introducer and
<code class="literal">
COLLATE
</code>
clause, to designate
it as a string that uses a particular character set and
collation:
</p>
<a class="indexterm" name="idm46045220610144">
</a>
<a class="indexterm" name="idm46045220608656">
</a>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa52601044"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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>_<em class="replaceable">charset_name</em><span class="token punctuation">]</span><span class="token string">'<em class="replaceable">string</em>'</span> <span class="token punctuation">[</span><span class="token keyword">COLLATE</span> <em class="replaceable">collation_name</em><span class="token punctuation">]</span></code></pre>
</div>
<p>
Examples:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa60348851"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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> _latin1<span class="token string">'<em class="replaceable">string</em>'</span><span class="token punctuation">;</span>
<span class="token keyword">SELECT</span> _binary<span class="token string">'<em class="replaceable">string</em>'</span><span class="token punctuation">;</span>
<span class="token keyword">SELECT</span> _utf8mb4<span class="token string">'<em class="replaceable">string</em>'</span> <span class="token keyword">COLLATE</span> utf8mb4_danish_ci<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="sa84577320"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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>
For information about these forms of string syntax, see
<a class="xref" href="charset-national.html" title="12.3.7 The National Character Set">
Section 12.3.7, “The National Character Set”
</a>
, and
<a class="xref" href="charset-introducer.html" title="12.3.8 Character Set Introducers">
Section 12.3.8, “Character Set Introducers”
</a>
.
</p>
<p>
Within a string, certain sequences have special meaning unless
the
<a class="link" href="sql-mode.html#sqlmode_no_backslash_escapes">
<code class="literal">
NO_BACKSLASH_ESCAPES
</code>
</a>
SQL
mode is enabled. Each of these sequences begins with a backslash
(
<code class="literal">
\
</code>
), known as the
<span class="emphasis">
<em>
escape
character
</em>
</span>
. MySQL recognizes the escape sequences
shown in
<a class="xref" href="string-literals.html#character-escape-sequences" title="Table 11.1 Special Character Escape Sequences">
Table 11.1, “Special Character Escape Sequences”
</a>
. For all
other escape sequences, backslash is ignored. That is, the
escaped character is interpreted as if it was not escaped. For
example,
<code class="literal">
\x
</code>
is just
<code class="literal">
x
</code>
.
These sequences are case-sensitive. For example,
<code class="literal">
\b
</code>
is interpreted as a backspace, but
<code class="literal">
\B
</code>
is interpreted as
<code class="literal">
B
</code>
.
Escape processing is done according to the character set
indicated by the
<a class="link" href="server-system-variables.html#sysvar_character_set_connection">
<code class="literal">
character_set_connection
</code>
</a>
system
variable. This is true even for strings that are preceded by an
introducer that indicates a different character set, as
discussed in
<a class="xref" href="charset-literal.html" title="12.3.6 Character String Literal Character Set and Collation">
Section 12.3.6, “Character String Literal Character Set and Collation”
</a>
.
</p>
<div class="table">
<a name="character-escape-sequences">
</a>
<p class="title">
<b>
Table 11.1 Special Character Escape Sequences
</b>
</p>
<div class="table-contents">
<table summary="Escape sequences and the characters they represent.">
<colgroup>
<col style="width: 15%"/>
<col style="width: 85%"/>
</colgroup>
<thead>
<tr>
<th>
Escape Sequence
</th>
<th>
Character Represented by Sequence
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<code class="literal">
\0
</code>
<a class="indexterm" name="idm46045220579648">
</a>
<a class="indexterm" name="idm46045220578704">
</a>
</td>
<td>
An ASCII NUL (
<code class="literal">
X'00'
</code>
) character
</td>
</tr>
<tr>
<td>
<code class="literal">
\'
</code>
<a class="indexterm" name="idm46045220574528">
</a>
<a class="indexterm" name="idm46045220573584">
</a>
</td>
<td>
A single quote (
<code class="literal">
'
</code>
) character
</td>
</tr>
<tr>
<td>
<code class="literal">
\"
</code>
<a class="indexterm" name="idm46045220569408">
</a>
<a class="indexterm" name="idm46045220568464">
</a>
</td>
<td>
A double quote (
<code class="literal">
"
</code>
) character
</td>
</tr>
<tr>
<td>
<code class="literal">
\b
</code>
<a class="indexterm" name="idm46045220564288">
</a>
<a class="indexterm" name="idm46045220563344">
</a>
</td>
<td>
A backspace character
</td>
</tr>
<tr>
<td>
<code class="literal">
\n
</code>
<a class="indexterm" name="idm46045220559856">
</a>
<a class="indexterm" name="idm46045220558912">
</a>
<a class="indexterm" name="idm46045220557968">
</a>
<a class="indexterm" name="idm46045220557024">
</a>
</td>
<td>
A newline (linefeed) character
</td>
</tr>
<tr>
<td>
<code class="literal">
\r
</code>
<a class="indexterm" name="idm46045220553520">
</a>
<a class="indexterm" name="idm46045220552576">
</a>
<a class="indexterm" name="idm46045220551632">
</a>
</td>
<td>
A carriage return character
</td>
</tr>
<tr>
<td>
<code class="literal">
\t
</code>
<a class="indexterm" name="idm46045220548128">
</a>
<a class="indexterm" name="idm46045220547184">
</a>
</td>
<td>
A tab character
</td>
</tr>
<tr>
<td>
<code class="literal">
\Z
</code>
<a class="indexterm" name="idm46045220543696">
</a>
<a class="indexterm" name="idm46045220542752">
</a>
</td>
<td>
ASCII 26 (Control+Z); see note following the table
</td>
</tr>
<tr>
<td>
<code class="literal">
\\
</code>
<a class="indexterm" name="idm46045220539232">
</a>
<a class="indexterm" name="idm46045220538288">
</a>
</td>
<td>
A backslash (
<code class="literal">
\
</code>
) character
</td>
</tr>
<tr>
<td>
<code class="literal">
\%
</code>
<a class="indexterm" name="idm46045220534112">
</a>
<a class="indexterm" name="idm46045220533168">
</a>
</td>
<td>
A
<code class="literal">
%
</code>
character; see note following the table
</td>
</tr>
<tr>
<td>
<code class="literal">
\_
</code>
<a class="indexterm" name="idm46045220528944">
</a>
<a class="indexterm" name="idm46045220528000">
</a>
</td>
<td>
A
<code class="literal">
_
</code>
character; see note following the table
</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: 110.688px;">
Escape Sequence
</th>
<th style="width: 627.312px;">
Character Represented by Sequence
</th>
</tr>
</thead>
</table>
</div>
</div>
<br class="table-break"/>
<p>
The ASCII 26 character can be encoded as
<code class="literal">
\Z
</code>
to enable you to work around the problem that ASCII 26 stands
for END-OF-FILE on Windows. ASCII 26 within a file causes
problems if you try to use
<code class="literal">
mysql
<em class="replaceable">
<code>
db_name
</code>
</em>
<
<em class="replaceable">
<code>
file_name
</code>
</em>
</code>
.
</p>
<p>
The
<code class="literal">
\%
</code>
and
<code class="literal">
\_
</code>
sequences
are used to search for literal instances of
<code class="literal">
%
</code>
and
<code class="literal">
_
</code>
in pattern-matching contexts where they
would otherwise be interpreted as wildcard characters. See the
description of the
<a class="link" href="string-comparison-functions.html#operator_like">
<code class="literal">
LIKE
</code>
</a>
operator in
<a class="xref" href="string-comparison-functions.html" title="14.8.1 String Comparison Functions and Operators">
Section 14.8.1, “String Comparison Functions and Operators”
</a>
. If you use
<code class="literal">
\%
</code>
or
<code class="literal">
\_
</code>
outside of
pattern-matching contexts, they evaluate to the strings
<code class="literal">
\%
</code>
and
<code class="literal">
\_
</code>
, not to
<code class="literal">
%
</code>
and
<code class="literal">
_
</code>
.
</p>
<a class="indexterm" name="idm46045220512672">
</a>
<p>
There are several ways to include quote characters within a
string:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
A
<code class="literal">
'
</code>
inside a string quoted with
<code class="literal">
'
</code>
may be written as
<code class="literal">
''
</code>
.
</p>
</li>
<li class="listitem">
<p>
A
<code class="literal">
"
</code>
inside a string quoted with
<code class="literal">
"
</code>
may be written as
<code class="literal">
""
</code>
.
</p>
</li>
<li class="listitem">
<p>
Precede the quote character by an escape character
(
<code class="literal">
\
</code>
).
</p>
</li>
<li class="listitem">
<p>
A
<code class="literal">
'
</code>
inside a string quoted with
<code class="literal">
"
</code>
needs no special treatment and need not
be doubled or escaped. In the same way,
<code class="literal">
"
</code>
inside a string quoted with
<code class="literal">
'
</code>
needs no
special treatment.
</p>
</li>
</ul>
</div>
<p>
The following
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
statements
demonstrate how quoting and escaping work:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa72181678"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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 string">'hello'</span><span class="token punctuation">,</span> <span class="token string">'"hello"'</span><span class="token punctuation">,</span> <span class="token string">'""hello""'</span><span class="token punctuation">,</span> <span class="token string">'hel'</span><span class="token string">'lo'</span><span class="token punctuation">,</span> <span class="token string">'\'hello'</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>
<span class="token output"><span class="token punctuation">|</span> hello <span class="token punctuation">|</span> "hello" <span class="token punctuation">|</span> ""hello"" <span class="token punctuation">|</span> hel'lo <span class="token punctuation">|</span> 'hello <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>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token string">"hello"</span><span class="token punctuation">,</span> <span class="token string">"'hello'"</span><span class="token punctuation">,</span> <span class="token string">"''hello''"</span><span class="token punctuation">,</span> <span class="token string">"hel"</span><span class="token string">"lo"</span><span class="token punctuation">,</span> <span class="token string">"\"hello"</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>
<span class="token output"><span class="token punctuation">|</span> hello <span class="token punctuation">|</span> 'hello' <span class="token punctuation">|</span> ''hello'' <span class="token punctuation">|</span> hel"lo <span class="token punctuation">|</span> "hello <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>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token string">'This\nIs\nFour\nLines'</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 operator">|</span> This
<span class="token operator">Is</span>
Four
<span class="token keyword">Lines</span> <span class="token operator">|</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> <span class="token string">'disappearing\ backslash'</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>
<span class="token output"><span class="token punctuation">|</span> disappearing backslash <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></code></pre>
</div>
<a class="indexterm" name="idm46045220492800">
</a>
<p>
To insert binary data into a string column (such as a
<a class="link" href="blob.html" title="13.3.4 The BLOB and TEXT Types">
<code class="literal">
BLOB
</code>
</a>
column), you should
represent certain characters by escape sequences. Backslash
(
<code class="literal">
\
</code>
) and the quote character used to quote the
string must be escaped. In certain client environments, it may
also be necessary to escape
<code class="literal">
NUL
</code>
or Control+Z.
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 truncates quoted strings
containing
<code class="literal">
NUL
</code>
characters if they are not
escaped, and Control+Z may be taken for END-OF-FILE on Windows
if not escaped. For the escape sequences that represent each of
these characters, see
<a class="xref" href="string-literals.html#character-escape-sequences" title="Table 11.1 Special Character Escape Sequences">
Table 11.1, “Special Character Escape Sequences”
</a>
.
</p>
<a class="indexterm" name="idm46045220485536">
</a>
<a class="indexterm" name="idm46045220484464">
</a>
<a class="indexterm" name="idm46045220482976">
</a>
<a class="indexterm" name="idm46045220481936">
</a>
<a class="indexterm" name="idm46045220480864">
</a>
<p>
When writing application programs, any string that might contain
any of these special characters must be properly escaped before
the string is used as a data value in an SQL statement that is
sent to the MySQL server. You can do this in two ways:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Process the string with a function that escapes the special
characters. In a C program, you can use the
<a class="ulink" href="/doc/c-api/8.4/en/mysql-real-escape-string-quote.html" target="_top">
<code class="literal">
mysql_real_escape_string_quote()
</code>
</a>
C API function to escape characters. See
<a class="ulink" href="/doc/c-api/8.4/en/mysql-real-escape-string-quote.html" target="_top">
mysql_real_escape_string_quote()
</a>
. Within SQL
statements that construct other SQL statements, you can use
the
<a class="link" href="string-functions.html#function_quote">
<code class="literal">
QUOTE()
</code>
</a>
function. The
Perl DBI interface provides a
<code class="literal">
quote
</code>
method to convert special characters to the proper escape
sequences. See
<a class="xref" href="apis-perl.html" title="31.9 MySQL Perl API">
Section 31.9, “MySQL Perl API”
</a>
. Other language
interfaces may provide a similar capability.
</p>
</li>
<li class="listitem">
<p>
As an alternative to explicitly escaping special characters,
many MySQL APIs provide a placeholder capability that
enables you to insert special markers into a statement
string, and then bind data values to them when you issue the
statement. In this case, the API takes care of escaping
special characters in the values for you.
</p>
</li>
</ul>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/information-schema-st-geometry-columns-table.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="information-schema-st-geometry-columns-table">
</a>
28.3.35 The INFORMATION_SCHEMA ST_GEOMETRY_COLUMNS Table
</h3>
</div>
</div>
</div>
<a class="indexterm" name="idm46045078574096">
</a>
<p>
The
<a class="link" href="information-schema-st-geometry-columns-table.html" title="28.3.35 The INFORMATION_SCHEMA ST_GEOMETRY_COLUMNS Table">
<code class="literal">
ST_GEOMETRY_COLUMNS
</code>
</a>
table
provides information about table columns that store spatial data.
This table is based on the SQL/MM (ISO/IEC 13249-3) standard, with
extensions as noted. MySQL implements
<a class="link" href="information-schema-st-geometry-columns-table.html" title="28.3.35 The INFORMATION_SCHEMA ST_GEOMETRY_COLUMNS Table">
<code class="literal">
ST_GEOMETRY_COLUMNS
</code>
</a>
as a view on the
<code class="literal">
INFORMATION_SCHEMA
</code>
<a class="link" href="information-schema-columns-table.html" title="28.3.8 The INFORMATION_SCHEMA COLUMNS Table">
<code class="literal">
COLUMNS
</code>
</a>
table.
</p>
<p>
The
<a class="link" href="information-schema-st-geometry-columns-table.html" title="28.3.35 The INFORMATION_SCHEMA ST_GEOMETRY_COLUMNS Table">
<code class="literal">
ST_GEOMETRY_COLUMNS
</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
column 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 column belongs.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
TABLE_NAME
</code>
</p>
<p>
The name of the table containing the column.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
COLUMN_NAME
</code>
</p>
<p>
The name of the column.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SRS_NAME
</code>
</p>
<p>
The spatial reference system (SRS) name.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SRS_ID
</code>
</p>
<p>
The spatial reference system ID (SRID).
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
GEOMETRY_TYPE_NAME
</code>
</p>
<p>
The column data type. Permitted values are:
<code class="literal">
geometry
</code>
,
<code class="literal">
point
</code>
,
<code class="literal">
linestring
</code>
,
<code class="literal">
polygon
</code>
,
<code class="literal">
multipoint
</code>
,
<code class="literal">
multilinestring
</code>
,
<code class="literal">
multipolygon
</code>
,
<code class="literal">
geometrycollection
</code>
. This column is a MySQL
extension to the standard.
</p>
</li>
</ul>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/drop-logfile-group.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="drop-logfile-group">
</a>
15.1.28 DROP LOGFILE GROUP Statement
</h3>
</div>
</div>
</div>
<a class="indexterm" name="idm46045183421792">
</a>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa30525518"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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">LOGFILE</span> <span class="token keyword">GROUP</span> <em class="replaceable">logfile_group</em>
<span class="token keyword">ENGINE</span> <span class="token punctuation">[</span><span class="token operator">=</span><span class="token punctuation">]</span> <em class="replaceable">engine_name</em></code></pre>
</div>
<p>
This statement drops the log file group named
<em class="replaceable">
<code>
logfile_group
</code>
</em>
. The log file group must
already exist or an error results. (For information on creating
log file groups, see
<a class="xref" href="create-logfile-group.html" title="15.1.16 CREATE LOGFILE GROUP Statement">
Section 15.1.16, “CREATE LOGFILE GROUP Statement”
</a>
.)
</p>
<div class="important" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Important
</div>
<p>
Before dropping a log file group, you must drop all tablespaces
that use that log file group for
<code class="literal">
UNDO
</code>
logging.
</p>
</div>
<p>
The required
<code class="literal">
ENGINE
</code>
clause provides the name of
the storage engine used by the log file group to be dropped. The
only permitted values for
<em class="replaceable">
<code>
engine_name
</code>
</em>
are
<a class="link" href="mysql-cluster.html" title="Chapter 25 MySQL NDB Cluster 8.4">
<code class="literal">
NDB
</code>
</a>
and
<a class="link" href="mysql-cluster.html" title="Chapter 25 MySQL NDB Cluster 8.4">
<code class="literal">
NDBCLUSTER
</code>
</a>
.
</p>
<p>
<a class="link" href="drop-logfile-group.html" title="15.1.28 DROP LOGFILE GROUP Statement">
<code class="literal">
DROP LOGFILE GROUP
</code>
</a>
is useful only
with Disk Data storage for NDB Cluster. 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>
.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/innodb-troubleshooting.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h2 class="title">
<a name="innodb-troubleshooting">
</a>
17.20 InnoDB Troubleshooting
</h2>
</div>
</div>
</div>
<div class="toc">
<dl class="toc">
<dt>
<span class="section">
<a href="error-creating-innodb.html">
17.20.1 Troubleshooting InnoDB I/O Problems
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="innodb-troubleshooting-recovery.html">
17.20.2 Troubleshooting Recovery Failures
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="forcing-innodb-recovery.html">
17.20.3 Forcing InnoDB Recovery
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="innodb-troubleshooting-datadict.html">
17.20.4 Troubleshooting InnoDB Data Dictionary Operations
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="innodb-error-handling.html">
17.20.5 InnoDB Error Handling
</a>
</span>
</dt>
</dl>
</div>
<a class="indexterm" name="idm46045149070336">
</a>
<p>
The following general guidelines apply to troubleshooting
<code class="literal">
InnoDB
</code>
problems:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
When an operation fails or you suspect a bug, look at the MySQL
server 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>
).
<a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html" target="_top">
Server Error Message Reference
</a>
provides
troubleshooting information for some of the common
<code class="literal">
InnoDB
</code>
-specific errors that you may
encounter.
</p>
</li>
<li class="listitem">
<p>
If the failure is related to a
<a class="link" href="glossary.html#glos_deadlock" title="deadlock">
deadlock
</a>
, run with the
<a class="link" href="innodb-parameters.html#sysvar_innodb_print_all_deadlocks">
<code class="literal">
innodb_print_all_deadlocks
</code>
</a>
option enabled so that details about each deadlock are printed
to the MySQL server error log. For information about deadlocks,
see
<a class="xref" href="innodb-deadlocks.html" title="17.7.5 Deadlocks in InnoDB">
Section 17.7.5, “Deadlocks in InnoDB”
</a>
.
</p>
</li>
<li class="listitem">
<p>
If the issue is related to the
<code class="literal">
InnoDB
</code>
data
dictionary, see
<a class="xref" href="innodb-troubleshooting-datadict.html" title="17.20.4 Troubleshooting InnoDB Data Dictionary Operations">
Section 17.20.4, “Troubleshooting InnoDB Data Dictionary Operations”
</a>
.
</p>
</li>
<li class="listitem">
<p>
When troubleshooting, it is usually best to run the MySQL server
from the command prompt, rather than through
<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 as a Windows service. You can
then see what
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
prints to the console,
and so have a better grasp of what is going on. On Windows,
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
<a class="link" href="server-options.html#option_mysqld_console">
<code class="option">
--console
</code>
</a>
option to direct the
output to the console window.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045149051824">
</a>
<a class="indexterm" name="idm46045149050336">
</a>
Enable the
<code class="literal">
InnoDB
</code>
Monitors to obtain
information about a problem (see
<a class="xref" href="innodb-monitors.html" title="17.17 InnoDB Monitors">
Section 17.17, “InnoDB Monitors”
</a>
). If the problem is
performance-related, or your server appears to be hung, you
should enable the standard Monitor to print information about
the internal state of
<code class="literal">
InnoDB
</code>
. If the problem
is with locks, enable the Lock Monitor. If the problem is with
table creation, tablespaces, or data dictionary operations,
refer to the
<a class="link" href="innodb-information-schema-system-tables.html" title="17.15.3 InnoDB INFORMATION_SCHEMA Schema Object Tables">
InnoDB
Information Schema system tables
</a>
to examine contents of
the
<code class="literal">
InnoDB
</code>
internal data dictionary.
</p>
<p>
<code class="literal">
InnoDB
</code>
temporarily enables standard
<code class="literal">
InnoDB
</code>
Monitor output under the following
conditions:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
A long semaphore wait
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
InnoDB
</code>
cannot find free blocks in the
buffer pool
</p>
</li>
<li class="listitem">
<p>
Over 67% of the buffer pool is occupied by lock heaps or the
adaptive hash index
</p>
</li>
</ul>
</div>
</li>
<li class="listitem">
<p>
If you suspect that a table is corrupt, run
<a class="link" href="check-table.html" title="15.7.3.2 CHECK TABLE Statement">
<code class="literal">
CHECK TABLE
</code>
</a>
on that table.
</p>
</li>
</ul>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/shutdown.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="shutdown">
</a>
15.7.8.9 SHUTDOWN Statement
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045168232752">
</a>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa19301780"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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">SHUTDOWN</span></code></pre>
</div>
<p>
This statement stops the MySQL server. It requires the
<a class="link" href="privileges-provided.html#priv_shutdown">
<code class="literal">
SHUTDOWN
</code>
</a>
privilege.
</p>
<p>
<a class="link" href="shutdown.html" title="15.7.8.9 SHUTDOWN Statement">
<code class="literal">
SHUTDOWN
</code>
</a>
provides an SQL-level
interface to the same functionality available using the
<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>
command. A successful
<a class="link" href="shutdown.html" title="15.7.8.9 SHUTDOWN Statement">
<code class="literal">
SHUTDOWN
</code>
</a>
sequence consists of
checking the privileges, validating the arguments, and sending
an OK packet to the client. Then the server is shut down.
</p>
<p>
The
<a class="link" href="server-status-variables.html#statvar_Com_xxx">
<code class="literal">
Com_shutdown
</code>
</a>
status variable tracks the number of
<a class="link" href="shutdown.html" title="15.7.8.9 SHUTDOWN Statement">
<code class="literal">
SHUTDOWN
</code>
</a>
statements. Because
status variables are initialized for each server startup and do
not persist across restarts,
<code class="literal">
Com_shutdown
</code>
normally has a value of zero, but can be nonzero if
<a class="link" href="shutdown.html" title="15.7.8.9 SHUTDOWN Statement">
<code class="literal">
SHUTDOWN
</code>
</a>
statements were executed
but failed.
</p>
<a class="indexterm" name="idm46045168216576">
</a>
<p>
Another way to stop the server is to send it a
<code class="literal">
SIGTERM
</code>
signal, which can be done by
<code class="literal">
root
</code>
or the account that owns the server
process.
<code class="literal">
SIGTERM
</code>
enables server shutdown to
be performed without having to connect to the server. See
<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>
.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/administration-issues.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="administration-issues">
</a>
B.3.3 Administration-Related Issues
</h3>
</div>
</div>
</div>
<div class="toc">
<dl class="toc">
<dt>
<span class="section">
<a href="file-permissions.html">
B.3.3.1 Problems with File Permissions
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="resetting-permissions.html">
B.3.3.2 How to Reset the Root Password
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="crashing.html">
B.3.3.3 What to Do If MySQL Keeps Crashing
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="full-disk.html">
B.3.3.4 How MySQL Handles a Full Disk
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="temporary-files.html">
B.3.3.5 Where MySQL Stores Temporary Files
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="problems-with-mysql-sock.html">
B.3.3.6 How to Protect or Change the MySQL Unix Socket File
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="timezone-problems.html">
B.3.3.7 Time Zone Problems
</a>
</span>
</dt>
</dl>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/show-relaylog-events.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="show-relaylog-events">
</a>
15.7.7.34 SHOW RELAYLOG EVENTS Statement
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045169725936">
</a>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa74669434"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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">RELAYLOG</span> <span class="token keyword">EVENTS</span>
<span class="token punctuation">[</span><span class="token keyword">IN</span> <span class="token string">'<em class="replaceable">log_name</em>'</span><span class="token punctuation">]</span>
<span class="token punctuation">[</span><span class="token keyword">FROM</span> <em class="replaceable">pos</em><span class="token punctuation">]</span>
<span class="token punctuation">[</span><span class="token keyword">LIMIT</span> <span class="token punctuation">[</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">row_count</em></span><span class="token punctuation">]</span>
<span class="token punctuation">[</span><em class="replaceable">channel_option</em><span class="token punctuation">]</span>
<em class="replaceable">channel_option</em>:
<span class="token keyword">FOR</span> <span class="token keyword">CHANNEL</span> <span class="token keyword"><em class="replaceable">channel</em></span></code></pre>
</div>
<p>
Shows the events in the relay log of a replica. If you do not
specify
<code class="literal">
'
<em class="replaceable">
<code>
log_name
</code>
</em>
'
</code>
, the
first relay log is displayed. This statement has no effect on
the source.
<code class="literal">
SHOW RELAYLOG EVENTS
</code>
requires the
<a class="link" href="privileges-provided.html#priv_replication-slave">
<code class="literal">
REPLICATION SLAVE
</code>
</a>
privilege.
</p>
<p>
The
<code class="literal">
LIMIT
</code>
clause has the same syntax as for
the
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
statement. See
<a class="xref" href="select.html" title="15.2.13 SELECT Statement">
Section 15.2.13, “SELECT Statement”
</a>
.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
Issuing a
<a class="link" href="show-relaylog-events.html" title="15.7.7.34 SHOW RELAYLOG EVENTS Statement">
<code class="literal">
SHOW RELAYLOG EVENTS
</code>
</a>
with no
<code class="literal">
LIMIT
</code>
clause could start a very
time- and resource-consuming process because the server
returns to the client the complete contents of the relay log
(including all statements modifying data that have been
received by the replica).
</p>
</div>
<p>
The optional
<code class="literal">
FOR CHANNEL
<em class="replaceable">
<code>
channel
</code>
</em>
</code>
clause enables you
to name which replication channel the statement applies to.
Providing a
<code class="literal">
FOR CHANNEL
<em class="replaceable">
<code>
channel
</code>
</em>
</code>
clause applies the
statement to a specific replication channel. If no channel is
named and no extra channels exist, the statement applies to the
default channel.
</p>
<p>
When using multiple replication channels, if a
<a class="link" href="show-relaylog-events.html" title="15.7.7.34 SHOW RELAYLOG EVENTS Statement">
<code class="literal">
SHOW RELAYLOG EVENTS
</code>
</a>
statement
does not have a channel defined using a
<code class="literal">
FOR CHANNEL
<em class="replaceable">
<code>
channel
</code>
</em>
</code>
clause an error is
generated. 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>
<a class="link" href="show-relaylog-events.html" title="15.7.7.34 SHOW RELAYLOG EVENTS Statement">
<code class="literal">
SHOW RELAYLOG EVENTS
</code>
</a>
displays the
following fields for each event in the relay log:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
Log_name
</code>
</p>
<p>
The name of the file that is being listed.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
Pos
</code>
</p>
<p>
The position at which the event occurs.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
Event_type
</code>
</p>
<p>
An identifier that describes the event type.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
Server_id
</code>
</p>
<p>
The server ID of the server on which the event originated.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
End_log_pos
</code>
</p>
<p>
The value of
<code class="literal">
End_log_pos
</code>
for this event
in the source's binary log.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
Info
</code>
</p>
<p>
More detailed information about the event type. The format
of this information depends on the event type.
</p>
</li>
</ul>
</div>
<p>
For compressed transaction payloads, the
<code class="literal">
Transaction_payload_event
</code>
is first printed as
a single unit, then it is unpacked and each event inside it is
printed.
</p>
<p>
Some events relating to the setting of user and system variables
are not included in the output from
<a class="link" href="show-relaylog-events.html" title="15.7.7.34 SHOW RELAYLOG EVENTS Statement">
<code class="literal">
SHOW
RELAYLOG EVENTS
</code>
</a>
. To get complete coverage of events
within a relay log, use
<a class="link" href="mysqlbinlog.html" title="6.6.9 mysqlbinlog — Utility for Processing Binary Log Files">
<span class="command">
<strong>
mysqlbinlog
</strong>
</span>
</a>
.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/upgrade-paths.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h2 class="title">
<a name="upgrade-paths">
</a>
3.2 Upgrade Paths
</h2>
</div>
</div>
</div>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Notes
</div>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Make sure you understand
<a class="link" href="mysql-releases.html" title="1.3 MySQL Releases: Innovation and LTS">
the
MySQL release model
</a>
for MySQL for MySQL long
long-term support (LTS) and Innovation versions before
proceeding with a downgrade.
</p>
</li>
<li class="listitem">
<p>
We recommend checking upgrade compatibility with MySQL
Shell's
<a class="ulink" href="/doc/mysql-shell/8.4/en/mysql-shell-utilities-upgrade.html" target="_top">
Upgrade Checker Utility
</a>
before performing an upgrade.
</p>
</li>
<li class="listitem">
<p>
A replication topology is upgraded by following the rolling
upgrade scheme described at
<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>
, which uses one of the
supported single-server methods for each individual server
upgrade.
</p>
</li>
<li class="listitem">
<p>
Monthly Rapid Updates (MRUs) and hot fixes also count as
releases in this documentation.
</p>
</li>
</ul>
</div>
</div>
<div class="table">
<a name="mysqld-upgrade-paths">
</a>
<p class="title">
<b>
Table 3.1 Upgrade Paths for MySQL Server
</b>
</p>
<div class="table-contents">
<table>
<colgroup>
<col width="35%"/>
<col width="15%"/>
<col width="50%"/>
</colgroup>
<thead>
<tr>
<th scope="col">
Upgrade Path
</th>
<th scope="col">
Path Examples
</th>
<th scope="col">
Supported Upgrade Methods
</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">
Within an LTS or Bugfix series
</th>
<td>
8.0.37 to 8.0.41 or 8.4.0 to 8.4.4
</td>
<td>
<a class="link" href="upgrade-binary-package.html#upgrade-procedure-inplace" title="In-Place Upgrade">
In-place upgrade
</a>
,
<a class="link" href="upgrade-binary-package.html#upgrade-procedure-logical" title="Logical Upgrade">
logical dump and
load
</a>
,
<a class="link" href="replication-upgrade.html" title="19.5.3 Upgrading or Downgrading a Replication Topology">
replication
</a>
, and
<a class="ulink" href="/doc/mysql-shell/8.4/en/mysql-innodb-cluster-clone-deployment.html" target="_top">
MySQL
Clone
</a>
</td>
</tr>
<tr>
<th scope="row">
From an LTS or Bugfix series to the next
<a class="link" href="glossary.html#glos_lts_series" title="LTS Series">
LTS series
</a>
</th>
<td>
8.0.37 to 8.4.x LTS
</td>
<td>
<a class="link" href="upgrade-binary-package.html#upgrade-procedure-inplace" title="In-Place Upgrade">
In-place upgrade
</a>
,
<a class="link" href="upgrade-binary-package.html#upgrade-procedure-logical" title="Logical Upgrade">
logical dump and
load
</a>
, and
<a class="link" href="replication-upgrade.html" title="19.5.3 Upgrading or Downgrading a Replication Topology">
replication
</a>
</td>
</tr>
<tr>
<th scope="row">
From an LTS or Bugfix release to an Innovation release
<span class="emphasis">
<em>
before
the next LTS series
</em>
</span>
</th>
<td>
8.0.34 to 8.3.0 or 8.4.0 to 9.0.0
</td>
<td>
<a class="link" href="upgrade-binary-package.html#upgrade-procedure-inplace" title="In-Place Upgrade">
In-place upgrade
</a>
,
<a class="link" href="upgrade-binary-package.html#upgrade-procedure-logical" title="Logical Upgrade">
logical dump and
load
</a>
, and
<a class="link" href="replication-upgrade.html" title="19.5.3 Upgrading or Downgrading a Replication Topology">
replication
</a>
</td>
</tr>
<tr>
<th scope="row">
From an
<a class="link" href="glossary.html#glos_innovation_series" title="Innovation Series">
Innovation series
</a>
to the next
<a class="link" href="glossary.html#glos_lts_series" title="LTS Series">
LTS
series
</a>
</th>
<td>
8.3.0 to 8.4 LTS
</td>
<td>
<a class="link" href="upgrade-binary-package.html#upgrade-procedure-inplace" title="In-Place Upgrade">
In-place upgrade
</a>
,
<a class="link" href="upgrade-binary-package.html#upgrade-procedure-logical" title="Logical Upgrade">
logical dump and
load
</a>
, and
<a class="link" href="replication-upgrade.html" title="19.5.3 Upgrading or Downgrading a Replication Topology">
replication
</a>
</td>
</tr>
<tr>
<th scope="row">
From an Innovation series to an Innovation release
<span class="emphasis">
<em>
after the
next LTS series
</em>
</span>
</th>
<td>
Not allowed, two steps are required: 8.3.0 to 8.4 LTS, and 8.4 LTS to
9.x Innovation
</td>
<td>
<a class="link" href="upgrade-binary-package.html#upgrade-procedure-inplace" title="In-Place Upgrade">
In-place upgrade
</a>
,
<a class="link" href="upgrade-binary-package.html#upgrade-procedure-logical" title="Logical Upgrade">
logical dump and
load
</a>
, and
<a class="link" href="replication-upgrade.html" title="19.5.3 Upgrading or Downgrading a Replication Topology">
replication
</a>
</td>
</tr>
<tr>
<th scope="row">
From within an Innovation series
</th>
<td>
8.1.0 to 8.3.0
</td>
<td>
<a class="link" href="upgrade-binary-package.html#upgrade-procedure-inplace" title="In-Place Upgrade">
In-place upgrade
</a>
,
<a class="link" href="upgrade-binary-package.html#upgrade-procedure-logical" title="Logical Upgrade">
logical dump and
load
</a>
, and
<a class="link" href="replication-upgrade.html" title="19.5.3 Upgrading or Downgrading a Replication Topology">
replication
</a>
</td>
</tr>
<tr>
<th scope="row">
From MySQL 5.7 to an LTS or Innovation release
</th>
<td>
MySQL 5.7 to 8.4
</td>
<td>
A bugfix or LTS series cannot be skipped, so in this example first
<a class="ulink" href="/doc/refman/8.0/en/upgrade-paths.html" target="_top">
upgrade MySQL 5.7
to MySQL 8.0
</a>
, and then upgrade MySQL 8.0 to MySQL
8.4.
</td>
</tr>
</tbody>
</table>
</div>
</div>
<br class="table-break"/>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/information-schema-check-constraints-table.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="information-schema-check-constraints-table">
</a>
28.3.5 The INFORMATION_SCHEMA CHECK_CONSTRAINTS Table
</h3>
</div>
</div>
</div>
<a class="indexterm" name="idm46045080314496">
</a>
<p>
<a class="link" href="create-table.html" title="15.1.20 CREATE TABLE Statement">
<code class="literal">
CREATE TABLE
</code>
</a>
supports the core
features of table and column
<code class="literal">
CHECK
</code>
constraints;
the
<a class="link" href="information-schema-check-constraints-table.html" title="28.3.5 The INFORMATION_SCHEMA CHECK_CONSTRAINTS Table">
<code class="literal">
CHECK_CONSTRAINTS
</code>
</a>
table provides
information about these constraints.
</p>
<p>
The
<a class="link" href="information-schema-check-constraints-table.html" title="28.3.5 The INFORMATION_SCHEMA CHECK_CONSTRAINTS Table">
<code class="literal">
CHECK_CONSTRAINTS
</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">
CONSTRAINT_CATALOG
</code>
</p>
<p>
The name of the catalog to which the constraint belongs. This
value is always
<code class="literal">
def
</code>
.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
CONSTRAINT_SCHEMA
</code>
</p>
<p>
The name of the schema (database) to which the constraint
belongs.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
CONSTRAINT_NAME
</code>
</p>
<p>
The name of the constraint.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
CHECK_CLAUSE
</code>
</p>
<p>
The expression that specifies the constraint condition.
</p>
</li>
</ul>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/innochecksum.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="innochecksum">
</a>
6.6.2 innochecksum — Offline InnoDB File Checksum Utility
</h3>
</div>
</div>
</div>
<a class="indexterm" name="idm46045308294976">
</a>
<p>
<a class="link" href="innochecksum.html" title="6.6.2 innochecksum — Offline InnoDB File Checksum Utility">
<span class="command">
<strong>
innochecksum
</strong>
</span>
</a>
prints checksums for
<code class="literal">
InnoDB
</code>
files. This tool reads an
<code class="literal">
InnoDB
</code>
tablespace file, calculates the
checksum for each page, compares the calculated checksum to the
stored checksum, and reports mismatches, which indicate damaged
pages. It was originally developed to speed up verifying the
integrity of tablespace files after power outages but can also
be used after file copies. Because checksum mismatches cause
<code class="literal">
InnoDB
</code>
to deliberately shut down a running
server, it may be preferable to use this tool rather than
waiting for an in-production server to encounter the damaged
pages.
</p>
<p>
<a class="link" href="innochecksum.html" title="6.6.2 innochecksum — Offline InnoDB File Checksum Utility">
<span class="command">
<strong>
innochecksum
</strong>
</span>
</a>
cannot be used on tablespace
files that the server already has open. For such files, you
should use
<a class="link" href="check-table.html" title="15.7.3.2 CHECK TABLE Statement">
<code class="literal">
CHECK TABLE
</code>
</a>
to check
tables within the tablespace. Attempting to run
<a class="link" href="innochecksum.html" title="6.6.2 innochecksum — Offline InnoDB File Checksum Utility">
<span class="command">
<strong>
innochecksum
</strong>
</span>
</a>
on a tablespace that the server
already has open results in an
<span class="errortext">
Unable to lock
file
</span>
error.
</p>
<p>
If checksum mismatches are found, restore the tablespace from
backup or start the server and attempt 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>
to make a backup of the tables
within the tablespace.
</p>
<p>
Invoke
<a class="link" href="innochecksum.html" title="6.6.2 innochecksum — Offline InnoDB File Checksum Utility">
<span class="command">
<strong>
innochecksum
</strong>
</span>
</a>
like this:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa92547492"><div class="copy-help left">Press ⌘+C to 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">innochecksum <span class="token punctuation">[</span><em class="replaceable">options</em><span class="token punctuation">]</span> <em class="replaceable">file_name</em></code></pre>
</div>
<h4>
<a name="idm46045308279552">
</a>
innochecksum Options
</h4>
<p>
<a class="link" href="innochecksum.html" title="6.6.2 innochecksum — Offline InnoDB File Checksum Utility">
<span class="command">
<strong>
innochecksum
</strong>
</span>
</a>
supports the following options.
For options that refer to page numbers, the numbers are
zero-based.
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a name="option_innochecksum_help">
</a>
<a class="link" href="innochecksum.html#option_innochecksum_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>
<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="idm46045308264304">
</a>
<a class="indexterm" name="idm46045308262816">
</a>
<p>
Displays command line help. Example usage:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa53418028"><div class="copy-help left">Press ⌘+C to 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">innochecksum <span class="token property">--help</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
<a name="option_innochecksum_info">
</a>
<a class="link" href="innochecksum.html#option_innochecksum_info">
<code class="option">
--info
</code>
</a>
,
<code class="option">
-I
</code>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for info">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--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="idm46045308247120">
</a>
<a class="indexterm" name="idm46045308245632">
</a>
<p>
Synonym for
<a class="link" href="innochecksum.html#option_innochecksum_help">
<code class="option">
--help
</code>
</a>
.
Displays command line help. Example usage:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa37445000"><div class="copy-help left">Press ⌘+C to 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">innochecksum <span class="token property">--info</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
<a name="option_innochecksum_version">
</a>
<a class="link" href="innochecksum.html#option_innochecksum_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>
<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="idm46045308229056">
</a>
<a class="indexterm" name="idm46045308227568">
</a>
<p>
Displays version information. Example usage:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa52154510"><div class="copy-help left">Press ⌘+C to 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">innochecksum <span class="token property">--version</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
<a name="option_innochecksum_verbose">
</a>
<a class="link" href="innochecksum.html#option_innochecksum_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>
<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="idm46045308211936">
</a>
<a class="indexterm" name="idm46045308210448">
</a>
<p>
Verbose mode; prints a progress indicator to the log file
every five seconds. In order for the progress indicator to
be printed, the log file must be specified using the
<code class="literal">
--log option
</code>
. To turn on
<code class="literal">
verbose
</code>
mode, run:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa64737922"><div class="copy-help left">Press ⌘+C to 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">innochecksum <span class="token property">--verbose</span></code></pre>
</div>
<p>
To turn off verbose mode, run:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa46956508"><div class="copy-help left">Press ⌘+C to 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">innochecksum <span class="token constant">--verbose</span><span class="token attr-value"><span class="token punctuation">=</span>FALSE</span></code></pre>
</div>
<p>
The
<code class="literal">
--verbose
</code>
option and
<code class="literal">
--log
</code>
option can be specified at the same
time. For example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa837397"><div class="copy-help left">Press ⌘+C to 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">innochecksum <span class="token property">--verbose</span> <span class="token constant">--log</span><span class="token attr-value"><span class="token punctuation">=</span>/var/lib/mysql/test/logtest.txt</span></code></pre>
</div>
<p>
To locate the progress indicator information in the log
file, you can perform the following search:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa84540626"><div class="copy-help left">Press ⌘+C to 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">cat <span class="token punctuation">.</span>/logtest<span class="token punctuation">.</span>txt | grep <span class="token property">-i</span> <span class="token atrule">"okay"</span></code></pre>
</div>
<p>
The progress indicator information in the log file appears
similar to the following:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-none"><div class="docs-select-all right" id="sa60791365"><div class="copy-help left">Press ⌘+C to 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">page 1663 okay: 2.863% done
page 8447 okay: 14.537% done
page 13695 okay: 23.568% done
page 18815 okay: 32.379% done
page 23039 okay: 39.648% done
page 28351 okay: 48.789% done
page 33023 okay: 56.828% done
page 37951 okay: 65.308% done
page 44095 okay: 75.881% done
page 49407 okay: 85.022% done
page 54463 okay: 93.722% done
...</code></pre>
</div>
</li>
<li class="listitem">
<p>
<a name="option_innochecksum_count">
</a>
<a class="link" href="innochecksum.html#option_innochecksum_count">
<code class="option">
--count
</code>
</a>
,
<code class="option">
-c
</code>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for count">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--count
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
Base name
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
true
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045308185520">
</a>
<a class="indexterm" name="idm46045308184032">
</a>
<p>
Print a count of the number of pages in the file and exit.
Example usage:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa5353300"><div class="copy-help left">Press ⌘+C to 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">innochecksum <span class="token property">--count</span> <span class="token punctuation">.</span><span class="token punctuation">.</span>/data/test/tab1<span class="token punctuation">.</span>ibd</code></pre>
</div>
</li>
<li class="listitem">
<p>
<a name="option_innochecksum_start-page">
</a>
<a class="link" href="innochecksum.html#option_innochecksum_start-page">
<code class="option">
--start-page=
<em class="replaceable">
<code>
num
</code>
</em>
</code>
</a>
,
<code class="option">
-s
<em class="replaceable">
<code>
num
</code>
</em>
</code>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for start-page">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--start-page=#
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
Numeric
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
0
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045308167808">
</a>
<a class="indexterm" name="idm46045308166320">
</a>
<p>
Start at this page number. Example usage:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa27963982"><div class="copy-help left">Press ⌘+C to 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">innochecksum <span class="token constant">--start-page</span><span class="token attr-value"><span class="token punctuation">=</span>600</span> <span class="token punctuation">.</span><span class="token punctuation">.</span>/data/test/tab1<span class="token punctuation">.</span>ibd</code></pre>
</div>
<p>
or:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa22751730"><div class="copy-help left">Press ⌘+C to 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">innochecksum <span class="token property">-s</span> 600 <span class="token punctuation">.</span><span class="token punctuation">.</span>/data/test/tab1<span class="token punctuation">.</span>ibd</code></pre>
</div>
</li>
<li class="listitem">
<p>
<a name="option_innochecksum_end-page">
</a>
<a class="link" href="innochecksum.html#option_innochecksum_end-page">
<code class="option">
--end-page=
<em class="replaceable">
<code>
num
</code>
</em>
</code>
</a>
,
<code class="option">
-e
<em class="replaceable">
<code>
num
</code>
</em>
</code>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for end-page">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--end-page=#
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
Numeric
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
0
</code>
</td>
</tr>
<tr>
<th>
Minimum Value
</th>
<td>
<code class="literal">
0
</code>
</td>
</tr>
<tr>
<th>
Maximum Value
</th>
<td>
<code class="literal">
18446744073709551615
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045308143904">
</a>
<a class="indexterm" name="idm46045308142416">
</a>
<p>
End at this page number. Example usage:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa56787347"><div class="copy-help left">Press ⌘+C to 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">innochecksum <span class="token constant">--end-page</span><span class="token attr-value"><span class="token punctuation">=</span>700</span> <span class="token punctuation">.</span><span class="token punctuation">.</span>/data/test/tab1<span class="token punctuation">.</span>ibd</code></pre>
</div>
<p>
or:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa56307808"><div class="copy-help left">Press ⌘+C to 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">innochecksum <span class="token property">--p</span> 700 <span class="token punctuation">.</span><span class="token punctuation">.</span>/data/test/tab1<span class="token punctuation">.</span>ibd</code></pre>
</div>
</li>
<li class="listitem">
<p>
<a name="option_innochecksum_page">
</a>
<a class="link" href="innochecksum.html#option_innochecksum_page">
<code class="option">
--page=
<em class="replaceable">
<code>
num
</code>
</em>
</code>
</a>
,
<code class="option">
-p
<em class="replaceable">
<code>
num
</code>
</em>
</code>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for page">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--page=#
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
Integer
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
0
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045308124784">
</a>
<a class="indexterm" name="idm46045308123296">
</a>
<p>
Check only this page number. Example usage:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa75565741"><div class="copy-help left">Press ⌘+C to 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">innochecksum <span class="token constant">--page</span><span class="token attr-value"><span class="token punctuation">=</span>701</span> <span class="token punctuation">.</span><span class="token punctuation">.</span>/data/test/tab1<span class="token punctuation">.</span>ibd</code></pre>
</div>
</li>
<li class="listitem">
<p>
<a name="option_innochecksum_strict-check">
</a>
<a class="link" href="innochecksum.html#option_innochecksum_strict-check">
<code class="option">
--strict-check
</code>
</a>
,
<code class="option">
-C
</code>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for strict-check">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--strict-check=algorithm
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
Enumeration
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
crc32
</code>
</td>
</tr>
<tr>
<th>
Valid Values
</th>
<td>
<p class="valid-value">
<code class="literal">
innodb
</code>
</p>
<p class="valid-value">
<code class="literal">
crc32
</code>
</p>
<p class="valid-value">
<code class="literal">
none
</code>
</p>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045308102944">
</a>
<a class="indexterm" name="idm46045308101456">
</a>
<p>
Specify a strict checksum algorithm. Options include
<code class="literal">
innodb
</code>
,
<code class="literal">
crc32
</code>
, and
<code class="literal">
none
</code>
.
</p>
<p>
In this example, the
<code class="literal">
innodb
</code>
checksum
algorithm is specified:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa25479592"><div class="copy-help left">Press ⌘+C to 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">innochecksum <span class="token constant">--strict-check</span><span class="token attr-value"><span class="token punctuation">=</span>innodb</span> <span class="token punctuation">.</span><span class="token punctuation">.</span>/data/test/tab1<span class="token punctuation">.</span>ibd</code></pre>
</div>
<p>
In this example, the
<code class="literal">
crc32
</code>
checksum
algorithm is specified:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa78778271"><div class="copy-help left">Press ⌘+C to 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">innochecksum <span class="token property">-C</span> crc32 <span class="token punctuation">.</span><span class="token punctuation">.</span>/data/test/tab1<span class="token punctuation">.</span>ibd</code></pre>
</div>
<p>
The following conditions apply:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
If you do not specify the
<a class="link" href="innochecksum.html#option_innochecksum_strict-check">
<code class="option">
--strict-check
</code>
</a>
option,
<a class="link" href="innochecksum.html" title="6.6.2 innochecksum — Offline InnoDB File Checksum Utility">
<span class="command">
<strong>
innochecksum
</strong>
</span>
</a>
validates
against
<code class="literal">
innodb
</code>
,
<code class="literal">
crc32
</code>
and
<code class="literal">
none
</code>
.
</p>
</li>
<li class="listitem">
<p>
If you specify the
<code class="literal">
none
</code>
option, only
checksums generated by
<code class="literal">
none
</code>
are
allowed.
</p>
</li>
<li class="listitem">
<p>
If you specify the
<code class="literal">
innodb
</code>
option,
only checksums generated by
<code class="literal">
innodb
</code>
are allowed.
</p>
</li>
<li class="listitem">
<p>
If you specify the
<code class="literal">
crc32
</code>
option, only
checksums generated by
<code class="literal">
crc32
</code>
are
allowed.
</p>
</li>
</ul>
</div>
</li>
<li class="listitem">
<p>
<a name="option_innochecksum_no-check">
</a>
<a class="link" href="innochecksum.html#option_innochecksum_no-check">
<code class="option">
--no-check
</code>
</a>
,
<code class="option">
-n
</code>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for no-check">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--no-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="idm46045308067200">
</a>
<a class="indexterm" name="idm46045308065712">
</a>
<p>
Ignore the checksum verification when rewriting a checksum.
This option may only be used with 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>
<a class="link" href="innochecksum.html#option_innochecksum_write">
<code class="option">
--write
</code>
</a>
option. If the
<a class="link" href="innochecksum.html#option_innochecksum_write">
<code class="option">
--write
</code>
</a>
option is not
specified,
<a class="link" href="innochecksum.html" title="6.6.2 innochecksum — Offline InnoDB File Checksum Utility">
<span class="command">
<strong>
innochecksum
</strong>
</span>
</a>
terminates.
</p>
<p>
In this example, an
<code class="literal">
innodb
</code>
checksum is
rewritten to replace an invalid checksum:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa54829348"><div class="copy-help left">Press ⌘+C to 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">innochecksum <span class="token property">--no-check</span> <span class="token property">--write</span> innodb <span class="token punctuation">.</span><span class="token punctuation">.</span>/data/test/tab1<span class="token punctuation">.</span>ibd</code></pre>
</div>
</li>
<li class="listitem">
<p>
<a name="option_innochecksum_allow-mismatches">
</a>
<a class="link" href="innochecksum.html#option_innochecksum_allow-mismatches">
<code class="option">
--allow-mismatches
</code>
</a>
,
<code class="option">
-a
</code>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for allow-mismatches">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--allow-mismatches=#
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
Integer
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
0
</code>
</td>
</tr>
<tr>
<th>
Minimum Value
</th>
<td>
<code class="literal">
0
</code>
</td>
</tr>
<tr>
<th>
Maximum Value
</th>
<td>
<code class="literal">
18446744073709551615
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045308039328">
</a>
<a class="indexterm" name="idm46045308037840">
</a>
<p>
The maximum number of checksum mismatches allowed before
<a class="link" href="innochecksum.html" title="6.6.2 innochecksum — Offline InnoDB File Checksum Utility">
<span class="command">
<strong>
innochecksum
</strong>
</span>
</a>
terminates. The default
setting is 0. If
<code class="literal">
--allow-mismatches=
</code>
<em class="replaceable">
<code>
N
</code>
</em>
,
where
<code class="literal">
<em class="replaceable">
<code>
N
</code>
</em>
>=0
</code>
,
<em class="replaceable">
<code>
N
</code>
</em>
mismatches are permitted and
<a class="link" href="innochecksum.html" title="6.6.2 innochecksum — Offline InnoDB File Checksum Utility">
<span class="command">
<strong>
innochecksum
</strong>
</span>
</a>
terminates at
<code class="literal">
<em class="replaceable">
<code>
N
</code>
</em>
+1
</code>
. When
<code class="literal">
--allow-mismatches
</code>
is set to 0,
<a class="link" href="innochecksum.html" title="6.6.2 innochecksum — Offline InnoDB File Checksum Utility">
<span class="command">
<strong>
innochecksum
</strong>
</span>
</a>
terminates on the first
checksum mismatch.
</p>
<p>
In this example, an existing
<code class="literal">
innodb
</code>
checksum is rewritten to set
<code class="literal">
--allow-mismatches
</code>
to 1.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa75598211"><div class="copy-help left">Press ⌘+C to 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">innochecksum <span class="token constant">--allow-mismatches</span><span class="token attr-value"><span class="token punctuation">=</span>1</span> <span class="token property">--write</span> innodb <span class="token punctuation">.</span><span class="token punctuation">.</span>/data/test/tab1<span class="token punctuation">.</span>ibd</code></pre>
</div>
<p>
With
<code class="literal">
--allow-mismatches
</code>
set to 1, if
there is a mismatch at page 600 and another at page 700 on a
file with 1000 pages, the checksum is updated for pages
0-599 and 601-699. Because
<code class="literal">
--allow-mismatches
</code>
is set to 1, the
checksum tolerates the first mismatch and terminates on the
second mismatch, leaving page 600 and pages 700-999
unchanged.
</p>
</li>
<li class="listitem">
<p>
<a name="option_innochecksum_write">
</a>
<a class="link" href="innochecksum.html#option_innochecksum_write">
<code class="option">
--write=
<em class="replaceable">
<code>
name
</code>
</em>
</code>
</a>
,
<code class="option">
-w
<em class="replaceable">
<code>
num
</code>
</em>
</code>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for write">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--write=algorithm
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
Enumeration
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
crc32
</code>
</td>
</tr>
<tr>
<th>
Valid Values
</th>
<td>
<p class="valid-value">
<code class="literal">
innodb
</code>
</p>
<p class="valid-value">
<code class="literal">
crc32
</code>
</p>
<p class="valid-value">
<code class="literal">
none
</code>
</p>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045308004816">
</a>
<a class="indexterm" name="idm46045308003328">
</a>
<p>
Rewrite a checksum. When rewriting an invalid checksum, the
<a class="link" href="innochecksum.html#option_innochecksum_no-check">
<code class="option">
--no-check
</code>
</a>
option must
be used together with the
<code class="option">
--write
</code>
option.
The
<a class="link" href="innochecksum.html#option_innochecksum_no-check">
<code class="option">
--no-check
</code>
</a>
option
tells
<a class="link" href="innochecksum.html" title="6.6.2 innochecksum — Offline InnoDB File Checksum Utility">
<span class="command">
<strong>
innochecksum
</strong>
</span>
</a>
to ignore verification
of the invalid checksum. You do not have to specify the
<a class="link" href="innochecksum.html#option_innochecksum_no-check">
<code class="option">
--no-check
</code>
</a>
option if
the current checksum is valid.
</p>
<p>
An algorithm must be specified when using the
<a class="link" href="innochecksum.html#option_innochecksum_write">
<code class="option">
--write
</code>
</a>
option.
Possible values for the
<code class="option">
--write
</code>
option are:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
<code class="literal">
innodb
</code>
: A checksum calculated in
software, using the original algorithm from
<code class="literal">
InnoDB
</code>
.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
crc32
</code>
: A checksum calculated using
the
<code class="literal">
crc32
</code>
algorithm, possibly done
with a hardware assist.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
none
</code>
: A constant number.
</p>
</li>
</ul>
</div>
<p>
The
<code class="option">
--write
</code>
option rewrites entire pages to
disk. If the new checksum is identical to the existing
checksum, the new checksum is not written to disk in order
to minimize I/O.
</p>
<p>
<a class="link" href="innochecksum.html" title="6.6.2 innochecksum — Offline InnoDB File Checksum Utility">
<span class="command">
<strong>
innochecksum
</strong>
</span>
</a>
obtains an exclusive lock
when the
<code class="option">
--write
</code>
option is used.
</p>
<p>
In this example, a
<code class="literal">
crc32
</code>
checksum is
written for
<code class="filename">
tab1.ibd
</code>
:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa72081089"><div class="copy-help left">Press ⌘+C to 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">innochecksum <span class="token property">-w</span> crc32 <span class="token punctuation">.</span><span class="token punctuation">.</span>/data/test/tab1<span class="token punctuation">.</span>ibd</code></pre>
</div>
<p>
In this example, a
<code class="literal">
crc32
</code>
checksum is
rewritten to replace an invalid
<code class="literal">
crc32
</code>
checksum:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa38722040"><div class="copy-help left">Press ⌘+C to 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">innochecksum <span class="token property">--no-check</span> <span class="token property">--write</span> crc32 <span class="token punctuation">.</span><span class="token punctuation">.</span>/data/test/tab1<span class="token punctuation">.</span>ibd</code></pre>
</div>
</li>
<li class="listitem">
<p>
<a name="option_innochecksum_page-type-summary">
</a>
<a class="link" href="innochecksum.html#option_innochecksum_page-type-summary">
<code class="option">
--page-type-summary
</code>
</a>
,
<code class="option">
-S
</code>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for page-type-summary">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--page-type-summary
</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="idm46045307966416">
</a>
<a class="indexterm" name="idm46045307964912">
</a>
<p>
Display a count of each page type in a tablespace. Example
usage:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa74724036"><div class="copy-help left">Press ⌘+C to 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">innochecksum <span class="token property">--page-type-summary</span> <span class="token punctuation">.</span><span class="token punctuation">.</span>/data/test/tab1<span class="token punctuation">.</span>ibd</code></pre>
</div>
<p>
Sample output for
<code class="literal">
--page-type-summary
</code>
:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-none"><div class="docs-select-all right" id="sa62446489"><div class="copy-help left">Press ⌘+C to 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">File::../data/test/tab1.ibd
================PAGE TYPE SUMMARY==============
#PAGE_COUNT PAGE_TYPE
===============================================
2 Index page
0 Undo log page
1 Inode page
0 Insert buffer free list page
2 Freshly allocated page
1 Insert buffer bitmap
0 System page
0 Transaction system page
1 File Space Header
0 Extent descriptor page
0 BLOB page
0 Compressed BLOB page
0 Other type of page
===============================================
Additional information:
Undo page type: 0 insert, 0 update, 0 other
Undo page state: 0 active, 0 cached, 0 to_free, 0 to_purge, 0 prepared, 0 other</code></pre>
</div>
</li>
<li class="listitem">
<p>
<a name="option_innochecksum_page-type-dump">
</a>
<a class="link" href="innochecksum.html#option_innochecksum_page-type-dump">
<code class="option">
--page-type-dump
</code>
</a>
,
<code class="option">
-D
</code>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for page-type-dump">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--page-type-dump=name
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
String
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
[none]
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045307947040">
</a>
<a class="indexterm" name="idm46045307945552">
</a>
<p>
Dump the page type information for each page in a tablespace
to
<code class="literal">
stderr
</code>
or
<code class="literal">
stdout
</code>
.
Example usage:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa66635377"><div class="copy-help left">Press ⌘+C to 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">innochecksum <span class="token constant">--page-type-dump</span><span class="token attr-value"><span class="token punctuation">=</span>/tmp/a.txt</span> <span class="token punctuation">.</span><span class="token punctuation">.</span>/data/test/tab1<span class="token punctuation">.</span>ibd</code></pre>
</div>
</li>
<li class="listitem">
<p>
<a name="option_innochecksum_log">
</a>
<a class="link" href="innochecksum.html#option_innochecksum_log">
<code class="option">
--log
</code>
</a>
,
<code class="option">
-l
</code>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for log">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--log=path
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
File name
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
[none]
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045307928496">
</a>
<a class="indexterm" name="idm46045307927008">
</a>
<p>
Log output for 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>
tool. A
log file name must be provided. Log output contains checksum
values for each tablespace page. For uncompressed tables,
LSN values are also provided. Example usage:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa10769239"><div class="copy-help left">Press ⌘+C to 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">innochecksum <span class="token constant">--log</span><span class="token attr-value"><span class="token punctuation">=</span>/tmp/log.txt</span> <span class="token punctuation">.</span><span class="token punctuation">.</span>/data/test/tab1<span class="token punctuation">.</span>ibd</code></pre>
</div>
<p>
or:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa37192702"><div class="copy-help left">Press ⌘+C to 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">innochecksum <span class="token property">-l</span> /tmp/log<span class="token punctuation">.</span>txt <span class="token punctuation">.</span><span class="token punctuation">.</span>/data/test/tab1<span class="token punctuation">.</span>ibd</code></pre>
</div>
</li>
<li class="listitem">
<p>
<a name="option_innochecksum_read-from-standard-in">
</a>
<code class="literal">
-
</code>
option.
</p>
<a class="indexterm" name="idm46045307919216">
</a>
<a class="indexterm" name="idm46045307917712">
</a>
<p>
Specify the
<code class="literal">
-
</code>
option to read from
standard input. If the
<code class="literal">
-
</code>
option is
missing when
<span class="quote">
“
<span class="quote">
read from standard in
</span>
”
</span>
is
expected,
<a class="link" href="innochecksum.html" title="6.6.2 innochecksum — Offline InnoDB File Checksum Utility">
<span class="command">
<strong>
innochecksum
</strong>
</span>
</a>
prints
<a class="link" href="innochecksum.html" title="6.6.2 innochecksum — Offline InnoDB File Checksum Utility">
<span class="command">
<strong>
innochecksum
</strong>
</span>
</a>
usage information indicating
that the
<span class="quote">
“
<span class="quote">
-
</span>
”
</span>
option was omitted. Example
usages:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa40380611"><div class="copy-help left">Press ⌘+C to 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">cat t1<span class="token punctuation">.</span>ibd | innochecksum -</code></pre>
</div>
<p>
In this example,
<a class="link" href="innochecksum.html" title="6.6.2 innochecksum — Offline InnoDB File Checksum Utility">
<span class="command">
<strong>
innochecksum
</strong>
</span>
</a>
writes the
<code class="literal">
crc32
</code>
checksum algorithm to
<code class="filename">
a.ibd
</code>
without changing the original
<code class="filename">
t1.ibd
</code>
file.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa57707235"><div class="copy-help left">Press ⌘+C to 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">cat t1<span class="token punctuation">.</span>ibd | innochecksum <span class="token constant">--write</span><span class="token attr-value"><span class="token punctuation">=</span>crc32</span> - > a<span class="token punctuation">.</span>ibd</code></pre>
</div>
</li>
</ul>
</div>
<h4>
<a name="idm46045307904848">
</a>
Running innochecksum on Multiple User-defined Tablespace Files
</h4>
<p>
The following examples demonstrate how to run
<a class="link" href="innochecksum.html" title="6.6.2 innochecksum — Offline InnoDB File Checksum Utility">
<span class="command">
<strong>
innochecksum
</strong>
</span>
</a>
on multiple user-defined
tablespace files (
<code class="filename">
.ibd
</code>
files).
</p>
<p>
Run
<a class="link" href="innochecksum.html" title="6.6.2 innochecksum — Offline InnoDB File Checksum Utility">
<span class="command">
<strong>
innochecksum
</strong>
</span>
</a>
for all tablespace
(
<code class="filename">
.ibd
</code>
) files in the
<span class="quote">
“
<span class="quote">
test
</span>
”
</span>
database:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa5843890"><div class="copy-help left">Press ⌘+C to 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">innochecksum <span class="token punctuation">.</span>/data/test/*<span class="token punctuation">.</span>ibd</code></pre>
</div>
<p>
Run
<a class="link" href="innochecksum.html" title="6.6.2 innochecksum — Offline InnoDB File Checksum Utility">
<span class="command">
<strong>
innochecksum
</strong>
</span>
</a>
for all tablespace files
(
<code class="filename">
.ibd
</code>
files) that have a file name starting
with
<span class="quote">
“
<span class="quote">
t
</span>
”
</span>
:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa77466648"><div class="copy-help left">Press ⌘+C to 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">innochecksum <span class="token punctuation">.</span>/data/test/t*<span class="token punctuation">.</span>ibd</code></pre>
</div>
<p>
Run
<a class="link" href="innochecksum.html" title="6.6.2 innochecksum — Offline InnoDB File Checksum Utility">
<span class="command">
<strong>
innochecksum
</strong>
</span>
</a>
for all tablespace files
(
<code class="filename">
.ibd
</code>
files) in the
<code class="filename">
data
</code>
directory:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa81499900"><div class="copy-help left">Press ⌘+C to 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">innochecksum <span class="token punctuation">.</span>/data/*/*<span class="token punctuation">.</span>ibd</code></pre>
</div>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
Running
<a class="link" href="innochecksum.html" title="6.6.2 innochecksum — Offline InnoDB File Checksum Utility">
<span class="command">
<strong>
innochecksum
</strong>
</span>
</a>
on multiple
user-defined tablespace files is not supported on Windows
operating systems, as Windows shells such as
<span class="command">
<strong>
cmd.exe
</strong>
</span>
do not support glob pattern
expansion. On Windows systems,
<a class="link" href="innochecksum.html" title="6.6.2 innochecksum — Offline InnoDB File Checksum Utility">
<span class="command">
<strong>
innochecksum
</strong>
</span>
</a>
must be run separately for each user-defined tablespace file.
For example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa21629920"><div class="copy-help left">Press ⌘+C to 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">innochecksum<span class="token punctuation">.</span>exe t1<span class="token punctuation">.</span>ibd
innochecksum<span class="token punctuation">.</span>exe t2<span class="token punctuation">.</span>ibd
innochecksum<span class="token punctuation">.</span>exe t3<span class="token punctuation">.</span>ibd</code></pre>
</div>
</div>
<h4>
<a name="idm46045307884576">
</a>
Running innochecksum on Multiple System Tablespace Files
</h4>
<p>
By default, there is only one
<code class="literal">
InnoDB
</code>
system
tablespace file (
<code class="filename">
ibdata1
</code>
) but multiple
files for the system tablespace can be defined using the
<a class="link" href="innodb-parameters.html#sysvar_innodb_data_file_path">
<code class="literal">
innodb_data_file_path
</code>
</a>
option.
In the following example, three files for the system tablespace
are defined using the
<a class="link" href="innodb-parameters.html#sysvar_innodb_data_file_path">
<code class="literal">
innodb_data_file_path
</code>
</a>
option:
<code class="filename">
ibdata1
</code>
,
<code class="filename">
ibdata2
</code>
, and
<code class="filename">
ibdata3
</code>
.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa32209107"><div class="copy-help left">Press ⌘+C to 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 punctuation">.</span>/bin/mysqld <span class="token property">--no-defaults</span> <span class="token constant">--innodb-data-file-path</span>=<span class="token atrule">"ibdata1:10M;ibdata2:10M;ibdata3:10M:autoextend"</span></code></pre>
</div>
<p>
The three files (
<code class="filename">
ibdata1
</code>
,
<code class="filename">
ibdata2
</code>
, and
<code class="filename">
ibdata3
</code>
)
form one logical system tablespace. To run
<a class="link" href="innochecksum.html" title="6.6.2 innochecksum — Offline InnoDB File Checksum Utility">
<span class="command">
<strong>
innochecksum
</strong>
</span>
</a>
on multiple files that form one
logical system tablespace,
<a class="link" href="innochecksum.html" title="6.6.2 innochecksum — Offline InnoDB File Checksum Utility">
<span class="command">
<strong>
innochecksum
</strong>
</span>
</a>
requires the
<code class="literal">
-
</code>
option to read tablespace
files in from standard input, which is equivalent to
concatenating multiple files to create one single file. For the
example provided above, the following
<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 would be used:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa81951293"><div class="copy-help left">Press ⌘+C to 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">cat ibdata* | innochecksum -</code></pre>
</div>
<p>
Refer to 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>
options information
for more information about the
<span class="quote">
“
<span class="quote">
-
</span>
”
</span>
option.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
Running
<a class="link" href="innochecksum.html" title="6.6.2 innochecksum — Offline InnoDB File Checksum Utility">
<span class="command">
<strong>
innochecksum
</strong>
</span>
</a>
on multiple files in
the same tablespace is not supported on Windows operating
systems, as Windows shells such as
<span class="command">
<strong>
cmd.exe
</strong>
</span>
do not support glob pattern expansion. On Windows systems,
<a class="link" href="innochecksum.html" title="6.6.2 innochecksum — Offline InnoDB File Checksum Utility">
<span class="command">
<strong>
innochecksum
</strong>
</span>
</a>
must be run separately for
each system tablespace file. For example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa83208852"><div class="copy-help left">Press ⌘+C to 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">innochecksum<span class="token punctuation">.</span>exe ibdata1
innochecksum<span class="token punctuation">.</span>exe ibdata2
innochecksum<span class="token punctuation">.</span>exe ibdata3</code></pre>
</div>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/hexadecimal-literals.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="hexadecimal-literals">
</a>
11.1.4 Hexadecimal Literals
</h3>
</div>
</div>
</div>
<a class="indexterm" name="idm46045220233184">
</a>
<a class="indexterm" name="idm46045220231696">
</a>
<p>
Hexadecimal literal values are written using
<code class="literal">
X'
<em class="replaceable">
<code>
val
</code>
</em>
'
</code>
or
<code class="literal">
0x
<em class="replaceable">
<code>
val
</code>
</em>
</code>
notation,
where
<em class="replaceable">
<code>
val
</code>
</em>
contains hexadecimal digits
(
<code class="literal">
0..9
</code>
,
<code class="literal">
A..F
</code>
). Lettercase
of the digits and of any leading
<code class="literal">
X
</code>
does not
matter. A leading
<code class="literal">
0x
</code>
is case-sensitive and
cannot be written as
<code class="literal">
0X
</code>
.
</p>
<p>
Legal hexadecimal literals:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa82029681"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql">X<span class="token string">'01AF'</span>
X<span class="token string">'01af'</span>
x<span class="token string">'01AF'</span>
x<span class="token string">'01af'</span>
<span class="token number">0x01AF</span>
<span class="token number">0x01af</span></code></pre>
</div>
<p>
Illegal hexadecimal literals:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-none"><div class="docs-select-all right" id="sa30149812"><div class="copy-help left">Press ⌘+C to 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">X'0G' (G is not a hexadecimal digit)
0X01AF (0X must be written as 0x)</code></pre>
</div>
<p>
Values written using
<code class="literal">
X'
<em class="replaceable">
<code>
val
</code>
</em>
'
</code>
notation
must contain an even number of digits or a syntax error occurs.
To correct the problem, pad the value with a leading zero:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa80029087"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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">@s</span> <span class="token operator">=</span> X<span class="token string">'FFF'</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;
check the manual that corresponds to your MySQL server
version for the right syntax to use near 'X'FFF''
</span>
<span class="token prompt">mysql></span> <span class="token keyword">SET</span> <span class="token variable">@s</span> <span class="token operator">=</span> X<span class="token string">'0FFF'</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected (0.00 sec)</span></code></pre>
</div>
<p>
Values written using
<code class="literal">
0x
<em class="replaceable">
<code>
val
</code>
</em>
</code>
notation
that contain an odd number of digits are treated as having an
extra leading
<code class="literal">
0
</code>
. For example,
<code class="literal">
0xaaa
</code>
is interpreted as
<code class="literal">
0x0aaa
</code>
.
</p>
<p>
By default, a hexadecimal literal is a binary string, where each
pair of hexadecimal digits represents a character:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa15059658"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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> X<span class="token string">'4D7953514C'</span><span class="token punctuation">,</span> <span class="token function">CHARSET</span><span class="token punctuation">(</span>X<span class="token string">'4D7953514C'</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>
<span class="token output"><span class="token punctuation">|</span> X'4D7953514C' <span class="token punctuation">|</span> CHARSET(X'4D7953514C') <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> MySQL <span class="token punctuation">|</span> binary <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 prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token number">0x5461626c65</span><span class="token punctuation">,</span> <span class="token function">CHARSET</span><span class="token punctuation">(</span><span class="token number">0x5461626c65</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>
<span class="token output"><span class="token punctuation">|</span> 0x5461626c65 <span class="token punctuation">|</span> CHARSET(0x5461626c65) <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> Table <span class="token punctuation">|</span> binary <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>
A hexadecimal literal may have an optional character set
introducer and
<code class="literal">
COLLATE
</code>
clause, to designate
it as a string that uses a particular character set and
collation:
</p>
<a class="indexterm" name="idm46045220208304">
</a>
<a class="indexterm" name="idm46045220206816">
</a>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa9273172"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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>_<em class="replaceable">charset_name</em><span class="token punctuation">]</span> X<span class="token string">'<em class="replaceable">val</em>'</span> <span class="token punctuation">[</span><span class="token keyword">COLLATE</span> <em class="replaceable">collation_name</em><span class="token punctuation">]</span></code></pre>
</div>
<p>
Examples:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa45385806"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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> _latin1 X<span class="token string">'4D7953514C'</span><span class="token punctuation">;</span>
<span class="token keyword">SELECT</span> _utf8mb4 <span class="token number">0x4D7953514C</span> <span class="token keyword">COLLATE</span> utf8mb4_danish_ci<span class="token punctuation">;</span></code></pre>
</div>
<p>
The examples use
<code class="literal">
X'
<em class="replaceable">
<code>
val
</code>
</em>
'
</code>
notation,
but
<code class="literal">
0x
<em class="replaceable">
<code>
val
</code>
</em>
</code>
notation
permits introducers as well. For information about introducers,
see
<a class="xref" href="charset-introducer.html" title="12.3.8 Character Set Introducers">
Section 12.3.8, “Character Set Introducers”
</a>
.
</p>
<p>
In numeric contexts, MySQL treats a hexadecimal literal like a
<code class="literal">
BIGINT UNSIGNED
</code>
(64-bit unsigned integer). To
ensure numeric treatment of a hexadecimal literal, use it in
numeric context. Ways to do this include adding 0 or using
<a class="link" href="cast-functions.html#function_cast">
<code class="literal">
CAST(... AS UNSIGNED)
</code>
</a>
. For
example, a hexadecimal literal assigned to a user-defined
variable is a binary string by default. To assign the value as a
number, use it in numeric context:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa9539658"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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">@v1</span> <span class="token operator">=</span> X<span class="token string">'41'</span><span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">SET</span> <span class="token variable">@v2</span> <span class="token operator">=</span> X<span class="token string">'41'</span><span class="token operator">+</span><span class="token number">0</span><span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">SET</span> <span class="token variable">@v3</span> <span class="token operator">=</span> <span class="token function">CAST</span><span class="token punctuation">(</span>X<span class="token string">'41'</span> <span class="token keyword">AS</span> <span class="token keyword">UNSIGNED</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 variable">@v1</span><span class="token punctuation">,</span> <span class="token variable">@v2</span><span class="token punctuation">,</span> <span class="token variable">@v3</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> @v1 <span class="token punctuation">|</span> @v2 <span class="token punctuation">|</span> @v3 <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> A <span class="token punctuation">|</span> 65 <span class="token punctuation">|</span> 65 <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></code></pre>
</div>
<p>
An empty hexadecimal value (
<code class="literal">
X''
</code>
) evaluates to
a zero-length binary string. Converted to a number, it produces
0:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa43823637"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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">CHARSET</span><span class="token punctuation">(</span>X<span class="token string">''</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token function">LENGTH</span><span class="token punctuation">(</span>X<span class="token string">''</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>
<span class="token output"><span class="token punctuation">|</span> CHARSET(X'') <span class="token punctuation">|</span> LENGTH(X'') <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>
<span class="token output"><span class="token punctuation">|</span> binary <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>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> X<span class="token string">''</span><span class="token operator">+</span><span class="token number">0</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>
<span class="token output"><span class="token punctuation">|</span> X''<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>
<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></code></pre>
</div>
<p>
The
<code class="literal">
X'
<em class="replaceable">
<code>
val
</code>
</em>
'
</code>
notation is based on standard SQL. The
<code class="literal">
0x
</code>
notation is based on ODBC, for which hexadecimal strings are
often used to supply values for
<a class="link" href="blob.html" title="13.3.4 The BLOB and TEXT Types">
<code class="literal">
BLOB
</code>
</a>
columns.
</p>
<p>
To convert a string or a number to a string in hexadecimal
format, use the
<a class="link" href="string-functions.html#function_hex">
<code class="literal">
HEX()
</code>
</a>
function:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa96170707"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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">HEX</span><span class="token punctuation">(</span><span class="token string">'cat'</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>
<span class="token output"><span class="token punctuation">|</span> HEX('cat') <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>
<span class="token output"><span class="token punctuation">|</span> 636174 <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>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> X<span class="token string">'636174'</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>
<span class="token output"><span class="token punctuation">|</span> X'636174' <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>
<span class="token output"><span class="token punctuation">|</span> cat <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></code></pre>
</div>
<a class="indexterm" name="idm46045220180432">
</a>
<a class="indexterm" name="idm46045220178944">
</a>
<p>
For hexadecimal literals, bit operations are considered numeric
context, but bit operations permit numeric or binary string
arguments in MySQL 8.4 and higher. To explicitly
specify binary string context for hexadecimal literals, use a
<code class="literal">
_binary
</code>
introducer for at least one of the
arguments:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa65639940"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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">@v1</span> <span class="token operator">=</span> X<span class="token string">'000D'</span> <span class="token operator">|</span> X<span class="token string">'0BC0'</span><span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">SET</span> <span class="token variable">@v2</span> <span class="token operator">=</span> _binary X<span class="token string">'000D'</span> <span class="token operator">|</span> X<span class="token string">'0BC0'</span><span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token function">HEX</span><span class="token punctuation">(</span><span class="token variable">@v1</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token function">HEX</span><span class="token punctuation">(</span><span class="token variable">@v2</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>
<span class="token output"><span class="token punctuation">|</span> HEX(@v1) <span class="token punctuation">|</span> HEX(@v2) <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> BCD <span class="token punctuation">|</span> 0BCD <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 displayed result appears similar for both bit operations,
but the result without
<code class="literal">
_binary
</code>
is a
<code class="literal">
BIGINT
</code>
value, whereas the result with
<code class="literal">
_binary
</code>
is a binary string. Due to the
difference in result types, the displayed values differ:
High-order 0 digits are not displayed for the numeric result.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/charset-metadata.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="charset-metadata">
</a>
12.2.2 UTF-8 for Metadata
</h3>
</div>
</div>
</div>
<a class="indexterm" name="idm46045218012320">
</a>
<a class="indexterm" name="idm46045218010832">
</a>
<a class="indexterm" name="idm46045218009344">
</a>
<p>
<span class="firstterm">
Metadata
</span>
is
<span class="quote">
“
<span class="quote">
the
data about the data.
</span>
”
</span>
Anything that
<span class="emphasis">
<em>
describes
</em>
</span>
the database—as opposed to
being the
<span class="emphasis">
<em>
contents
</em>
</span>
of the database—is
metadata. Thus column names, database names, user names, version
names, and most of the string results from
<a class="link" href="show.html" title="15.7.7 SHOW Statements">
<code class="literal">
SHOW
</code>
</a>
are metadata. This is also
true of the contents of tables in
<code class="literal">
INFORMATION_SCHEMA
</code>
because those tables by
definition contain information about database objects.
</p>
<p>
Representation of metadata must satisfy these requirements:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
All metadata must be in the same character set. Otherwise,
neither the
<a class="link" href="show.html" title="15.7.7 SHOW Statements">
<code class="literal">
SHOW
</code>
</a>
statements
nor
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
statements for
tables in
<code class="literal">
INFORMATION_SCHEMA
</code>
would work
properly because different rows in the same column of the
results of these operations would be in different character
sets.
</p>
</li>
<li class="listitem">
<p>
Metadata must include all characters in all languages.
Otherwise, users would not be able to name columns and
tables using their own languages.
</p>
</li>
</ul>
</div>
<p>
To satisfy both requirements, MySQL stores metadata in a Unicode
character set, namely UTF-8. This does not cause any disruption
if you never use accented or non-Latin characters. But if you
do, you should be aware that metadata is in UTF-8.
</p>
<p>
The metadata requirements mean that the return values of the
<a class="link" href="information-functions.html#function_user">
<code class="literal">
USER()
</code>
</a>
,
<a class="link" href="information-functions.html#function_current-user">
<code class="literal">
CURRENT_USER()
</code>
</a>
,
<a class="link" href="information-functions.html#function_session-user">
<code class="literal">
SESSION_USER()
</code>
</a>
,
<a class="link" href="information-functions.html#function_system-user">
<code class="literal">
SYSTEM_USER()
</code>
</a>
,
<a class="link" href="information-functions.html#function_database">
<code class="literal">
DATABASE()
</code>
</a>
, and
<a class="link" href="information-functions.html#function_version">
<code class="literal">
VERSION()
</code>
</a>
functions have the
UTF-8 character set by default.
</p>
<p>
The server sets the
<a class="link" href="server-system-variables.html#sysvar_character_set_system">
<code class="literal">
character_set_system
</code>
</a>
system
variable to the name of the metadata character set:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa46736618"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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">VARIABLES</span> <span class="token operator">LIKE</span> <span class="token string">'character_set_system'</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> 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>
<span class="token output"><span class="token punctuation">|</span> character_set_system <span class="token punctuation">|</span> utf8mb3 <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></code></pre>
</div>
<p>
Storage of metadata using Unicode does
<span class="emphasis">
<em>
not
</em>
</span>
mean that the server returns headers of columns and the results
of
<a class="link" href="describe.html" title="15.8.1 DESCRIBE Statement">
<code class="literal">
DESCRIBE
</code>
</a>
functions in the
<a class="link" href="server-system-variables.html#sysvar_character_set_system">
<code class="literal">
character_set_system
</code>
</a>
character
set by default. When you use
<code class="literal">
SELECT column1 FROM
t
</code>
, the name
<code class="literal">
column1
</code>
itself is
returned from the server to the client in the character set
determined by the value of the
<a class="link" href="server-system-variables.html#sysvar_character_set_results">
<code class="literal">
character_set_results
</code>
</a>
system
variable, which has a default value of
<code class="literal">
utf8mb4
</code>
. If you want the server to pass
metadata results back in a different character set, use the
<a class="link" href="set-names.html" title="15.7.6.3 SET NAMES Statement">
<code class="literal">
SET NAMES
</code>
</a>
statement to force the
server to perform character set conversion.
<a class="link" href="set-names.html" title="15.7.6.3 SET NAMES Statement">
<code class="literal">
SET NAMES
</code>
</a>
sets the
<a class="link" href="server-system-variables.html#sysvar_character_set_results">
<code class="literal">
character_set_results
</code>
</a>
and other
related system variables. (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>
.) Alternatively, a client
program can perform the conversion after receiving the result
from the server. It is more efficient for the client to perform
the conversion, but this option is not always available for all
clients.
</p>
<p>
If
<a class="link" href="server-system-variables.html#sysvar_character_set_results">
<code class="literal">
character_set_results
</code>
</a>
is set
to
<code class="literal">
NULL
</code>
, no conversion is performed and the
server returns metadata using its original character set (the
set indicated by
<a class="link" href="server-system-variables.html#sysvar_character_set_system">
<code class="literal">
character_set_system
</code>
</a>
).
</p>
<p>
Error messages returned from the server to the client are
converted to the client character set automatically, as with
metadata.
</p>
<p>
If you are using (for example) the
<a class="link" href="information-functions.html#function_user">
<code class="literal">
USER()
</code>
</a>
function for comparison or
assignment within a single statement, don't worry. MySQL
performs some automatic conversion for you.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa64011689"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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> <span class="token function">USER</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=</span> latin1_column<span class="token punctuation">;</span></code></pre>
</div>
<p>
This works because the contents of
<code class="literal">
latin1_column
</code>
are automatically converted to
UTF-8 before the comparison.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa16091371"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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">INSERT</span> <span class="token keyword">INTO</span> t1 <span class="token punctuation">(</span>latin1_column<span class="token punctuation">)</span> <span class="token keyword">SELECT</span> <span class="token function">USER</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
This works because the contents of
<a class="link" href="information-functions.html#function_user">
<code class="literal">
USER()
</code>
</a>
are automatically
converted to
<code class="literal">
latin1
</code>
before the assignment.
</p>
<p>
Although automatic conversion is not in the SQL standard, the
standard does say that every character set is (in terms of
supported characters) a
<span class="quote">
“
<span class="quote">
subset
</span>
”
</span>
of Unicode.
Because it is a well-known principle that
<span class="quote">
“
<span class="quote">
what applies to
a superset can apply to a subset,
</span>
”
</span>
we believe that a
collation for Unicode can apply for comparisons with non-Unicode
strings. For more information about coercion of strings, see
<a class="xref" href="charset-collation-coercibility.html" title="12.8.4 Collation Coercibility in Expressions">
Section 12.8.4, “Collation Coercibility in Expressions”
</a>
.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/information-schema-table-privileges-table.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="information-schema-table-privileges-table">
</a>
28.3.43 The INFORMATION_SCHEMA TABLE_PRIVILEGES Table
</h3>
</div>
</div>
</div>
<a class="indexterm" name="idm46045078210704">
</a>
<p>
The
<a class="link" href="information-schema-table-privileges-table.html" title="28.3.43 The INFORMATION_SCHEMA TABLE_PRIVILEGES Table">
<code class="literal">
TABLE_PRIVILEGES
</code>
</a>
table provides
information about table privileges. It takes its values from the
<code class="literal">
mysql.tables_priv
</code>
system table.
</p>
<p>
The
<a class="link" href="information-schema-table-privileges-table.html" title="28.3.43 The INFORMATION_SCHEMA TABLE_PRIVILEGES Table">
<code class="literal">
TABLE_PRIVILEGES
</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">
GRANTEE
</code>
</p>
<p>
The name of the account to which the privilege is granted, in
<code class="literal">
'
<em class="replaceable">
<code>
user_name
</code>
</em>
'@'
<em class="replaceable">
<code>
host_name
</code>
</em>
'
</code>
format.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
TABLE_CATALOG
</code>
</p>
<p>
The name of the catalog to which the table 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 belongs.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
TABLE_NAME
</code>
</p>
<p>
The name of the table.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
PRIVILEGE_TYPE
</code>
</p>
<p>
The privilege granted. The value can be any privilege that can
be granted at the table level; see
<a class="xref" href="grant.html" title="15.7.1.6 GRANT Statement">
Section 15.7.1.6, “GRANT Statement”
</a>
.
Each row lists a single privilege, so there is one row per
table privilege held by the grantee.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
IS_GRANTABLE
</code>
</p>
<p>
<code class="literal">
YES
</code>
if the user has the
<a class="link" href="privileges-provided.html#priv_grant-option">
<code class="literal">
GRANT OPTION
</code>
</a>
privilege,
<code class="literal">
NO
</code>
otherwise. The output does not list
<a class="link" href="privileges-provided.html#priv_grant-option">
<code class="literal">
GRANT OPTION
</code>
</a>
as a separate row
with
<code class="literal">
PRIVILEGE_TYPE='GRANT OPTION'
</code>
.
</p>
</li>
</ul>
</div>
<h4>
<a name="idm46045078185392">
</a>
Notes
</h4>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="link" href="information-schema-table-privileges-table.html" title="28.3.43 The INFORMATION_SCHEMA TABLE_PRIVILEGES Table">
<code class="literal">
TABLE_PRIVILEGES
</code>
</a>
is a nonstandard
<code class="literal">
INFORMATION_SCHEMA
</code>
table.
</p>
</li>
</ul>
</div>
<p>
The following statements are
<span class="emphasis">
<em>
not
</em>
</span>
equivalent:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa45776051"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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> INFORMATION_SCHEMA<span class="token punctuation">.</span>TABLE_PRIVILEGES
<span class="token keyword">SHOW</span> <span class="token keyword">GRANTS</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/mysql-enterprise-encryption.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h2 class="title">
<a name="mysql-enterprise-encryption">
</a>
32.3 MySQL Enterprise Encryption Overview
</h2>
</div>
</div>
</div>
<a class="indexterm" name="idm46045060223936">
</a>
<a class="indexterm" name="idm46045060222848">
</a>
<p>
MySQL Enterprise Edition includes a set of encryption functions based on the OpenSSL
library that expose OpenSSL capabilities at the SQL level. These
functions enable Enterprise applications to perform the following
operations:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Implement added data protection using public-key asymmetric
cryptography
</p>
</li>
<li class="listitem">
<p>
Create public and private keys and digital signatures
</p>
</li>
<li class="listitem">
<p>
Perform asymmetric encryption and decryption
</p>
</li>
<li class="listitem">
<p>
Use cryptographic hashing for digital signing and data
verification and validation
</p>
</li>
</ul>
</div>
<p>
For more information, see
<a class="xref" href="enterprise-encryption.html" title="8.6 MySQL Enterprise Encryption">
Section 8.6, “MySQL Enterprise Encryption”
</a>
.
</p>
<p>
For other related Enterprise security features, see
<a class="xref" href="mysql-enterprise-security.html" title="32.2 MySQL Enterprise Security Overview">
Section 32.2, “MySQL Enterprise Security Overview”
</a>
.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/replication-delayed.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="replication-delayed">
</a>
19.4.11 Delayed Replication
</h3>
</div>
</div>
</div>
<a class="indexterm" name="idm46045136114512">
</a>
<a class="indexterm" name="idm46045136113440">
</a>
<a class="indexterm" name="idm46045136111952">
</a>
<a class="indexterm" name="idm46045136110864">
</a>
<p>
MySQL supports delayed replication such that a replica server
deliberately executes transactions later than the source by at
least a specified amount of time. This section describes how to
configure a replication delay on a replica, and how to monitor
replication delay.
</p>
<p>
In MySQL 8.4, the method of delaying replication
depends on two timestamps,
<code class="literal">
immediate_commit_timestamp
</code>
and
<code class="literal">
original_commit_timestamp
</code>
(see
<a class="xref" href="replication-delayed.html#replication-delayed-timestamps" title="Replication Delay Timestamps">
Replication Delay Timestamps
</a>
); delayed
replication is measured using these timestamps. If either the
immediate source or replica is not using these timestamps, the
implementation of delayed replication from MySQL 5.7 is used (see
<a class="ulink" href="/doc/refman/5.7/en/replication-delayed.html" target="_top">
Delayed Replication
</a>
). This section
describes delayed replication between servers which are all using
these timestamps.
</p>
<p>
The default replication delay is 0 seconds. Use 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
SOURCE_DELAY=
<em class="replaceable">
<code>
N
</code>
</em>
</code>
</a>
statement to
set the delay to
<em class="replaceable">
<code>
N
</code>
</em>
seconds. A
transaction received from the source is not executed until at
least
<em class="replaceable">
<code>
N
</code>
</em>
seconds later than its commit
on the immediate source. The delay happens per transaction (not
event as in previous MySQL versions) and the actual delay is
imposed only on
<code class="literal">
gtid_log_event
</code>
or
<code class="literal">
anonymous_gtid_log_event
</code>
. The other events in
the transaction always follow these events without any waiting
time imposed on them.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
<a class="link" href="start-replica.html" title="15.4.2.4 START REPLICA Statement">
<code class="literal">
START REPLICA
</code>
</a>
and
<a class="link" href="stop-replica.html" title="15.4.2.5 STOP REPLICA Statement">
<code class="literal">
STOP REPLICA
</code>
</a>
take effect
immediately and ignore any delay.
<a class="link" href="reset-replica.html" title="15.4.2.3 RESET REPLICA Statement">
<code class="literal">
RESET
REPLICA
</code>
</a>
resets the delay to 0.
</p>
</div>
<p>
The
<a class="link" href="performance-schema-replication-applier-configuration-table.html" title="29.12.11.2 The replication_applier_configuration Table">
<code class="literal">
replication_applier_configuration
</code>
</a>
Performance Schema table contains the
<code class="literal">
DESIRED_DELAY
</code>
column which shows the delay
configured using the
<code class="literal">
SOURCE_DELAY
</code>
option. The
<a class="link" href="performance-schema-replication-applier-status-table.html" title="29.12.11.5 The replication_applier_status Table">
<code class="literal">
replication_applier_status
</code>
</a>
Performance Schema table contains the
<code class="literal">
REMAINING_DELAY
</code>
column which shows the number
of delay seconds remaining.
</p>
<p>
Delayed replication can be used for several purposes:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
To protect against user mistakes on the source. With a delay
you can roll back a delayed replica to the time just before
the mistake.
</p>
</li>
<li class="listitem">
<p>
To test how the system behaves when there is a lag. For
example, in an application, a lag might be caused by a heavy
load on the replica. However, it can be difficult to generate
this load level. Delayed replication can simulate the lag
without having to simulate the load. It can also be used to
debug conditions related to a lagging replica.
</p>
</li>
<li class="listitem">
<p>
To inspect what the database looked like in the past, without
having to reload a backup. For example, by configuring a
replica with a delay of one week, if you then need to see what
the database looked like before the last few days' worth of
development, the delayed replica can be inspected.
</p>
</li>
</ul>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h4 class="title">
<a name="replication-delayed-timestamps">
</a>
Replication Delay Timestamps
</h4>
</div>
</div>
</div>
<p>
MySQL 8.4 provides a new method for measuring delay
(also referred to as replication lag) in replication topologies
that depends on the following timestamps associated with the
GTID of each transaction (instead of each event) written to the
binary log.
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
original_commit_timestamp
</code>
: the number of
microseconds since epoch when the transaction was written
(committed) to the binary log of the original source.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
immediate_commit_timestamp
</code>
: the number of
microseconds since epoch when the transaction was written
(committed) to the binary log of the immediate source.
</p>
</li>
</ul>
</div>
<p>
The output of
<a class="link" href="mysqlbinlog.html" title="6.6.9 mysqlbinlog — Utility for Processing Binary Log Files">
<span class="command">
<strong>
mysqlbinlog
</strong>
</span>
</a>
displays these
timestamps in two formats, microseconds from epoch and also
<code class="literal">
TIMESTAMP
</code>
format, which is based on the user
defined time zone for better readability. For example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-none"><div class="docs-select-all right" id="sa23259625"><div class="copy-help left">Press ⌘+C to 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">#170404 10:48:05 server id 1 end_log_pos 233 CRC32 0x016ce647 GTID last_committed=0
\ sequence_number=1 original_committed_timestamp=1491299285661130 immediate_commit_timestamp=1491299285843771
# original_commit_timestamp=1491299285661130 (2017-04-04 10:48:05.661130 WEST)
# immediate_commit_timestamp=1491299285843771 (2017-04-04 10:48:05.843771 WEST)
/*!80001 SET @@SESSION.original_commit_timestamp=1491299285661130*//*!*/;
SET @@SESSION.GTID_NEXT= 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa:1'/*!*/;
# at 233</code></pre>
</div>
<p>
As a rule, the
<code class="literal">
original_commit_timestamp
</code>
is
always the same on all replicas where the transaction is
applied. In source-replica replication, the
<code class="literal">
original_commit_timestamp
</code>
of a transaction in
the (original) source’s binary log is always the same as its
<code class="literal">
immediate_commit_timestamp
</code>
. In the
replica’s relay log, the
<code class="literal">
original_commit_timestamp
</code>
and
<code class="literal">
immediate_commit_timestamp
</code>
of the transaction
are the same as in the source’s binary log; whereas in its own
binary log, the transaction’s
<code class="literal">
immediate_commit_timestamp
</code>
corresponds to
when the replica committed the transaction.
</p>
<p>
In a Group Replication setup, when the original source is a
member of a group, the
<code class="literal">
original_commit_timestamp
</code>
is generated when
the transaction is ready to be committed. In other words, when
it finished executing on the original source and its write set
is ready to be sent to all members of the group for
certification. When the original source is a server outside the
group, the
<code class="literal">
original_commit_timestamp
</code>
is
preserved. The same
<code class="literal">
original_commit_timestamp
</code>
for a particular transaction is replicated to all servers in the
group, and to any replica outside the group that is replicating
from a member. Each recipient of the transaction also stores the
local commit time in its binary log using
<code class="literal">
immediate_commit_timestamp
</code>
.
</p>
<p>
View change events, which are exclusive to Group Replication,
are a special case. Transactions containing these events are
generated by each group member but share the same GTID (so, they
are not first executed in a source and then replicated to the
group, but all members of the group execute and apply the same
transaction). Group members set local timestamp values for
transactions associated with view change events.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h4 class="title">
<a name="replication-delayed-monitoring">
</a>
Monitoring Replication Delay
</h4>
</div>
</div>
</div>
<p>
One of the most common ways to monitor replication delay (lag)
in previous MySQL versions was by relying on the
<code class="literal">
Seconds_Behind_Master
</code>
field in the output of
<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>
. However,
this metric is not suitable when using replication topologies
more complex than the traditional source-replica setup, such as
Group Replication. The addition of
<code class="literal">
immediate_commit_timestamp
</code>
and
<code class="literal">
original_commit_timestamp
</code>
to MySQL 8 provides
a much finer degree of information about replication delay. The
recommended method to monitor replication delay in a topology
that supports these timestamps is using the following
Performance Schema tables.
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="link" href="performance-schema-replication-connection-status-table.html" title="29.12.11.13 The replication_connection_status Table">
<code class="literal">
replication_connection_status
</code>
</a>
:
current status of the connection to the source, provides
information on the last and current transaction the
connection thread queued into the relay log.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="performance-schema-replication-applier-status-by-coordinator-table.html" title="29.12.11.6 The replication_applier_status_by_coordinator Table">
<code class="literal">
replication_applier_status_by_coordinator
</code>
</a>
:
current status of the coordinator thread that only displays
information when using a multithreaded replica, provides
information on the last transaction buffered by the
coordinator thread to a worker’s queue, as well as the
transaction it is currently buffering.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="performance-schema-replication-applier-status-by-worker-table.html" title="29.12.11.7 The replication_applier_status_by_worker Table">
<code class="literal">
replication_applier_status_by_worker
</code>
</a>
:
current status of the thread(s) applying transactions
received from the source, provides information about the
transactions applied by the replication SQL thread, or by
each worker thread when using a multithreaded replica.
</p>
</li>
</ul>
</div>
<p>
Using these tables you can monitor information about the last
transaction the corresponding thread processed and the
transaction that thread is currently processing. This
information comprises:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
a transaction’s GTID
</p>
</li>
<li class="listitem">
<p>
a transaction's
<code class="literal">
original_commit_timestamp
</code>
and
<code class="literal">
immediate_commit_timestamp
</code>
, retrieved
from the replica’s relay log
</p>
</li>
<li class="listitem">
<p>
the time a thread started processing a transaction
</p>
</li>
<li class="listitem">
<p>
for the last processed transaction, the time the thread
finished processing it
</p>
</li>
</ul>
</div>
<p>
In addition to the Performance Schema tables, the output of
<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>
has three
fields that show:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
SQL_Delay
</code>
: A nonnegative integer
indicating the replication delay configured using
<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
SOURCE_DELAY=
<em class="replaceable">
<code>
N
</code>
</em>
</code>
</a>
, where
<em class="replaceable">
<code>
N
</code>
</em>
is measured in seconds.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SQL_Remaining_Delay
</code>
: When
<code class="literal">
Replica_SQL_Running_State
</code>
is
<code class="literal">
Waiting until SOURCE_DELAY seconds after master
executed event
</code>
, this field contains an integer
indicating the number of seconds left of the delay. At other
times, this field is
<code class="literal">
NULL
</code>
.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
Replica_SQL_Running_State
</code>
: A string
indicating the state of the SQL thread (analogous to
<code class="literal">
Replica_IO_State
</code>
). The value is identical
to the
<code class="literal">
State
</code>
value of the SQL thread as
displayed by
<a class="link" href="show-processlist.html" title="15.7.7.31 SHOW PROCESSLIST Statement">
<code class="literal">
SHOW
PROCESSLIST
</code>
</a>
.
</p>
</li>
</ul>
</div>
<p>
When the replication SQL thread is waiting for the delay to
elapse before executing an event,
<a class="link" href="show-processlist.html" title="15.7.7.31 SHOW PROCESSLIST Statement">
<code class="literal">
SHOW
PROCESSLIST
</code>
</a>
displays its
<code class="literal">
State
</code>
value as
<code class="literal">
Waiting until SOURCE_DELAY seconds after
master executed event
</code>
.
</p>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/sys-schema-reference.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h2 class="title">
<a name="sys-schema-reference">
</a>
30.4 sys Schema Object Reference
</h2>
</div>
</div>
</div>
<div class="toc">
<dl class="toc">
<dt>
<span class="section">
<a href="sys-schema-object-index.html">
30.4.1 sys Schema Object Index
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="sys-schema-tables.html">
30.4.2 sys Schema Tables and Triggers
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="sys-schema-views.html">
30.4.3 sys Schema Views
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="sys-schema-procedures.html">
30.4.4 sys Schema Stored Procedures
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="sys-schema-functions.html">
30.4.5 sys Schema Stored Functions
</a>
</span>
</dt>
</dl>
</div>
<p>
The
<a class="link" href="sys-schema.html" title="Chapter 30 MySQL sys Schema">
<code class="literal">
sys
</code>
</a>
schema includes tables and
triggers, views, and stored procedures and functions. The
following sections provide details for each of these objects.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/converting-tables-to-innodb.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="converting-tables-to-innodb">
</a>
17.6.1.5 Converting Tables from MyISAM to InnoDB
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045166371344">
</a>
<a class="indexterm" name="idm46045166369424">
</a>
<p>
If you have
<a class="link" href="myisam-storage-engine.html" title="18.2 The MyISAM Storage Engine">
<code class="literal">
MyISAM
</code>
</a>
tables that you want
to convert to
<a class="link" href="innodb-storage-engine.html" title="Chapter 17 The InnoDB Storage Engine">
<code class="literal">
InnoDB
</code>
</a>
for better
reliability and scalability, review the following guidelines and
tips before converting.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
Partitioned
<code class="literal">
MyISAM
</code>
tables created in previous
versions of MySQL are not compatible with MySQL 8.4.
Such tables must be prepared prior to upgrade, either by removing
the partitioning, or by converting them to
<code class="literal">
InnoDB
</code>
. See
<a class="xref" href="partitioning-limitations-storage-engines.html" title="26.6.2 Partitioning Limitations Relating to Storage Engines">
Section 26.6.2, “Partitioning Limitations Relating to Storage Engines”
</a>
, for
more information.
</p>
</div>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="xref" href="converting-tables-to-innodb.html#innodb-convert-memory-usage" title="Adjusting Memory Usage for MyISAM and InnoDB">
Adjusting Memory Usage for MyISAM and InnoDB
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="converting-tables-to-innodb.html#innodb-convert-transactions" title="Handling Too-Long Or Too-Short Transactions">
Handling Too-Long Or Too-Short Transactions
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="converting-tables-to-innodb.html#innodb-convert-deadlock" title="Handling Deadlocks">
Handling Deadlocks
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="converting-tables-to-innodb.html#innodb-convert-plan-storage" title="Storage Layout">
Storage Layout
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="converting-tables-to-innodb.html#innodb-convert-convert" title="Converting an Existing Table">
Converting an Existing Table
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="converting-tables-to-innodb.html#innodb-convert-clone" title="Cloning the Structure of a Table">
Cloning the Structure of a Table
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="converting-tables-to-innodb.html#innodb-convert-transfer" title="Transferring Data">
Transferring Data
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="converting-tables-to-innodb.html#innodb-convert-storage-requirements" title="Storage Requirements">
Storage Requirements
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="converting-tables-to-innodb.html#innodb-convert-primary-key" title="Defining Primary Keys">
Defining Primary Keys
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="converting-tables-to-innodb.html#innodb-convert-application-performance" title="Application Performance Considerations">
Application Performance Considerations
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="converting-tables-to-innodb.html#innodb-convert-understand-files" title="Understanding Files Associated with InnoDB Tables">
Understanding Files Associated with InnoDB Tables
</a>
</p>
</li>
</ul>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="innodb-convert-memory-usage">
</a>
Adjusting Memory Usage for MyISAM and InnoDB
</h5>
</div>
</div>
</div>
<a class="indexterm" name="idm46045166348416">
</a>
<p>
As you transition away from
<code class="literal">
MyISAM
</code>
tables,
lower the value of the
<a class="link" href="server-system-variables.html#sysvar_key_buffer_size">
<code class="literal">
key_buffer_size
</code>
</a>
configuration
option to free memory no longer needed for caching results.
Increase the value of the
<a class="link" href="innodb-parameters.html#sysvar_innodb_buffer_pool_size">
<code class="literal">
innodb_buffer_pool_size
</code>
</a>
configuration option, which performs a similar role of allocating
cache memory for
<code class="literal">
InnoDB
</code>
tables. The
<code class="literal">
InnoDB
</code>
<a class="link" href="glossary.html#glos_buffer_pool" title="buffer pool">
buffer
pool
</a>
caches both table data and index data, speeding up
lookups for queries and keeping query results in memory for reuse.
For guidance regarding buffer pool size configuration, see
<a class="xref" href="memory-use.html" title="10.12.3.1 How MySQL Uses Memory">
Section 10.12.3.1, “How MySQL Uses Memory”
</a>
.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="innodb-convert-transactions">
</a>
Handling Too-Long Or Too-Short Transactions
</h5>
</div>
</div>
</div>
<a class="indexterm" name="idm46045166338688">
</a>
<p>
Because
<code class="literal">
MyISAM
</code>
tables do not support
<a class="link" href="glossary.html#glos_transaction" title="transaction">
transactions
</a>
, you might
not have paid much attention to the
<a class="link" href="server-system-variables.html#sysvar_autocommit">
<code class="literal">
autocommit
</code>
</a>
configuration option
and the
<a class="link" href="commit.html" title="15.3.1 START TRANSACTION, COMMIT, and ROLLBACK Statements">
<code class="literal">
COMMIT
</code>
</a>
and
<a class="link" href="commit.html" title="15.3.1 START TRANSACTION, COMMIT, and ROLLBACK Statements">
<code class="literal">
ROLLBACK
</code>
</a>
statements. These keywords are important to allow multiple
sessions to read and write
<code class="literal">
InnoDB
</code>
tables
concurrently, providing substantial scalability benefits in
write-heavy workloads.
</p>
<p>
While a transaction is open, the system keeps a snapshot of the
data as seen at the beginning of the transaction, which can cause
substantial overhead if the system inserts, updates, and deletes
millions of rows while a stray transaction keeps running. Thus,
take care to avoid transactions that run for too long:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
If you are using a
<a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
<span class="command">
<strong>
mysql
</strong>
</span>
</a>
session for
interactive experiments, always
<a class="link" href="commit.html" title="15.3.1 START TRANSACTION, COMMIT, and ROLLBACK Statements">
<code class="literal">
COMMIT
</code>
</a>
(to finalize the
changes) or
<a class="link" href="commit.html" title="15.3.1 START TRANSACTION, COMMIT, and ROLLBACK Statements">
<code class="literal">
ROLLBACK
</code>
</a>
(to
undo the changes) when finished. Close down interactive
sessions rather than leave them open for long periods, to
avoid keeping transactions open for long periods by accident.
</p>
</li>
<li class="listitem">
<p>
Make sure that any error handlers in your application also
<a class="link" href="commit.html" title="15.3.1 START TRANSACTION, COMMIT, and ROLLBACK Statements">
<code class="literal">
ROLLBACK
</code>
</a>
incomplete changes or
<a class="link" href="commit.html" title="15.3.1 START TRANSACTION, COMMIT, and ROLLBACK Statements">
<code class="literal">
COMMIT
</code>
</a>
completed changes.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="commit.html" title="15.3.1 START TRANSACTION, COMMIT, and ROLLBACK Statements">
<code class="literal">
ROLLBACK
</code>
</a>
is
a relatively expensive operation, because
<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>
operations are written
to
<code class="literal">
InnoDB
</code>
tables prior to the
<a class="link" href="commit.html" title="15.3.1 START TRANSACTION, COMMIT, and ROLLBACK Statements">
<code class="literal">
COMMIT
</code>
</a>
, with the expectation
that most changes are committed successfully and rollbacks are
rare. When experimenting with large volumes of data, avoid
making changes to large numbers of rows and then rolling back
those changes.
</p>
</li>
<li class="listitem">
<p>
When loading large volumes of data with a sequence of
<a class="link" href="insert.html" title="15.2.7 INSERT Statement">
<code class="literal">
INSERT
</code>
</a>
statements, periodically
<a class="link" href="commit.html" title="15.3.1 START TRANSACTION, COMMIT, and ROLLBACK Statements">
<code class="literal">
COMMIT
</code>
</a>
the results to avoid
having transactions that last for hours. In typical load
operations for data warehousing, if something goes wrong, you
truncate the table (using
<a class="link" href="truncate-table.html" title="15.1.37 TRUNCATE TABLE Statement">
<code class="literal">
TRUNCATE
TABLE
</code>
</a>
) and start over from the beginning rather than
doing a
<a class="link" href="commit.html" title="15.3.1 START TRANSACTION, COMMIT, and ROLLBACK Statements">
<code class="literal">
ROLLBACK
</code>
</a>
.
</p>
</li>
</ul>
</div>
<p>
The preceding tips save memory and disk space that can be wasted
during too-long transactions. When transactions are shorter than
they should be, the problem is excessive I/O. With each
<a class="link" href="commit.html" title="15.3.1 START TRANSACTION, COMMIT, and ROLLBACK Statements">
<code class="literal">
COMMIT
</code>
</a>
, MySQL makes sure each
change is safely recorded to disk, which involves some I/O.
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
For most operations on
<code class="literal">
InnoDB
</code>
tables, you
should use the setting
<a class="link" href="server-system-variables.html#sysvar_autocommit">
<code class="literal">
autocommit=0
</code>
</a>
. From an
efficiency perspective, this avoids unnecessary I/O when you
issue large numbers of consecutive
<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>
, or
<a class="link" href="delete.html" title="15.2.2 DELETE Statement">
<code class="literal">
DELETE
</code>
</a>
statements. From a
safety perspective, this allows you to issue a
<a class="link" href="commit.html" title="15.3.1 START TRANSACTION, COMMIT, and ROLLBACK Statements">
<code class="literal">
ROLLBACK
</code>
</a>
statement to recover lost or garbled data if you make a
mistake on 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, or in an
exception handler in your application.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="server-system-variables.html#sysvar_autocommit">
<code class="literal">
autocommit=1
</code>
</a>
is suitable for
<code class="literal">
InnoDB
</code>
tables when running a sequence of
queries for generating reports or analyzing statistics. In
this situation, there is no I/O penalty related to
<a class="link" href="commit.html" title="15.3.1 START TRANSACTION, COMMIT, and ROLLBACK Statements">
<code class="literal">
COMMIT
</code>
</a>
or
<a class="link" href="commit.html" title="15.3.1 START TRANSACTION, COMMIT, and ROLLBACK Statements">
<code class="literal">
ROLLBACK
</code>
</a>
,
and
<code class="literal">
InnoDB
</code>
can
<a class="link" href="innodb-performance-ro-txn.html" title="10.5.3 Optimizing InnoDB Read-Only Transactions">
automatically
optimize the read-only workload
</a>
.
</p>
</li>
<li class="listitem">
<p>
If you make a series of related changes, finalize all the
changes at once with a single
<a class="link" href="commit.html" title="15.3.1 START TRANSACTION, COMMIT, and ROLLBACK Statements">
<code class="literal">
COMMIT
</code>
</a>
at the end. For example,
if you insert related pieces of information into several
tables, do a single
<a class="link" href="commit.html" title="15.3.1 START TRANSACTION, COMMIT, and ROLLBACK Statements">
<code class="literal">
COMMIT
</code>
</a>
after making all the changes. Or if you run many consecutive
<a class="link" href="insert.html" title="15.2.7 INSERT Statement">
<code class="literal">
INSERT
</code>
</a>
statements, do a single
<a class="link" href="commit.html" title="15.3.1 START TRANSACTION, COMMIT, and ROLLBACK Statements">
<code class="literal">
COMMIT
</code>
</a>
after all the data is
loaded; if you are doing millions of
<a class="link" href="insert.html" title="15.2.7 INSERT Statement">
<code class="literal">
INSERT
</code>
</a>
statements, perhaps
split up the huge transaction by issuing a
<a class="link" href="commit.html" title="15.3.1 START TRANSACTION, COMMIT, and ROLLBACK Statements">
<code class="literal">
COMMIT
</code>
</a>
every ten thousand or
hundred thousand records, so the transaction does not grow too
large.
</p>
</li>
<li class="listitem">
<p>
Remember that even a
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
statement opens a transaction, so after running some report or
debugging queries in an interactive
<a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
<span class="command">
<strong>
mysql
</strong>
</span>
</a>
session, either issue a
<a class="link" href="commit.html" title="15.3.1 START TRANSACTION, COMMIT, and ROLLBACK Statements">
<code class="literal">
COMMIT
</code>
</a>
or close 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>
session.
</p>
</li>
</ul>
</div>
<p>
For related information, see
<a class="xref" href="innodb-autocommit-commit-rollback.html" title="17.7.2.2 autocommit, Commit, and Rollback">
Section 17.7.2.2, “autocommit, Commit, and Rollback”
</a>
.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="innodb-convert-deadlock">
</a>
Handling Deadlocks
</h5>
</div>
</div>
</div>
<a class="indexterm" name="idm46045166271456">
</a>
<p>
You might see warning messages referring to
<span class="quote">
“
<span class="quote">
deadlocks
</span>
”
</span>
in the MySQL error log, or the output of
<a class="link" href="show-engine.html" title="15.7.7.16 SHOW ENGINE Statement">
<code class="literal">
SHOW ENGINE INNODB
STATUS
</code>
</a>
. A
<a class="link" href="glossary.html#glos_deadlock" title="deadlock">
deadlock
</a>
is not a serious issue for
<code class="literal">
InnoDB
</code>
tables, and
often does not require any corrective action. When two
transactions start modifying multiple tables, accessing the tables
in a different order, they can reach a state where each
transaction is waiting for the other and neither can proceed. When
<a class="link" href="glossary.html#glos_deadlock_detection" title="deadlock detection">
deadlock detection
</a>
is enabled (the default), MySQL immediately detects this condition
and cancels (
<a class="link" href="glossary.html#glos_rollback" title="rollback">
rolls back
</a>
) the
<span class="quote">
“
<span class="quote">
smaller
</span>
”
</span>
transaction, allowing the other to proceed.
If deadlock detection is disabled using the
<a class="link" href="innodb-parameters.html#sysvar_innodb_deadlock_detect">
<code class="literal">
innodb_deadlock_detect
</code>
</a>
configuration option,
<code class="literal">
InnoDB
</code>
relies on the
<a class="link" href="innodb-parameters.html#sysvar_innodb_lock_wait_timeout">
<code class="literal">
innodb_lock_wait_timeout
</code>
</a>
setting
to roll back transactions in case of a deadlock.
</p>
<p>
Either way, your applications need error-handling logic to restart
a transaction that is forcibly cancelled due to a deadlock. When
you re-issue the same SQL statements as before, the original
timing issue no longer applies. Either the other transaction has
already finished and yours can proceed, or the other transaction
is still in progress and your transaction waits until it finishes.
</p>
<p>
If deadlock warnings occur constantly, you might review the
application code to reorder the SQL operations in a consistent
way, or to shorten the transactions. You can test with the
<a class="link" href="innodb-parameters.html#sysvar_innodb_print_all_deadlocks">
<code class="literal">
innodb_print_all_deadlocks
</code>
</a>
option
enabled to see all deadlock warnings in the MySQL error log,
rather than only the last warning in the
<a class="link" href="show-engine.html" title="15.7.7.16 SHOW ENGINE Statement">
<code class="literal">
SHOW ENGINE INNODB
STATUS
</code>
</a>
output.
</p>
<p>
For more information, see
<a class="xref" href="innodb-deadlocks.html" title="17.7.5 Deadlocks in InnoDB">
Section 17.7.5, “Deadlocks in InnoDB”
</a>
.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="innodb-convert-plan-storage">
</a>
Storage Layout
</h5>
</div>
</div>
</div>
<a class="indexterm" name="idm46045166253536">
</a>
<p>
To get the best performance from
<code class="literal">
InnoDB
</code>
tables,
you can adjust a number of parameters related to storage layout.
</p>
<p>
When you convert
<code class="literal">
MyISAM
</code>
tables that are large,
frequently accessed, and hold vital data, investigate and consider
the
<a class="link" href="innodb-parameters.html#sysvar_innodb_file_per_table">
<code class="literal">
innodb_file_per_table
</code>
</a>
and
<a class="link" href="innodb-parameters.html#sysvar_innodb_page_size">
<code class="literal">
innodb_page_size
</code>
</a>
variables, and
the
<a class="link" href="innodb-row-format.html" title="17.10 InnoDB Row Formats">
<code class="literal">
ROW_FORMAT
</code>
and
<code class="literal">
KEY_BLOCK_SIZE
</code>
clauses
</a>
of the
<a class="link" href="create-table.html" title="15.1.20 CREATE TABLE Statement">
<code class="literal">
CREATE TABLE
</code>
</a>
statement.
</p>
<p>
During your initial experiments, the most important setting is
<a class="link" href="innodb-parameters.html#sysvar_innodb_file_per_table">
<code class="literal">
innodb_file_per_table
</code>
</a>
. When this
setting is enabled, which is the default, new
<code class="literal">
InnoDB
</code>
tables are implicitly created in
<a class="link" href="glossary.html#glos_file_per_table" title="file-per-table">
file-per-table
</a>
tablespaces. In contrast with the
<code class="literal">
InnoDB
</code>
system
tablespace, file-per-table tablespaces allow disk space to be
reclaimed by the operating system when a table is truncated or
dropped. File-per-table tablespaces also support
<a class="link" href="glossary.html#glos_dynamic_row_format" title="dynamic row format">
DYNAMIC
</a>
and
<a class="link" href="glossary.html#glos_compressed_row_format" title="compressed row format">
COMPRESSED
</a>
row
formats and associated features such as table compression,
efficient off-page storage for long variable-length columns, and
large index prefixes. 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>
.
</p>
<p>
You can also store
<code class="literal">
InnoDB
</code>
tables in a shared
general tablespace, which support multiple tables and all row
formats. For more information, see
<a class="xref" href="general-tablespaces.html" title="17.6.3.3 General Tablespaces">
Section 17.6.3.3, “General Tablespaces”
</a>
.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="innodb-convert-convert">
</a>
Converting an Existing Table
</h5>
</div>
</div>
</div>
<p>
To convert a non-
<code class="literal">
InnoDB
</code>
table to use
<code class="literal">
InnoDB
</code>
use
<a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
<code class="literal">
ALTER
TABLE
</code>
</a>
:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa55990344"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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> <span class="token keyword"><em class="replaceable">table_name</em></span> <span class="token keyword">ENGINE</span><span class="token operator">=</span>InnoDB<span class="token punctuation">;</span></code></pre>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="innodb-convert-clone">
</a>
Cloning the Structure of a Table
</h5>
</div>
</div>
</div>
<p>
You might make an
<code class="literal">
InnoDB
</code>
table that is a clone
of a MyISAM table, rather than using
<a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
<code class="literal">
ALTER
TABLE
</code>
</a>
to perform conversion, to test the old and new
table side-by-side before switching.
</p>
<p>
Create an empty
<code class="literal">
InnoDB
</code>
table with identical
column and index definitions. Use
<code class="literal">
SHOW CREATE TABLE
<em class="replaceable">
<code>
table_name
</code>
</em>
\G
</code>
to see the full
<a class="link" href="create-table.html" title="15.1.20 CREATE TABLE Statement">
<code class="literal">
CREATE TABLE
</code>
</a>
statement to use.
Change the
<code class="literal">
ENGINE
</code>
clause to
<code class="literal">
ENGINE=INNODB
</code>
.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="innodb-convert-transfer">
</a>
Transferring Data
</h5>
</div>
</div>
</div>
<a class="indexterm" name="idm46045166219296">
</a>
<p>
To transfer a large volume of data into an empty
<code class="literal">
InnoDB
</code>
table created as shown in the previous
section, insert the rows with
<code class="literal">
INSERT INTO
<em class="replaceable">
<code>
innodb_table
</code>
</em>
SELECT * FROM
<em class="replaceable">
<code>
myisam_table
</code>
</em>
ORDER BY
<em class="replaceable">
<code>
primary_key_columns
</code>
</em>
</code>
.
</p>
<p>
You can also create the indexes for the
<code class="literal">
InnoDB
</code>
table after inserting the data. Historically, creating new
secondary indexes was a slow operation for
<code class="literal">
InnoDB
</code>
, but now you can create the indexes
after the data is loaded with relatively little overhead from the
index creation step.
</p>
<p>
If you have
<code class="literal">
UNIQUE
</code>
constraints on secondary
keys, you can speed up a table import by turning off the
uniqueness checks temporarily during the import operation:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa22763723"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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> unique_checks<span class="token operator">=</span><span class="token number">0</span><span class="token punctuation">;</span>
<span class="token punctuation"></span><em class="replaceable"><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span> <span class="token keyword">import</span> operation <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span></em><span class="token punctuation"></span>
<span class="token keyword">SET</span> unique_checks<span class="token operator">=</span><span class="token number">1</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
For big tables, this saves disk I/O because
<code class="literal">
InnoDB
</code>
can use its
<a class="link" href="glossary.html#glos_change_buffer" title="change buffer">
change buffer
</a>
to write
secondary index records as a batch. Be certain that the data
contains no duplicate keys.
<a class="link" href="server-system-variables.html#sysvar_unique_checks">
<code class="literal">
unique_checks
</code>
</a>
permits but does
not require storage engines to ignore duplicate keys.
</p>
<p>
For better control over the insertion process, you can insert big
tables in pieces:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa4052160"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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">INSERT</span> <span class="token keyword">INTO</span> newtable <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> oldtable
<span class="token keyword">WHERE</span> yourkey <span class="token operator">></span> <em class="replaceable">something</em> <span class="token operator">AND</span> yourkey <span class="token operator"><=</span> <em class="replaceable">somethingelse</em><span class="token punctuation">;</span></code></pre>
</div>
<p>
After all records are inserted, you can rename the tables.
</p>
<p>
During the conversion of big tables, increase the size of the
<code class="literal">
InnoDB
</code>
buffer pool to reduce disk I/O.
Typically, the recommended buffer pool size is 50 to 75 percent of
system memory. You can also increase the size of
<code class="literal">
InnoDB
</code>
log files.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="innodb-convert-storage-requirements">
</a>
Storage Requirements
</h5>
</div>
</div>
</div>
<a class="indexterm" name="idm46045166200192">
</a>
<p>
If you intend to make several temporary copies of your data in
<code class="literal">
InnoDB
</code>
tables during the conversion process, it
is recommended that you create the tables in file-per-table
tablespaces so that you can reclaim the disk space when you drop
the tables. When the
<a class="link" href="innodb-parameters.html#sysvar_innodb_file_per_table">
<code class="literal">
innodb_file_per_table
</code>
</a>
configuration option is enabled (the default), newly created
<code class="literal">
InnoDB
</code>
tables are implicitly created in
file-per-table tablespaces.
</p>
<p>
Whether you convert the
<code class="literal">
MyISAM
</code>
table directly
or create a cloned
<code class="literal">
InnoDB
</code>
table, make sure that
you have sufficient disk space to hold both the old and new tables
during the process.
<span class="bold">
<strong>
<code class="literal">
InnoDB
</code>
tables require
more disk space than
<code class="literal">
MyISAM
</code>
tables.
</strong>
</span>
If an
<a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
<code class="literal">
ALTER TABLE
</code>
</a>
operation runs
out of space, it starts a rollback, and that can take hours if it
is disk-bound. For inserts,
<code class="literal">
InnoDB
</code>
uses the
insert buffer to merge secondary index records to indexes in
batches. That saves a lot of disk I/O. For rollback, no such
mechanism is used, and the rollback can take 30 times longer than
the insertion.
</p>
<p>
In the case of a runaway rollback, if you do not have valuable
data in your database, it may be advisable to kill the database
process rather than wait for millions of disk I/O operations to
complete. For the complete procedure, see
<a class="xref" href="forcing-innodb-recovery.html" title="17.20.3 Forcing InnoDB Recovery">
Section 17.20.3, “Forcing InnoDB Recovery”
</a>
.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="innodb-convert-primary-key">
</a>
Defining Primary Keys
</h5>
</div>
</div>
</div>
<a class="indexterm" name="idm46045166186256">
</a>
<p>
The
<code class="literal">
PRIMARY KEY
</code>
clause is a critical factor
affecting the performance of MySQL queries and the space usage for
tables and indexes. The primary key uniquely identifies a row in a
table. Every row in the table should have a primary key value, and
no two rows can have the same primary key value.
</p>
<p>
These are guidelines for the primary key, followed by more
detailed explanations.
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Declare a
<code class="literal">
PRIMARY KEY
</code>
for each table.
Typically, it is the most important column that you refer to
in
<code class="literal">
WHERE
</code>
clauses when looking up a single
row.
</p>
</li>
<li class="listitem">
<p>
Declare the
<code class="literal">
PRIMARY KEY
</code>
clause in the
original
<a class="link" href="create-table.html" title="15.1.20 CREATE TABLE Statement">
<code class="literal">
CREATE TABLE
</code>
</a>
statement, rather than adding it later through an
<a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
<code class="literal">
ALTER TABLE
</code>
</a>
statement.
</p>
</li>
<li class="listitem">
<p>
Choose the column and its data type carefully. Prefer numeric
columns over character or string ones.
</p>
</li>
<li class="listitem">
<p>
Consider using an auto-increment column if there is not
another stable, unique, non-null, numeric column to use.
</p>
</li>
<li class="listitem">
<p>
An auto-increment column is also a good choice if there is any
doubt whether the value of the primary key column could ever
change. Changing the value of a primary key column is an
expensive operation, possibly involving rearranging data
within the table and within each secondary index.
</p>
</li>
</ul>
</div>
<p>
Consider adding a
<a class="link" href="glossary.html#glos_primary_key" title="primary key">
primary
key
</a>
to any table that does not already have one. Use the
smallest practical numeric type based on the maximum projected
size of the table. This can make each row slightly more compact,
which can yield substantial space savings for large tables. The
space savings are multiplied if the table has any
<a class="link" href="glossary.html#glos_secondary_index" title="secondary index">
secondary indexes
</a>
,
because the primary key value is repeated in each secondary index
entry. In addition to reducing data size on disk, a small primary
key also lets more data fit into the
<a class="link" href="glossary.html#glos_buffer_pool" title="buffer pool">
buffer pool
</a>
, speeding up
all kinds of operations and improving concurrency.
</p>
<p>
If the table already has a primary key on some longer column, such
as a
<code class="literal">
VARCHAR
</code>
, consider adding a new unsigned
<code class="literal">
AUTO_INCREMENT
</code>
column and switching the primary
key to that, even if that column is not referenced in queries.
This design change can produce substantial space savings in the
secondary indexes. You can designate the former primary key
columns as
<code class="literal">
UNIQUE NOT NULL
</code>
to enforce the same
constraints as the
<code class="literal">
PRIMARY KEY
</code>
clause, that is,
to prevent duplicate or null values across all those columns.
</p>
<p>
If you spread related information across multiple tables,
typically each table uses the same column for its primary key. For
example, a personnel database might have several tables, each with
a primary key of employee number. A sales database might have some
tables with a primary key of customer number, and other tables
with a primary key of order number. Because lookups using the
primary key are very fast, you can construct efficient join
queries for such tables.
</p>
<p>
If you leave the
<code class="literal">
PRIMARY KEY
</code>
clause out
entirely, MySQL creates an invisible one for you. It is a 6-byte
value that might be longer than you need, thus wasting space.
Because it is hidden, you cannot refer to it in queries.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="innodb-convert-application-performance">
</a>
Application Performance Considerations
</h5>
</div>
</div>
</div>
<a class="indexterm" name="idm46045166162352">
</a>
<p>
The reliability and scalability features of
<code class="literal">
InnoDB
</code>
require more disk storage than
equivalent
<code class="literal">
MyISAM
</code>
tables. You might change the
column and index definitions slightly, for better space
utilization, reduced I/O and memory consumption when processing
result sets, and better query optimization plans making efficient
use of index lookups.
</p>
<p>
If you set up a numeric ID column for the primary key, use that
value to cross-reference with related values in any other tables,
particularly for
<a class="link" href="glossary.html#glos_join" title="join">
join
</a>
queries.
For example, rather than accepting a country name as input and
doing queries searching for the same name, do one lookup to
determine the country ID, then do other queries (or a single join
query) to look up relevant information across several tables.
Rather than storing a customer or catalog item number as a string
of digits, potentially using up several bytes, convert it to a
numeric ID for storing and querying. A 4-byte unsigned
<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 can index over 4 billion
items (with the US meaning of billion: 1000 million). For the
ranges of the different integer types, see
<a class="xref" href="integer-types.html" title="13.1.2 Integer Types (Exact Value) - INTEGER, INT, SMALLINT, TINYINT, MEDIUMINT, BIGINT">
Section 13.1.2, “Integer Types (Exact Value) - INTEGER, INT, SMALLINT, TINYINT,
MEDIUMINT, BIGINT”
</a>
.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="innodb-convert-understand-files">
</a>
Understanding Files Associated with InnoDB Tables
</h5>
</div>
</div>
</div>
<a class="indexterm" name="idm46045166153440">
</a>
<p>
<code class="literal">
InnoDB
</code>
files require more care and planning
than
<code class="literal">
MyISAM
</code>
files do.
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
You must not delete the
<a class="link" href="glossary.html#glos_ibdata_file" title="ibdata file">
ibdata files
</a>
that
represent the
<code class="literal">
InnoDB
</code>
<a class="link" href="glossary.html#glos_system_tablespace" title="system tablespace">
system
tablespace
</a>
.
</p>
</li>
<li class="listitem">
<p>
Methods of moving or copying
<code class="literal">
InnoDB
</code>
tables
to a different server are described in
<a class="xref" href="innodb-migration.html" title="17.6.1.4 Moving or Copying InnoDB Tables">
Section 17.6.1.4, “Moving or Copying InnoDB Tables”
</a>
.
</p>
</li>
</ul>
</div>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/interaction-with-debug-option.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="interaction-with-debug-option">
</a>
10.15.7 Interaction with the --debug Option
</h3>
</div>
</div>
</div>
<p>
Anything written to the trace is automatically written to the
debug file.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/performance-schema-persisted-variables-table.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="performance-schema-persisted-variables-table">
</a>
29.12.14.1 Performance Schema persisted_variables Table
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045070128864">
</a>
<a class="indexterm" name="idm46045070127776">
</a>
<p>
The
<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
provides an SQL interface to the
<code class="filename">
mysqld-auto.cnf
</code>
file that stores
persisted global system variable settings, enabling the file
contents to be inspected at runtime using
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
statements. Variables
are persisted 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>
or
<code class="literal">
PERSIST_ONLY
</code>
statements; 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>
. The table
contains a row for each persisted system variable in the file.
Variables not persisted do not appear in the table.
</p>
<p>
The
<a class="link" href="privileges-provided.html#priv_sensitive-variables-observer">
<code class="literal">
SENSITIVE_VARIABLES_OBSERVER
</code>
</a>
privilege is required to view the values of sensitive system
variables in this table.
</p>
<p>
For information about persisted system variables, 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>
Suppose that
<code class="filename">
mysqld-auto.cnf
</code>
looks like
this (slightly reformatted):
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-json"><div class="docs-select-all right" id="sa56997257"><div class="copy-help left">Press ⌘+C to 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">"Version"</span><span class="token operator">:</span> <span class="token number">1</span><span class="token punctuation">,</span>
<span class="token property">"mysql_server"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"max_connections"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"Value"</span><span class="token operator">:</span> <span class="token string">"1000"</span><span class="token punctuation">,</span>
<span class="token property">"Metadata"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"Timestamp"</span><span class="token operator">:</span> <span class="token number">1.519921706e+15</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 punctuation">,</span>
<span class="token property">"autocommit"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"Value"</span><span class="token operator">:</span> <span class="token string">"ON"</span><span class="token punctuation">,</span>
<span class="token property">"Metadata"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"Timestamp"</span><span class="token operator">:</span> <span class="token number">1.519921707e+15</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 punctuation">}</span>
<span class="token punctuation">}</span></code></pre>
</div>
<p>
Then
<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>
has
these contents:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa87815541"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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>persisted_variables<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> VARIABLE_NAME <span class="token punctuation">|</span> VARIABLE_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>
<span class="token output"><span class="token punctuation">|</span> autocommit <span class="token punctuation">|</span> ON <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> max_connections <span class="token punctuation">|</span> 1000 <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>
<p>
The
<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 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 variable name listed in
<code class="filename">
mysqld-auto.cnf
</code>
.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
VARIABLE_VALUE
</code>
</p>
<p>
The value listed for the variable in
<code class="filename">
mysqld-auto.cnf
</code>
.
</p>
</li>
</ul>
</div>
<p>
<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>
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">
VARIABLE_NAME
</code>
)
</p>
</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 not permitted
for the
<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.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/group-replication-frequently-asked-questions.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h2 class="title">
<a name="group-replication-frequently-asked-questions">
</a>
20.10 Frequently Asked Questions
</h2>
</div>
</div>
</div>
<a class="indexterm" name="idm46045128294032">
</a>
<p>
This section provides answers to frequently asked questions.
</p>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h3 class="title">
<a name="group-replication-maximum-number-servers">
</a>
What is the maximum number of MySQL servers in a group?
</h3>
</div>
</div>
</div>
<p>
A group can consist of maximum 9 servers. Attempting to add
another server to a group with 9 members causes the request to
join to be refused. This limit has been identified from testing
and benchmarking as a safe boundary where the group performs
reliably on a stable local area network.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h3 class="title">
<a name="group-replication-servers-in-a-group-connected">
</a>
How are servers in a group connected?
</h3>
</div>
</div>
</div>
<p>
Servers in a group connect to the other servers in the group by
opening a peer-to-peer TCP connection. These connections are only
used for internal communication and message passing between
servers in the group. This address is configured by the
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_local_address">
<code class="literal">
group_replication_local_address
</code>
</a>
variable.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h3 class="title">
<a name="group-replication-what-is-the-group-replication-bootstrap-group-option-used-for">
</a>
What is the group_replication_bootstrap_group option used for?
</h3>
</div>
</div>
</div>
<p>
The bootstrap flag instructs a member to
<span class="emphasis">
<em>
create
</em>
</span>
a group and act as the initial seed
server. The second member joining the group needs to ask the
member that bootstrapped the group to dynamically change the
configuration in order for it to be added to the group.
</p>
<p>
A member needs to bootstrap the group in two scenarios. When the
group is originally created, or when shutting down and restarting
the entire group.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h3 class="title">
<a name="group-replication-credentials-for-recovery">
</a>
How do I set credentials for the distributed recovery process?
</h3>
</div>
</div>
</div>
<p>
You can set the user credentials permanently as the credentials
for the
<code class="literal">
group_replication_recovery
</code>
channel,
using 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. You can specify them in the
<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>
statement
each time Group Replication is started.
</p>
<p>
User credentials set using
<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>
are stored in plain text in the replication
metadata repositories on the server, but user credentials
specified on
<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>
are saved in memory only, and are
removed by a
<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>
statement or server shutdown. Using
<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 specify the user credentials
therefore helps to secure the Group Replication servers against
unauthorized access. However, this method is not compatible with
starting Group Replication automatically, as specified by the
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_start_on_boot">
<code class="literal">
group_replication_start_on_boot
</code>
</a>
system variable. For more information, see
<a class="xref" href="group-replication-secure-user.html" title="20.6.3.1 Secure User Credentials for Distributed Recovery">
Section 20.6.3.1, “Secure User Credentials for Distributed Recovery”
</a>
.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h3 class="title">
<a name="group-replication-scale-out-write-load">
</a>
Can I scale-out my write-load using Group Replication?
</h3>
</div>
</div>
</div>
<p>
Not directly, but MySQL Group replication is a shared nothing full
replication solution, where all servers in the group replicate the
same amount of data. Therefore if one member in the group writes N
bytes to storage as the result of a transaction commit operation,
then roughly N bytes are written to storage on other members as
well, because the transaction is replicated everywhere.
</p>
<p>
However, given that other members do not have to do the same
amount of processing that the original member had to do when it
originally executed the transaction, they apply the changes
faster. Transactions are replicated in a format that is used to
apply row transformations only, without having to re-execute
transactions again (row-based format).
</p>
<p>
Furthermore, given that changes are propagated and applied in
row-based format, this means that they are received in an
optimized and compact format, and likely reducing the number of IO
operations required when compared to the originating member.
</p>
<p>
To summarize, you can scale-out processing, by spreading conflict
free transactions throughout different members in the group. And
you can likely scale-out a small fraction of your IO operations,
since remote servers receive only the necessary changes to
read-modify-write changes to stable storage.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h3 class="title">
<a name="group-replication-performance-compared">
</a>
Does Group Replication require more network bandwidth and CPU, when
compared to simple replication and under the same workload?
</h3>
</div>
</div>
</div>
<p>
Some additional load is expected because servers need to be
constantly interacting with each other for synchronization
purposes. It is difficult to quantify how much more data. It also
depends on the size of the group (three servers puts less stress
on the bandwidth requirements than nine servers in the group).
</p>
<p>
Also the memory and CPU footprint are larger, because more complex
work is done for the server synchronization part and for the group
messaging.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h3 class="title">
<a name="group-replication-deploy-across-wide-area-network">
</a>
Can I deploy Group Replication across wide-area networks?
</h3>
</div>
</div>
</div>
<p>
Yes, but the network connection between each member
<span class="emphasis">
<em>
must
</em>
</span>
be reliable and have suitable
performance. Low latency, high bandwidth network connections are a
requirement for optimal performance.
</p>
<p>
If network bandwidth alone is an issue, then
<a class="xref" href="group-replication-message-compression.html" title="20.7.4 Message Compression">
Section 20.7.4, “Message Compression”
</a>
can be
used to lower the bandwidth required. However, if the network
drops packets, leading to re-transmissions and higher end-to-end
latency, throughput and latency are both negatively affected.
</p>
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Warning
</div>
<p>
When the network round-trip time (RTT) between any group members
is 5 seconds or more you could encounter problems as the
built-in failure detection mechanism could be incorrectly
triggered.
</p>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h3 class="title">
<a name="group-replication-automatically-rejoin-temporary-problems">
</a>
Do members automatically rejoin a group in case of temporary
connectivity problems?
</h3>
</div>
</div>
</div>
<p>
This depends on the reason for the connectivity problem. If the
connectivity problem is transient and the reconnection is quick
enough that the failure detector is not aware of it, then the
server may not be removed from the group. If it is a
"long" connectivity problem, then the failure detector
eventually suspects a problem and the server is removed from the
group.
</p>
<p>
Two settings are available to increase the chances of a member
remaining in or rejoining a group:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_member_expel_timeout">
<code class="literal">
group_replication_member_expel_timeout
</code>
</a>
increases the time between the creation of a suspicion (which
happens after an initial 5-second detection period) and the
expulsion of the member. You can set a waiting period of up to
1 hour. A waiting period of 5 seconds is set by default.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_autorejoin_tries">
<code class="literal">
group_replication_autorejoin_tries
</code>
</a>
makes a member try to rejoin the group after an expulsion or
unreachable majority timeout. The member makes the specified
number of auto-rejoin attempts five minutes apart. This
feature is active by default; the member makes three
auto-rejoin attempts.
</p>
</li>
</ul>
</div>
<p>
If a server is expelled from the group and any auto-rejoin
attempts do not succeed, you need to join it back again. In other
words, after a server is removed explicitly from the group you
need to rejoin it manually (or have a script doing it
automatically).
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h3 class="title">
<a name="group-replication-member-excluded">
</a>
When is a member excluded from a group?
</h3>
</div>
</div>
</div>
<p>
If the member becomes silent, the other members remove it from the
group configuration. In practice this may happen when the member
has crashed or there is a network disconnection.
</p>
<p>
The failure is detected after a given timeout elapses for a given
member and a new configuration without the silent member in it is
created.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h3 class="title">
<a name="group-replication-node-lag">
</a>
What happens when one node is significantly lagging behind?
</h3>
</div>
</div>
</div>
<p>
There is no method for defining policies for when to expel members
automatically from the group. You need to find out why a member is
lagging behind and fix that or remove the member from the group.
Otherwise, if the server is so slow that it triggers the flow
control, then the entire group slows down as well. The flow
control can be configured according to the your needs.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h3 class="title">
<a name="group-replication-member-responsible-reconfiguration">
</a>
Upon suspicion of a problem in the group, is there a special member
responsible for triggering a reconfiguration?
</h3>
</div>
</div>
</div>
<p>
No, there is no special member in the group in charge of
triggering a reconfiguration.
</p>
<p>
Any member can suspect that there is a problem. All members need
to (automatically) agree that a given member has failed. One
member is in charge of expelling it from the group, by triggering
a reconfiguration. Which member is responsible for expelling the
member is not something you can control or set.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h3 class="title">
<a name="group-replication-provide-sharding">
</a>
Can I use Group Replication for sharding?
</h3>
</div>
</div>
</div>
<p>
Group Replication is designed to provide highly available replica
sets; data and writes are duplicated on each member in the group.
For scaling beyond what a single system can provide, you need an
orchestration and sharding framework built around a number of
Group Replication sets, where each replica set maintains and
manages a given shard or partition of your total dataset. This
type of setup, often called a
<span class="quote">
“
<span class="quote">
sharded cluster
</span>
”
</span>
,
allows you to scale reads and writes linearly and without limit.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h3 class="title">
<a name="group-replication-using-selinux">
</a>
How do I use Group Replication with SELinux?
</h3>
</div>
</div>
</div>
<p>
If SELinux is enabled, which you can verify using
<span class="command">
<strong>
sestatus -v
</strong>
</span>
, then you need to enable the use of
the Group Replication communication port. See
<a class="xref" href="selinux-context-mysql-feature-ports.html#selinux-context-group-replication-port" title="Setting the TCP Port Context for Group Replication">
Setting the TCP Port Context for Group Replication
</a>
.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h3 class="title">
<a name="group-replication-using-iptables">
</a>
How do I use Group Replication with iptables?
</h3>
</div>
</div>
</div>
<p>
If
<span class="command">
<strong>
iptables
</strong>
</span>
is enabled, then you need to open
up the Group Replication port for communication between the
machines. To see the current rules in place on each machine, issue
<span class="command">
<strong>
iptables -L
</strong>
</span>
. Assuming the port configured is
33061, enable communication over the necessary port by issuing
<span class="command">
<strong>
iptables -A INPUT -p tcp --dport 33061 -j
ACCEPT
</strong>
</span>
.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h3 class="title">
<a name="group-replication-recover-relay-log">
</a>
How do I recover the relay log for a replication channel used by a group
member?
</h3>
</div>
</div>
</div>
<p>
The replication channels used by Group Replication behave in the
same way as replication channels used in asynchronous source to
replica replication, and as such rely on the relay log. In the
event of a change of the
<a class="link" href="replication-options-replica.html#sysvar_relay_log">
<code class="literal">
relay_log
</code>
</a>
variable, or when the
option is not set and the host name changes, there is a chance of
errors. See
<a class="xref" href="replica-logs-relaylog.html" title="19.2.4.1 The Relay Log">
Section 19.2.4.1, “The Relay Log”
</a>
for a recovery
procedure in this situation. Alternatively, another way of fixing
the issue specifically in Group Replication is to issue a
<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>
statement
and then a
<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>
statement to restart the instance. The Group Replication plugin
creates the
<code class="literal">
group_replication_applier
</code>
channel
again.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h3 class="title">
<a name="group-replication-two-bind-addresses">
</a>
Why does Group Replication use two bind addresses?
</h3>
</div>
</div>
</div>
<p>
Group Replication uses two bind addresses in order to split
network traffic between the SQL address, used by clients to
communicate with the member, and the
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_local_address">
<code class="literal">
group_replication_local_address
</code>
</a>
,
used internally by the group members to communicate. For example,
assume a server with two network interfaces assigned to the
network addresses
<code class="literal">
203.0.113.1
</code>
and
<code class="literal">
198.51.100.179
</code>
. In such a situation you could
use
<code class="literal">
203.0.113.1:33061
</code>
for the internal group
network address by setting
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_local_address">
<code class="literal">
group_replication_local_address=203.0.113.1:33061
</code>
</a>
.
Then you could use
<code class="literal">
198.51.100.179
</code>
for
<a class="link" href="server-system-variables.html#sysvar_hostname">
<code class="literal">
hostname
</code>
</a>
and
<code class="literal">
3306
</code>
for the
<a class="link" href="server-system-variables.html#sysvar_port">
<code class="literal">
port
</code>
</a>
. Client SQL applications
would then connect to the member at
<code class="literal">
198.51.100.179:3306
</code>
. This enables you to
configure different rules on the different networks. Similarly,
the internal group communication can be separated from the network
connection used for client applications, for increased security.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h3 class="title">
<a name="group-replication-hostnames">
</a>
How does Group Replication use network addresses and hostnames?
</h3>
</div>
</div>
</div>
<p>
Group Replication uses network connections between members and
therefore its functionality is directly impacted by how you
configure hostnames and ports. For example, Group Replication's
distributed recovery process creates a connection to an existing
group member using the server's hostname and port. When a member
joins a group it receives the group membership information, using
the network address information that is listed at
<a class="link" href="performance-schema-replication-group-members-table.html" title="29.12.11.16 The replication_group_members Table">
<code class="literal">
performance_schema.replication_group_members
</code>
</a>
.
One of the members listed in that table is selected as the donor
of the missing data from the group to the joining member.
</p>
<p>
This means that any value you configure using a hostname, such as
the SQL network address or the group seeds address, must be a
fully qualified name and resolvable by each member of the group.
You can ensure this for example through DNS, or correctly
configured
<code class="filename">
/etc/hosts
</code>
files, or other local
processes. If a you want to configure the
<code class="literal">
MEMBER_HOST
</code>
value on a server, specify it using
the
<a class="link" href="replication-options-replica.html#sysvar_report_host">
<code class="option">
--report-host
</code>
</a>
option on the
server before joining it to the group.
</p>
<div class="important" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Important
</div>
<p>
The assigned value is used directly and is not affected by the
<a class="link" href="server-system-variables.html#sysvar_skip_name_resolve">
<code class="literal">
skip_name_resolve
</code>
</a>
system
variable.
</p>
</div>
<p>
To configure
<code class="literal">
MEMBER_PORT
</code>
on a server, specify
it using the
<a class="link" href="replication-options-replica.html#sysvar_report_port">
<code class="literal">
report_port
</code>
</a>
system
variable.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h3 class="title">
<a name="group-replication-auto-increment-increment">
</a>
Why did the auto increment setting on the server change?
</h3>
</div>
</div>
</div>
<p>
When Group Replication is started on a server, the value of
<a class="link" href="replication-options-source.html#sysvar_auto_increment_increment">
<code class="literal">
auto_increment_increment
</code>
</a>
is
changed to the value of
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_auto_increment_increment">
<code class="literal">
group_replication_auto_increment_increment
</code>
</a>
,
which defaults to 7, and the value of
<a class="link" href="replication-options-source.html#sysvar_auto_increment_offset">
<code class="literal">
auto_increment_offset
</code>
</a>
is changed
to the server ID. The changes are reverted when Group Replication
is stopped. These settings avoid the selection of duplicate
auto-increment values for writes on group members, which causes
rollback of transactions. The default auto increment value of 7
for Group Replication represents a balance between the number of
usable values and the permitted maximum size of a replication
group (9 members).
</p>
<p>
The changes are made and reverted only if
<a class="link" href="replication-options-source.html#sysvar_auto_increment_increment">
<code class="literal">
auto_increment_increment
</code>
</a>
and
<a class="link" href="replication-options-source.html#sysvar_auto_increment_offset">
<code class="literal">
auto_increment_offset
</code>
</a>
each has
its default value (1 in both cases). If their values have already
been modified from the default, Group Replication does not alter
them. The system variables are also not modified when Group
Replication is in single-primary mode, where only one server
writes.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h3 class="title">
<a name="group-replication-how-to-find-primary">
</a>
How do I find the primary?
</h3>
</div>
</div>
</div>
<p>
If the group is operating in single-primary mode, it can be useful
to find out which member is the primary. See
<a class="xref" href="group-replication-single-primary-mode.html#group-replication-find-primary" title="20.1.3.1.2 Finding the Primary">
Section 20.1.3.1.2, “Finding the Primary”
</a>
</p>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/mysql-cluster-programs-ndb-config.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="mysql-cluster-programs-ndb-config">
</a>
25.5.7 ndb_config — Extract NDB Cluster Configuration Information
</h3>
</div>
</div>
</div>
<a class="indexterm" name="idm46045105514512">
</a>
<p>
This tool extracts current configuration information for data
nodes, SQL nodes, and API nodes from one of a number of sources:
an NDB Cluster management node, or its
<code class="filename">
config.ini
</code>
or
<code class="filename">
my.cnf
</code>
file. By default, the management node is the source for the
configuration data; to override the default, execute ndb_config
with the
<a class="link" href="mysql-cluster-programs-ndb-config.html#option_ndb_config_config-file">
<code class="option">
--config-file
</code>
</a>
or
<a class="link" href="mysql-cluster-programs-ndb-config.html#option_ndb_config_mycnf">
<code class="option">
--mycnf
</code>
</a>
option. It is also
possible to use a data node as the source by specifying its node
ID with
<a class="link" href="mysql-cluster-programs-ndb-config.html#option_ndb_config_config_from_node">
<code class="option">
--config_from_node=
<em class="replaceable">
<code>
node_id
</code>
</em>
</code>
</a>
.
</p>
<p>
<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>
can also provide an offline dump
of all configuration parameters which can be used, along with
their default, maximum, and minimum values and other
information. The dump can be produced in either text or XML
format; for more information, see the discussion of the
<a class="link" href="mysql-cluster-programs-ndb-config.html#option_ndb_config_configinfo">
<code class="option">
--configinfo
</code>
</a>
and
<a class="link" href="mysql-cluster-programs-ndb-config.html#option_ndb_config_xml">
<code class="option">
--xml
</code>
</a>
options later in this
section).
</p>
<p>
You can filter the results by section (
<code class="literal">
DB
</code>
,
<code class="literal">
SYSTEM
</code>
, or
<code class="literal">
CONNECTIONS
</code>
)
using one of the options
<a class="link" href="mysql-cluster-programs-ndb-config.html#option_ndb_config_nodes">
<code class="option">
--nodes
</code>
</a>
,
<a class="link" href="mysql-cluster-programs-ndb-config.html#option_ndb_config_system">
<code class="option">
--system
</code>
</a>
, or
<a class="link" href="mysql-cluster-programs-ndb-config.html#option_ndb_config_connections">
<code class="option">
--connections
</code>
</a>
.
</p>
<p>
All options that can be used with
<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>
are shown in the following table. Additional descriptions follow
the table.
</p>
<p>
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a name="option_ndb_config_character-sets-dir">
</a>
<a class="link" href="mysql-cluster-programs-ndb-config.html#option_ndb_config_character-sets-dir">
<code class="option">
--character-sets-dir
</code>
</a>
</p>
<a class="indexterm" name="idm46045105492816">
</a>
<a class="indexterm" name="idm46045105491360">
</a>
<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=path
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Directory containing character sets.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_config_cluster-config-suffix">
</a>
<a class="link" href="mysql-cluster-programs-ndb-config.html#option_ndb_config_cluster-config-suffix">
<code class="option">
cluster-config-suffix
</code>
</a>
</p>
<a class="indexterm" name="idm46045105481504">
</a>
<a class="indexterm" name="idm46045105480048">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for cluster-config-suffix">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--cluster-config-suffix=name
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
String
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
[none]
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Override defaults group suffix when reading cluster
configuration sections in
<code class="filename">
my.cnf
</code>
; used
in testing.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_config_configinfo">
</a>
<a class="link" href="mysql-cluster-programs-ndb-config.html#option_ndb_config_configinfo">
<code class="option">
--configinfo
</code>
</a>
</p>
<a class="indexterm" name="idm46045105465088">
</a>
<a class="indexterm" name="idm46045105463600">
</a>
<p>
The
<code class="option">
--configinfo
</code>
option causes
<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>
to dump a list of each NDB
Cluster configuration parameter supported by the NDB Cluster
distribution of which
<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>
is a
part, including the following information:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
A brief description of each parameter's purpose,
effects, and usage
</p>
</li>
<li class="listitem">
<p>
The section of the
<code class="filename">
config.ini
</code>
file
where the parameter may be used
</p>
</li>
<li class="listitem">
<p>
The parameter's data type or unit of measurement
</p>
</li>
<li class="listitem">
<p>
Where applicable, the parameter's default, minimum,
and maximum values
</p>
</li>
<li class="listitem">
<p>
NDB Cluster release version and build information
</p>
</li>
</ul>
</div>
<p>
By default, this output is in text format. Part of this
output is shown here:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa64070203"><div class="copy-help left">Press ⌘+C to 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_config</span> <span class="token property">--configinfo</span>
****** SYSTEM ******
Name <span class="token punctuation">(</span>String<span class="token punctuation">)</span>
Name of system <span class="token punctuation">(</span>NDB Cluster<span class="token punctuation">)</span>
MANDATORY
PrimaryMGMNode <span class="token punctuation">(</span>Non-negative Integer<span class="token punctuation">)</span>
Node id of Primary ndb_mgmd<span class="token punctuation">(</span>MGM<span class="token punctuation">)</span> node
Default<span class="token punctuation">:</span> 0 <span class="token punctuation">(</span>Min<span class="token punctuation">:</span> 0<span class="token punctuation">,</span> Max<span class="token punctuation">:</span> 4294967039<span class="token punctuation">)</span>
ConfigGenerationNumber <span class="token punctuation">(</span>Non-negative Integer<span class="token punctuation">)</span>
Configuration generation number
Default<span class="token punctuation">:</span> 0 <span class="token punctuation">(</span>Min<span class="token punctuation">:</span> 0<span class="token punctuation">,</span> Max<span class="token punctuation">:</span> 4294967039<span class="token punctuation">)</span>
****** DB ******
MaxNoOfSubscriptions <span class="token punctuation">(</span>Non-negative Integer<span class="token punctuation">)</span>
Max no of subscriptions <span class="token punctuation">(</span>default 0 <span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">=</span></span> MaxNoOfTables<span class="token punctuation">)</span>
Default<span class="token punctuation">:</span> 0 <span class="token punctuation">(</span>Min<span class="token punctuation">:</span> 0<span class="token punctuation">,</span> Max<span class="token punctuation">:</span> 4294967039<span class="token punctuation">)</span>
MaxNoOfSubscribers <span class="token punctuation">(</span>Non-negative Integer<span class="token punctuation">)</span>
Max no of subscribers <span class="token punctuation">(</span>default 0 <span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">=</span></span> 2 * MaxNoOfTables<span class="token punctuation">)</span>
Default<span class="token punctuation">:</span> 0 <span class="token punctuation">(</span>Min<span class="token punctuation">:</span> 0<span class="token punctuation">,</span> Max<span class="token punctuation">:</span> 4294967039<span class="token punctuation">)</span>
…</code></pre>
</div>
<p>
Use this option together with the
<a class="link" href="mysql-cluster-programs-ndb-config.html#option_ndb_config_xml">
<code class="option">
--xml
</code>
</a>
option to obtain
output in XML format.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_config_config-binary-file">
</a>
<a class="link" href="mysql-cluster-programs-ndb-config.html#option_ndb_config_config-binary-file">
<code class="option">
--config-binary-file=
<em class="replaceable">
<code>
path-to-file
</code>
</em>
</code>
</a>
</p>
<a class="indexterm" name="idm46045105445680">
</a>
<a class="indexterm" name="idm46045105444224">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for config-binary-file">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--config-binary-file=path/to/file
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
File name
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Gives the path to the management server's cached binary
configuration file
(
<code class="filename">
ndb_
<em class="replaceable">
<code>
nodeID
</code>
</em>
_config.bin.
<em class="replaceable">
<code>
seqno
</code>
</em>
</code>
).
This may be a relative or absolute path. If the management
server and the
<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>
binary used
reside on different hosts, you must use an absolute path.
</p>
<p>
This example demonstrates combining
<code class="option">
--config-binary-file
</code>
with other
<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>
options to obtain useful
output:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa41322807"><div class="copy-help left">Press ⌘+C to 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_config</span> <span class="token constant">--config-binary-file</span><span class="token attr-value"><span class="token punctuation">=</span>../mysql-cluster/ndb_50_config.bin.1</span> <span class="token property">--diff-default</span> <span class="token constant">--type</span><span class="token attr-value"><span class="token punctuation">=</span>ndbd</span>
config of <span class="token property"><span class="token punctuation">[</span>DB<span class="token punctuation">]</span></span> node id 5 that is different from default
CONFIG_PARAMETER<span class="token punctuation">,</span>ACTUAL_VALUE<span class="token punctuation">,</span>DEFAULT_VALUE
NodeId<span class="token punctuation">,</span>5<span class="token punctuation">,</span><span class="token punctuation">(</span>mandatory<span class="token punctuation">)</span>
BackupDataDir<span class="token punctuation">,</span>/local/data/8<span class="token punctuation">.</span>4<span class="token punctuation">,</span><span class="token punctuation">(</span>null<span class="token punctuation">)</span>
DataDir<span class="token punctuation">,</span>/local/data/8<span class="token punctuation">.</span>4<span class="token punctuation">,</span><span class="token punctuation">.</span>
DataMemory<span class="token punctuation">,</span>2G<span class="token punctuation">,</span>98M
FileSystemPath<span class="token punctuation">,</span>/local/data/8<span class="token punctuation">.</span>4<span class="token punctuation">,</span><span class="token punctuation">(</span>null<span class="token punctuation">)</span>
HostName<span class="token punctuation">,</span>127<span class="token punctuation">.</span>0<span class="token punctuation">.</span>0<span class="token punctuation">.</span>1<span class="token punctuation">,</span>localhost
Nodegroup<span class="token punctuation">,</span>0<span class="token punctuation">,</span><span class="token punctuation">(</span>null<span class="token punctuation">)</span>
ThreadConfig<span class="token punctuation">,</span><span class="token punctuation">,</span><span class="token punctuation">(</span>null<span class="token punctuation">)</span>
config of <span class="token property"><span class="token punctuation">[</span>DB<span class="token punctuation">]</span></span> node id 6 that is different from default
CONFIG_PARAMETER<span class="token punctuation">,</span>ACTUAL_VALUE<span class="token punctuation">,</span>DEFAULT_VALUE
NodeId<span class="token punctuation">,</span>6<span class="token punctuation">,</span><span class="token punctuation">(</span>mandatory<span class="token punctuation">)</span>
BackupDataDir<span class="token punctuation">,</span>/local/data/8<span class="token punctuation">.</span>4<span class="token punctuation">,</span><span class="token punctuation">(</span>null<span class="token punctuation">)</span>
DataDir<span class="token punctuation">,</span>/local/data/8<span class="token punctuation">.</span>4<span class="token punctuation">.</span>
DataMemory<span class="token punctuation">,</span>2G<span class="token punctuation">,</span>98M
FileSystemPath<span class="token punctuation">,</span>/local/data/8<span class="token punctuation">.</span>4<span class="token punctuation">,</span><span class="token punctuation">(</span>null<span class="token punctuation">)</span>
HostName<span class="token punctuation">,</span>127<span class="token punctuation">.</span>0<span class="token punctuation">.</span>0<span class="token punctuation">.</span>1<span class="token punctuation">,</span>localhost
Nodegroup<span class="token punctuation">,</span>0<span class="token punctuation">,</span><span class="token punctuation">(</span>null<span class="token punctuation">)</span>
ThreadConfig<span class="token punctuation">,</span><span class="token punctuation">,</span><span class="token punctuation">(</span>null<span class="token punctuation">)</span>
<span class="token prompt">$> </span><span class="token command">ndb_config</span> <span class="token constant">--config-binary-file</span><span class="token attr-value"><span class="token punctuation">=</span>../mysql-cluster/ndb_50_config.bin.1</span> <span class="token property">--diff-default</span> <span class="token property">--system</span>
config of <span class="token property"><span class="token punctuation">[</span>SYSTEM<span class="token punctuation">]</span></span> system
CONFIG_PARAMETER<span class="token punctuation">,</span>ACTUAL_VALUE<span class="token punctuation">,</span>DEFAULT_VALUE
Name<span class="token punctuation">,</span>MC_20220906060042<span class="token punctuation">,</span><span class="token punctuation">(</span>mandatory<span class="token punctuation">)</span>
ConfigGenerationNumber<span class="token punctuation">,</span>1<span class="token punctuation">,</span>0
PrimaryMGMNode<span class="token punctuation">,</span>50<span class="token punctuation">,</span>0</code></pre>
</div>
<p>
The relevant portions of the
<code class="filename">
config.ini
</code>
file are shown here:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-ini"><div class="docs-select-all right" id="sa41789182"><div class="copy-help left">Press ⌘+C to 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> 2G</span>
<span class="token constant">NoOfReplicas</span><span class="token attr-value"><span class="token punctuation">=</span> 2</span>
<span class="token selector">[ndb_mgmd]</span>
<span class="token constant">NodeId</span><span class="token attr-value"><span class="token punctuation">=</span> 50</span>
<span class="token constant">HostName</span><span class="token attr-value"><span class="token punctuation">=</span> 127.0.0.1</span>
<span class="token selector">[ndbd]</span>
<span class="token constant">NodeId</span><span class="token attr-value"><span class="token punctuation">=</span> 5</span>
<span class="token constant">HostName</span><span class="token attr-value"><span class="token punctuation">=</span> 127.0.0.1</span>
<span class="token constant">DataDir</span><span class="token attr-value"><span class="token punctuation">=</span> /local/data/8.4</span>
<span class="token selector">[ndbd]</span>
<span class="token constant">NodeId</span><span class="token attr-value"><span class="token punctuation">=</span> 6</span>
<span class="token constant">HostName</span><span class="token attr-value"><span class="token punctuation">=</span> 127.0.0.1</span>
<span class="token constant">DataDir</span><span class="token attr-value"><span class="token punctuation">=</span> /local/data/8.4</span></code></pre>
</div>
<p>
By comparing the output with the configuration file, you can
see that all of the settings in the file have been written
by the management server to the binary cache, and thus,
applied to the cluster.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_config_config-file">
</a>
<a class="link" href="mysql-cluster-programs-ndb-config.html#option_ndb_config_config-file">
<code class="option">
--config-file=
<em class="replaceable">
<code>
path-to-file
</code>
</em>
</code>
</a>
</p>
<a class="indexterm" name="idm46045105416992">
</a>
<a class="indexterm" name="idm46045105415504">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for config-file">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--config-file=file_name
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
File name
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Gives the path to the cluster configuration file
(
<code class="filename">
config.ini
</code>
). This may be a relative or
absolute path. If the management server and the
<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>
binary used reside on
different hosts, you must use an absolute path.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_config_config_from_node">
</a>
<a class="link" href="mysql-cluster-programs-ndb-config.html#option_ndb_config_config_from_node">
<code class="option">
--config_from_node=#
</code>
</a>
</p>
<a class="indexterm" name="idm46045105399408">
</a>
<a class="indexterm" name="idm46045105397920">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for config_from_node">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--config-from-node=#
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
Numeric
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
none
</code>
</td>
</tr>
<tr>
<th>
Minimum Value
</th>
<td>
<code class="literal">
1
</code>
</td>
</tr>
<tr>
<th>
Maximum Value
</th>
<td>
<code class="literal">
48
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Obtain the cluster's configuration data from the data
node that has this ID.
</p>
<p>
If the node having this ID is not a data node,
<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>
fails with an error. (To
obtain configuration data from the management node instead,
simply omit this option.)
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_config_connect-retries">
</a>
<a class="link" href="mysql-cluster-programs-ndb-config.html#option_ndb_config_connect-retries">
<code class="option">
--connect-retries
</code>
</a>
</p>
<a class="indexterm" name="idm46045105376880">
</a>
<a class="indexterm" name="idm46045105375392">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for connect-retries">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--connect-retries=#
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
Integer
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
12
</code>
</td>
</tr>
<tr>
<th>
Minimum Value
</th>
<td>
<code class="literal">
0
</code>
</td>
</tr>
<tr>
<th>
Maximum Value
</th>
<td>
<code class="literal">
12
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Number of times to retry connection before giving up.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_config_connect-retry-delay">
</a>
<a class="link" href="mysql-cluster-programs-ndb-config.html#option_ndb_config_connect-retry-delay">
<code class="option">
--connect-retry-delay
</code>
</a>
</p>
<a class="indexterm" name="idm46045105356368">
</a>
<a class="indexterm" name="idm46045105354912">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for connect-retry-delay">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--connect-retry-delay=#
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
Integer
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
5
</code>
</td>
</tr>
<tr>
<th>
Minimum Value
</th>
<td>
<code class="literal">
0
</code>
</td>
</tr>
<tr>
<th>
Maximum Value
</th>
<td>
<code class="literal">
5
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Number of seconds to wait between attempts to contact
management server.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_config_connect-string">
</a>
<a class="link" href="mysql-cluster-programs-ndb-config.html#option_ndb_config_connect-string">
<code class="option">
--connect-string
</code>
</a>
</p>
<a class="indexterm" name="idm46045105335792">
</a>
<a class="indexterm" name="idm46045105334304">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for connect-string">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--connect-string=connection_string
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
String
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
[none]
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Same as
<a class="link" href="mysql-cluster-programs-ndb-config.html#option_ndb_config_ndb-connectstring">
<code class="option">
--ndb-connectstring
</code>
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_config_connections">
</a>
<a class="link" href="mysql-cluster-programs-ndb-config.html#option_ndb_config_connections">
<code class="option">
--connections
</code>
</a>
</p>
<a class="indexterm" name="idm46045105319232">
</a>
<a class="indexterm" name="idm46045105317744">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for connections">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--connections
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Tells
<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>
to print
<code class="literal">
CONNECTIONS
</code>
information only—that
is, information about parameters found in the
<code class="literal">
[tcp]
</code>
,
<code class="literal">
[tcp default]
</code>
,
<code class="literal">
[shm]
</code>
, or
<code class="literal">
[shm
default]
</code>
sections of the cluster configuration
file (see
<a class="xref" href="mysql-cluster-tcp-definition.html" title="25.4.3.10 NDB Cluster TCP/IP Connections">
Section 25.4.3.10, “NDB Cluster TCP/IP Connections”
</a>
,
and
<a class="xref" href="mysql-cluster-shm-definition.html" title="25.4.3.12 NDB Cluster Shared-Memory Connections">
Section 25.4.3.12, “NDB Cluster Shared-Memory Connections”
</a>
, for more
information).
</p>
<p>
This option is mutually exclusive with
<a class="link" href="mysql-cluster-programs-ndb-config.html#option_ndb_config_nodes">
<code class="option">
--nodes
</code>
</a>
and
<a class="link" href="mysql-cluster-programs-ndb-config.html#option_ndb_config_system">
<code class="option">
--system
</code>
</a>
; only one of
these 3 options can be used.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_config_core-file">
</a>
<a class="link" href="mysql-cluster-programs-ndb-config.html#option_ndb_config_core-file">
<code class="option">
--core-file
</code>
</a>
</p>
<a class="indexterm" name="idm46045105299040">
</a>
<a class="indexterm" name="idm46045105297552">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for core-file">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--core-file
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Write core file on error; used in debugging.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_config_defaults-extra-file">
</a>
<a class="link" href="mysql-cluster-programs-ndb-config.html#option_ndb_config_defaults-extra-file">
<code class="option">
--defaults-extra-file
</code>
</a>
</p>
<a class="indexterm" name="idm46045105287712">
</a>
<a class="indexterm" name="idm46045105286256">
</a>
<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=path
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
String
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
[none]
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Read given file after global files are read.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_config_defaults-file">
</a>
<a class="link" href="mysql-cluster-programs-ndb-config.html#option_ndb_config_defaults-file">
<code class="option">
--defaults-file
</code>
</a>
</p>
<a class="indexterm" name="idm46045105271904">
</a>
<a class="indexterm" name="idm46045105270416">
</a>
<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=path
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
String
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
[none]
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Read default options from given file only.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_config_defaults-group-suffix">
</a>
<a class="link" href="mysql-cluster-programs-ndb-config.html#option_ndb_config_defaults-group-suffix">
<code class="option">
--defaults-group-suffix
</code>
</a>
</p>
<a class="indexterm" name="idm46045105256144">
</a>
<a class="indexterm" name="idm46045105254688">
</a>
<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=string
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
String
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
[none]
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Also read groups with concat(group, suffix).
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_config_diff-default">
</a>
<a class="link" href="mysql-cluster-programs-ndb-config.html#option_ndb_config_diff-default">
<code class="option">
--diff-default
</code>
</a>
</p>
<a class="indexterm" name="idm46045105240400">
</a>
<a class="indexterm" name="idm46045105238912">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for diff-default">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--diff-default
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Print only configuration parameters that have non-default
values.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_config_fields">
</a>
<a class="link" href="mysql-cluster-programs-ndb-config.html#option_ndb_config_fields">
<code class="option">
--fields=
<em class="replaceable">
<code>
delimiter
</code>
</em>
</code>
</a>
,
<code class="option">
-f
</code>
<em class="replaceable">
<code>
delimiter
</code>
</em>
</p>
<a class="indexterm" name="idm46045105228048">
</a>
<a class="indexterm" name="idm46045105226560">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for fields">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--fields=string
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
String
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Specifies a
<em class="replaceable">
<code>
delimiter
</code>
</em>
string used
to separate the fields in the result. The default is
<code class="literal">
,
</code>
(the comma character).
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
If the
<em class="replaceable">
<code>
delimiter
</code>
</em>
contains
spaces or escapes (such as
<code class="literal">
\n
</code>
for the
linefeed character), then it must be quoted.
</p>
</div>
</li>
<li class="listitem">
<p>
<a name="option_ndb_config_help">
</a>
<a class="link" href="mysql-cluster-programs-ndb-config.html#option_ndb_config_help">
<code class="option">
--help
</code>
</a>
</p>
<a class="indexterm" name="idm46045105209344">
</a>
<a class="indexterm" name="idm46045105207856">
</a>
<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>
<p>
Display help text and exit.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_config_host">
</a>
<a class="link" href="mysql-cluster-programs-ndb-config.html#option_ndb_config_host">
<code class="option">
--host=
<em class="replaceable">
<code>
hostname
</code>
</em>
</code>
</a>
</p>
<a class="indexterm" name="idm46045105197888">
</a>
<a class="indexterm" name="idm46045105196400">
</a>
<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=name
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
String
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Specifies the host name of the node for which configuration
information is to be obtained.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
While the hostname
<code class="literal">
localhost
</code>
usually
resolves to the IP address
<code class="literal">
127.0.0.1
</code>
,
this may not necessarily be true for all operating
platforms and configurations. This means that it is
possible, when
<code class="literal">
localhost
</code>
is used in
<code class="filename">
config.ini
</code>
, for
<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
<code class="option">
--host=localhost
</code>
</strong>
</span>
</a>
to fail if
<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>
is run on a different host
where
<code class="literal">
localhost
</code>
resolves to a different
address (for example, on some versions of SUSE Linux, this
is
<code class="literal">
127.0.0.2
</code>
). In general, for best
results, you should use numeric IP addresses for all NDB
Cluster configuration values relating to hosts, or verify
that all NDB Cluster hosts handle
<code class="literal">
localhost
</code>
in the same fashion.
</p>
</div>
</li>
<li class="listitem">
<p>
<a name="option_ndb_config_login-path">
</a>
<a class="link" href="mysql-cluster-programs-ndb-config.html#option_ndb_config_login-path">
<code class="option">
--login-path
</code>
</a>
</p>
<a class="indexterm" name="idm46045105172944">
</a>
<a class="indexterm" name="idm46045105171456">
</a>
<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=path
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
String
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
[none]
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Read given path from login file.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_config_mycnf">
</a>
<a class="link" href="mysql-cluster-programs-ndb-config.html#option_ndb_config_mycnf">
<code class="option">
--mycnf
</code>
</a>
</p>
<a class="indexterm" name="idm46045105157408">
</a>
<a class="indexterm" name="idm46045105155920">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for mycnf">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--mycnf
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Read configuration data from the
<code class="filename">
my.cnf
</code>
file.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_config_ndb-connectstring">
</a>
<a class="link" href="mysql-cluster-programs-ndb-config.html#option_ndb_config_ndb-connectstring">
<code class="option">
--ndb-connectstring=
<em class="replaceable">
<code>
connection_string
</code>
</em>
</code>
</a>
,
<code class="option">
-c
<em class="replaceable">
<code>
connection_string
</code>
</em>
</code>
</p>
<a class="indexterm" name="idm46045105144544">
</a>
<a class="indexterm" name="idm46045105143088">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for ndb-connectstring">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--ndb-connectstring=connection_string
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
String
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
[none]
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Specifies the connection string to use in connecting to the
management server. The format for the connection string is
the same as described in
<a class="xref" href="mysql-cluster-connection-strings.html" title="25.4.3.3 NDB Cluster Connection Strings">
Section 25.4.3.3, “NDB Cluster Connection Strings”
</a>
, and
defaults to
<code class="literal">
localhost:1186
</code>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_config_ndb-mgm-tls">
</a>
<a class="link" href="mysql-cluster-programs-ndb-config.html#option_ndb_config_ndb-mgm-tls">
<code class="option">
--ndb-mgm-tls
</code>
</a>
</p>
<a class="indexterm" name="idm46045105127168">
</a>
<a class="indexterm" name="idm46045105125680">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for ndb-mgm-tls">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--ndb-mgm-tls=level
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
Enumeration
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
relaxed
</code>
</td>
</tr>
<tr>
<th>
Valid Values
</th>
<td>
<p class="valid-value">
<code class="literal">
relaxed
</code>
</p>
<p class="valid-value">
<code class="literal">
strict
</code>
</p>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Sets the level of TLS support required to connect to the
management server; one of
<code class="literal">
relaxed
</code>
or
<code class="literal">
strict
</code>
.
<code class="literal">
relaxed
</code>
(the
default) means that a TLS connection is attempted, but
success is not required;
<code class="literal">
strict
</code>
means
that TLS is required to connect.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_config_ndb-mgmd-host">
</a>
<a class="link" href="mysql-cluster-programs-ndb-config.html#option_ndb_config_ndb-mgmd-host">
<code class="option">
--ndb-mgmd-host
</code>
</a>
</p>
<a class="indexterm" name="idm46045105104624">
</a>
<a class="indexterm" name="idm46045105103136">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for ndb-mgmd-host">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--ndb-mgmd-host=connection_string
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
String
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
[none]
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Same as
<a class="link" href="mysql-cluster-programs-ndb-config.html#option_ndb_config_ndb-connectstring">
<code class="option">
--ndb-connectstring
</code>
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_config_ndb-nodeid">
</a>
<a class="link" href="mysql-cluster-programs-ndb-config.html#option_ndb_config_ndb-nodeid">
<code class="option">
--ndb-nodeid
</code>
</a>
</p>
<a class="indexterm" name="idm46045105087952">
</a>
<a class="indexterm" name="idm46045105086464">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for ndb-nodeid">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--ndb-nodeid=#
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
Integer
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
[none]
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Set node ID for this node, overriding any ID set by
<a class="link" href="mysql-cluster-programs-ndb-config.html#option_ndb_config_ndb-connectstring">
<code class="option">
--ndb-connectstring
</code>
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_config_ndb-optimized-node-selection">
</a>
<a class="link" href="mysql-cluster-programs-ndb-config.html#option_ndb_config_ndb-optimized-node-selection">
<code class="option">
--ndb-optimized-node-selection
</code>
</a>
</p>
<a class="indexterm" name="idm46045105071152">
</a>
<a class="indexterm" name="idm46045105069648">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for ndb-optimized-node-selection">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--ndb-optimized-node-selection
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Enable optimizations for selection of nodes for
transactions. Enabled by default; use
<code class="option">
--skip-ndb-optimized-node-selection
</code>
to
disable.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_config_ndb-tls-search-path">
</a>
<a class="link" href="mysql-cluster-programs-ndb-config.html#option_ndb_config_ndb-tls-search-path">
<code class="option">
--ndb-tls-search-path
</code>
</a>
</p>
<a class="indexterm" name="idm46045105059296">
</a>
<a class="indexterm" name="idm46045105057840">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for ndb-tls-search-path">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--ndb-tls-search-path=list
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
Path name
</td>
</tr>
<tr>
<th>
Default Value (Unix)
</th>
<td>
<code class="literal">
$HOME/ndb-tls
</code>
</td>
</tr>
<tr>
<th>
Default Value (Windows)
</th>
<td>
<code class="literal">
$HOMEDIR/ndb-tls
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Specify a list of directories to search for a CA file. On
Unix platforms, the directory names are separated by colons
(
<code class="literal">
:
</code>
); on Windows systems, the semicolon
character (
<code class="literal">
;
</code>
) is used as the separator. A
directory reference may be relative or absolute; it may
contain one or more environment variables, each denoted by a
prefixed dollar sign (
<code class="literal">
$
</code>
), and expanded
prior to use.
</p>
<p>
Searching begins with the leftmost named directory and
proceeds from left to right until a file is found. An empty
string denotes an empty search path, which causes all
searches to fail. A string consisting of a single dot
(
<code class="literal">
.
</code>
) indicates that the search path
limited to the current working directory.
</p>
<p>
If no search path is supplied, the compiled-in default value
is used. This value depends on the platform used: On
Windows, this is
<code class="literal">
\ndb-tls
</code>
; on other
platforms (including Linux), it is
<code class="literal">
$HOME/ndb-tls
</code>
. This can be overridden by
compiling NDB Cluster using
<a class="link" href="source-configuration-options.html#option_cmake_with_ndb_tls_search_path">
<code class="option">
-DWITH_NDB_TLS_SEARCH_PATH
</code>
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_config_no-defaults">
</a>
<a class="link" href="mysql-cluster-programs-ndb-config.html#option_ndb_config_no-defaults">
<code class="option">
--no-defaults
</code>
</a>
</p>
<a class="indexterm" name="idm46045105034080">
</a>
<a class="indexterm" name="idm46045105032592">
</a>
<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>
<p>
Do not read default options from any option file other than
login file.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_config_no-login-paths">
</a>
<a class="link" href="mysql-cluster-programs-ndb-config.html#option_ndb_config_no-login-paths">
<code class="option">
--no-login-paths
</code>
</a>
</p>
<a class="indexterm" name="idm46045105022768">
</a>
<a class="indexterm" name="idm46045105021280">
</a>
<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>
<p>
Skips reading options from the login path file.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_config_nodeid">
</a>
<a class="link" href="mysql-cluster-programs-ndb-config.html#option_ndb_config_nodeid">
<code class="option">
--nodeid=
<em class="replaceable">
<code>
node_id
</code>
</em>
</code>
</a>
</p>
<a class="indexterm" name="idm46045105011280">
</a>
<a class="indexterm" name="idm46045105009792">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for ndb-nodeid">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--ndb-nodeid=#
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
Integer
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
[none]
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Specify the node ID of the node for which configuration
information is to be obtained.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_config_nodes">
</a>
<a class="link" href="mysql-cluster-programs-ndb-config.html#option_ndb_config_nodes">
<code class="option">
--nodes
</code>
</a>
</p>
<a class="indexterm" name="idm46045104995744">
</a>
<a class="indexterm" name="idm46045104994256">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for nodes">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--nodes
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Tells
<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>
to print information
relating only to parameters defined in an
<code class="literal">
[ndbd]
</code>
or
<code class="literal">
[ndbd
default]
</code>
section of the cluster configuration file
(see
<a class="xref" href="mysql-cluster-ndbd-definition.html" title="25.4.3.6 Defining NDB Cluster Data Nodes">
Section 25.4.3.6, “Defining NDB Cluster Data Nodes”
</a>
).
</p>
<p>
This option is mutually exclusive with
<a class="link" href="mysql-cluster-programs-ndb-config.html#option_ndb_config_connections">
<code class="option">
--connections
</code>
</a>
and
<a class="link" href="mysql-cluster-programs-ndb-config.html#option_ndb_config_system">
<code class="option">
--system
</code>
</a>
; only one of
these 3 options can be used.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_config_print-defaults">
</a>
<a class="link" href="mysql-cluster-programs-ndb-config.html#option_ndb_config_print-defaults">
<code class="option">
--print-defaults
</code>
</a>
</p>
<a class="indexterm" name="idm46045104978512">
</a>
<a class="indexterm" name="idm46045104977024">
</a>
<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>
<p>
Print program argument list and exit.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_config_query">
</a>
<a class="link" href="mysql-cluster-programs-ndb-config.html#option_ndb_config_query">
<code class="option">
--query=
<em class="replaceable">
<code>
query-options
</code>
</em>
</code>
</a>
,
<code class="option">
-q
</code>
<em class="replaceable">
<code>
query-options
</code>
</em>
</p>
<a class="indexterm" name="idm46045104966240">
</a>
<a class="indexterm" name="idm46045104964752">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for query">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--query=string
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
String
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
This is a comma-delimited list of
<span class="firstterm">
query
options
</span>
—that is, a list of one or more node
attributes to be returned. These include
<code class="literal">
nodeid
</code>
(node ID), type (node
type—that is,
<code class="literal">
ndbd
</code>
,
<code class="literal">
mysqld
</code>
, or
<code class="literal">
ndb_mgmd
</code>
),
and any configuration parameters whose values are to be
obtained.
</p>
<p>
For example,
<code class="option">
--query=nodeid,type,datamemory,datadir
</code>
returns the node ID, node type,
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-datamemory">
<code class="literal">
DataMemory
</code>
</a>
, and
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-datadir">
<code class="literal">
DataDir
</code>
</a>
for each
node.
</p>
<a class="indexterm" name="idm46045104945632">
</a>
<a class="indexterm" name="idm46045104944144">
</a>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
If a given parameter is not applicable to a certain type
of node, than an empty string is returned for the
corresponding value. See the examples later in this
section for more information.
</p>
</div>
</li>
<li class="listitem">
<p>
<a name="option_ndb_config_query-all">
</a>
<a class="link" href="mysql-cluster-programs-ndb-config.html#option_ndb_config_query-all">
<code class="option">
--query-all
</code>
</a>
,
<code class="option">
-a
</code>
</p>
<a class="indexterm" name="idm46045104938784">
</a>
<a class="indexterm" name="idm46045104937296">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for query-all">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--query-all
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
String
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Returns a comma-delimited list of all query options (node
attributes; note that this list is a single string.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_config_rows">
</a>
<a class="link" href="mysql-cluster-programs-ndb-config.html#option_ndb_config_rows">
<code class="option">
--rows=
<em class="replaceable">
<code>
separator
</code>
</em>
</code>
</a>
,
<code class="option">
-r
</code>
<em class="replaceable">
<code>
separator
</code>
</em>
</p>
<a class="indexterm" name="idm46045104922144">
</a>
<a class="indexterm" name="idm46045104920656">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for rows">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--rows=string
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
String
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Specifies a
<em class="replaceable">
<code>
separator
</code>
</em>
string used
to separate the rows in the result. The default is a space
character.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
If the
<em class="replaceable">
<code>
separator
</code>
</em>
contains
spaces or escapes (such as
<code class="literal">
\n
</code>
for the
linefeed character), then it must be quoted.
</p>
</div>
</li>
<li class="listitem">
<p>
<a name="option_ndb_config_system">
</a>
<a class="link" href="mysql-cluster-programs-ndb-config.html#option_ndb_config_system">
<code class="option">
--system
</code>
</a>
</p>
<a class="indexterm" name="idm46045104904144">
</a>
<a class="indexterm" name="idm46045104902656">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for system">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--system
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Tells
<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>
to print
<code class="literal">
SYSTEM
</code>
information only. This consists of
system variables that cannot be changed at run time; thus,
there is no corresponding section of the cluster
configuration file for them. They can be seen (prefixed with
<code class="literal">
****** SYSTEM ******
</code>
) in the output of
<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>
<a class="link" href="mysql-cluster-programs-ndb-config.html#option_ndb_config_configinfo">
<code class="option">
--configinfo
</code>
</a>
.
</p>
<p>
This option is mutually exclusive with
<a class="link" href="mysql-cluster-programs-ndb-config.html#option_ndb_config_nodes">
<code class="option">
--nodes
</code>
</a>
and
<a class="link" href="mysql-cluster-programs-ndb-config.html#option_ndb_config_connections">
<code class="option">
--connections
</code>
</a>
; only one
of these 3 options can be used.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_config_type">
</a>
<a class="link" href="mysql-cluster-programs-ndb-config.html#option_ndb_config_type">
<code class="option">
--type=
<em class="replaceable">
<code>
node_type
</code>
</em>
</code>
</a>
</p>
<a class="indexterm" name="idm46045104885120">
</a>
<a class="indexterm" name="idm46045104883632">
</a>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for type">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--type=name
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
Enumeration
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
[none]
</code>
</td>
</tr>
<tr>
<th>
Valid Values
</th>
<td>
<p class="valid-value">
<code class="literal">
ndbd
</code>
</p>
<p class="valid-value">
<code class="literal">
mysqld
</code>
</p>
<p class="valid-value">
<code class="literal">
ndb_mgmd
</code>
</p>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Filters results so that only configuration values applying
to nodes of the specified
<em class="replaceable">
<code>
node_type
</code>
</em>
(
<code class="literal">
ndbd
</code>
,
<code class="literal">
mysqld
</code>
, or
<code class="literal">
ndb_mgmd
</code>
) are returned.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_config_usage">
</a>
<a class="link" href="mysql-cluster-programs-ndb-config.html#option_ndb_config_usage">
<code class="option">
--usage
</code>
</a>
,
<code class="option">
--help
</code>
, or
<code class="option">
-?
</code>
</p>
<a class="indexterm" name="idm46045104861216">
</a>
<a class="indexterm" name="idm46045104859728">
</a>
<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>
<p>
Causes
<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>
to print a list of
available options, and then exit.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_config_version">
</a>
<a class="link" href="mysql-cluster-programs-ndb-config.html#option_ndb_config_version">
<code class="option">
--version
</code>
</a>
,
<code class="option">
-V
</code>
</p>
<a class="indexterm" name="idm46045104848224">
</a>
<a class="indexterm" name="idm46045104846736">
</a>
<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>
<p>
Causes
<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>
to print a version
information string, and then exit.
</p>
</li>
<li class="listitem">
<p>
<a name="option_ndb_config_xml">
</a>
<code class="option">
--configinfo
</code>
<a class="link" href="mysql-cluster-programs-ndb-config.html#option_ndb_config_xml">
<code class="option">
--xml
</code>
</a>
</p>
<a class="indexterm" name="idm46045104835504">
</a>
<a class="indexterm" name="idm46045104834016">
</a>
<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">
--configinfo --xml
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Cause
<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>
<a class="link" href="mysql-cluster-programs-ndb-config.html#option_ndb_config_configinfo">
<code class="option">
--configinfo
</code>
</a>
to provide
output as XML by adding this option. A portion of such
output is shown in this example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa13533404"><div class="copy-help left">Press ⌘+C to 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_config</span> <span class="token property">--configinfo</span> <span class="token property">--xml</span>
<configvariables protocolversion=<span class="token atrule">"1"</span> ndbversionstring=<span class="token atrule">"5.7.44-ndb-7.5.36"</span>
ndbversion=<span class="token atrule">"460032"</span> ndbversionmajor=<span class="token atrule">"7"</span> ndbversionminor=<span class="token atrule">"5"</span>
ndbversionbuild=<span class="token atrule">"0"</span>>
<section name=<span class="token atrule">"SYSTEM"</span>>
<param name=<span class="token atrule">"Name"</span> comment=<span class="token atrule">"Name of system (NDB Cluster)"</span> type=<span class="token atrule">"string"</span>
mandatory=<span class="token atrule">"true"</span>/>
<param name=<span class="token atrule">"PrimaryMGMNode"</span> comment=<span class="token atrule">"Node id of Primary ndb_mgmd(MGM) node"</span>
type=<span class="token atrule">"unsigned"</span> default=<span class="token atrule">"0"</span> min=<span class="token atrule">"0"</span> max=<span class="token atrule">"4294967039"</span>/>
<param name=<span class="token atrule">"ConfigGenerationNumber"</span> comment=<span class="token atrule">"Configuration generation number"</span>
type=<span class="token atrule">"unsigned"</span> default=<span class="token atrule">"0"</span> min=<span class="token atrule">"0"</span> max=<span class="token atrule">"4294967039"</span>/>
</section>
<section name=<span class="token atrule">"MYSQLD"</span> primarykeys=<span class="token atrule">"NodeId"</span>>
<param name=<span class="token atrule">"wan"</span> comment=<span class="token atrule">"Use WAN TCP setting as default"</span> type=<span class="token atrule">"bool"</span>
default=<span class="token atrule">"false"</span>/>
<param name=<span class="token atrule">"HostName"</span> comment=<span class="token atrule">"Name of computer for this node"</span>
type=<span class="token atrule">"string"</span> default=<span class="token atrule">""</span>/>
<param name=<span class="token atrule">"Id"</span> comment=<span class="token atrule">"NodeId"</span> type=<span class="token atrule">"unsigned"</span> mandatory=<span class="token atrule">"true"</span>
min=<span class="token atrule">"1"</span> max=<span class="token atrule">"255"</span> deprecated=<span class="token atrule">"true"</span>/>
<param name=<span class="token atrule">"NodeId"</span> comment=<span class="token atrule">"Number identifying application node (mysqld(API))"</span>
type=<span class="token atrule">"unsigned"</span> mandatory=<span class="token atrule">"true"</span> min=<span class="token atrule">"1"</span> max=<span class="token atrule">"255"</span>/>
<param name=<span class="token atrule">"ExecuteOnComputer"</span> comment=<span class="token atrule">"HostName"</span> type=<span class="token atrule">"string"</span>
deprecated=<span class="token atrule">"true"</span>/>
…
</section>
…
</configvariables></code></pre>
</div>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
Normally, the XML output produced by
<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>
<code class="option">
--configinfo
</code>
<code class="option">
--xml
</code>
is
formatted using one line per element; we have added extra
whitespace in the previous example, as well as the next
one, for reasons of legibility. This should not make any
difference to applications using this output, since most
XML processors either ignore nonessential whitespace as a
matter of course, or can be instructed to do so.
</p>
</div>
<p>
The XML output also indicates when changing a given
parameter requires that data nodes be restarted using the
<a class="link" href="mysql-cluster-programs-ndbd.html#option_ndbd_initial">
<code class="option">
--initial
</code>
</a>
option. This is shown
by the presence of an
<code class="literal">
initial="true"
</code>
attribute in the corresponding
<code class="literal">
<param>
</code>
element. In addition, the
restart type (
<code class="literal">
system
</code>
or
<code class="literal">
node
</code>
) is also shown; if a given parameter
requires a system restart, this is indicated by the presence
of a
<code class="literal">
restart="system"
</code>
attribute in the
corresponding
<code class="literal">
<param>
</code>
element. For
example, changing the value set for the
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-diskless">
<code class="literal">
Diskless
</code>
</a>
parameter
requires a system initial restart, as shown here (with the
<code class="literal">
restart
</code>
and
<code class="literal">
initial
</code>
attributes highlighted for visibility):
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-xml"><div class="docs-select-all right" id="sa11538081"><div class="copy-help left">Press ⌘+C to 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>param</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>Diskless<span class="token punctuation">"</span></span> <span class="token attr-name">comment</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>Run wo/ disk<span class="token punctuation">"</span></span> <span class="token attr-name">type</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>bool<span class="token punctuation">"</span></span> <span class="token attr-name">default</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>false<span class="token punctuation">"</span></span>
<span class="token attr-name"></span><em><span class="token attr-name">restart</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>system<span class="token punctuation">"</span></span> <span class="token attr-name">initial</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>true<span class="token punctuation">"</span></span></em><span class="token attr-value"><span class="token punctuation"></span></span><span class="token punctuation">/></span></span></code></pre>
</div>
<p>
Currently, no
<code class="literal">
initial
</code>
attribute is
included in the XML output for
<code class="literal">
<param>
</code>
elements corresponding to
parameters which do not require initial restarts; in other
words,
<code class="literal">
initial="false"
</code>
is the default,
and the value
<code class="literal">
false
</code>
should be assumed if
the attribute is not present. Similarly, the default restart
type is
<code class="literal">
node
</code>
(that is, an online or
<span class="quote">
“
<span class="quote">
rolling
</span>
”
</span>
restart of the cluster), but the
<code class="literal">
restart
</code>
attribute is included only if the
restart type is
<code class="literal">
system
</code>
(meaning that all
cluster nodes must be shut down at the same time, then
restarted).
</p>
<p>
Deprecated parameters are indicated in the XML output by the
<code class="literal">
deprecated
</code>
attribute, as shown here:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-xml"><div class="docs-select-all right" id="sa52301452"><div class="copy-help left">Press ⌘+C to 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>param</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>NoOfDiskPagesToDiskAfterRestartACC<span class="token punctuation">"</span></span> <span class="token attr-name">comment</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>DiskCheckpointSpeed<span class="token punctuation">"</span></span>
<span class="token attr-name">type</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>unsigned<span class="token punctuation">"</span></span> <span class="token attr-name">default</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>20<span class="token punctuation">"</span></span> <span class="token attr-name">min</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">max</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>4294967039<span class="token punctuation">"</span></span> <span class="token attr-name"></span><em><span class="token attr-name">deprecated</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>true<span class="token punctuation">"</span></span></em><span class="token attr-value"><span class="token punctuation"></span></span><span class="token punctuation">/></span></span></code></pre>
</div>
<p>
In such cases, the
<code class="literal">
comment
</code>
refers to one
or more parameters that supersede the deprecated parameter.
Similarly to
<code class="literal">
initial
</code>
, the
<code class="literal">
deprecated
</code>
attribute is indicated only
when the parameter is deprecated, with
<code class="literal">
deprecated="true"
</code>
, and does not appear at
all for parameters which are not deprecated. (Bug #21127135)
</p>
<p>
Parameters that are required are indicated with
<code class="literal">
mandatory="true"
</code>
, as shown here:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-xml"><div class="docs-select-all right" id="sa98634153"><div class="copy-help left">Press ⌘+C to 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>param</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>NodeId<span class="token punctuation">"</span></span>
<span class="token attr-name">comment</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>Number identifying application node (mysqld(API))<span class="token punctuation">"</span></span>
<span class="token attr-name">type</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>unsigned<span class="token punctuation">"</span></span> <span class="token attr-name"></span><em><span class="token attr-name">mandatory</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>true<span class="token punctuation">"</span></span></em><span class="token attr-value"><span class="token punctuation"></span></span> <span class="token attr-name">min</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">max</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>255<span class="token punctuation">"</span></span><span class="token punctuation">/></span></span></code></pre>
</div>
<p>
In much the same way that the
<code class="literal">
initial
</code>
or
<code class="literal">
deprecated
</code>
attribute is displayed only
for a parameter that requires an initial restart or that is
deprecated, the
<code class="literal">
mandatory
</code>
attribute is
included only if the given parameter is actually required.
</p>
<div class="important" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Important
</div>
<p>
The
<code class="option">
--xml
</code>
option can be used only with
the
<code class="option">
--configinfo
</code>
option. Using
<code class="option">
--xml
</code>
without
<code class="option">
--configinfo
</code>
fails with an error.
</p>
</div>
<p>
Unlike the options used with this program to obtain current
configuration data,
<code class="option">
--configinfo
</code>
and
<code class="option">
--xml
</code>
use information obtained from the NDB
Cluster sources when
<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>
was
compiled. For this reason, no connection to a running NDB
Cluster or access to a
<code class="filename">
config.ini
</code>
or
<code class="filename">
my.cnf
</code>
file is required for these two
options.
</p>
</li>
</ul>
</div>
<p>
Combining other
<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>
options (such as
<a class="link" href="mysql-cluster-programs-ndb-config.html#option_ndb_config_query">
<code class="option">
--query
</code>
</a>
or
<a class="link" href="mysql-cluster-programs-ndb-config.html#option_ndb_config_type">
<code class="option">
--type
</code>
</a>
) with
<code class="option">
--configinfo
</code>
(with or without the
<code class="option">
--xml
</code>
option is not supported. Currently, if
you attempt to do so, the usual result is that all other options
besides
<code class="option">
--configinfo
</code>
or
<code class="option">
--xml
</code>
are simply ignored.
<span class="emphasis">
<em>
However, this behavior is not
guaranteed and is subject to change at any time
</em>
</span>
. In
addition, since
<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>
, when used with
the
<code class="option">
--configinfo
</code>
option, does not access the
NDB Cluster or read any files, trying to specify additional
options such as
<code class="option">
--ndb-connectstring
</code>
or
<code class="option">
--config-file
</code>
with
<code class="option">
--configinfo
</code>
serves no purpose.
</p>
<h4>
<a name="idm46045104771232">
</a>
Examples
</h4>
<div class="orderedlist">
<ol class="orderedlist" type="1">
<li class="listitem">
<p>
To obtain the node ID and type of each node in the cluster:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa31057695"><div class="copy-help left">Press ⌘+C to 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_config</span> <span class="token constant">--query</span><span class="token attr-value"><span class="token punctuation">=</span>nodeid,type</span> <span class="token constant">--fields</span>=<span class="token atrule">':'</span> <span class="token constant">--rows</span>=<span class="token atrule">'\n'</span>
1<span class="token punctuation">:</span>ndbd
2<span class="token punctuation">:</span>ndbd
3<span class="token punctuation">:</span>ndbd
4<span class="token punctuation">:</span>ndbd
5<span class="token punctuation">:</span>ndb_mgmd
6<span class="token punctuation">:</span>mysqld
7<span class="token punctuation">:</span>mysqld
8<span class="token punctuation">:</span>mysqld
9<span class="token punctuation">:</span>mysqld</code></pre>
</div>
<p>
In this example, we used the
<a class="link" href="mysql-cluster-programs-ndb-config.html#option_ndb_config_fields">
<code class="option">
--fields
</code>
</a>
options to
separate the ID and type of each node with a colon character
(
<code class="literal">
:
</code>
), and the
<a class="link" href="mysql-cluster-programs-ndb-config.html#option_ndb_config_rows">
<code class="option">
--rows
</code>
</a>
options to place
the values for each node on a new line in the output.
</p>
</li>
<li class="listitem">
<p>
To produce a connection string that can be used by data,
SQL, and API nodes to connect to the management server:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa41480850"><div class="copy-help left">Press ⌘+C to 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_config</span> <span class="token constant">--config-file</span><span class="token attr-value"><span class="token punctuation">=</span>usr/local/mysql/cluster-data/config.ini</span> \
<span class="token constant">--query</span><span class="token attr-value"><span class="token punctuation">=</span>hostname,portnumber</span> <span class="token constant">--fields</span><span class="token attr-value"><span class="token punctuation">=</span>:</span> <span class="token constant">--rows</span><span class="token attr-value"><span class="token punctuation">=</span>,</span> <span class="token constant">--type</span><span class="token attr-value"><span class="token punctuation">=</span>ndb_mgmd</span>
198<span class="token punctuation">.</span>51<span class="token punctuation">.</span>100<span class="token punctuation">.</span>179<span class="token punctuation">:</span>1186</code></pre>
</div>
</li>
<li class="listitem">
<p>
This invocation of
<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>
checks only
data nodes (using the
<a class="link" href="mysql-cluster-programs-ndb-config.html#option_ndb_config_type">
<code class="option">
--type
</code>
</a>
option), and shows
the values for each node's ID and host name, as well as
the values set for its
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-datamemory">
<code class="literal">
DataMemory
</code>
</a>
and
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-datadir">
<code class="literal">
DataDir
</code>
</a>
parameters:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa78342557"><div class="copy-help left">Press ⌘+C to 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_config</span> <span class="token constant">--type</span><span class="token attr-value"><span class="token punctuation">=</span>ndbd</span> <span class="token constant">--query</span><span class="token attr-value"><span class="token punctuation">=</span>nodeid,host,datamemory,datadir</span> <span class="token property">-f</span> <span class="token atrule">' : '</span> <span class="token property">-r</span> <span class="token atrule">'\n'</span>
1 <span class="token punctuation">:</span> 198<span class="token punctuation">.</span>51<span class="token punctuation">.</span>100<span class="token punctuation">.</span>193 <span class="token punctuation">:</span> 83886080 <span class="token punctuation">:</span> /usr/local/mysql/cluster-data
2 <span class="token punctuation">:</span> 198<span class="token punctuation">.</span>51<span class="token punctuation">.</span>100<span class="token punctuation">.</span>112 <span class="token punctuation">:</span> 83886080 <span class="token punctuation">:</span> /usr/local/mysql/cluster-data
3 <span class="token punctuation">:</span> 198<span class="token punctuation">.</span>51<span class="token punctuation">.</span>100<span class="token punctuation">.</span>176 <span class="token punctuation">:</span> 83886080 <span class="token punctuation">:</span> /usr/local/mysql/cluster-data
4 <span class="token punctuation">:</span> 198<span class="token punctuation">.</span>51<span class="token punctuation">.</span>100<span class="token punctuation">.</span>119 <span class="token punctuation">:</span> 83886080 <span class="token punctuation">:</span> /usr/local/mysql/cluster-data</code></pre>
</div>
<p>
In this example, we used the short options
<code class="option">
-f
</code>
and
<code class="option">
-r
</code>
for setting the
field delimiter and row separator, respectively, as well as
the short option
<code class="option">
-q
</code>
to pass a list of
parameters to be obtained.
</p>
</li>
<li class="listitem">
<p>
To exclude results from any host except one in particular,
use the
<a class="link" href="mysql-cluster-programs-ndb-config.html#option_ndb_config_host">
<code class="option">
--host
</code>
</a>
option:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa59793535"><div class="copy-help left">Press ⌘+C to 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_config</span> <span class="token constant">--host</span><span class="token attr-value"><span class="token punctuation">=</span>198.51.100.176</span> <span class="token property">-f</span> <span class="token punctuation">:</span> <span class="token property">-r</span> <span class="token atrule">'\n'</span> <span class="token property">-q</span> id<span class="token punctuation">,</span>type
3<span class="token punctuation">:</span>ndbd
5<span class="token punctuation">:</span>ndb_mgmd</code></pre>
</div>
<p>
In this example, we also used the short form
<code class="option">
-q
</code>
to determine the attributes to be
queried.
</p>
<p>
Similarly, you can limit results to a node with a specific
ID using the
<a class="link" href="mysql-cluster-programs-ndb-config.html#option_ndb_config_nodeid">
<code class="option">
--nodeid
</code>
</a>
option.
</p>
</li>
</ol>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/performance-schema-thread-filtering.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="performance-schema-thread-filtering">
</a>
29.4.6 Pre-Filtering by Thread
</h3>
</div>
</div>
</div>
<p>
The
<a class="link" href="performance-schema-threads-table.html" title="29.12.22.8 The threads Table">
<code class="literal">
threads
</code>
</a>
table contains a row
for each server thread. Each row contains information about a
thread and indicates whether monitoring is enabled for it. For
the Performance Schema to monitor a thread, these things must be
true:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
The
<code class="literal">
thread_instrumentation
</code>
consumer 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 must
be
<code class="literal">
YES
</code>
.
</p>
</li>
<li class="listitem">
<p>
The
<code class="literal">
threads.INSTRUMENTED
</code>
column must be
<code class="literal">
YES
</code>
.
</p>
</li>
<li class="listitem">
<p>
Monitoring occurs only for those thread events produced from
instruments that are enabled 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>
</li>
</ul>
</div>
<p>
The
<a class="link" href="performance-schema-threads-table.html" title="29.12.22.8 The threads Table">
<code class="literal">
threads
</code>
</a>
table also indicates
for each server thread whether to perform historical event
logging. This includes wait, stage, statement, and transaction
events and affects logging to these tables:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-none"><div class="docs-select-all right" id="sa1634873"><div class="copy-help left">Press ⌘+C to 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">events_waits_history
events_waits_history_long
events_stages_history
events_stages_history_long
events_statements_history
events_statements_history_long
events_transactions_history
events_transactions_history_long</code></pre>
</div>
<p>
For historical event logging to occur, these things must be
true:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
The appropriate history-related consumers 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 must be
enabled. For example, wait event logging in the
<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>
and
<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>
tables requires the corresponding
<code class="literal">
events_waits_history
</code>
and
<code class="literal">
events_waits_history_long
</code>
consumers to be
<code class="literal">
YES
</code>
.
</p>
</li>
<li class="listitem">
<p>
The
<code class="literal">
threads.HISTORY
</code>
column must be
<code class="literal">
YES
</code>
.
</p>
</li>
<li class="listitem">
<p>
Logging occurs only for those thread events produced from
instruments that are enabled 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>
</li>
</ul>
</div>
<p>
For foreground threads (resulting from client connections), the
initial values of the
<code class="literal">
INSTRUMENTED
</code>
and
<code class="literal">
HISTORY
</code>
columns in
<a class="link" href="performance-schema-threads-table.html" title="29.12.22.8 The threads Table">
<code class="literal">
threads
</code>
</a>
table rows are determined
by whether the user account associated with a thread matches any
row in the
<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>
table. The
values come from the
<code class="literal">
ENABLED
</code>
and
<code class="literal">
HISTORY
</code>
columns of the matching
<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>
table row.
</p>
<p>
For background threads, there is no associated user.
<code class="literal">
INSTRUMENTED
</code>
and
<code class="literal">
HISTORY
</code>
are
<code class="literal">
YES
</code>
by default and
<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>
is not consulted.
</p>
<p>
The initial
<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>
contents
look like this:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa50900419"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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_actors<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> HOST <span class="token punctuation">|</span> USER <span class="token punctuation">|</span> ROLE <span class="token punctuation">|</span> ENABLED <span class="token punctuation">|</span> HISTORY <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> % <span class="token punctuation">|</span> % <span class="token punctuation">|</span> % <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></code></pre>
</div>
<p>
The
<code class="literal">
HOST
</code>
and
<code class="literal">
USER
</code>
columns
should contain a literal host or user name, or
<code class="literal">
'%'
</code>
to match any name.
</p>
<p>
The
<code class="literal">
ENABLED
</code>
and
<code class="literal">
HISTORY
</code>
columns indicate whether to enable instrumentation and
historical event logging for matching threads, subject to the
other conditions described previously.
</p>
<p>
When the Performance Schema checks for a match for each new
foreground thread in
<code class="literal">
setup_actors
</code>
, it tries
to find more specific matches first, using the
<code class="literal">
USER
</code>
and
<code class="literal">
HOST
</code>
columns
(
<code class="literal">
ROLE
</code>
is unused):
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Rows with
<code class="literal">
USER='
<em class="replaceable">
<code>
literal
</code>
</em>
'
</code>
and
<code class="literal">
HOST='
<em class="replaceable">
<code>
literal
</code>
</em>
'
</code>
.
</p>
</li>
<li class="listitem">
<p>
Rows with
<code class="literal">
USER='
<em class="replaceable">
<code>
literal
</code>
</em>
'
</code>
and
<code class="literal">
HOST='%'
</code>
.
</p>
</li>
<li class="listitem">
<p>
Rows with
<code class="literal">
USER='%'
</code>
and
<code class="literal">
HOST='
<em class="replaceable">
<code>
literal
</code>
</em>
'
</code>
.
</p>
</li>
<li class="listitem">
<p>
Rows with
<code class="literal">
USER='%'
</code>
and
<code class="literal">
HOST='%'
</code>
.
</p>
</li>
</ul>
</div>
<p>
The order in which matching occurs matters because different
matching
<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>
rows can have
different
<code class="literal">
USER
</code>
and
<code class="literal">
HOST
</code>
values. This enables instrumenting and historical event logging
to be applied selectively per host, user, or account (user and
host combination), based on the
<code class="literal">
ENABLED
</code>
and
<code class="literal">
HISTORY
</code>
column values:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
When the best match is a row with
<code class="literal">
ENABLED=YES
</code>
, the
<code class="literal">
INSTRUMENTED
</code>
value for the thread becomes
<code class="literal">
YES
</code>
. When the best match is a row with
<code class="literal">
HISTORY=YES
</code>
, the
<code class="literal">
HISTORY
</code>
value for the thread becomes
<code class="literal">
YES
</code>
.
</p>
</li>
<li class="listitem">
<p>
When the best match is a row with
<code class="literal">
ENABLED=NO
</code>
, the
<code class="literal">
INSTRUMENTED
</code>
value for the thread becomes
<code class="literal">
NO
</code>
. When the best match is a row with
<code class="literal">
HISTORY=NO
</code>
, the
<code class="literal">
HISTORY
</code>
value for the thread becomes
<code class="literal">
NO
</code>
.
</p>
</li>
<li class="listitem">
<p>
When no match is found, the
<code class="literal">
INSTRUMENTED
</code>
and
<code class="literal">
HISTORY
</code>
values for the thread become
<code class="literal">
NO
</code>
.
</p>
</li>
</ul>
</div>
<p>
The
<code class="literal">
ENABLED
</code>
and
<code class="literal">
HISTORY
</code>
columns in
<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>
rows can be
set to
<code class="literal">
YES
</code>
or
<code class="literal">
NO
</code>
independent of one another. This means you can enable
instrumentation separately from whether you collect historical
events.
</p>
<p>
By default, monitoring and historical event collection are
enabled for all new foreground threads because the
<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>
table initially
contains a row with
<code class="literal">
'%'
</code>
for both
<code class="literal">
HOST
</code>
and
<code class="literal">
USER
</code>
. To perform
more limited matching such as to enable monitoring only for some
foreground threads, you must change this row because it matches
any connection, and add rows for more specific
<code class="literal">
HOST
</code>
/
<code class="literal">
USER
</code>
combinations.
</p>
<p>
Suppose that you modify
<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>
as follows:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa33745681"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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_actors
<span class="token keyword">SET</span> ENABLED <span class="token operator">=</span> <span class="token string">'NO'</span><span class="token punctuation">,</span> <span class="token keyword">HISTORY</span> <span class="token operator">=</span> <span class="token string">'NO'</span>
<span class="token keyword">WHERE</span> <span class="token keyword">HOST</span> <span class="token operator">=</span> <span class="token string">'%'</span> <span class="token operator">AND</span> <span class="token keyword">USER</span> <span class="token operator">=</span> <span class="token string">'%'</span><span class="token punctuation">;</span>
<span class="token keyword">INSERT</span> <span class="token keyword">INTO</span> performance_schema<span class="token punctuation">.</span>setup_actors
<span class="token punctuation">(</span><span class="token keyword">HOST</span><span class="token punctuation">,</span><span class="token keyword">USER</span><span class="token punctuation">,</span><span class="token keyword">ROLE</span><span class="token punctuation">,</span>ENABLED<span class="token punctuation">,</span><span class="token keyword">HISTORY</span><span class="token punctuation">)</span>
<span class="token keyword">VALUES</span><span class="token punctuation">(</span><span class="token string">'localhost'</span><span class="token punctuation">,</span><span class="token string">'joe'</span><span class="token punctuation">,</span><span class="token string">'%'</span><span class="token punctuation">,</span><span class="token string">'YES'</span><span class="token punctuation">,</span><span class="token string">'YES'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">INSERT</span> <span class="token keyword">INTO</span> performance_schema<span class="token punctuation">.</span>setup_actors
<span class="token punctuation">(</span><span class="token keyword">HOST</span><span class="token punctuation">,</span><span class="token keyword">USER</span><span class="token punctuation">,</span><span class="token keyword">ROLE</span><span class="token punctuation">,</span>ENABLED<span class="token punctuation">,</span><span class="token keyword">HISTORY</span><span class="token punctuation">)</span>
<span class="token keyword">VALUES</span><span class="token punctuation">(</span><span class="token string">'hosta.example.com'</span><span class="token punctuation">,</span><span class="token string">'joe'</span><span class="token punctuation">,</span><span class="token string">'%'</span><span class="token punctuation">,</span><span class="token string">'YES'</span><span class="token punctuation">,</span><span class="token string">'NO'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">INSERT</span> <span class="token keyword">INTO</span> performance_schema<span class="token punctuation">.</span>setup_actors
<span class="token punctuation">(</span><span class="token keyword">HOST</span><span class="token punctuation">,</span><span class="token keyword">USER</span><span class="token punctuation">,</span><span class="token keyword">ROLE</span><span class="token punctuation">,</span>ENABLED<span class="token punctuation">,</span><span class="token keyword">HISTORY</span><span class="token punctuation">)</span>
<span class="token keyword">VALUES</span><span class="token punctuation">(</span><span class="token string">'%'</span><span class="token punctuation">,</span><span class="token string">'sam'</span><span class="token punctuation">,</span><span class="token string">'%'</span><span class="token punctuation">,</span><span class="token string">'NO'</span><span class="token punctuation">,</span><span class="token string">'YES'</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
The
<a class="link" href="update.html" title="15.2.17 UPDATE Statement">
<code class="literal">
UPDATE
</code>
</a>
statement changes the
default match to disable instrumentation and historical event
collection. The
<a class="link" href="insert.html" title="15.2.7 INSERT Statement">
<code class="literal">
INSERT
</code>
</a>
statements
add rows for more specific matches.
</p>
<p>
Now the Performance Schema determines how to set the
<code class="literal">
INSTRUMENTED
</code>
and
<code class="literal">
HISTORY
</code>
values for new connection threads as follows:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
If
<code class="literal">
joe
</code>
connects from the local host, the
connection matches the first inserted row. The
<code class="literal">
INSTRUMENTED
</code>
and
<code class="literal">
HISTORY
</code>
values for the thread become
<code class="literal">
YES
</code>
.
</p>
</li>
<li class="listitem">
<p>
If
<code class="literal">
joe
</code>
connects from
<code class="literal">
hosta.example.com
</code>
, the connection matches
the second inserted row. The
<code class="literal">
INSTRUMENTED
</code>
value for the thread becomes
<code class="literal">
YES
</code>
and the
<code class="literal">
HISTORY
</code>
value becomes
<code class="literal">
NO
</code>
.
</p>
</li>
<li class="listitem">
<p>
If
<code class="literal">
joe
</code>
connects from any other host,
there is no match. The
<code class="literal">
INSTRUMENTED
</code>
and
<code class="literal">
HISTORY
</code>
values for the thread become
<code class="literal">
NO
</code>
.
</p>
</li>
<li class="listitem">
<p>
If
<code class="literal">
sam
</code>
connects from any host, the
connection matches the third inserted row. The
<code class="literal">
INSTRUMENTED
</code>
value for the thread becomes
<code class="literal">
NO
</code>
and the
<code class="literal">
HISTORY
</code>
value becomes
<code class="literal">
YES
</code>
.
</p>
</li>
<li class="listitem">
<p>
For any other connection, the row with
<code class="literal">
HOST
</code>
and
<code class="literal">
USER
</code>
set to
<code class="literal">
'%'
</code>
matches. This row now has
<code class="literal">
ENABLED
</code>
and
<code class="literal">
HISTORY
</code>
set to
<code class="literal">
NO
</code>
, so the
<code class="literal">
INSTRUMENTED
</code>
and
<code class="literal">
HISTORY
</code>
values for the thread become
<code class="literal">
NO
</code>
.
</p>
</li>
</ul>
</div>
<p>
Modifications to the
<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>
table affect only foreground threads created subsequent to the
modification, not existing threads. To affect existing threads,
modify the
<code class="literal">
INSTRUMENTED
</code>
and
<code class="literal">
HISTORY
</code>
columns of
<a class="link" href="performance-schema-threads-table.html" title="29.12.22.8 The threads Table">
<code class="literal">
threads
</code>
</a>
table rows.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/binary-log.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="binary-log">
</a>
7.4.4 The Binary Log
</h3>
</div>
</div>
</div>
<div class="toc">
<dl class="toc">
<dt>
<span class="section">
<a href="binary-log-formats.html">
7.4.4.1 Binary Logging Formats
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="binary-log-setting.html">
7.4.4.2 Setting The Binary Log Format
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="binary-log-mixed.html">
7.4.4.3 Mixed Binary Logging Format
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="binary-log-mysql-database.html">
7.4.4.4 Logging Format for Changes to mysql Database Tables
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="binary-log-transaction-compression.html">
7.4.4.5 Binary Log Transaction Compression
</a>
</span>
</dt>
</dl>
</div>
<a class="indexterm" name="idm46045258354432">
</a>
<a class="indexterm" name="idm46045258353360">
</a>
<p>
The binary log contains
<span class="quote">
“
<span class="quote">
events
</span>
”
</span>
that describe
database changes such as table creation operations or changes to
table data. It also contains events for statements that
potentially could have made changes (for example, a
<a class="link" href="delete.html" title="15.2.2 DELETE Statement">
<code class="literal">
DELETE
</code>
</a>
which matched no rows),
unless row-based logging is used. The binary log also contains
information about how long each statement took that updated data.
The binary log has two important purposes:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
For replication, the binary log on a replication source server
provides a record of the data changes to be sent to replicas.
The source sends the information contained in its binary log
to its replicas, which reproduce those transactions to make
the same data changes that were made on the source. See
<a class="xref" href="replication-implementation.html" title="19.2 Replication Implementation">
Section 19.2, “Replication Implementation”
</a>
.
</p>
</li>
<li class="listitem">
<p>
Certain data recovery operations require use of the binary
log. After a backup has been restored, the events in the
binary log that were recorded after the backup was made are
re-executed. These events bring databases up to date from the
point of the backup. See
<a class="xref" href="point-in-time-recovery.html" title="9.5 Point-in-Time (Incremental) Recovery">
Section 9.5, “Point-in-Time (Incremental) Recovery”
</a>
.
</p>
</li>
</ul>
</div>
<p>
The binary log is not used for 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="show.html" title="15.7.7 SHOW Statements">
<code class="literal">
SHOW
</code>
</a>
that do not modify data. To
log all statements (for example, to identify a problem query), use
the general query log. 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>
.
</p>
<p>
Running a server with binary logging enabled makes performance
slightly slower. However, the benefits of the binary log in
enabling you to set up replication and for restore operations
generally outweigh this minor performance decrement.
</p>
<p>
The binary log is resilient to unexpected halts. Only complete
events or transactions are logged or read back.
</p>
<p>
Passwords in statements written to the binary log are rewritten by
the server not to occur literally in plain text. See also
<a class="xref" href="password-logging.html" title="8.1.2.3 Passwords and Logging">
Section 8.1.2.3, “Passwords and Logging”
</a>
.
</p>
<p>
MySQL binary log files and relay log files can be encrypted,
helping to protect these files and the potentially sensitive data
contained in them from being misused by outside attackers, and
also from unauthorized viewing by users of the operating system
where they are stored. You enable encryption on a MySQL server by
setting the
<a class="link" href="replication-options-binary-log.html#sysvar_binlog_encryption">
<code class="literal">
binlog_encryption
</code>
</a>
system variable to
<code class="literal">
ON
</code>
. For more information,
see
<a class="xref" href="replication-binlog-encryption.html" title="19.3.2 Encrypting Binary Log Files and Relay Log Files">
Section 19.3.2, “Encrypting Binary Log Files and Relay Log Files”
</a>
.
</p>
<p>
The following discussion describes some of the server options and
variables that affect the operation of binary logging. For a
complete list, see
<a class="xref" href="replication-options-binary-log.html" title="19.1.6.4 Binary Logging Options and Variables">
Section 19.1.6.4, “Binary Logging Options and Variables”
</a>
.
</p>
<p>
Binary logging is enabled by default (the
<a class="link" href="replication-options-binary-log.html#sysvar_log_bin">
<code class="literal">
log_bin
</code>
</a>
system variable is set to
ON). The exception is if you use
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
to
initialize the data directory manually by invoking it with the
<a class="link" href="server-options.html#option_mysqld_initialize">
<code class="option">
--initialize
</code>
</a>
or
<a class="link" href="server-options.html#option_mysqld_initialize-insecure">
<code class="option">
--initialize-insecure
</code>
</a>
option, when
binary logging is disabled by default, but can be enabled by
specifying the
<a class="link" href="replication-options-binary-log.html#option_mysqld_log-bin">
<code class="option">
--log-bin
</code>
</a>
option.
</p>
<p>
To disable binary logging, you can specify the
<a class="link" href="replication-options-binary-log.html#option_mysqld_log-bin">
<code class="option">
--skip-log-bin
</code>
</a>
or
<a class="link" href="replication-options-binary-log.html#option_mysqld_log-bin">
<code class="option">
--disable-log-bin
</code>
</a>
option at startup. If either of these options is specified and
<a class="link" href="replication-options-binary-log.html#option_mysqld_log-bin">
<code class="option">
--log-bin
</code>
</a>
is also specified, the
option specified later takes precedence.
</p>
<p>
The
<a class="link" href="replication-options-binary-log.html#sysvar_log_replica_updates">
<code class="option">
--log-replica-updates
</code>
</a>
and
<a class="link" href="replication-options-replica.html#sysvar_replica_preserve_commit_order">
<code class="option">
--replica-preserve-commit-order
</code>
</a>
options require binary logging. If you disable binary logging,
either omit these options, or specify
<code class="option">
--log-replica-updates=OFF
</code>
and
<code class="option">
--skip-replica-preserve-commit-order
</code>
. MySQL
disables these options by default when
<a class="link" href="replication-options-binary-log.html#option_mysqld_log-bin">
<code class="option">
--skip-log-bin
</code>
</a>
or
<a class="link" href="replication-options-binary-log.html#option_mysqld_log-bin">
<code class="option">
--disable-log-bin
</code>
</a>
is specified. If you specify
<code class="option">
--log-replica-updates
</code>
or
<a class="link" href="replication-options-replica.html#sysvar_replica_preserve_commit_order">
<code class="option">
--replica-preserve-commit-order
</code>
</a>
together with
<a class="link" href="replication-options-binary-log.html#option_mysqld_log-bin">
<code class="option">
--skip-log-bin
</code>
</a>
or
<a class="link" href="replication-options-binary-log.html#option_mysqld_log-bin">
<code class="option">
--disable-log-bin
</code>
</a>
,
a warning or error message is issued.
</p>
<p>
The
<a class="link" href="replication-options-binary-log.html#option_mysqld_log-bin">
<code class="option">
--log-bin[=
<em class="replaceable">
<code>
base_name
</code>
</em>
]
</code>
</a>
option is used to specify the base name for binary log files. If
you do not supply the
<code class="option">
--log-bin
</code>
option, MySQL
uses
<code class="filename">
binlog
</code>
as the default base name for the
binary log files. For compatibility with earlier releases, if you
supply the
<code class="option">
--log-bin
</code>
option with no string or
with an empty string, the base name defaults to
<code class="filename">
<em class="replaceable">
<code>
host_name
</code>
</em>
-bin
</code>
,
using the name of the host machine. It is recommended that you
specify a base name, so that if the host name changes, you can
easily continue to use the same binary log file names (see
<a class="xref" href="known-issues.html" title="B.3.7 Known Issues in MySQL">
Section B.3.7, “Known Issues in MySQL”
</a>
). If you supply an extension in the
log name (for example,
<a class="link" href="replication-options-binary-log.html#option_mysqld_log-bin">
<code class="option">
--log-bin=
<em class="replaceable">
<code>
base_name.extension
</code>
</em>
</code>
</a>
),
the extension is silently removed and ignored.
</p>
<p>
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
appends a numeric extension to the
binary log base name to generate binary log file names. The number
increases each time the server creates a new log file, thus
creating an ordered series of files. The server creates a new file
in the series each time any of the following events occurs:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
The server is started or restarted
</p>
</li>
<li class="listitem">
<p>
The server flushes the logs.
</p>
</li>
<li class="listitem">
<p>
The size of the current log file reaches
<a class="link" href="replication-options-binary-log.html#sysvar_max_binlog_size">
<code class="literal">
max_binlog_size
</code>
</a>
.
</p>
</li>
</ul>
</div>
<p>
A binary log file may become larger than
<a class="link" href="replication-options-binary-log.html#sysvar_max_binlog_size">
<code class="literal">
max_binlog_size
</code>
</a>
if you are using
large transactions because a transaction is written to the file in
one piece, never split between files.
</p>
<p>
To keep track of which binary log files have been used,
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
also creates a binary log index file
that contains the names of the binary log files. By default, this
has the same base name as the binary log file, with the extension
<code class="literal">
'.index'
</code>
. You can change the name of the binary
log index file with the
<a class="link" href="replication-options-binary-log.html#option_mysqld_log-bin-index">
<code class="option">
--log-bin-index[=
<em class="replaceable">
<code>
file_name
</code>
</em>
]
</code>
</a>
option. You should not manually edit this file while
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
is running; doing so would confuse
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
.
</p>
<p>
The term
<span class="quote">
“
<span class="quote">
binary log file
</span>
”
</span>
generally denotes an
individual numbered file containing database events. The term
<span class="quote">
“
<span class="quote">
binary log
</span>
”
</span>
collectively denotes the set of numbered
binary log files plus the index file.
</p>
<p>
The default location for binary log files and the binary log index
file is the data directory. You can use the
<a class="link" href="replication-options-binary-log.html#option_mysqld_log-bin">
<code class="option">
--log-bin
</code>
</a>
option to specify an
alternative location, by adding a leading absolute path name to
the base name to specify a different directory. When the server
reads an entry from the binary log index file, which tracks the
binary log files that have been used, it checks whether the entry
contains a relative path. If it does, the relative part of the
path is replaced with the absolute path set using the
<a class="link" href="replication-options-binary-log.html#option_mysqld_log-bin">
<code class="option">
--log-bin
</code>
</a>
option. An absolute path
recorded in the binary log index file remains unchanged; in such a
case, the index file must be edited manually to enable a new path
or paths to be used. The binary log file base name and any
specified path are available as the
<a class="link" href="replication-options-binary-log.html#sysvar_log_bin_basename">
<code class="literal">
log_bin_basename
</code>
</a>
system variable.
</p>
<p>
The server can be started with the default server ID when binary
logging is enabled, but an informational message is issued if you
do not specify a server ID explicitly using the
<a class="link" href="replication-options.html#sysvar_server_id">
<code class="literal">
server_id
</code>
</a>
system variable. For
servers that are used in a replication topology, you must specify
a unique nonzero server ID for each server.
</p>
<p>
A client that has privileges sufficient to set restricted session
system variables (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>
) can disable binary
logging of its own statements by using a
<a class="link" href="set-sql-log-bin.html" title="15.4.1.3 SET sql_log_bin Statement">
<code class="literal">
SET
sql_log_bin=OFF
</code>
</a>
statement.
</p>
<p>
By default, the server logs the length of the event as well as the
event itself and uses this to verify that the event was written
correctly. You can also cause the server to write checksums for
the events by setting the
<a class="link" href="replication-options-binary-log.html#sysvar_binlog_checksum">
<code class="literal">
binlog_checksum
</code>
</a>
system variable.
When reading back from the binary log, the source uses the event
length by default, but can be made to use checksums if available
by enabling
<a class="link" href="replication-options-binary-log.html#sysvar_source_verify_checksum">
<code class="literal">
source_verify_checksum
</code>
</a>
. The
replication I/O (receiver) thread on the replica also verifies
events received from the source. You can cause the replication SQL
(applier) thread to use checksums if available when reading from
the relay log by enabling
<a class="link" href="replication-options-replica.html#sysvar_replica_sql_verify_checksum">
<code class="literal">
replica_sql_verify_checksum
</code>
</a>
.
</p>
<p>
The format of the events recorded in the binary log is dependent
on the binary logging format. Three format types are supported:
row-based logging, statement-based logging and mixed-base logging.
The binary logging format used depends on the MySQL version. For
descriptions of the logging formats, see
<a class="xref" href="binary-log-formats.html" title="7.4.4.1 Binary Logging Formats">
Section 7.4.4.1, “Binary Logging Formats”
</a>
.
</p>
<p>
The server evaluates the
<a class="link" href="replication-options-binary-log.html#option_mysqld_binlog-do-db">
<code class="option">
--binlog-do-db
</code>
</a>
and
<a class="link" href="replication-options-binary-log.html#option_mysqld_binlog-ignore-db">
<code class="option">
--binlog-ignore-db
</code>
</a>
options in the
same way as it does the
<a class="link" href="replication-options-replica.html#option_mysqld_replicate-do-db">
<code class="option">
--replicate-do-db
</code>
</a>
and
<a class="link" href="replication-options-replica.html#option_mysqld_replicate-ignore-db">
<code class="option">
--replicate-ignore-db
</code>
</a>
options. For
information about how this is done, see
<a class="xref" href="replication-rules-db-options.html" title="19.2.5.1 Evaluation of Database-Level Replication and Binary Logging Options">
Section 19.2.5.1, “Evaluation of Database-Level Replication and Binary Logging Options”
</a>
.
</p>
<p>
A replica is started with
<a class="link" href="replication-options-binary-log.html#sysvar_log_replica_updates">
<code class="literal">
log_replica_updates
</code>
</a>
enabled by
default, meaning that the replica writes to its own binary log any
data modifications that are received from the source. The binary
log must be enabled for this setting to work (see
<a class="xref" href="replication-options-replica.html" title="19.1.6.3 Replica Server Options and Variables">
Section 19.1.6.3, “Replica Server Options and Variables”
</a>
). This setting
enables the replica to act as a source to other replicas.
</p>
<p>
You can delete all binary log files with the
<a class="link" href="reset-binary-logs-and-gtids.html" title="15.4.1.2 RESET BINARY LOGS AND GTIDS Statement">
<code class="literal">
RESET BINARY LOGS AND GTIDS
</code>
</a>
statement, or a subset of them with
<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>
. See
<a class="xref" href="reset.html" title="15.7.8.6 RESET Statement">
Section 15.7.8.6, “RESET Statement”
</a>
, and
<a class="xref" href="purge-binary-logs.html" title="15.4.1.1 PURGE BINARY LOGS Statement">
Section 15.4.1.1, “PURGE BINARY LOGS Statement”
</a>
.
</p>
<p>
If you are using MySQL Replication, you should not delete old
binary log files on the source until you are sure that no replica
still needs to use them. For example, if your replicas never run
more than three days behind, once a day you can execute
<a class="link" href="mysqladmin.html" title="6.5.2 mysqladmin — A MySQL Server Administration Program">
<span class="command">
<strong>
mysqladmin flush-logs binary
</strong>
</span>
</a>
on the source and
then remove any logs that are more than three days old. You can
remove the files manually, but it is preferable to use
<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>
, which also
safely updates the binary log index file for you (and which can
take a date argument). See
<a class="xref" href="purge-binary-logs.html" title="15.4.1.1 PURGE BINARY LOGS Statement">
Section 15.4.1.1, “PURGE BINARY LOGS Statement”
</a>
.
</p>
<p>
You can display the contents of binary log files with the
<a class="link" href="mysqlbinlog.html" title="6.6.9 mysqlbinlog — Utility for Processing Binary Log Files">
<span class="command">
<strong>
mysqlbinlog
</strong>
</span>
</a>
utility. This can be useful when
you want to reprocess statements in the log for a recovery
operation. For example, you can update a MySQL server from the
binary log as follows:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa23452066"><div class="copy-help left">Press ⌘+C to 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">mysqlbinlog</span> <em class="replaceable">log_file</em> | mysql <span class="token property">-h</span> <em class="replaceable">server_name</em></code></pre>
</div>
<p>
<a class="link" href="mysqlbinlog.html" title="6.6.9 mysqlbinlog — Utility for Processing Binary Log Files">
<span class="command">
<strong>
mysqlbinlog
</strong>
</span>
</a>
also can be used to display the
contents of the relay log file on a replica, because they are
written using the same format as binary log files. For more
information on the
<a class="link" href="mysqlbinlog.html" title="6.6.9 mysqlbinlog — Utility for Processing Binary Log Files">
<span class="command">
<strong>
mysqlbinlog
</strong>
</span>
</a>
utility and how
to use it, see
<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>
. For more information
about the binary log and recovery operations, see
<a class="xref" href="point-in-time-recovery.html" title="9.5 Point-in-Time (Incremental) Recovery">
Section 9.5, “Point-in-Time (Incremental) Recovery”
</a>
.
</p>
<p>
Binary logging is done immediately after a statement or
transaction completes but before any locks are released or any
commit is done. This ensures that the log is logged in commit
order.
</p>
<p>
Updates to nontransactional tables are stored in the binary log
immediately after execution.
</p>
<p>
Within an uncommitted transaction, all updates
(
<a class="link" href="update.html" title="15.2.17 UPDATE Statement">
<code class="literal">
UPDATE
</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="insert.html" title="15.2.7 INSERT Statement">
<code class="literal">
INSERT
</code>
</a>
) that change transactional
tables such as
<code class="literal">
InnoDB
</code>
tables are cached until a
<a class="link" href="commit.html" title="15.3.1 START TRANSACTION, COMMIT, and ROLLBACK Statements">
<code class="literal">
COMMIT
</code>
</a>
statement is received by the
server. At that point,
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
writes the entire
transaction to the binary log before the
<a class="link" href="commit.html" title="15.3.1 START TRANSACTION, COMMIT, and ROLLBACK Statements">
<code class="literal">
COMMIT
</code>
</a>
is executed.
</p>
<p>
Modifications to nontransactional tables cannot be rolled back. If
a transaction that is rolled back includes modifications to
nontransactional tables, the entire transaction is logged with a
<a class="link" href="commit.html" title="15.3.1 START TRANSACTION, COMMIT, and ROLLBACK Statements">
<code class="literal">
ROLLBACK
</code>
</a>
statement at the end to ensure that the modifications to those
tables are replicated.
</p>
<p>
When a thread that handles the transaction starts, it allocates a
buffer of
<a class="link" href="replication-options-binary-log.html#sysvar_binlog_cache_size">
<code class="literal">
binlog_cache_size
</code>
</a>
to
buffer statements. If a statement is bigger than this, the thread
opens a temporary file to store the transaction. The temporary
file is deleted when the thread ends. If binary log encryption is
active on the server, the temporary file is encrypted.
</p>
<p>
The
<a class="link" href="server-status-variables.html#statvar_Binlog_cache_use">
<code class="literal">
Binlog_cache_use
</code>
</a>
status
variable shows the number of transactions that used this buffer
(and possibly a temporary file) for storing statements. The
<a class="link" href="server-status-variables.html#statvar_Binlog_cache_disk_use">
<code class="literal">
Binlog_cache_disk_use
</code>
</a>
status
variable shows how many of those transactions actually had to use
a temporary file. These two variables can be used for tuning
<a class="link" href="replication-options-binary-log.html#sysvar_binlog_cache_size">
<code class="literal">
binlog_cache_size
</code>
</a>
to a large
enough value that avoids the use of temporary files.
</p>
<p>
The
<a class="link" href="replication-options-binary-log.html#sysvar_max_binlog_cache_size">
<code class="literal">
max_binlog_cache_size
</code>
</a>
system
variable (default 4GB, which is also the maximum) can be used to
restrict the total size used to cache a multiple-statement
transaction. If a transaction is larger than this many bytes, it
fails and rolls back. The minimum value is 4096.
</p>
<p>
If you are using the binary log and row based logging, concurrent
inserts are converted to normal inserts for
<code class="literal">
CREATE ...
SELECT
</code>
or
<a class="link" href="insert-select.html" title="15.2.7.1 INSERT ... SELECT Statement">
<code class="literal">
INSERT ...
SELECT
</code>
</a>
statements. This is done to ensure that you can
re-create an exact copy of your tables by applying the log during
a backup operation. If you are using statement-based logging, the
original statement is written to the log.
</p>
<p>
The binary log format has some known limitations that can affect
recovery from backups. See
<a class="xref" href="replication-features.html" title="19.5.1 Replication Features and Issues">
Section 19.5.1, “Replication Features and Issues”
</a>
.
</p>
<p>
Binary logging for stored programs is done as described in
<a class="xref" href="stored-programs-logging.html" title="27.7 Stored Program Binary Logging">
Section 27.7, “Stored Program Binary Logging”
</a>
.
</p>
<p>
Note that the binary log format differs in MySQL 8.4
from previous versions of MySQL, due to enhancements in
replication. See
<a class="xref" href="replication-compatibility.html" title="19.5.2 Replication Compatibility Between MySQL Versions">
Section 19.5.2, “Replication Compatibility Between MySQL Versions”
</a>
.
</p>
<p>
If the server is unable to write to the binary log, flush binary
log files, or synchronize the binary log to disk, the binary log
on the replication source server can become inconsistent and
replicas can lose synchronization with the source. The
<a class="link" href="replication-options-binary-log.html#sysvar_binlog_error_action">
<code class="literal">
binlog_error_action
</code>
</a>
system
variable controls the action taken if an error of this type is
encountered with the binary log.
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
The default setting,
<code class="literal">
ABORT_SERVER
</code>
, makes
the server halt binary logging and shut down. At this point,
you can identify and correct the cause of the error. On
restart, recovery proceeds as in the case of an unexpected
server halt (see
<a class="xref" href="replication-solutions-unexpected-replica-halt.html" title="19.4.2 Handling an Unexpected Halt of a Replica">
Section 19.4.2, “Handling an Unexpected Halt of a Replica”
</a>
).
</p>
</li>
<li class="listitem">
<p>
The setting
<code class="literal">
IGNORE_ERROR
</code>
provides backward
compatibility with older versions of MySQL. With this setting,
the server continues the ongoing transaction and logs the
error, then halts binary logging, but continues to perform
updates. At this point, you can identify and correct the cause
of the error. To resume binary logging,
<a class="link" href="replication-options-binary-log.html#sysvar_log_bin">
<code class="literal">
log_bin
</code>
</a>
must be enabled
again, which requires a server restart. Only use this option
if you require backward compatibility, and the binary log is
non-essential on this MySQL server instance. For example, you
might use the binary log only for intermittent auditing or
debugging of the server, and not use it for replication from
the server or rely on it for point-in-time restore operations.
</p>
</li>
</ul>
</div>
<p>
By default, the binary log is synchronized to disk at each write
(
<a class="link" href="replication-options-binary-log.html#sysvar_sync_binlog">
<code class="literal">
sync_binlog=1
</code>
</a>
). If
<a class="link" href="replication-options-binary-log.html#sysvar_sync_binlog">
<code class="literal">
sync_binlog
</code>
</a>
was not enabled, and
the operating system or machine (not only the MySQL server)
crashed, there is a chance that the last statements of the binary
log could be lost. To prevent this, enable the
<a class="link" href="replication-options-binary-log.html#sysvar_sync_binlog">
<code class="literal">
sync_binlog
</code>
</a>
system variable to
synchronize the binary log to disk after every
<em class="replaceable">
<code>
N
</code>
</em>
commit groups. See
<a class="xref" href="server-system-variables.html" title="7.1.8 Server System Variables">
Section 7.1.8, “Server System Variables”
</a>
. The safest value for
<a class="link" href="replication-options-binary-log.html#sysvar_sync_binlog">
<code class="literal">
sync_binlog
</code>
</a>
is 1 (the default),
but this is also the slowest.
</p>
<p>
In earlier MySQL releases, there was a chance of inconsistency
between the table content and binary log content if a crash
occurred, even with
<a class="link" href="replication-options-binary-log.html#sysvar_sync_binlog">
<code class="literal">
sync_binlog
</code>
</a>
set to 1. For example, if you are using
<code class="literal">
InnoDB
</code>
tables and the MySQL server processes a
<a class="link" href="commit.html" title="15.3.1 START TRANSACTION, COMMIT, and ROLLBACK Statements">
<code class="literal">
COMMIT
</code>
</a>
statement, it writes many
prepared transactions to the binary log in sequence, synchronizes
the binary log, and then commits the transaction into
<code class="literal">
InnoDB
</code>
. If the server unexpectedly exited
between those two operations, the transaction would be rolled back
by
<code class="literal">
InnoDB
</code>
at restart but still exist in the
binary log. Such an issue was resolved in previous releases by
enabling
<code class="literal">
InnoDB
</code>
support for two-phase commit in
XA transactions. In MySQL 8.4,
<code class="literal">
InnoDB
</code>
support for two-phase commit in XA
transactions is always enabled.
</p>
<p>
<code class="literal">
InnoDB
</code>
support for two-phase commit in XA
transactions ensures that the binary log and
<code class="literal">
InnoDB
</code>
data files are synchronized. However,
the MySQL server should also be configured to synchronize the
binary log and the
<code class="literal">
InnoDB
</code>
logs to disk before
committing the transaction. The
<code class="literal">
InnoDB
</code>
logs are
synchronized by default, and
<code class="literal">
sync_binlog=1
</code>
ensures the binary log is synchronized. The effect of implicit
<code class="literal">
InnoDB
</code>
support for two-phase commit in XA
transactions and
<code class="literal">
sync_binlog=1
</code>
is that at
restart after a crash, after doing a rollback of transactions, the
MySQL server scans the latest binary log file to collect
transaction
<em class="replaceable">
<code>
xid
</code>
</em>
values and calculate
the last valid position in the binary log file. The MySQL server
then tells
<code class="literal">
InnoDB
</code>
to complete any prepared
transactions that were successfully written to the to the binary
log, and truncates the binary log to the last valid position. This
ensures that the binary log reflects the exact data of
<code class="literal">
InnoDB
</code>
tables, and therefore the replica
remains in synchrony with the source because it does not receive a
statement which has been rolled back.
</p>
<p>
If the MySQL server discovers at crash recovery that the binary
log is shorter than it should have been, it lacks at least one
successfully committed
<code class="literal">
InnoDB
</code>
transaction. This
should not happen if
<code class="literal">
sync_binlog=1
</code>
and the
disk/file system do an actual sync when they are requested to
(some do not), so the server prints an error message
<code class="literal">
The
binary log
<em class="replaceable">
<code>
file_name
</code>
</em>
is shorter than
its expected size
</code>
. In this case, this binary log is not
correct and replication should be restarted from a fresh snapshot
of the source's data.
</p>
<p>
The session values of the following system variables are written
to the binary log and honored by the replica when parsing the
binary log:
</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_sql_mode">
<code class="literal">
sql_mode
</code>
</a>
(except that the
<a class="link" href="sql-mode.html#sqlmode_no_dir_in_create">
<code class="literal">
NO_DIR_IN_CREATE
</code>
</a>
mode is not
replicated; see
<a class="xref" href="replication-features-variables.html" title="19.5.1.39 Replication and Variables">
Section 19.5.1.39, “Replication and Variables”
</a>
)
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="server-system-variables.html#sysvar_foreign_key_checks">
<code class="literal">
foreign_key_checks
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="server-system-variables.html#sysvar_unique_checks">
<code class="literal">
unique_checks
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="server-system-variables.html#sysvar_character_set_client">
<code class="literal">
character_set_client
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="server-system-variables.html#sysvar_collation_connection">
<code class="literal">
collation_connection
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="server-system-variables.html#sysvar_collation_database">
<code class="literal">
collation_database
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="server-system-variables.html#sysvar_collation_server">
<code class="literal">
collation_server
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="server-system-variables.html#sysvar_sql_auto_is_null">
<code class="literal">
sql_auto_is_null
</code>
</a>
</p>
</li>
</ul>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/connecting-using-uri-or-key-value-pairs.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="connecting-using-uri-or-key-value-pairs">
</a>
6.2.5 Connecting to the Server Using URI-Like Strings or Key-Value Pairs
</h3>
</div>
</div>
</div>
<a class="indexterm" name="idm46045322678576">
</a>
<a class="indexterm" name="idm46045322677120">
</a>
<p>
This section describes use of URI-like connection strings or
key-value pairs to specify how to establish connections to the
MySQL server, for clients such as MySQL Shell. For information on
establishing connections using command-line options, for 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>
or
<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="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>
. For additional information if
you are unable to connect, see
<a class="xref" href="problems-connecting.html" title="8.2.22 Troubleshooting Problems Connecting to MySQL">
Section 8.2.22, “Troubleshooting Problems Connecting to MySQL”
</a>
.
</p>
<a class="indexterm" name="idm46045322671072">
</a>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
The term
<span class="quote">
“
<span class="quote">
URI-like
</span>
”
</span>
signifies connection-string
syntax that is similar to but not identical to the URI (uniform
resource identifier) syntax defined by
<a class="ulink" href="https://tools.ietf.org/html/rfc3986" target="_blank">
RFC
3986
</a>
.
</p>
</div>
<p>
The following MySQL clients support connecting to a MySQL server
using a URI-like connection string or key-value pairs:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
MySQL Shell
</p>
</li>
<li class="listitem">
<p>
MySQL Connectors which implement X DevAPI
</p>
</li>
</ul>
</div>
<p>
This section documents all valid URI-like string and key-value
pair connection parameters, many of which are similar to those
specified with command-line options:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Parameters specified with a URI-like string use a syntax such
as
<code class="literal">
[email protected]:3306/main-schema
</code>
. For
the full syntax, see
<a class="xref" href="connecting-using-uri-or-key-value-pairs.html#connecting-using-uri" title="Connecting Using URI-Like Connection Strings">
Connecting Using URI-Like Connection Strings
</a>
.
</p>
</li>
<li class="listitem">
<p>
Parameters specified with key-value pairs use a syntax such as
<code class="literal">
{user:'myuser', host:'example.com', port:3306,
schema:'main-schema'}
</code>
. For the full syntax, see
<a class="xref" href="connecting-using-uri-or-key-value-pairs.html#connecting-using-key-value-pairs" title="Connecting Using Key-Value Pairs">
Connecting Using Key-Value Pairs
</a>
.
</p>
</li>
</ul>
</div>
<p>
Connection parameters are not case-sensitive. Each parameter, if
specified, can be given only once. If a parameter is specified
more than once, an error occurs.
</p>
<p>
This section covers the following topics:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="xref" href="connecting-using-uri-or-key-value-pairs.html#connection-parameters-base" title="Base Connection Parameters">
Base Connection Parameters
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="connecting-using-uri-or-key-value-pairs.html#connection-parameters-additional" title="Additional Connection parameters">
Additional Connection parameters
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="connecting-using-uri-or-key-value-pairs.html#connecting-using-uri" title="Connecting Using URI-Like Connection Strings">
Connecting Using URI-Like Connection Strings
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="connecting-using-uri-or-key-value-pairs.html#connecting-using-key-value-pairs" title="Connecting Using Key-Value Pairs">
Connecting Using Key-Value Pairs
</a>
</p>
</li>
</ul>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h4 class="title">
<a name="connection-parameters-base">
</a>
Base Connection Parameters
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045322652800">
</a>
<p>
The following discussion describes the parameters available when
specifying a connection to MySQL. These parameters can be
provided using either a string that conforms to the base
URI-like syntax (see
<a class="xref" href="connecting-using-uri-or-key-value-pairs.html#connecting-using-uri" title="Connecting Using URI-Like Connection Strings">
Connecting Using URI-Like Connection Strings
</a>
), or
as key-value pairs (see
<a class="xref" href="connecting-using-uri-or-key-value-pairs.html#connecting-using-key-value-pairs" title="Connecting Using Key-Value Pairs">
Connecting Using Key-Value Pairs
</a>
).
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<em class="replaceable">
<code>
scheme
</code>
</em>
: The transport protocol to
use. Use
<code class="literal">
mysqlx
</code>
for X Protocol
connections and
<code class="literal">
mysql
</code>
for
classic MySQL protocol connections. If no protocol is specified,
the server attempts to guess the protocol. Connectors that
support DNS SRV can use the
<code class="literal">
mysqlx+srv
</code>
scheme (see
<a class="ulink" href="/doc/x-devapi-userguide/en/connecting-dns-srv.html" target="_top">
Connections Using DNS SRV Records
</a>
).
</p>
</li>
<li class="listitem">
<p>
<em class="replaceable">
<code>
user
</code>
</em>
: The MySQL user account to
provide for the authentication process.
</p>
</li>
<li class="listitem">
<p>
<em class="replaceable">
<code>
password
</code>
</em>
: The password to use for
the authentication process.
</p>
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Warning
</div>
<p>
Specifying an explicit password in the connection
specification is insecure and not recommended. Later
discussion shows how to cause an interactive prompt for
the password to occur.
</p>
</div>
</li>
<li class="listitem">
<p>
<em class="replaceable">
<code>
host
</code>
</em>
: The host on which the
server instance is running. The value can be a host name,
IPv4 address, or IPv6 address. If no host is specified, the
default is
<code class="literal">
localhost
</code>
.
</p>
</li>
<li class="listitem">
<p>
<em class="replaceable">
<code>
port
</code>
</em>
: The TCP/IP network port on
which the target MySQL server is listening for connections.
If no port is specified, the default is 33060 for
X Protocol connections and 3306 for classic MySQL protocol
connections.
</p>
</li>
<li class="listitem">
<p>
<em class="replaceable">
<code>
socket
</code>
</em>
: The path to a Unix socket
file or the name of a Windows named pipe. Values are local
file paths. In URI-like strings, they must be encoded, using
either percent encoding or by surrounding the path with
parentheses. Parentheses eliminate the need to percent
encode characters such as the
<code class="literal">
/
</code>
directory
separator character. For example, to connect as
<code class="literal">
root@localhost
</code>
using the Unix socket
<code class="filename">
/tmp/mysql.sock
</code>
, specify the path using
percent encoding as
<code class="literal">
root@localhost?socket=%2Ftmp%2Fmysql.sock
</code>
,
or using parentheses as
<code class="literal">
root@localhost?socket=(/tmp/mysql.sock)
</code>
.
</p>
</li>
<li class="listitem">
<p>
<em class="replaceable">
<code>
schema
</code>
</em>
: The default database for
the connection. If no database is specified, the connection
has no default database.
</p>
</li>
</ul>
</div>
<p>
The handling of
<code class="literal">
localhost
</code>
on Unix depends on
the type of transport protocol. Connections using
classic MySQL protocol handle
<code class="literal">
localhost
</code>
the same
way as other MySQL clients, which means that
<code class="literal">
localhost
</code>
is assumed to be for socket-based
connections. For connections using X Protocol, the behavior of
<code class="literal">
localhost
</code>
differs in that it is assumed to
represent the loopback address, for example, IPv4 address
127.0.0.1.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h4 class="title">
<a name="connection-parameters-additional">
</a>
Additional Connection parameters
</h4>
</div>
</div>
</div>
<p>
You can specify options for the connection, either as attributes
in a URI-like string by appending
<code class="literal">
?
<em class="replaceable">
<code>
attribute=value
</code>
</em>
</code>
,
or as key-value pairs. The following options are available:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
ssl-mode
</code>
: The desired security state for
the connection. The following modes are permissible:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
<code class="literal">
DISABLED
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
PREFERRED
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
REQUIRED
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
VERIFY_CA
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
VERIFY_IDENTITY
</code>
</p>
</li>
</ul>
</div>
<div class="important" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Important
</div>
<p>
<code class="literal">
VERIFY_CA
</code>
and
<code class="literal">
VERIFY_IDENTITY
</code>
are better choices than
the default
<code class="literal">
PREFERRED
</code>
, because they
help prevent man-in-the-middle attacks.
</p>
</div>
<p>
For information about these modes, see the
<a class="link" href="connection-options.html#option_general_ssl-mode">
<code class="option">
--ssl-mode
</code>
</a>
option
description in
<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>
<code class="literal">
ssl-ca
</code>
: The path to the X.509 certificate
authority file in PEM format.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ssl-capath
</code>
: The path to the directory
that contains the X.509 certificates authority files in PEM
format.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ssl-cert
</code>
: The path to the X.509
certificate file in PEM format.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ssl-cipher
</code>
: The encryption cipher to use
for connections that use TLS protocols up through TLSv1.2.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ssl-crl
</code>
: The path to the file that
contains certificate revocation lists in PEM format.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ssl-crlpath
</code>
: The path to the directory
that contains certificate revocation-list files in PEM
format.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ssl-key
</code>
: The path to the X.509 key file
in PEM format.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
tls-version
</code>
: The TLS protocols permitted
for classic MySQL protocol encrypted connections. This option is
supported by MySQL Shell only. The value of
<code class="literal">
tls-version
</code>
(singular) is a comma
separated list, for example
<code class="literal">
TLSv1.2,TLSv1.3
</code>
. 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>
.
This option depends on the
<code class="literal">
ssl-mode
</code>
option not being set to
<code class="literal">
DISABLED
</code>
.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
tls-versions
</code>
: The permissible TLS
protocols for encrypted X Protocol connections. The value
of
<code class="literal">
tls-versions
</code>
(plural) is an array such
as
<code class="literal">
[TLSv1.2,TLSv1.3]
</code>
. 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>
.
This option depends on the
<code class="literal">
ssl-mode
</code>
option not being set to
<code class="literal">
DISABLED
</code>
.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
tls-ciphersuites
</code>
: The permitted TLS
cipher suites. The value of
<code class="literal">
tls-ciphersuites
</code>
is a list of IANA cipher
suite names as listed at
<a class="ulink" href="https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml#tls-parameters-4" target="_blank">
TLS
Ciphersuites
</a>
. 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>
.
This option depends on the
<code class="literal">
ssl-mode
</code>
option not being set to
<code class="literal">
DISABLED
</code>
.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
auth-method
</code>
: The authentication method to
use for the connection. The default is
<code class="literal">
AUTO
</code>
, meaning that the server attempts to
guess. The following methods are permissible:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
<code class="literal">
AUTO
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MYSQL41
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SHA256_MEMORY
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
FROM_CAPABILITIES
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
FALLBACK
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
PLAIN
</code>
</p>
</li>
</ul>
</div>
<p>
For X Protocol connections, any configured
<code class="literal">
auth-method
</code>
is overridden to this
sequence of authentication methods:
<code class="literal">
MYSQL41
</code>
,
<code class="literal">
SHA256_MEMORY
</code>
,
<code class="literal">
PLAIN
</code>
.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
get-server-public-key
</code>
: Request from the
server the public key required for RSA key pair-based
password exchange. Use when connecting to MySQL 8+ servers
over classic MySQL protocol with SSL mode
<code class="literal">
DISABLED
</code>
. You must specify the protocol
in this case. For example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-simple"><div class="docs-select-all right" id="sa88335432"><div class="copy-help left">Press ⌘+C to 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">mysql<span class="token operator">:</span><span class="token operator">/</span><span class="token operator">/</span>user@localhost<span class="token operator">:</span>3306<span class="token operator">?</span>get<span class="token operator">-</span>server<span class="token operator">-</span>public<span class="token operator">-</span>key<span class="token operator">=</span>true</code></pre>
</div>
<p>
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
<code class="literal">
server-public-key-path=
<em class="replaceable">
<code>
file_name
</code>
</em>
</code>
is given and specifies a valid public key file, it takes
precedence over
<code class="literal">
get-server-public-key
</code>
.
</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>
<code class="literal">
server-public-key-path
</code>
: 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. Use when connecting to MySQL 8+ servers
over classic MySQL protocol with SSL mode
<code class="literal">
DISABLED
</code>
.
</p>
<p>
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
<code class="literal">
server-public-key-path=
<em class="replaceable">
<code>
file_name
</code>
</em>
</code>
is given and specifies a valid public key file, it takes
precedence over
<code class="literal">
get-server-public-key
</code>
.
</p>
<p>
For information about the
<code class="literal">
sha256_password
</code>
(deprecated) 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>
<code class="literal">
ssh
</code>
: The URI for connection to an SSH
server to access a MySQL server instance using SSH
tunneling. The URI format is
<code class="literal">
[user@]host[:port]
</code>
. Use the
<code class="literal">
uri
</code>
option to specify the URI of the
target MySQL server instance. For information on SSH tunnel
connections from MySQL Shell, see
<a class="ulink" href="/doc/mysql-shell/8.4/en/mysql-shell-connection-ssh.html" target="_top">
Using an SSH Tunnel
</a>
.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
uri
</code>
: The URI for a MySQL server instance
that is to be accessed through an SSH tunnel from the server
specified by the
<code class="literal">
ssh
</code>
option. The URI
format is
<code class="literal">
[scheme://][user@]host[:port]
</code>
.
Do not use the base connection parameters
(
<code class="literal">
scheme
</code>
,
<code class="literal">
user
</code>
,
<code class="literal">
host
</code>
,
<code class="literal">
port
</code>
) to specify
the MySQL server connection for SSH tunneling, just use the
<code class="literal">
uri
</code>
option.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ssh-password
</code>
: The password for the
connection to the SSH server.
</p>
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Warning
</div>
<p>
Specifying an explicit password in the connection
specification is insecure and not recommended.
MySQL Shell prompts for a password interactively when one
is required.
</p>
</div>
</li>
<li class="listitem">
<p>
<code class="literal">
ssh-config-file
</code>
: The SSH configuration
file for the connection to the SSH server. You can use the
MySQL Shell configuration option
<code class="literal">
ssh.configFile
</code>
to set a custom file as
the default if this option is not specified. If
<code class="literal">
ssh.configFile
</code>
has not been set, the
default is the standard SSH configuration file
<code class="literal">
~/.ssh/config
</code>
.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ssh-identity-file
</code>
: The identity file to
use for the connection to the SSH server. The default if
this option is not specified is any identity file configured
in an SSH agent (if used), or in the SSH configuration file,
or the standard private key file in the SSH configuration
folder (
<code class="literal">
~/.ssh/id_rsa
</code>
).
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ssh-identity-pass
</code>
: The passphrase for the
identity file specified by the
<code class="literal">
ssh-identity-file
</code>
option.
</p>
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Warning
</div>
<p>
Specifying an explicit password in the connection
specification is insecure and not recommended.
MySQL Shell prompts for a password interactively when one
is required.
</p>
</div>
</li>
<li class="listitem">
<p>
<code class="literal">
connect-timeout
</code>
: An integer value used to
configure the number of seconds that clients, such as
MySQL Shell, wait until they stop trying to connect to an
unresponsive MySQL server.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
compression
</code>
: This option requests or
disables compression for the connection.
</p>
<p>
The values available for this option are:
<code class="literal">
required
</code>
, which requests compression and
fails if the server does not support it;
<code class="literal">
preferred
</code>
, which requests compression and
falls back to an uncompressed connection; and
<code class="literal">
disabled
</code>
, which requests an uncompressed
connection and fails if the server does not permit those.
<code class="literal">
preferred
</code>
is the default for X Protocol
connections, and
<code class="literal">
disabled
</code>
is the default
for classic MySQL protocol connections. For information on
X Plugin connection compression control, see
<a class="xref" href="x-plugin-connection-compression.html" title="22.5.5 Connection Compression with X Plugin">
Section 22.5.5, “Connection Compression with X Plugin”
</a>
.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
Different MySQL clients implement their support for
connection compression differently. Consult your client's
documentation for details.
</p>
</div>
</li>
<li class="listitem">
<p>
<code class="literal">
compression-algorithms
</code>
and
<code class="literal">
compression-level
</code>
: These options are
available in MySQL Shell for more control over connection
compression. You can specify them to select the compression
algorithm used for the connection, and the numeric
compression level used with that algorithm. You can also use
<code class="literal">
compression-algorithms
</code>
in place of
<code class="literal">
compression
</code>
to request compression for
the connection. For information on MySQL Shell's connection
compression control, see
<a class="ulink" href="/doc/mysql-shell/8.4/en/mysql-shell-compressed-connections.html" target="_top">
Using Compressed Connections
</a>
.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
connection-attributes
</code>
: Controls the
key-value pairs that application programs pass to the server
at connect time. For general information about connection
attributes, 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>
.
Clients usually define a default set of attributes, which
can be disabled or enabled. For example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-simple"><div class="docs-select-all right" id="sa81331129"><div class="copy-help left">Press ⌘+C to 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">mysqlx<span class="token operator">:</span><span class="token operator">/</span><span class="token operator">/</span>user@host<span class="token operator">?</span>connection<span class="token operator">-</span>attributes
mysqlx<span class="token operator">:</span><span class="token operator">/</span><span class="token operator">/</span>user@host<span class="token operator">?</span>connection<span class="token operator">-</span>attributes<span class="token operator">=</span>true
mysqlx<span class="token operator">:</span><span class="token operator">/</span><span class="token operator">/</span>user@host<span class="token operator">?</span>connection<span class="token operator">-</span>attributes<span class="token operator">=</span>false</code></pre>
</div>
<p>
The default behavior is to send the default attribute set.
Applications can specify attributes to be passed in addition
to the default attributes. You specify additional connection
attributes as a
<code class="literal">
connection-attributes
</code>
parameter in a connection string. The
<code class="literal">
connection-attributes
</code>
parameter value
must be empty (the same as specifying
<code class="literal">
true
</code>
), a
<code class="literal">
Boolean
</code>
value
(
<code class="literal">
true
</code>
or
<code class="literal">
false
</code>
to
enable or disable the default attribute set), or a list or
zero or more
<code class="literal">
key=value
</code>
specifiers
separated by commas (to be sent in addition to the default
attribute set). Within a list, a missing key value evaluates
as an empty string. Further examples:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-simple"><div class="docs-select-all right" id="sa18975580"><div class="copy-help left">Press ⌘+C to 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">mysqlx<span class="token operator">:</span><span class="token operator">/</span><span class="token operator">/</span>user@host<span class="token operator">?</span>connection<span class="token operator">-</span>attributes<span class="token operator">=</span><span class="token punctuation">[</span>attr1<span class="token operator">=</span>val1<span class="token punctuation">,</span>attr2<span class="token punctuation">,</span>attr3<span class="token operator">=</span><span class="token punctuation">]</span>
mysqlx<span class="token operator">:</span><span class="token operator">/</span><span class="token operator">/</span>user@host<span class="token operator">?</span>connection<span class="token operator">-</span>attributes<span class="token operator">=</span><span class="token punctuation">[</span><span class="token punctuation">]</span></code></pre>
</div>
<p>
Application-defined attribute names cannot begin with
<code class="literal">
_
</code>
because such names are reserved for
internal attributes.
</p>
</li>
</ul>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h4 class="title">
<a name="connecting-using-uri">
</a>
Connecting Using URI-Like Connection Strings
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045322495968">
</a>
<p>
You can specify a connection to MySQL Server using a URI-like
string. Such strings can be used with the MySQL Shell with the
<a class="ulink" href="/doc/mysql-shell/8.4/en/mysqlsh.html#option_mysqlsh_uri" target="_top">
<code class="option">
--uri
</code>
</a>
command option, the
MySQL Shell
<code class="literal">
\connect
</code>
command, and MySQL
Connectors which implement X DevAPI.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
The term
<span class="quote">
“
<span class="quote">
URI-like
</span>
”
</span>
signifies connection-string
syntax that is similar to but not identical to the URI
(uniform resource identifier) syntax defined by
<a class="ulink" href="https://tools.ietf.org/html/rfc3986" target="_blank">
RFC
3986
</a>
.
</p>
</div>
<p>
A URI-like connection string has the following syntax:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-simple"><div class="docs-select-all right" id="sa43213184"><div class="copy-help left">Press ⌘+C to 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"><span class="token punctuation">[</span><em class="replaceable">scheme</em><span class="token operator">:</span><span class="token operator">/</span><span class="token operator">/</span><span class="token punctuation">]</span><span class="token punctuation">[</span><em class="replaceable">user</em><span class="token punctuation">[</span><span class="token operator">:</span><span class="token punctuation">[</span><em class="replaceable">password</em><span class="token punctuation">]</span><span class="token punctuation">]</span>@<span class="token punctuation">]</span><em class="replaceable">host</em><span class="token punctuation">[</span><span class="token operator">:</span><em class="replaceable">port</em><span class="token punctuation">]</span><span class="token punctuation">[</span><span class="token operator">/</span><em class="replaceable">schema</em><span class="token punctuation">]</span><span class="token punctuation">[</span><span class="token operator">?</span><em class="replaceable">attribute1<span class="token operator">=</span>value1<span class="token operator">&</span>attribute2<span class="token operator">=</span>value2<span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span></em><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>
Percent encoding must be used for reserved characters in the
elements of the URI-like string. For example, if you specify a
string that includes the
<code class="literal">
@
</code>
character, the
character must be replaced by
<code class="literal">
%40
</code>
. If you
include a zone ID in an IPv6 address, the
<code class="literal">
%
</code>
character used as the separator must be replaced with
<code class="literal">
%25
</code>
.
</p>
</div>
<p>
The parameters you can use in a URI-like connection string are
described at
<a class="xref" href="connecting-using-uri-or-key-value-pairs.html#connection-parameters-base" title="Base Connection Parameters">
Base Connection Parameters
</a>
.
</p>
<p>
MySQL Shell's
<code class="literal">
shell.parseUri()
</code>
and
<code class="literal">
shell.unparseUri()
</code>
methods can be used to
deconstruct and assemble a URI-like connection string. Given a
URI-like connection string,
<code class="literal">
shell.parseUri()
</code>
returns a dictionary containing each element found in the
string.
<code class="literal">
shell.unparseUri()
</code>
converts a
dictionary of URI components and connection options into a valid
URI-like connection string for connecting to MySQL, which can be
used in MySQL Shell or by MySQL Connectors which implement
X DevAPI.
</p>
<p>
If no password is specified in the URI-like string, which is
recommended, interactive clients prompt for the password. The
following examples show how to specify URI-like strings with the
user name
<em class="replaceable">
<code>
user_name
</code>
</em>
. In each case,
the password is prompted for.
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
An X Protocol connection to a local server instance
listening at port 33065.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-simple"><div class="docs-select-all right" id="sa2420919"><div class="copy-help left">Press ⌘+C to 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">mysqlx<span class="token operator">:</span><span class="token operator">/</span><span class="token operator">/</span><em class="replaceable">user_name</em>@localhost<span class="token operator">:</span>33065</code></pre>
</div>
</li>
<li class="listitem">
<p>
A classic MySQL protocol connection to a local server instance
listening at port 3333.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-simple"><div class="docs-select-all right" id="sa28795018"><div class="copy-help left">Press ⌘+C to 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">mysql<span class="token operator">:</span><span class="token operator">/</span><span class="token operator">/</span><em class="replaceable">user_name</em>@localhost<span class="token operator">:</span>3333</code></pre>
</div>
</li>
<li class="listitem">
<p>
An X Protocol connection to a remote server instance, using
a host name, an IPv4 address, and an IPv6 address.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-simple"><div class="docs-select-all right" id="sa63382840"><div class="copy-help left">Press ⌘+C to 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">mysqlx<span class="token operator">:</span><span class="token operator">/</span><span class="token operator">/</span><em class="replaceable">user_name</em>@server<span class="token punctuation">.</span>example<span class="token punctuation">.</span>com<span class="token operator">/</span>
mysqlx<span class="token operator">:</span><span class="token operator">/</span><span class="token operator">/</span><em class="replaceable">user_name</em>@198<span class="token punctuation">.</span>51<span class="token punctuation">.</span>100<span class="token punctuation">.</span>14<span class="token operator">:</span>123
mysqlx<span class="token operator">:</span><span class="token operator">/</span><span class="token operator">/</span><em class="replaceable">user_name</em>@<span class="token punctuation">[</span>2001<span class="token operator">:</span>db8<span class="token operator">:</span>85a3<span class="token operator">:</span>8d3<span class="token operator">:</span>1319<span class="token operator">:</span>8a2e<span class="token operator">:</span>370<span class="token operator">:</span>7348<span class="token punctuation">]</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
An X Protocol connection using a socket, with the path
provided using either percent encoding or parentheses.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-simple"><div class="docs-select-all right" id="sa16057668"><div class="copy-help left">Press ⌘+C to 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">mysqlx<span class="token operator">:</span><span class="token operator">/</span><span class="token operator">/</span><em class="replaceable">user_name</em>@<span class="token operator">/</span><em class="replaceable">path</em><span class="token operator">%</span>2F<em class="replaceable">to</em><span class="token operator">%</span>2F<em class="replaceable">socket<span class="token punctuation">.</span>sock</em>
mysqlx<span class="token operator">:</span><span class="token operator">/</span><span class="token operator">/</span><em class="replaceable">user_name</em>@<span class="token punctuation">(</span><span class="token operator"></span><em class="replaceable"><span class="token operator">/</span>path<span class="token operator">/</span>to<span class="token operator">/</span>socket<span class="token punctuation">.</span>sock</em><span class="token punctuation">)</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
An optional path can be specified, which represents a
database.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-simple"><div class="docs-select-all right" id="sa14034423"><div class="copy-help left">Press ⌘+C to 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"><span class="token comment" spellcheck="true"># use 'world' as the default database</span>
mysqlx<span class="token operator">:</span><span class="token operator">/</span><span class="token operator">/</span><em class="replaceable">user_name</em>@198<span class="token punctuation">.</span>51<span class="token punctuation">.</span>100<span class="token punctuation">.</span>1<span class="token operator">/</span>world
<span class="token comment" spellcheck="true"># use 'world_x' as the default database, encoding _ as %5F</span>
mysqlx<span class="token operator">:</span><span class="token operator">/</span><span class="token operator">/</span><em class="replaceable">user_name</em>@198<span class="token punctuation">.</span>51<span class="token punctuation">.</span>100<span class="token punctuation">.</span>2<span class="token operator">:</span>33060<span class="token operator">/</span>world<span class="token operator">%</span>5Fx</code></pre>
</div>
</li>
<li class="listitem">
<p>
An optional query can be specified, consisting of values
each given as a
<code class="literal">
<em class="replaceable">
<code>
key
</code>
</em>
=
<em class="replaceable">
<code>
value
</code>
</em>
</code>
pair or as a single
<em class="replaceable">
<code>
key
</code>
</em>
. To
specify multiple values, separate them by
<code class="literal">
,
</code>
characters. A mix of
<code class="literal">
<em class="replaceable">
<code>
key
</code>
</em>
=
<em class="replaceable">
<code>
value
</code>
</em>
</code>
and
<em class="replaceable">
<code>
key
</code>
</em>
values is permissible.
Values can be of type list, with list values ordered by
appearance. Strings must be either percent encoded or
surrounded by parentheses. The following are equivalent.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-simple"><div class="docs-select-all right" id="sa9097626"><div class="copy-help left">Press ⌘+C to 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">ssluser@127<span class="token punctuation">.</span>0<span class="token punctuation">.</span>0<span class="token punctuation">.</span>1<span class="token operator">?</span>ssl<span class="token operator">-</span>ca<span class="token operator">=</span><span class="token operator">%</span>2Froot<span class="token operator">%</span>2Fclientcert<span class="token operator">%</span>2Fca<span class="token operator">-</span>cert<span class="token punctuation">.</span>pem\
<span class="token operator">&</span>ssl<span class="token operator">-</span>cert<span class="token operator">=</span><span class="token operator">%</span>2Froot<span class="token operator">%</span>2Fclientcert<span class="token operator">%</span>2Fclient<span class="token operator">-</span>cert<span class="token punctuation">.</span>pem\
<span class="token operator">&</span>ssl<span class="token operator">-</span>key<span class="token operator">=</span><span class="token operator">%</span>2Froot<span class="token operator">%</span>2Fclientcert<span class="token operator">%</span>2Fclient<span class="token operator">-</span>key
ssluser@127<span class="token punctuation">.</span>0<span class="token punctuation">.</span>0<span class="token punctuation">.</span>1<span class="token operator">?</span>ssl<span class="token operator">-</span>ca<span class="token operator">=</span><span class="token punctuation">(</span><span class="token operator">/</span>root<span class="token operator">/</span>clientcert<span class="token operator">/</span>ca<span class="token operator">-</span>cert<span class="token punctuation">.</span>pem<span class="token punctuation">)</span>\
<span class="token operator">&</span>ssl<span class="token operator">-</span>cert<span class="token operator">=</span><span class="token punctuation">(</span><span class="token operator">/</span>root<span class="token operator">/</span>clientcert<span class="token operator">/</span>client<span class="token operator">-</span>cert<span class="token punctuation">.</span>pem<span class="token punctuation">)</span>\
<span class="token operator">&</span>ssl<span class="token operator">-</span>key<span class="token operator">=</span><span class="token punctuation">(</span><span class="token operator">/</span>root<span class="token operator">/</span>clientcert<span class="token operator">/</span>client<span class="token operator">-</span>key<span class="token punctuation">)</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
To specify a TLS version and ciphersuite to use for
encrypted connections:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-simple"><div class="docs-select-all right" id="sa18824530"><div class="copy-help left">Press ⌘+C to 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">mysql<span class="token operator">:</span><span class="token operator">/</span><span class="token operator">/</span><em class="replaceable">user_name</em>@198<span class="token punctuation">.</span>51<span class="token punctuation">.</span>100<span class="token punctuation">.</span>2<span class="token operator">:</span>3306<span class="token operator">/</span>world<span class="token operator">%</span>5Fx<span class="token operator">?</span>\
tls<span class="token operator">-</span>versions<span class="token operator">=</span><span class="token punctuation">[</span>TLSv1<span class="token punctuation">.</span>2<span class="token punctuation">,</span>TLSv1<span class="token punctuation">.</span>3<span class="token punctuation">]</span><span class="token operator">&</span>tls<span class="token operator">-</span>ciphersuites<span class="token operator">=</span><span class="token punctuation">[</span>TLS_DHE_PSK_WITH_AES_128_\
GCM_SHA256<span class="token punctuation">,</span> TLS_CHACHA20_POLY1305_SHA256<span class="token punctuation">]</span></code></pre>
</div>
</li>
</ul>
</div>
<p>
The previous examples assume that connections require a
password. With interactive clients, the specified user's
password is requested at the login prompt. If the user account
has no password (which is insecure and not recommended), or if
socket peer-credential authentication is in use (for example,
with Unix socket connections), you must explicitly specify in
the connection string that no password is being provided and the
password prompt is not required. To do this, place a
<code class="literal">
:
</code>
after the
<em class="replaceable">
<code>
user_name
</code>
</em>
in the string but do not
specify a password after it. For example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-simple"><div class="docs-select-all right" id="sa33817309"><div class="copy-help left">Press ⌘+C to 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">mysqlx<span class="token operator">:</span><span class="token operator">/</span><span class="token operator">/</span><em class="replaceable">user_name</em><span class="token operator">:</span>@localhost</code></pre>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h4 class="title">
<a name="connecting-using-key-value-pairs">
</a>
Connecting Using Key-Value Pairs
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045322444848">
</a>
<p>
In MySQL Shell and some MySQL Connectors which implement
X DevAPI, you can specify a connection to MySQL Server using
key-value pairs, supplied in language-natural constructs for the
implementation. For example, you can supply connection
parameters using key-value pairs as a JSON object in JavaScript,
or as a dictionary in Python. Regardless of the way the
key-value pairs are supplied, the concept remains the same: the
keys as described in this section can be assigned values that
are used to specify a connection. You can specify connections
using key-value pairs in MySQL Shell's
<code class="literal">
shell.connect()
</code>
method or InnoDB Cluster's
<code class="literal">
dba.createCluster()
</code>
method, and with some of
the MySQL Connectors which implement X DevAPI.
</p>
<p>
Generally, key-value pairs are surrounded by
<code class="literal">
{
</code>
and
<code class="literal">
}
</code>
characters and the
<code class="literal">
,
</code>
character is used as a separator between
key-value pairs. The
<code class="literal">
:
</code>
character is used
between keys and values, and strings must be delimited (for
example, using the
<code class="literal">
'
</code>
character). It is not
necessary to percent encode strings, unlike URI-like connection
strings.
</p>
<p>
A connection specified as key-value pairs has the following
format:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-simple"><div class="docs-select-all right" id="sa47076036"><div class="copy-help left">Press ⌘+C to 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"><span class="token punctuation">{</span> <em class="replaceable">key</em><span class="token operator">:</span> <em class="replaceable">value</em><span class="token punctuation">,</span> <em class="replaceable">key</em><span class="token operator">:</span> <em class="replaceable">value</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></code></pre>
</div>
<p>
The parameters you can use as keys for a connection are
described at
<a class="xref" href="connecting-using-uri-or-key-value-pairs.html#connection-parameters-base" title="Base Connection Parameters">
Base Connection Parameters
</a>
.
</p>
<p>
If no password is specified in the key-value pairs, which is
recommended, interactive clients prompt for the password. The
following examples show how to specify connections using
key-value pairs with the user name
<code class="literal">
'
<em class="replaceable">
<code>
user_name
</code>
</em>
'
</code>
. In
each case, the password is prompted for.
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
An X Protocol connection to a local server instance
listening at port 33065.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-simple"><div class="docs-select-all right" id="sa57425353"><div class="copy-help left">Press ⌘+C to 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"><span class="token punctuation">{</span>user<span class="token operator">:</span>'<em class="replaceable">user_name</em>'<span class="token punctuation">,</span> host<span class="token operator">:</span>'localhost'<span class="token punctuation">,</span> port<span class="token operator">:</span>33065<span class="token punctuation">}</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
A classic MySQL protocol connection to a local server instance
listening at port 3333.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-simple"><div class="docs-select-all right" id="sa8621848"><div class="copy-help left">Press ⌘+C to 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"><span class="token punctuation">{</span>user<span class="token operator">:</span>'<em class="replaceable">user_name</em>'<span class="token punctuation">,</span> host<span class="token operator">:</span>'localhost'<span class="token punctuation">,</span> port<span class="token operator">:</span>3333<span class="token punctuation">}</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
An X Protocol connection to a remote server instance, using
a host name, an IPv4 address, and an IPv6 address.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-simple"><div class="docs-select-all right" id="sa49865985"><div class="copy-help left">Press ⌘+C to 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"><span class="token punctuation">{</span>user<span class="token operator">:</span>'<em class="replaceable">user_name</em>'<span class="token punctuation">,</span> host<span class="token operator">:</span>'server<span class="token punctuation">.</span>example<span class="token punctuation">.</span>com'<span class="token punctuation">}</span>
<span class="token punctuation">{</span>user<span class="token operator">:</span>'<em class="replaceable">user_name</em>'<span class="token punctuation">,</span> host<span class="token operator">:</span>198<span class="token punctuation">.</span>51<span class="token punctuation">.</span>100<span class="token punctuation">.</span>14<span class="token operator">:</span>123<span class="token punctuation">}</span>
<span class="token punctuation">{</span>user<span class="token operator">:</span>'<em class="replaceable">user_name</em>'<span class="token punctuation">,</span> host<span class="token operator">:</span><span class="token punctuation">[</span>2001<span class="token operator">:</span>db8<span class="token operator">:</span>85a3<span class="token operator">:</span>8d3<span class="token operator">:</span>1319<span class="token operator">:</span>8a2e<span class="token operator">:</span>370<span class="token operator">:</span>7348<span class="token punctuation">]</span><span class="token punctuation">}</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
An X Protocol connection using a socket.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-simple"><div class="docs-select-all right" id="sa43812348"><div class="copy-help left">Press ⌘+C to 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"><span class="token punctuation">{</span>user<span class="token operator">:</span>'<em class="replaceable">user_name</em>'<span class="token punctuation">,</span> socket<span class="token operator">:</span>'<span class="token operator"></span><em class="replaceable"><span class="token operator">/</span>path<span class="token operator">/</span>to<span class="token operator">/</span>socket<span class="token operator">/</span>file</em>'<span class="token punctuation">}</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
An optional schema can be specified, which represents a
database.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-simple"><div class="docs-select-all right" id="sa2510072"><div class="copy-help left">Press ⌘+C to 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"><span class="token punctuation">{</span>user<span class="token operator">:</span>'<em class="replaceable">user_name</em>'<span class="token punctuation">,</span> host<span class="token operator">:</span>'localhost'<span class="token punctuation">,</span> schema<span class="token operator">:</span>'world'<span class="token punctuation">}</span></code></pre>
</div>
</li>
</ul>
</div>
<p>
The previous examples assume that connections require a
password. With interactive clients, the specified user's
password is requested at the login prompt. If the user account
has no password (which is insecure and not recommended), or if
socket peer-credential authentication is in use (for example,
with Unix socket connections), you must explicitly specify that
no password is being provided and the password prompt is not
required. To do this, provide an empty string using
<code class="literal">
''
</code>
after the
<code class="literal">
password
</code>
key.
For example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-simple"><div class="docs-select-all right" id="sa99734671"><div class="copy-help left">Press ⌘+C to 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"><span class="token punctuation">{</span>user<span class="token operator">:</span>'<em class="replaceable">user_name</em>'<span class="token punctuation">,</span> password<span class="token operator">:</span>''<span class="token punctuation">,</span> host<span class="token operator">:</span>'localhost'<span class="token punctuation">}</span></code></pre>
</div>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/cannot-initialize-character-set.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="cannot-initialize-character-set">
</a>
B.3.2.15 Can't initialize character set
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045054210352">
</a>
<p>
You might see an error like this if you have character set
problems:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-none"><div class="docs-select-all right" id="sa48298874"><div class="copy-help left">Press ⌘+C to 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">MySQL Connection Failed: Can't initialize character set <em class="replaceable">charset_name</em></code></pre>
</div>
<p>
This error can have any of the following causes:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
The character set is a multibyte character set and you
have no support for the character set in the client. In
this case, you need to recompile the client by running
<span class="command">
<strong>
CMake
</strong>
</span>
with the
<a class="link" href="source-configuration-options.html#option_cmake_default_charset">
<code class="option">
-DDEFAULT_CHARSET=
<em class="replaceable">
<code>
charset_name
</code>
</em>
</code>
</a>
option. See
<a class="xref" href="source-configuration-options.html" title="2.8.7 MySQL Source-Configuration Options">
Section 2.8.7, “MySQL Source-Configuration Options”
</a>
.
</p>
<p>
All standard MySQL binaries are compiled with support for
all multibyte character sets.
</p>
</li>
<li class="listitem">
<p>
The character set is a simple character set that is not
compiled into
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
, and the character
set definition files are not in the place where the client
expects to find them.
</p>
<p>
In this case, you need to use one of the following methods
to solve the problem:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
Recompile the client with support for the character
set. See
<a class="xref" href="source-configuration-options.html" title="2.8.7 MySQL Source-Configuration Options">
Section 2.8.7, “MySQL Source-Configuration Options”
</a>
.
</p>
</li>
<li class="listitem">
<p>
Specify to the client the directory where the
character set definition files are located. For many
clients, you can do this with the
<code class="option">
--character-sets-dir
</code>
option.
</p>
</li>
<li class="listitem">
<p>
Copy the character definition files to the path where
the client expects them to be.
</p>
</li>
</ul>
</div>
</li>
</ul>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/innodb-backup-recovery.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h2 class="title">
<a name="innodb-backup-recovery">
</a>
17.18 InnoDB Backup and Recovery
</h2>
</div>
</div>
</div>
<div class="toc">
<dl class="toc">
<dt>
<span class="section">
<a href="innodb-backup.html">
17.18.1 InnoDB Backup
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="innodb-recovery.html">
17.18.2 InnoDB Recovery
</a>
</span>
</dt>
</dl>
</div>
<p>
This section covers topics related to
<code class="literal">
InnoDB
</code>
backup and recovery.
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
For information about backup techniques applicable to
<code class="literal">
InnoDB
</code>
, see
<a class="xref" href="innodb-backup.html" title="17.18.1 InnoDB Backup">
Section 17.18.1, “InnoDB Backup”
</a>
.
</p>
</li>
<li class="listitem">
<p>
For information about point-in-time recovery, recovery from disk
failure or corruption, and how
<code class="literal">
InnoDB
</code>
performs crash recovery, see
<a class="xref" href="innodb-recovery.html" title="17.18.2 InnoDB Recovery">
Section 17.18.2, “InnoDB Recovery”
</a>
.
</p>
</li>
</ul>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/replication-howto.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="replication-howto">
</a>
19.1.2 Setting Up Binary Log File Position Based Replication
</h3>
</div>
</div>
</div>
<div class="toc">
<dl class="toc">
<dt>
<span class="section">
<a href="replication-howto-masterbaseconfig.html">
19.1.2.1 Setting the Replication Source Configuration
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="replication-howto-slavebaseconfig.html">
19.1.2.2 Setting the Replica Configuration
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="replication-howto-repuser.html">
19.1.2.3 Creating a User for Replication
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="replication-howto-masterstatus.html">
19.1.2.4 Obtaining the Replication Source Binary Log Coordinates
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="replication-snapshot-method.html">
19.1.2.5 Choosing a Method for Data Snapshots
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="replication-setup-replicas.html">
19.1.2.6 Setting Up Replicas
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="replication-howto-slaveinit.html">
19.1.2.7 Setting the Source Configuration on the Replica
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="replication-howto-additionalslaves.html">
19.1.2.8 Adding Replicas to a Replication Environment
</a>
</span>
</dt>
</dl>
</div>
<p>
This section describes how to set up a MySQL server to use binary
log file position based replication. There are a number of
different methods for setting up replication, and the exact method
to use depends on how you are setting up replication, and whether
you already have data in the database on the source that you want
to replicate.
</p>
<div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Tip
</div>
<p>
To deploy multiple instances of MySQL, you can use
<a class="ulink" href="/doc/mysql-shell/8.4/en/mysql-innodb-cluster.html" target="_top">
InnoDB Cluster
</a>
which enables you to easily administer a group of MySQL server instances in
<a class="ulink" href="/doc/mysql-shell/8.4/en/" target="_top">
MySQL Shell
</a>
. InnoDB Cluster wraps MySQL Group Replication in a programmatic environment that enables you easily deploy a cluster of MySQL instances to achieve high availability. In addition, InnoDB Cluster interfaces seamlessly with
<a class="ulink" href="/doc/mysql-router/8.4/en/" target="_top">
MySQL Router
</a>
, which enables your applications to connect to the cluster without writing your own failover process. For similar use cases that do not require high availability, however, you can use
<a class="ulink" href="/doc/mysql-shell/8.4/en/mysql-innodb-replicaset.html" target="_top">
InnoDB ReplicaSet
</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>
<p>
There are some generic tasks that are common to all setups:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
On the source, you must ensure that binary logging is enabled,
and configure a unique server ID. This might require a server
restart. See
<a class="xref" href="replication-howto-masterbaseconfig.html" title="19.1.2.1 Setting the Replication Source Configuration">
Section 19.1.2.1, “Setting the Replication Source Configuration”
</a>
.
</p>
</li>
<li class="listitem">
<p>
On each replica that you want to connect to the source, you
must configure a unique server ID. This might require a server
restart. See
<a class="xref" href="replication-howto-slavebaseconfig.html" title="19.1.2.2 Setting the Replica Configuration">
Section 19.1.2.2, “Setting the Replica Configuration”
</a>
.
</p>
</li>
<li class="listitem">
<p>
Optionally, create a separate user for your replicas to use
during authentication with the source when reading the binary
log for replication. See
<a class="xref" href="replication-howto-repuser.html" title="19.1.2.3 Creating a User for Replication">
Section 19.1.2.3, “Creating a User for Replication”
</a>
.
</p>
</li>
<li class="listitem">
<p>
Before creating a data snapshot or starting the replication
process, on the source you should record the current position
in the binary log. You need this information when configuring
the replica so that the replica knows where within the binary
log to start executing events. See
<a class="xref" href="replication-howto-masterstatus.html" title="19.1.2.4 Obtaining the Replication Source Binary Log Coordinates">
Section 19.1.2.4, “Obtaining the Replication Source Binary Log Coordinates”
</a>
.
</p>
</li>
<li class="listitem">
<p>
If you already have data on the source and want to use it to
synchronize the replica, you need to create a data snapshot to
copy the data to the replica. The storage engine you are using
has an impact on how you create the snapshot. When you are
using
<a class="link" href="myisam-storage-engine.html" title="18.2 The MyISAM Storage Engine">
<code class="literal">
MyISAM
</code>
</a>
, you must stop
processing statements on the source to obtain a read-lock,
then obtain its current binary log coordinates and dump its
data, before permitting the source to continue executing
statements. If you do not stop the execution of statements,
the data dump and the source status information become
mismatched, resulting in inconsistent or corrupted databases
on the replicas. For more information on replicating a
<a class="link" href="myisam-storage-engine.html" title="18.2 The MyISAM Storage Engine">
<code class="literal">
MyISAM
</code>
</a>
source, see
<a class="xref" href="replication-howto-masterstatus.html" title="19.1.2.4 Obtaining the Replication Source Binary Log Coordinates">
Section 19.1.2.4, “Obtaining the Replication Source Binary Log Coordinates”
</a>
. If you are
using
<a class="link" href="innodb-storage-engine.html" title="Chapter 17 The InnoDB Storage Engine">
<code class="literal">
InnoDB
</code>
</a>
, you do not need a
read-lock and a transaction that is long enough to transfer
the data snapshot is sufficient. For more information, see
<a class="xref" href="innodb-and-mysql-replication.html" title="17.19 InnoDB and MySQL Replication">
Section 17.19, “InnoDB and MySQL Replication”
</a>
.
</p>
</li>
<li class="listitem">
<p>
Configure the replica with settings for connecting to the
source, such as the host name, login credentials, and binary
log file name and position. See
<a class="xref" href="replication-howto-slaveinit.html" title="19.1.2.7 Setting the Source Configuration on the Replica">
Section 19.1.2.7, “Setting the Source Configuration on the Replica”
</a>
.
</p>
</li>
<li class="listitem">
<p>
Implement replication-specific security measures on the
sources and replicas as appropriate for your system. See
<a class="xref" href="replication-security.html" title="19.3 Replication Security">
Section 19.3, “Replication Security”
</a>
.
</p>
</li>
</ul>
</div>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
Certain steps within the setup process require the
<a class="link" href="privileges-provided.html#priv_super">
<code class="literal">
SUPER
</code>
</a>
privilege. If you do not
have this privilege, it might not be possible to enable
replication.
</p>
</div>
<p>
After configuring the basic options, select your scenario:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
To set up replication for a fresh installation of a source and
replicas that contain no data, see
<a class="xref" href="replication-setup-replicas.html#replication-howto-newservers" title="19.1.2.6.1 Setting Up Replication with New Source and Replicas">
Section 19.1.2.6.1, “Setting Up Replication with New Source and Replicas”
</a>
.
</p>
</li>
<li class="listitem">
<p>
To set up replication of a new source using the data from an
existing MySQL server, see
<a class="xref" href="replication-setup-replicas.html#replication-howto-existingdata" title="19.1.2.6.2 Setting Up Replication with Existing Data">
Section 19.1.2.6.2, “Setting Up Replication with Existing Data”
</a>
.
</p>
</li>
<li class="listitem">
<p>
To add replicas to an existing replication environment, see
<a class="xref" href="replication-howto-additionalslaves.html" title="19.1.2.8 Adding Replicas to a Replication Environment">
Section 19.1.2.8, “Adding Replicas to a Replication Environment”
</a>
.
</p>
</li>
</ul>
</div>
<p>
Before administering MySQL replication servers, read this entire
chapter and try all statements mentioned in
<a class="xref" href="replication-statements-source.html" title="15.4.1 SQL Statements for Controlling Source Servers">
Section 15.4.1, “SQL Statements for Controlling Source Servers”
</a>
, and
<a class="xref" href="replication-statements-replica.html" title="15.4.2 SQL Statements for Controlling Replica Servers">
Section 15.4.2, “SQL Statements for Controlling Replica Servers”
</a>
. Also familiarize
yourself with the replication startup options described in
<a class="xref" href="replication-options.html" title="19.1.6 Replication and Binary Logging Options and Variables">
Section 19.1.6, “Replication and Binary Logging Options and Variables”
</a>
.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/change-replication-source-to.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="change-replication-source-to">
</a>
15.4.2.2 CHANGE REPLICATION SOURCE TO Statement
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045177656384">
</a>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa91303097"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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">SOURCE</span> <span class="token keyword">TO</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> <em class="replaceable">channel_option</em> <span class="token punctuation">]</span>
<span class="token keyword"><em class="replaceable">option</em></span>: {
<span class="token keyword">SOURCE_BIND</span> <span class="token operator">=</span> <span class="token string">'<em class="replaceable">interface_name</em>'</span>
<span class="token operator">|</span> <span class="token keyword">SOURCE_HOST</span> <span class="token operator">=</span> <span class="token string">'<em class="replaceable">host_name</em>'</span>
<span class="token operator">|</span> <span class="token keyword">SOURCE_USER</span> <span class="token operator">=</span> <span class="token string">'<em class="replaceable">user_name</em>'</span>
<span class="token operator">|</span> <span class="token keyword">SOURCE_PASSWORD</span> <span class="token operator">=</span> <span class="token string">'<em class="replaceable">password</em>'</span>
<span class="token operator">|</span> <span class="token keyword">SOURCE_PORT</span> <span class="token operator">=</span> <em class="replaceable">port_num</em>
<span class="token operator">|</span> <span class="token keyword">PRIVILEGE_CHECKS_USER</span> <span class="token operator">=</span> {<span class="token boolean">NULL</span> <span class="token operator">|</span> <span class="token string">'<em class="replaceable">account</em>'</span>}
<span class="token operator">|</span> <span class="token keyword">REQUIRE_ROW_FORMAT</span> <span class="token operator">=</span> {<span class="token number">0</span><span class="token operator">|</span><span class="token number">1</span>}
<span class="token operator">|</span> <span class="token keyword">REQUIRE_TABLE_PRIMARY_KEY_CHECK</span> <span class="token operator">=</span> {<span class="token keyword">STREAM</span> <span class="token operator">|</span> <span class="token keyword">ON</span> <span class="token operator">|</span> <span class="token keyword">OFF</span> <span class="token operator">|</span> GENERATE}
<span class="token operator">|</span> <span class="token keyword">ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS</span> <span class="token operator">=</span> {<span class="token keyword">OFF</span> <span class="token operator">|</span> <span class="token keyword">LOCAL</span> <span class="token operator">|</span> <em class="replaceable">uuid</em>}
<span class="token operator">|</span> <span class="token keyword">SOURCE_LOG_FILE</span> <span class="token operator">=</span> <span class="token string">'<em class="replaceable">source_log_name</em>'</span>
<span class="token operator">|</span> <span class="token keyword">SOURCE_LOG_POS</span> <span class="token operator">=</span> <span class="token keyword"><em class="replaceable">source_log_pos</em></span>
<span class="token operator">|</span> <span class="token keyword">SOURCE_AUTO_POSITION</span> <span class="token operator">=</span> {<span class="token number">0</span><span class="token operator">|</span><span class="token number">1</span>}
<span class="token operator">|</span> <span class="token keyword">RELAY_LOG_FILE</span> <span class="token operator">=</span> <span class="token string">'<em class="replaceable">relay_log_name</em>'</span>
<span class="token operator">|</span> <span class="token keyword">RELAY_LOG_POS</span> <span class="token operator">=</span> <span class="token keyword"><em class="replaceable">relay_log_pos</em></span>
<span class="token operator">|</span> <span class="token keyword">SOURCE_HEARTBEAT_PERIOD</span> <span class="token operator">=</span> <span class="token keyword"><em class="replaceable">interval</em></span>
<span class="token operator">|</span> <span class="token keyword">SOURCE_CONNECT_RETRY</span> <span class="token operator">=</span> <span class="token keyword"><em class="replaceable">interval</em></span>
<span class="token operator">|</span> <span class="token keyword">SOURCE_RETRY_COUNT</span> <span class="token operator">=</span> <em class="replaceable">count</em>
<span class="token operator">|</span> <span class="token keyword">SOURCE_CONNECTION_AUTO_FAILOVER</span> <span class="token operator">=</span> {<span class="token number">0</span><span class="token operator">|</span><span class="token number">1</span>}
<span class="token operator">|</span> <span class="token keyword">SOURCE_DELAY</span> <span class="token operator">=</span> <span class="token keyword"><em class="replaceable">interval</em></span>
<span class="token operator">|</span> <span class="token keyword">SOURCE_COMPRESSION_ALGORITHMS</span> <span class="token operator">=</span> <span class="token string">'<em class="replaceable">algorithm</em>[,<em class="replaceable">algorithm</em>][,<em class="replaceable">algorithm</em>]'</span>
<span class="token operator">|</span> <span class="token keyword">SOURCE_ZSTD_COMPRESSION_LEVEL</span> <span class="token operator">=</span> <span class="token keyword"><em class="replaceable">level</em></span>
<span class="token operator">|</span> <span class="token keyword">SOURCE_SSL</span> <span class="token operator">=</span> {<span class="token number">0</span><span class="token operator">|</span><span class="token number">1</span>}
<span class="token operator">|</span> <span class="token keyword">SOURCE_SSL_CA</span> <span class="token operator">=</span> <span class="token string">'<em class="replaceable">ca_file_name</em>'</span>
<span class="token operator">|</span> <span class="token keyword">SOURCE_SSL_CAPATH</span> <span class="token operator">=</span> <span class="token string">'<em class="replaceable">ca_directory_name</em>'</span>
<span class="token operator">|</span> <span class="token keyword">SOURCE_SSL_CERT</span> <span class="token operator">=</span> <span class="token string">'<em class="replaceable">cert_file_name</em>'</span>
<span class="token operator">|</span> <span class="token keyword">SOURCE_SSL_CRL</span> <span class="token operator">=</span> <span class="token string">'<em class="replaceable">crl_file_name</em>'</span>
<span class="token operator">|</span> <span class="token keyword">SOURCE_SSL_CRLPATH</span> <span class="token operator">=</span> <span class="token string">'<em class="replaceable">crl_directory_name</em>'</span>
<span class="token operator">|</span> <span class="token keyword">SOURCE_SSL_KEY</span> <span class="token operator">=</span> <span class="token string">'<em class="replaceable">key_file_name</em>'</span>
<span class="token operator">|</span> <span class="token keyword">SOURCE_SSL_CIPHER</span> <span class="token operator">=</span> <span class="token string">'<em class="replaceable">cipher_list</em>'</span>
<span class="token operator">|</span> <span class="token keyword">SOURCE_SSL_VERIFY_SERVER_CERT</span> <span class="token operator">=</span> {<span class="token number">0</span><span class="token operator">|</span><span class="token number">1</span>}
<span class="token operator">|</span> <span class="token keyword">SOURCE_TLS_VERSION</span> <span class="token operator">=</span> <span class="token string">'<em class="replaceable">protocol_list</em>'</span>
<span class="token operator">|</span> <span class="token keyword">SOURCE_TLS_CIPHERSUITES</span> <span class="token operator">=</span> <span class="token string">'<em class="replaceable">ciphersuite_list</em>'</span>
<span class="token operator">|</span> <span class="token keyword">SOURCE_PUBLIC_KEY_PATH</span> <span class="token operator">=</span> <span class="token string">'<em class="replaceable">key_file_name</em>'</span>
<span class="token operator">|</span> <span class="token keyword">GET_SOURCE_PUBLIC_KEY</span> <span class="token operator">=</span> {<span class="token number">0</span><span class="token operator">|</span><span class="token number">1</span>}
<span class="token operator">|</span> <span class="token keyword">NETWORK_NAMESPACE</span> <span class="token operator">=</span> <span class="token string">'<em class="replaceable">namespace</em>'</span>
<span class="token operator">|</span> <span class="token keyword">IGNORE_SERVER_IDS</span> <span class="token operator">=</span> <span class="token punctuation">(</span><em class="replaceable">server_id_list</em><span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token operator">|</span> <span class="token keyword">GTID_ONLY</span> <span class="token operator">=</span> {<span class="token number">0</span><span class="token operator">|</span><span class="token number">1</span>}
}
<em class="replaceable">channel_option</em>:
<span class="token keyword">FOR</span> <span class="token keyword">CHANNEL</span> <span class="token keyword"><em class="replaceable">channel</em></span>
<em class="replaceable">server_id_list</em>:
<span class="token punctuation">[</span><em class="replaceable">server_id</em> <span class="token punctuation">[</span><span class="token punctuation">,</span> <em class="replaceable">server_id</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></code></pre>
</div>
<p>
<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>
changes the parameters that the replica server uses for
connecting to the source and reading data from the source. It
also updates the contents of the replication metadata
repositories (see
<a class="xref" href="replica-logs.html" title="19.2.4 Relay Log and Replication Metadata Repositories">
Section 19.2.4, “Relay Log and Replication Metadata Repositories”
</a>
).
</p>
<p>
<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>
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>
Options that you do not specify on 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 retain their value,
except as indicated in the following discussion. In most cases,
there is therefore no need to specify options that do not
change.
</p>
<p>
Values used for
<code class="literal">
SOURCE_HOST
</code>
and other
<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>
options are checked for linefeed (
<code class="literal">
\n
</code>
or
<code class="literal">
0x0A
</code>
) characters. The presence of such
characters in these values causes the statement to fail with an
error.
</p>
<p>
The optional
<code class="literal">
FOR CHANNEL
<em class="replaceable">
<code>
channel
</code>
</em>
</code>
clause lets you
name which replication channel the statement applies to.
Providing a
<code class="literal">
FOR CHANNEL
<em class="replaceable">
<code>
channel
</code>
</em>
</code>
clause applies 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 to a specific replication channel, and is used to add
a new channel or modify an existing channel. For example, to add
a new channel called
<code class="literal">
channel2
</code>
:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa5690360"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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">SOURCE</span> <span class="token keyword">TO</span> <span class="token keyword">SOURCE_HOST</span><span class="token operator">=</span>host1<span class="token punctuation">,</span> <span class="token keyword">SOURCE_PORT</span><span class="token operator">=</span><span class="token number">3002</span> <span class="token keyword">FOR</span> <span class="token keyword">CHANNEL</span> <span class="token string">'channel2'</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
If no clause is named and no extra channels exist, 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 applies to the default channel, whose name is the
empty string (""). When you have set up multiple replication
channels, every
<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 must name a channel using the
<code class="literal">
FOR CHANNEL
<em class="replaceable">
<code>
channel
</code>
</em>
</code>
clause. 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>
For some of the options of 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, you must issue a
<a class="link" href="stop-replica.html" title="15.4.2.5 STOP REPLICA Statement">
<code class="literal">
STOP REPLICA
</code>
</a>
statement prior to
issuing 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 (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 afterwards). Sometimes, you only
need to stop the replication SQL (applier) thread or the
replication I/O (receiver) thread, not both:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
When the applier thread is stopped, you can execute
<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>
using any combination that is otherwise allowed of
<code class="literal">
RELAY_LOG_FILE
</code>
,
<code class="literal">
RELAY_LOG_POS
</code>
, and
<code class="literal">
SOURCE_DELAY
</code>
options, even if the
replication receiver thread is running. No other options may
be used with this statement when the receiver thread is
running.
</p>
</li>
<li class="listitem">
<p>
When the receiver thread is stopped, you can execute
<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>
using any of the options for this statement (in any allowed
combination)
<span class="emphasis">
<em>
except
</em>
</span>
<code class="literal">
RELAY_LOG_FILE
</code>
,
<code class="literal">
RELAY_LOG_POS
</code>
,
<code class="literal">
SOURCE_DELAY
</code>
, or
<code class="literal">
SOURCE_AUTO_POSITION = 1
</code>
even when the
applier thread is running.
</p>
</li>
<li class="listitem">
<p>
Both the receiver thread and the applier thread must be
stopped before issuing 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 employs
<code class="literal">
SOURCE_AUTO_POSITION = 1
</code>
,
<code class="literal">
GTID_ONLY = 1
</code>
, or
<code class="literal">
ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS
</code>
.
</p>
</li>
</ul>
</div>
<p>
You can check the current state of the replication applier
thread and replication receiver thread using
<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>
. Note that the Group Replication
applier channel (
<code class="literal">
group_replication_applier
</code>
)
has no receiver thread, only an applier thread.
</p>
<p>
<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>
statements have a number of side-effects and interactions that
you should be aware of beforehand:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<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>
causes an implicit commit of an ongoing transaction. See
<a class="xref" href="implicit-commit.html" title="15.3.3 Statements That Cause an Implicit Commit">
Section 15.3.3, “Statements That Cause an Implicit Commit”
</a>
.
</p>
</li>
<li class="listitem">
<p>
<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>
causes the previous values for
<code class="literal">
SOURCE_HOST
</code>
,
<code class="literal">
SOURCE_PORT
</code>
,
<code class="literal">
SOURCE_LOG_FILE
</code>
, and
<code class="literal">
SOURCE_LOG_POS
</code>
to be written to the error
log, along with other information about the replica's
state prior to execution.
</p>
</li>
<li class="listitem">
<p>
If you are using statement-based replication and temporary
tables, it is possible for 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 following a
<a class="link" href="stop-replica.html" title="15.4.2.5 STOP REPLICA Statement">
<code class="literal">
STOP
REPLICA
</code>
</a>
statement to leave behind temporary tables
on the replica. A warning
(
<a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html#error_er_warn_open_temp_tables_must_be_zero" target="_top">
<code class="literal">
ER_WARN_OPEN_TEMP_TABLES_MUST_BE_ZERO
</code>
</a>
)
is issued whenever this occurs. You can avoid this in such
cases by making sure that the value of the
<a class="link" href="server-status-variables.html#statvar_Replica_open_temp_tables">
<code class="literal">
Replica_open_temp_tables
</code>
</a>
system status variable is equal to 0 prior to executing such
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.
</p>
</li>
<li class="listitem">
<p>
When using a multithreaded replica
(
<a class="link" href="replication-options-replica.html#sysvar_replica_parallel_workers">
<code class="literal">
replica_parallel_workers
</code>
</a>
> 0), stopping the replica can cause gaps in the sequence
of transactions that have been executed from the relay log,
regardless of whether the replica was stopped intentionally
or otherwise. In MySQL 8.4, these can be
resolved using GTID auto-positioning.
</p>
</li>
</ul>
</div>
<p>
The following options are available for
<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>
statements:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a name="crs-opt-assign_gtids_to_anonymous_transactions">
</a>
<a class="link" href="change-replication-source-to.html#crs-opt-assign_gtids_to_anonymous_transactions">
<code class="literal">
ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS
= {OFF | LOCAL |
<em class="replaceable">
<code>
uuid
</code>
</em>
}
</code>
</a>
</p>
<p>
Makes the replication channel assign a GTID to replicated
transactions that do not have one, enabling replication from
a source that does not use GTID-based replication, to a
replica that does. For a multi-source replica, you can have
a mix of channels that use
<code class="literal">
ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS
</code>
,
and channels that do not. The default is
<code class="literal">
OFF
</code>
, meaning that the feature is not
used.
</p>
<p>
<code class="literal">
LOCAL
</code>
assigns a GTID including the
replica's own UUID (the
<a class="link" href="replication-options.html#sysvar_server_uuid">
<code class="literal">
server_uuid
</code>
</a>
setting).
<code class="literal">
<em class="replaceable">
<code>
uuid
</code>
</em>
</code>
assigns a
GTID including the specified UUID, such as the
<a class="link" href="replication-options.html#sysvar_server_uuid">
<code class="literal">
server_uuid
</code>
</a>
setting for the
replication source server. Using a nonlocal UUID lets you
differentiate between transactions that originated on the
replica and transactions that originated on the source, and
for a multi-source replica, between transactions that
originated on different sources. The UUID you choose only
has significance for the replica's own use. If any of the
transactions sent by the source do have a GTID already, that
GTID is retained.
</p>
<p>
Channels specific to Group Replication cannot use
<code class="literal">
ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS
</code>
,
but an asynchronous replication channel for another source
on a server instance that is a Group Replication group
member can do so. In that case, do not specify the Group
Replication group name as the UUID for creating the GTIDs.
</p>
<p>
To set
<code class="literal">
ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS
</code>
to
<code class="literal">
LOCAL
</code>
or
<code class="literal">
<em class="replaceable">
<code>
uuid
</code>
</em>
</code>
, the
replica must have
<a class="link" href="replication-options-gtids.html#sysvar_gtid_mode">
<code class="literal">
gtid_mode=ON
</code>
</a>
set, and this
cannot be changed afterwards. This option is for use with a
source that has binary log file position based replication,
so
<code class="literal">
SOURCE_AUTO_POSITION=1
</code>
cannot be set
for the channel. Both the replication SQL thread and the
replication I/O (receiver) thread must be stopped before
setting this option.
</p>
<div class="important" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Important
</div>
<p>
A replica set up with
<code class="literal">
ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS
</code>
on any channel cannot be promoted to replace the
replication source server in the event that a failover is
required, and a backup taken from the replica cannot be
used to restore the replication source server. The same
restriction applies to replacing or restoring other
replicas that use
<code class="literal">
ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS
</code>
on any channel.
</p>
</div>
<p>
For further restrictions and information, see
<a class="xref" href="replication-gtids-assign-anon.html" title="19.1.3.6 Replication From a Source Without GTIDs to a Replica With GTIDs">
Section 19.1.3.6, “Replication From a Source Without GTIDs to a Replica With GTIDs”
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="crs-opt-get_source_public_key">
</a>
<a class="link" href="change-replication-source-to.html#crs-opt-get_source_public_key">
<code class="literal">
GET_SOURCE_PUBLIC_KEY =
{0|1}
</code>
</a>
</p>
<p>
Enables RSA key pair-based password exchange by requesting
the public key from the source. The option is disabled by
default.
</p>
<p>
This option applies to replicas that authenticate with the
<code class="literal">
caching_sha2_password
</code>
authentication
plugin. For connections by accounts that authenticate using
this plugin, the source does not send the public key unless
requested, so it must be requested or specified in the
client. If
<code class="literal">
SOURCE_PUBLIC_KEY_PATH
</code>
is
given and specifies a valid public key file, it takes
precedence over
<code class="literal">
GET_SOURCE_PUBLIC_KEY
</code>
. If
you are using a replication user account that authenticates
with the
<code class="literal">
caching_sha2_password
</code>
plugin
(the default), and you are not using a secure connection,
you must specify either this option or the
<code class="literal">
SOURCE_PUBLIC_KEY_PATH
</code>
option to provide
the RSA public key to the replica.
</p>
</li>
<li class="listitem">
<p>
<a name="crs-opt-gtid_only">
</a>
<a class="link" href="change-replication-source-to.html#crs-opt-gtid_only">
<code class="literal">
GTID_ONLY = {0|1}
</code>
</a>
</p>
<p>
Stops the replication channel persisting file names and file
positions in the replication metadata repositories.
<code class="literal">
GTID_ONLY
</code>
is disabled by default for
asynchronous replication channels, but is enabled by default
for Group Replication channels, for which it cannot be
disabled.
</p>
<p>
For replication channels with this setting, in-memory file
positions are still tracked, and file positions can still be
observed for debugging purposes in error messages and
through interfaces such as
<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>
statements (where they are shown as being
invalid if they are out of date). However, the writes and
reads required to persist and check the file positions are
avoided in situations where GTID-based replication does not
actually require them, including the transaction queuing and
application process.
</p>
<p>
This option can be used only if both the replication SQL
(applier) thread and replication I/O (receiver) thread are
stopped. To set
<code class="literal">
GTID_ONLY = 1
</code>
for a
replication channel, GTIDs must be in use on the server
(
<a class="link" href="replication-options-gtids.html#sysvar_gtid_mode">
<code class="literal">
gtid_mode = ON
</code>
</a>
), and
row-based binary logging must be in use on the source
(statement-based replication is not supported). The options
<code class="literal">
REQUIRE_ROW_FORMAT = 1
</code>
and
<code class="literal">
SOURCE_AUTO_POSITION = 1
</code>
must be set for
the replication channel.
</p>
<p>
When
<code class="literal">
GTID_ONLY = 1
</code>
is set, the replica
uses
<a class="link" href="replication-options-replica.html#sysvar_replica_parallel_workers">
<code class="literal">
replica_parallel_workers=1
</code>
</a>
if that system variable is set to zero for the server, so it
is always technically a multi-threaded applier. This is
because a multi-threaded applier uses saved positions rather
than the replication metadata repositories to locate the
start of a transaction that it needs to reapply.
</p>
<p>
If you disable
<code class="literal">
GTID_ONLY
</code>
after setting
it, the existing relay logs are deleted and the existing
known binary log file positions are persisted, even if they
are stale. The file positions for the binary log and relay
log in the replication metadata repositories might be
invalid, and a warning is returned if this is the case.
Provided that
<code class="literal">
SOURCE_AUTO_POSITION
</code>
is
still enabled, GTID auto-positioning is used to provide the
correct positioning.
</p>
<p>
If you also disable
<code class="literal">
SOURCE_AUTO_POSITION
</code>
,
the file positions for the binary log and relay log in the
replication metadata repositories are used for positioning
if they are valid. If they are marked as invalid, you must
provide a valid binary log file name and position
(
<code class="literal">
SOURCE_LOG_FILE
</code>
and
<code class="literal">
SOURCE_LOG_POS
</code>
). If you also provide a
relay log file name and position
(
<code class="literal">
RELAY_LOG_FILE
</code>
and
<code class="literal">
RELAY_LOG_POS
</code>
), the relay logs are
preserved and the applier position is set to the stated
position. GTID auto-skip ensures that any transactions
already applied are skipped even if the eventual applier
position is not correct.
</p>
</li>
<li class="listitem">
<p>
<a name="crs-opt-ignore_server_ids">
</a>
<a class="link" href="change-replication-source-to.html#crs-opt-ignore_server_ids">
<code class="literal">
IGNORE_SERVER_IDS =
(
<em class="replaceable">
<code>
server_id_list
</code>
</em>
)
</code>
</a>
</p>
<p>
Makes the replica ignore events originating from the
specified servers. The option takes a comma-separated list
of 0 or more server IDs. Log rotation and deletion events
from the servers are not ignored, and are recorded in the
relay log.
</p>
<p>
In circular replication, the originating server normally
acts as the terminator of its own events, so that they are
not applied more than once. Thus, this option is useful in
circular replication when one of the servers in the circle
is removed. Suppose that you have a circular replication
setup with 4 servers, having server IDs 1, 2, 3, and 4, and
server 3 fails. When bridging the gap by starting
replication from server 2 to server 4, you can include
<code class="literal">
IGNORE_SERVER_IDS = (3)
</code>
in 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 that you issue on server 4 to tell it to use
server 2 as its source instead of server 3. Doing so causes
it to ignore and not to propagate any statements that
originated with the server that is no longer in use.
</p>
<p>
If
<code class="literal">
IGNORE_SERVER_IDS
</code>
contains the
server's own ID and the server was started with the
<a class="link" href="replication-options-replica.html#option_mysqld_replicate-same-server-id">
<code class="option">
--replicate-same-server-id
</code>
</a>
option enabled, an error results.
</p>
<p>
The source metadata repository and the output of
<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>
provide the list of servers that
are currently ignored. For more information, see
<a class="xref" href="replica-logs-status.html" title="19.2.4.2 Replication Metadata Repositories">
Section 19.2.4.2, “Replication Metadata Repositories”
</a>
, and
<a class="xref" href="show-replica-status.html" title="15.7.7.35 SHOW REPLICA STATUS Statement">
Section 15.7.7.35, “SHOW REPLICA STATUS Statement”
</a>
.
</p>
<p>
If 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 is issued without
<code class="literal">
IGNORE_SERVER_IDS
</code>
, any existing list is
preserved. To clear the list of ignored servers, it is
necessary to use the option with an empty list, like this:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa21454213"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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">SOURCE</span> <span class="token keyword">TO</span> <span class="token keyword">IGNORE_SERVER_IDS</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>
<a class="link" href="reset-replica.html" title="15.4.2.3 RESET REPLICA Statement">
<code class="literal">
RESET REPLICA
ALL
</code>
</a>
also clears
<code class="literal">
IGNORE_SERVER_IDS
</code>
.
</p>
<p>
When global transaction identifiers (GTIDs) are used for
replication, transactions that have already been applied are
automatically ignored. Because of this,
<code class="literal">
IGNORE_SERVER_IDS
</code>
is not compatible with
<a class="link" href="replication-options-gtids.html#sysvar_gtid_mode">
<code class="literal">
gtid_mode=ON
</code>
</a>
. If
<code class="literal">
gtid_mode
</code>
is
<code class="literal">
ON
</code>
,
<code class="literal">
CHANGE REPLICATION SOURCE TO
</code>
with a
non-empty
<code class="literal">
IGNORE_SERVER_IDS
</code>
list is
rejected with an error. Likewise, if any existing
replication channel was created with a list of server IDs to
be ignored,
<code class="literal">
SET gtid_mode=ON
</code>
is also
rejected. Before starting GTID-based replication, check for
and clear any ignored server ID lists on the servers
involved; you can do this by checking the output from
<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>
. In such
cases, you can clear the list by issuing
<code class="literal">
CHANGE
REPLICATION SOURCE TO
</code>
with an empty list of server
IDs as shown previously.
</p>
</li>
<li class="listitem">
<p>
<a name="crs-opt-network_namespace">
</a>
<a class="link" href="change-replication-source-to.html#crs-opt-network_namespace">
<code class="literal">
NETWORK_NAMESPACE =
'
<em class="replaceable">
<code>
namespace
</code>
</em>
'
</code>
</a>
</p>
<p>
The network namespace to use for TCP/IP connections to the
replication source server or, if the MySQL communication
stack is in use, for Group Replication’s group
communication connections. The maximum length of the string
value is 64 characters. If this option is omitted,
connections from the replica use the default (global)
namespace. On platforms that do not implement network
namespace support, failure occurs when the replica attempts
to connect to the source. For information about network
namespaces, see
<a class="xref" href="network-namespace-support.html" title="7.1.14 Network Namespace Support">
Section 7.1.14, “Network Namespace Support”
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="crs-opt-privilege_checks_user">
</a>
<a class="link" href="change-replication-source-to.html#crs-opt-privilege_checks_user">
<code class="literal">
PRIVILEGE_CHECKS_USER = {NULL |
'
<em class="replaceable">
<code>
account
</code>
</em>
'}
</code>
</a>
</p>
<p>
Names a user account that supplies a security context for
the specified channel.
<code class="literal">
NULL
</code>
, which is the
default, means no security context is used.
</p>
<p>
The user name and host name for the user account must follow
the syntax described in
<a class="xref" href="account-names.html" title="8.2.4 Specifying Account Names">
Section 8.2.4, “Specifying Account Names”
</a>
, and
the user must not be an anonymous user (with a blank user
name) or the
<code class="literal">
CURRENT_USER
</code>
. The account
must have the
<a class="link" href="privileges-provided.html#priv_replication-applier">
<code class="literal">
REPLICATION_APPLIER
</code>
</a>
privilege, plus the required privileges to execute the
transactions replicated on the channel. For details of the
privileges required by the account, see
<a class="xref" href="replication-privilege-checks.html" title="19.3.3 Replication Privilege Checks">
Section 19.3.3, “Replication Privilege Checks”
</a>
. When you
restart the replication channel, the privilege checks are
applied from that point on. If you do not specify a channel
and no other channels exist, the statement is applied to the
default channel.
</p>
<p>
The use of row-based binary logging is strongly recommended
when
<code class="literal">
PRIVILEGE_CHECKS_USER
</code>
is set, and
you can set
<code class="literal">
REQUIRE_ROW_FORMAT
</code>
to enforce
this. For example, to start privilege checks on the channel
<code class="literal">
channel_1
</code>
on a running replica, issue the
following statements:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa64254625"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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">STOP</span> <span class="token keyword">REPLICA</span> <span class="token keyword">FOR</span> <span class="token keyword">CHANNEL</span> <span class="token string">'channel_1'</span><span class="token punctuation">;</span>
<span class="token keyword">CHANGE</span> <span class="token keyword">REPLICATION</span> <span class="token keyword">SOURCE</span> <span class="token keyword">TO</span>
<span class="token keyword">PRIVILEGE_CHECKS_USER</span> <span class="token operator">=</span> <span class="token string">'<em class="replaceable">user</em>'</span>@<span class="token string">'<em class="replaceable">host</em>'</span><span class="token punctuation">,</span>
<span class="token keyword">REQUIRE_ROW_FORMAT</span> <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">,</span>
<span class="token keyword">FOR</span> <span class="token keyword">CHANNEL</span> <span class="token string">'channel_1'</span><span class="token punctuation">;</span>
<span class="token keyword">START</span> <span class="token keyword">REPLICA</span> <span class="token keyword">FOR</span> <span class="token keyword">CHANNEL</span> <span class="token string">'channel_1'</span><span class="token punctuation">;</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
<a name="crs-opt-relay_log_file">
</a>
<a class="link" href="change-replication-source-to.html#crs-opt-relay_log_file">
<code class="literal">
RELAY_LOG_FILE =
'
<em class="replaceable">
<code>
relay_log_file
</code>
</em>
'
</code>
</a>
,
<a class="link" href="change-replication-source-to.html#crs-opt-relay_log_file">
<code class="literal">
RELAY_LOG_POS =
'
<em class="replaceable">
<code>
relay_log_pos
</code>
</em>
'
</code>
</a>
</p>
<p>
The relay log file name, and the location in that file, at
which the replication SQL thread begins reading from the
replica's relay log the next time the thread starts.
<code class="literal">
RELAY_LOG_FILE
</code>
can use either an absolute
or relative path, and uses the same base name as
<code class="literal">
SOURCE_LOG_FILE
</code>
. The maximum length of
the string value is 511 characters.
</p>
<p>
A
<code class="literal">
CHANGE REPLICATION SOURCE TO
</code>
statement
using
<code class="literal">
RELAY_LOG_FILE
</code>
,
<code class="literal">
RELAY_LOG_POS
</code>
, or both options can be
executed on a running replica when the replication SQL
(applier) thread is stopped. Relay logs are preserved if at
least one of the replication applier thread and the
replication I/O (receiver) thread is running. If both
threads are stopped, all relay log files are deleted unless
at least one of
<code class="literal">
RELAY_LOG_FILE
</code>
or
<code class="literal">
RELAY_LOG_POS
</code>
is specified. For the Group
Replication applier channel
(
<code class="literal">
group_replication_applier
</code>
), which only
has an applier thread and no receiver thread, this is the
case if the applier thread is stopped, but with that channel
you cannot use the
<code class="literal">
RELAY_LOG_FILE
</code>
and
<code class="literal">
RELAY_LOG_POS
</code>
options.
</p>
</li>
<li class="listitem">
<p>
<a name="crs-opt-require_row_format">
</a>
<a class="link" href="change-replication-source-to.html#crs-opt-require_row_format">
<code class="literal">
REQUIRE_ROW_FORMAT = {0|1}
</code>
</a>
</p>
<p>
Permits only row-based replication events to be processed by
the replication channel. This option prevents the
replication applier from taking actions such as creating
temporary tables and executing
<code class="literal">
LOAD DATA
INFILE
</code>
requests, which increases the security of
the channel. The
<code class="literal">
REQUIRE_ROW_FORMAT
</code>
option is disabled by default for asynchronous replication
channels, but it is enabled by default for Group Replication
channels, and it cannot be disabled for them. For more
information, see
<a class="xref" href="replication-privilege-checks.html" title="19.3.3 Replication Privilege Checks">
Section 19.3.3, “Replication Privilege Checks”
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="crs-opt-require_table_primary_key_check">
</a>
<a class="link" href="change-replication-source-to.html#crs-opt-require_table_primary_key_check">
<code class="literal">
REQUIRE_TABLE_PRIMARY_KEY_CHECK =
{STREAM | ON | OFF | GENERATE}
</code>
</a>
</p>
<p>
This option lets a replica set its own policy for primary
key checks, as follows:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
<code class="literal">
ON
</code>
: The replica sets
<a class="link" href="server-system-variables.html#sysvar_sql_require_primary_key">
<code class="literal">
sql_require_primary_key =
ON
</code>
</a>
; any replicated
<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 must result in a table that
contains a primary key.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
OFF
</code>
: The replica sets
<code class="literal">
sql_require_primary_key = OFF
</code>
; no
replicated
<code class="literal">
CREATE TABLE
</code>
or
<code class="literal">
ALTER TABLE
</code>
statement is checked for
the presence of a primary key.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
STREAM
</code>
: The replica uses whatever
value of
<code class="literal">
sql_require_primary_key
</code>
is
replicated from the source for each transaction. This is
the default value, and the default behavior.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
GENERATE
</code>
: Causes the replica to
generate an invisible primary key for any
<a class="link" href="innodb-storage-engine.html" title="Chapter 17 The InnoDB Storage Engine">
<code class="literal">
InnoDB
</code>
</a>
table that, as
replicated, lacks a primary key. 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>
, for more
information.
</p>
<p>
<code class="literal">
GENERATE
</code>
is not compatible with Group
Replication; you can use
<code class="literal">
ON
</code>
,
<code class="literal">
OFF
</code>
, or
<code class="literal">
STREAM
</code>
.
</p>
</li>
</ul>
</div>
<p>
A divergence based on the presence of a generated invisible
primary key solely on a source or replica table is supported
by MySQL Replication as long as the source supports GIPKs
and the replica uses MySQL version 8.0.32 or later. If you
use GIPKs on a replica with the source using an earlier
version of MySQL, such divergences in schema, other than the
extra GIPK on the replica, are not supported and may result
in replication errors.
</p>
<p>
For multisource replication, setting
<code class="literal">
REQUIRE_TABLE_PRIMARY_KEY_CHECK
</code>
to
<code class="literal">
ON
</code>
or
<code class="literal">
OFF
</code>
lets the
replica normalize behavior across replication channels for
different sources, and to keep a consistent setting for
<a class="link" href="server-system-variables.html#sysvar_sql_require_primary_key">
<code class="literal">
sql_require_primary_key
</code>
</a>
.
Using
<code class="literal">
ON
</code>
safeguards against the
accidental loss of primary keys when multiple sources update
the same set of tables. Using
<code class="literal">
OFF
</code>
lets
sources that can manipulate primary keys to work alongside
sources that cannot.
</p>
<p>
In the case of multiple replicas, when
<code class="literal">
REQUIRE_TABLE_PRIMARY_KEY_CHECK
</code>
is set to
<code class="literal">
GENERATE
</code>
, the generated invisible primary
key added by a given replica is independent of any such key
added on any other replica. This means that, if generated
invisible primary keys are in use, the values in the
generated primary key columns on different replicas are not
guaranteed to be the same. This may be an issue when failing
over to such a replica.
</p>
<p>
When
<code class="literal">
PRIVILEGE_CHECKS_USER
</code>
is
<code class="literal">
NULL
</code>
(the default), the user account does
not need administration level privileges to set restricted
session variables. Setting this option to a value other than
<code class="literal">
NULL
</code>
means that, when
<code class="literal">
REQUIRE_TABLE_PRIMARY_KEY_CHECK
</code>
is
<code class="literal">
ON
</code>
,
<code class="literal">
OFF
</code>
, or
<code class="literal">
GENERATE
</code>
, the user account does not
require session administration level privileges to set
restricted session variables such as
<a class="link" href="server-system-variables.html#sysvar_sql_require_primary_key">
<code class="literal">
sql_require_primary_key
</code>
</a>
,
avoiding the need to grant the account such privileges. For
more information, see
<a class="xref" href="replication-privilege-checks.html" title="19.3.3 Replication Privilege Checks">
Section 19.3.3, “Replication Privilege Checks”
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="crs-opt-source_auto_position">
</a>
<a class="link" href="change-replication-source-to.html#crs-opt-source_auto_position">
<code class="literal">
SOURCE_AUTO_POSITION =
{0|1}
</code>
</a>
</p>
<p>
Makes the replica attempt to connect to the source using the
auto-positioning feature of GTID-based replication, rather
than a binary log file based position. This option is used
to start a replica using GTID-based replication. The default
is 0, meaning that GTID auto-positioning and GTID-based
replication are not used. This option can be used with
<code class="literal">
CHANGE REPLICATION SOURCE TO
</code>
only if both
the replication SQL (applier) thread and replication I/O
(receiver) thread are stopped.
</p>
<p>
Both the replica and the source must have GTIDs enabled
(
<a class="link" href="replication-options-gtids.html#sysvar_gtid_mode">
<code class="literal">
GTID_MODE=ON
</code>
</a>
,
<code class="literal">
ON_PERMISSIVE,
</code>
or
<code class="literal">
OFF_PERMISSIVE
</code>
on the replica, and
<a class="link" href="replication-options-gtids.html#sysvar_gtid_mode">
<code class="literal">
GTID_MODE=ON
</code>
</a>
on the
source).
<code class="literal">
SOURCE_LOG_FILE
</code>
,
<code class="literal">
SOURCE_LOG_POS
</code>
,
<code class="literal">
RELAY_LOG_FILE
</code>
, and
<code class="literal">
RELAY_LOG_POS
</code>
cannot be specified
together with
<code class="literal">
SOURCE_AUTO_POSITION = 1
</code>
.
If multi-source replication is enabled on the replica, you
need to set the
<code class="literal">
SOURCE_AUTO_POSITION = 1
</code>
option for each applicable replication channel.
</p>
<p>
With
<code class="literal">
SOURCE_AUTO_POSITION = 1
</code>
set, in the
initial connection handshake, the replica sends a GTID set
containing the transactions that it has already received,
committed, or both. The source responds by sending all
transactions recorded in its binary log whose GTID is not
included in the GTID set sent by the replica. This exchange
ensures that the source only sends the transactions with a
GTID that the replica has not already recorded or committed.
If the replica receives transactions from more than one
source, as in the case of a diamond topology, the auto-skip
function ensures that the transactions are not applied
twice. For details of how the GTID set sent by the replica
is computed, see
<a class="xref" href="replication-gtids-auto-positioning.html" title="19.1.3.3 GTID Auto-Positioning">
Section 19.1.3.3, “GTID Auto-Positioning”
</a>
.
</p>
<p>
If any of the transactions that should be sent by the source
have been purged from the source's binary log, or added to
the set of GTIDs in the
<a class="link" href="replication-options-gtids.html#sysvar_gtid_purged">
<code class="literal">
gtid_purged
</code>
</a>
system variable
by another method, the source sends the error
<a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html#error_er_source_has_purged_required_gtids" target="_top">
<code class="literal">
ER_SOURCE_HAS_PURGED_REQUIRED_GTIDS
</code>
</a>
to the replica, and replication does not start. The GTIDs of
the missing purged transactions are identified and listed in
the source's error log in the warning message
<a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html#error_er_found_missing_gtids" target="_top">
<code class="literal">
ER_FOUND_MISSING_GTIDS
</code>
</a>
.
Also, if during the exchange of transactions it is found
that the replica has recorded or committed transactions with
the source's UUID in the GTID, but the source itself has not
committed them, the source sends the error
<a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html#error_er_replica_has_more_gtids_than_source" target="_top">
<code class="literal">
ER_REPLICA_HAS_MORE_GTIDS_THAN_SOURCE
</code>
</a>
to the replica and replication does not start. For
information on how to handle these situations, see
<a class="xref" href="replication-gtids-auto-positioning.html" title="19.1.3.3 GTID Auto-Positioning">
Section 19.1.3.3, “GTID Auto-Positioning”
</a>
.
</p>
<p>
You can see whether replication is running with GTID
auto-positioning enabled by checking the Performance Schema
<a class="link" href="performance-schema-replication-connection-status-table.html" title="29.12.11.13 The replication_connection_status Table">
<code class="literal">
replication_connection_status
</code>
</a>
table or the output of
<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>
. Disabling the
<code class="literal">
SOURCE_AUTO_POSITION
</code>
option again makes
the replica revert to file-based replication.
</p>
</li>
<li class="listitem">
<p>
<a name="crs-opt-source_bind">
</a>
<a class="link" href="change-replication-source-to.html#crs-opt-source_bind">
<code class="literal">
SOURCE_BIND =
'
<em class="replaceable">
<code>
interface_name
</code>
</em>
'
</code>
</a>
</p>
<p>
Determines which of the replica's network interfaces is
chosen for connecting to the source, for use on replicas
that have multiple network interfaces. Specify the IP
address of the network interface. The maximum length of the
string value is 255 characters.
</p>
<p>
The IP address configured with this option, if any, can be
seen in the
<code class="literal">
Source_Bind
</code>
column of the
output from
<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>
. In the source metadata repository
table
<code class="literal">
mysql.slave_master_info
</code>
, the value
can be seen as the
<code class="literal">
Source_bind
</code>
column.
The ability to bind a replica to a specific network
interface is also supported by NDB Cluster.
</p>
</li>
<li class="listitem">
<p>
<a name="crs-opt-source_compression_algorithms">
</a>
<a class="link" href="change-replication-source-to.html#crs-opt-source_compression_algorithms">
<code class="literal">
SOURCE_COMPRESSION_ALGORITHMS =
'
<em class="replaceable">
<code>
algorithm
</code>
</em>
[,
<em class="replaceable">
<code>
algorithm
</code>
</em>
][,
<em class="replaceable">
<code>
algorithm
</code>
</em>
]'
</code>
</a>
</p>
<p>
Specifies one, two, or three of the permitted compression
algorithms for connections to the replication source server,
separated by commas. The maximum length of the string value
is 99 characters. The default value is
<code class="literal">
uncompressed
</code>
.
</p>
<p>
The available algorithms are
<code class="literal">
zlib
</code>
,
<code class="literal">
zstd
</code>
, and
<code class="literal">
uncompressed
</code>
, 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 algorithms can be specified in any
order, but it is not an order of preference - the algorithm
negotiation process attempts to use
<code class="literal">
zlib
</code>
,
then
<code class="literal">
zstd
</code>
, then
<code class="literal">
uncompressed
</code>
, if they are specified.
</p>
<p>
The value of
<code class="literal">
SOURCE_COMPRESSION_ALGORITHMS
</code>
applies
only if the
<a class="link" href="replication-options-replica.html#sysvar_replica_compressed_protocol">
<code class="literal">
replica_compressed_protocol
</code>
</a>
system variable is disabled. If
<code class="literal">
replica_compressed_protocol
</code>
is enabled,
it takes precedence over
<code class="literal">
SOURCE_COMPRESSION_ALGORITHMS
</code>
and
connections to the source use
<code class="literal">
zlib
</code>
compression if both source and replica support that
algorithm. 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>
<p>
Binary log transaction compression is activated by the
<a class="link" href="replication-options-binary-log.html#sysvar_binlog_transaction_compression">
<code class="literal">
binlog_transaction_compression
</code>
</a>
system variable, and can also be used to save bandwidth. If
you do this in combination with connection compression,
connection compression has less opportunity to act on the
data, but can still compress headers and those events and
transaction payloads that are uncompressed. For more
information on binary log transaction compression, see
<a class="xref" href="binary-log-transaction-compression.html" title="7.4.4.5 Binary Log Transaction Compression">
Section 7.4.4.5, “Binary Log Transaction Compression”
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="crs-opt-source_connect_retry">
</a>
<a class="link" href="change-replication-source-to.html#crs-opt-source_connect_retry">
<code class="literal">
SOURCE_CONNECT_RETRY =
<em class="replaceable">
<code>
interval
</code>
</em>
</code>
</a>
</p>
<p>
Specifies the interval in seconds between the reconnection
attempts that the replica makes after the connection to the
source times out. The default interval is 60.
</p>
<p>
The number of attempts is limited by the
<code class="literal">
SOURCE_RETRY_COUNT
</code>
option. If both the
default settings are used, the replica waits 60 seconds
between reconnection attempts
(
<code class="literal">
SOURCE_CONNECT_RETRY=60
</code>
), and keeps
attempting to reconnect at this rate for 10 minutes
(
<code class="literal">
SOURCE_RETRY_COUNT=10
</code>
). These values are
recorded in the source metadata repository and shown in the
<a class="link" href="performance-schema-replication-connection-configuration-table.html" title="29.12.11.11 The replication_connection_configuration Table">
<code class="literal">
replication_connection_configuration
</code>
</a>
Performance Schema table.
</p>
</li>
<li class="listitem">
<p>
<a name="crs-opt-source_connection_auto_failover">
</a>
<a class="link" href="change-replication-source-to.html#crs-opt-source_connection_auto_failover">
<code class="literal">
SOURCE_CONNECTION_AUTO_FAILOVER =
{0|1}
</code>
</a>
</p>
<p>
Activates the asynchronous connection failover mechanism for
a replication channel if one or more alternative replication
source servers are available (so when there are multiple
MySQL servers or groups of servers that share the replicated
data). The default is 0, meaning that the mechanism is not
activated. For full information and instructions to set up
this feature, see
<a class="xref" href="replication-asynchronous-connection-failover-replica.html" title="19.4.9.2 Asynchronous Connection Failover for Replicas">
Section 19.4.9.2, “Asynchronous Connection Failover for Replicas”
</a>
.
</p>
<p>
The asynchronous connection failover mechanism takes over
after the reconnection attempts controlled by
<code class="literal">
SOURCE_CONNECT_RETRY
</code>
and
<code class="literal">
SOURCE_RETRY_COUNT
</code>
are exhausted. It
reconnects the replica to an alternative source chosen from
a specified source list, which you can manage using the
functions
<a class="link" href="replication-functions-async-failover.html#function_asynchronous-connection-failover-add-source">
<code class="literal">
asynchronous_connection_failover_add_source()
</code>
</a>
and
<a class="link" href="replication-functions-async-failover.html#function_asynchronous-connection-failover-delete-source">
<code class="literal">
asynchronous_connection_failover_delete_source()
</code>
</a>
.
To add and remove managed groups of servers, use
<a class="link" href="replication-functions-async-failover.html#function_asynchronous-connection-failover-add-managed">
<code class="literal">
asynchronous_connection_failover_add_managed()
</code>
</a>
and
<a class="link" href="replication-functions-async-failover.html#function_asynchronous-connection-failover-delete-managed">
<code class="literal">
asynchronous_connection_failover_delete_managed()
</code>
</a>
instead. For more information, see
<a class="xref" href="replication-asynchronous-connection-failover.html" title="19.4.9 Switching Sources and Replicas with Asynchronous Connection Failover">
Section 19.4.9, “Switching Sources and Replicas with Asynchronous Connection Failover”
</a>
.
</p>
<div class="important" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Important
</div>
<div class="orderedlist">
<ol class="orderedlist" type="1">
<li class="listitem">
<p>
You can only set
<code class="literal">
SOURCE_CONNECTION_AUTO_FAILOVER = 1
</code>
when GTID auto-positioning is in use
(
<code class="literal">
SOURCE_AUTO_POSITION = 1
</code>
).
</p>
</li>
<li class="listitem">
<p>
When you set
<code class="literal">
SOURCE_CONNECTION_AUTO_FAILOVER
= 1
</code>
, set
<code class="literal">
SOURCE_RETRY_COUNT
</code>
and
<code class="literal">
SOURCE_CONNECT_RETRY
</code>
to minimal
numbers that just allow a few retry attempts with the
same source, in case the connection failure is caused
by a transient network outage. Otherwise the
asynchronous connection failover mechanism cannot be
activated promptly. Suitable values are
<code class="literal">
SOURCE_RETRY_COUNT=3
</code>
and
<code class="literal">
SOURCE_CONNECT_RETRY=10
</code>
, which make
the replica retry the connection 3 times with
10-second intervals between.
</p>
</li>
<li class="listitem">
<p>
When you set
<code class="literal">
SOURCE_CONNECTION_AUTO_FAILOVER
= 1
</code>
, the replication metadata repositories
must contain the credentials for a replication user
account that can be used to connect to all the servers
on the source list for the replication channel. The
account must also have
<code class="literal">
SELECT
</code>
permissions on the Performance Schema tables. These
credentials can be set using 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 with the
<code class="literal">
SOURCE_USER
</code>
and
<code class="literal">
SOURCE_PASSWORD
</code>
options. For more
information, see
<a class="xref" href="replication-asynchronous-connection-failover.html" title="19.4.9 Switching Sources and Replicas with Asynchronous Connection Failover">
Section 19.4.9, “Switching Sources and Replicas with Asynchronous Connection Failover”
</a>
.
</p>
</li>
<li class="listitem">
<p>
When you set
<code class="literal">
SOURCE_CONNECTION_AUTO_FAILOVER
= 1
</code>
, asynchronous connection failover for
replicas is automatically activated if this
replication channel is on a Group Replication primary
in a group in single-primary mode. With this function
active, if the primary that is replicating goes
offline or into an error state, the new primary starts
replication on the same channel when it is elected. If
you want to use the function, this replication channel
must also be set up on all the secondary servers in
the replication group, and on any new joining members.
(If the servers are provisioned using MySQL’s clone
functionality, this all happens automatically.) If you
do not want to use the function, disable it by using
the
<a class="link" href="group-replication-functions-for-member-actions.html#function_group-replication-disable-member-action">
<code class="literal">
group_replication_disable_member_action()
</code>
</a>
function to disable the Group Replication member
action
<code class="literal">
mysql_start_failover_channels_if_primary
</code>
,
which is enabled by default. For more information, see
<a class="xref" href="replication-asynchronous-connection-failover-replica.html" title="19.4.9.2 Asynchronous Connection Failover for Replicas">
Section 19.4.9.2, “Asynchronous Connection Failover for Replicas”
</a>
.
</p>
</li>
</ol>
</div>
</div>
</li>
<li class="listitem">
<p>
<a name="crs-opt-source_delay">
</a>
<a class="link" href="change-replication-source-to.html#crs-opt-source_delay">
<code class="literal">
SOURCE_DELAY =
<em class="replaceable">
<code>
interval
</code>
</em>
</code>
</a>
</p>
<p>
Specifies how many seconds behind the source the replica
must lag. An event received from the source is not executed
until at least
<em class="replaceable">
<code>
interval
</code>
</em>
seconds
later than its execution on the source.
<em class="replaceable">
<code>
interval
</code>
</em>
must be a nonnegative
integer in the range from 0 to
2
<sup>
31
</sup>
−1. The default is 0.
For more information, see
<a class="xref" href="replication-delayed.html" title="19.4.11 Delayed Replication">
Section 19.4.11, “Delayed Replication”
</a>
.
</p>
<p>
A
<code class="literal">
CHANGE REPLICATION SOURCE TO
</code>
statement
using the
<code class="literal">
SOURCE_DELAY
</code>
option can be
executed on a running replica when the replication SQL
thread is stopped.
</p>
</li>
<li class="listitem">
<p>
<a name="crs-opt-source_heartbeat_period">
</a>
<a class="link" href="change-replication-source-to.html#crs-opt-source_heartbeat_period">
<code class="literal">
SOURCE_HEARTBEAT_PERIOD =
<em class="replaceable">
<code>
interval
</code>
</em>
</code>
</a>
</p>
<p>
Controls the heartbeat interval, which stops the connection
timeout occurring in the absence of data if the connection
is still good. A heartbeat signal is sent to the replica
after that number of seconds, and the waiting period is
reset whenever the source's binary log is updated with an
event. Heartbeats are therefore sent by the source only if
there are no unsent events in the binary log file for a
period longer than this.
</p>
<p>
The heartbeat interval
<em class="replaceable">
<code>
interval
</code>
</em>
is a decimal value having the range 0 to 4294967 seconds and
a resolution in milliseconds; the smallest nonzero value is
0.001. Setting
<em class="replaceable">
<code>
interval
</code>
</em>
to 0
disables heartbeats altogether. The heartbeat interval
defaults to half the value of the
<a class="link" href="replication-options-replica.html#sysvar_replica_net_timeout">
<code class="literal">
replica_net_timeout
</code>
</a>
system
variable. It is recorded in the source metadata repository
and shown in the
<a class="link" href="performance-schema-replication-connection-configuration-table.html" title="29.12.11.11 The replication_connection_configuration Table">
<code class="literal">
replication_connection_configuration
</code>
</a>
Performance Schema table.
</p>
<p>
The
<a class="link" href="replication-options-replica.html#sysvar_replica_net_timeout">
<code class="literal">
replica_net_timeout
</code>
</a>
system variable specifies the number of seconds that the
replica waits for either more data or a heartbeat signal
from the source, before the replica considers the connection
broken, aborts the read, and tries to reconnect. The default
value is 60 seconds (one minute). Note that a change to the
value or default setting of
<a class="link" href="replication-options-replica.html#sysvar_replica_net_timeout">
<code class="literal">
replica_net_timeout
</code>
</a>
does
not automatically change the heartbeat interval, whether
that has been set explicitly or is using a previously
calculated default. A warning is issued if you set the
global value of
<code class="literal">
replica_net_timeout
</code>
to a
value less than that of the current heartbeat interval. If
<code class="literal">
replica_net_timeout
</code>
is changed, you must
also issue
<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>
to adjust the heartbeat interval to an
appropriate value so that the heartbeat signal occurs before
the connection timeout. If you do not do this, the heartbeat
signal has no effect, and if no data is received from the
source, the replica can make repeated reconnection attempts,
creating zombie dump threads.
</p>
</li>
<li class="listitem">
<p>
<a name="crs-opt-source_host">
</a>
<a class="link" href="change-replication-source-to.html#crs-opt-source_host">
<code class="literal">
SOURCE_HOST =
'
<em class="replaceable">
<code>
host_name
</code>
</em>
'
</code>
</a>
</p>
<p>
The host name or IP address of the replication source
server. The replica uses this to connect to the source. The
maximum length of the string value is 255 characters.
</p>
<p>
If you specify
<code class="literal">
SOURCE_HOST
</code>
or
<code class="literal">
SOURCE_PORT
</code>
, the replica assumes that the
source server is different from before (even if the option
value is the same as its current value.) In this case, the
old values for the source's binary log file name and
position are considered no longer applicable, so if you do
not specify
<code class="literal">
SOURCE_LOG_FILE
</code>
and
<code class="literal">
SOURCE_LOG_POS
</code>
in the statement,
<code class="literal">
SOURCE_LOG_FILE=''
</code>
and
<code class="literal">
SOURCE_LOG_POS=4
</code>
are silently appended to
it.
</p>
<p>
Setting
<code class="literal">
SOURCE_HOST=''
</code>
(that is, setting
its value explicitly to an empty string) is
<span class="emphasis">
<em>
not
</em>
</span>
the same as not setting
<code class="literal">
SOURCE_HOST
</code>
at all. Trying to set
<code class="literal">
SOURCE_HOST
</code>
to an empty string fails with
an error.
</p>
</li>
<li class="listitem">
<p>
<a name="crs-opt-source_log_file">
</a>
<a class="link" href="change-replication-source-to.html#crs-opt-source_log_file">
<code class="literal">
SOURCE_LOG_FILE =
'
<em class="replaceable">
<code>
source_log_name
</code>
</em>
'
</code>
</a>
,
<a class="link" href="change-replication-source-to.html#crs-opt-source_log_file">
<code class="literal">
SOURCE_LOG_POS =
<em class="replaceable">
<code>
source_log_pos
</code>
</em>
</code>
</a>
</p>
<p>
The binary log file name, and the location in that file, at
which the replication I/O (receiver) thread begins reading
from the source's binary log the next time the thread
starts. Specify these options if you are using binary log
file position based replication.
</p>
<p>
<code class="literal">
SOURCE_LOG_FILE
</code>
must include the numeric
suffix of a specific binary log file that is available on
the source server, for example,
<code class="literal">
SOURCE_LOG_FILE='binlog.000145'
</code>
. The
maximum length of the string value is 511 characters.
</p>
<p>
<code class="literal">
SOURCE_LOG_POS
</code>
is the numeric position
for the replica to start reading in that file.
<code class="literal">
SOURCE_LOG_POS=4
</code>
represents the start of
the events in a binary log file.
</p>
<p>
If you specify either of
<code class="literal">
SOURCE_LOG_FILE
</code>
or
<code class="literal">
SOURCE_LOG_POS
</code>
, you cannot specify
<code class="literal">
SOURCE_AUTO_POSITION = 1
</code>
, which is for
GTID-based replication.
</p>
<p>
If neither of
<code class="literal">
SOURCE_LOG_FILE
</code>
or
<code class="literal">
SOURCE_LOG_POS
</code>
is specified, the replica
uses the last coordinates of the
<span class="emphasis">
<em>
replication SQL
thread
</em>
</span>
before
<code class="literal">
CHANGE REPLICATION SOURCE
TO
</code>
was issued. This ensures that there is no
discontinuity in replication, even if the replication SQL
(applier) thread was late compared to the replication I/O
(receiver) thread.
</p>
</li>
<li class="listitem">
<p>
<a name="crs-opt-source_password">
</a>
<a class="link" href="change-replication-source-to.html#crs-opt-source_password">
<code class="literal">
SOURCE_PASSWORD =
'
<em class="replaceable">
<code>
password
</code>
</em>
'
</code>
</a>
</p>
<p>
The password for the replication user account to use for
connecting to the replication source server. The maximum
length of the string value is 32 characters. If you specify
<code class="literal">
SOURCE_PASSWORD
</code>
,
<code class="literal">
SOURCE_USER
</code>
is also required.
</p>
<p>
The password used for a replication user account in a
<code class="literal">
CHANGE REPLICATION SOURCE TO
</code>
statement is
limited to 32 characters in length. Trying to use a password
of more than 32 characters causes
<code class="literal">
CHANGE
REPLICATION SOURCE TO
</code>
to fail.
</p>
<p>
The password is masked in MySQL Server’s logs, Performance
Schema tables, and
<a class="link" href="show-processlist.html" title="15.7.7.31 SHOW PROCESSLIST Statement">
<code class="literal">
SHOW
PROCESSLIST
</code>
</a>
statements.
</p>
</li>
<li class="listitem">
<p>
<a name="crs-opt-source_port">
</a>
<a class="link" href="change-replication-source-to.html#crs-opt-source_port">
<code class="literal">
SOURCE_PORT =
<em class="replaceable">
<code>
port_num
</code>
</em>
</code>
</a>
</p>
<p>
The TCP/IP port number that the replica uses to connect to
the replication source server.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
Replication cannot use Unix socket files. You must be able
to connect to the replication source server using TCP/IP.
</p>
</div>
<p>
If you specify
<code class="literal">
SOURCE_HOST
</code>
or
<code class="literal">
SOURCE_PORT
</code>
, the replica assumes that the
source server is different from before (even if the option
value is the same as its current value.) In this case, the
old values for the source's binary log file name and
position are considered no longer applicable, so if you do
not specify
<code class="literal">
SOURCE_LOG_FILE
</code>
and
<code class="literal">
SOURCE_LOG_POS
</code>
in the statement,
<code class="literal">
SOURCE_LOG_FILE=''
</code>
and
<code class="literal">
SOURCE_LOG_POS=4
</code>
are silently appended to
it.
</p>
</li>
<li class="listitem">
<p>
<a name="crs-opt-source_public_key_path">
</a>
<a class="link" href="change-replication-source-to.html#crs-opt-source_public_key_path">
<code class="literal">
SOURCE_PUBLIC_KEY_PATH =
'
<em class="replaceable">
<code>
key_file_name
</code>
</em>
'
</code>
</a>
</p>
<p>
Enables RSA key pair-based password exchange by providing
the path name to a file containing a replica-side copy of
the public key required by the source. The file must be in
PEM format. The maximum length of the string value is 511
characters.
</p>
<p>
This option applies to replicas that authenticate with the
<code class="literal">
sha256_password
</code>
(deprecated) or
<code class="literal">
caching_sha2_password
</code>
authentication
plugin. (For
<code class="literal">
sha256_password
</code>
,
<code class="literal">
SOURCE_PUBLIC_KEY_PATH
</code>
can be used only
if MySQL was built using OpenSSL.) If you are using a
replication user account that authenticates with the
<code class="literal">
caching_sha2_password
</code>
plugin (the
default), and you are not using a secure connection, you
must specify either this option or the
<code class="literal">
GET_SOURCE_PUBLIC_KEY=1
</code>
option to provide
the RSA public key to the replica.
</p>
</li>
<li class="listitem">
<p>
<a name="crs-opt-source_retry_count">
</a>
<a class="link" href="change-replication-source-to.html#crs-opt-source_retry_count">
<code class="literal">
SOURCE_RETRY_COUNT =
<em class="replaceable">
<code>
count
</code>
</em>
</code>
</a>
</p>
<p>
Sets the maximum number of reconnection attempts that the
replica makes after the connection to the source times out,
as determined by the
<a class="link" href="replication-options-replica.html#sysvar_replica_net_timeout">
<code class="literal">
replica_net_timeout
</code>
</a>
system
variable. If the replica does need to reconnect, the first
retry occurs immediately after the timeout. The default is
10 attempts.
</p>
<p>
The interval between the attempts is specified by the
<code class="literal">
SOURCE_CONNECT_RETRY
</code>
option. If both the
default settings are used, the replica waits 60 seconds
between reconnection attempts
(
<code class="literal">
SOURCE_CONNECT_RETRY=60
</code>
), and keeps
attempting to reconnect at this rate for 10 minutes
(
<code class="literal">
SOURCE_RETRY_COUNT=10
</code>
). A setting of 0
for
<code class="literal">
SOURCE_RETRY_COUNT
</code>
means that there
is no limit on the number of reconnection attempts, so the
replica keeps trying to reconnect indefinitely.
</p>
<p>
The values for
<code class="literal">
SOURCE_CONNECT_RETRY
</code>
and
<code class="literal">
SOURCE_RETRY_COUNT
</code>
are recorded in the
source metadata repository and shown in the
<a class="link" href="performance-schema-replication-connection-configuration-table.html" title="29.12.11.11 The replication_connection_configuration Table">
<code class="literal">
replication_connection_configuration
</code>
</a>
Performance Schema table.
<code class="literal">
SOURCE_RETRY_COUNT
</code>
supersedes the
<a class="link" href="replication-options-replica.html#option_mysqld_master-retry-count">
<code class="option">
--master-retry-count
</code>
</a>
server
startup option.
</p>
</li>
<li class="listitem">
<p>
<a name="crs-opt-source_ssl">
</a>
<a class="link" href="change-replication-source-to.html#crs-opt-source_ssl">
<code class="literal">
SOURCE_SSL = {0|1}
</code>
</a>
</p>
<p>
Specify whether the replica encrypts the replication
connection. The default is 0, meaning that the replica does
not encrypt the replication connection. If you set
<code class="literal">
SOURCE_SSL=1
</code>
, you can configure the
encryption using the
<code class="literal">
SOURCE_SSL_
<em class="replaceable">
<code>
xxx
</code>
</em>
</code>
and
<code class="literal">
SOURCE_TLS_
<em class="replaceable">
<code>
xxx
</code>
</em>
</code>
options.
</p>
<p>
Setting
<code class="literal">
SOURCE_SSL=1
</code>
for a replication
connection and then setting no further
<code class="literal">
SOURCE_SSL_
<em class="replaceable">
<code>
xxx
</code>
</em>
</code>
options corresponds to setting
<code class="literal">
--ssl-mode=REQUIRED
</code>
for the client, as
described in
<a class="xref" href="connection-options.html#encrypted-connection-options" title="Command Options for Encrypted Connections">
Command Options for Encrypted Connections
</a>
.
With
<code class="literal">
SOURCE_SSL=1
</code>
, the connection attempt
only succeeds if an encrypted connection can be established.
A replication connection does not fall back to an
unencrypted connection, so there is no setting corresponding
to the
<code class="literal">
--ssl-mode=PREFERRED
</code>
setting for
replication. If
<code class="literal">
SOURCE_SSL=0
</code>
is set, this
corresponds to
<code class="literal">
--ssl-mode=DISABLED
</code>
.
</p>
<div class="important" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Important
</div>
<p>
To help prevent sophisticated man-in-the-middle attacks,
it is important for the replica to verify the server’s
identity. You can specify additional
<code class="literal">
SOURCE_SSL_
<em class="replaceable">
<code>
xxx
</code>
</em>
</code>
options to correspond to the settings
<code class="literal">
--ssl-mode=VERIFY_CA
</code>
and
<code class="literal">
--ssl-mode=VERIFY_IDENTITY
</code>
, which are a
better choice than the default setting to help prevent
this type of attack. With these settings, the replica
checks that the server’s certificate is valid, and
checks that the host name the replica is using matches the
identity in the server’s certificate. To implement one
of these levels of verification, you must first ensure
that the CA certificate for the server is reliably
available to the replica, otherwise availability issues
will result. For this reason, they are not the default
setting.
</p>
</div>
</li>
<li class="listitem">
<p>
<a name="crs-opt-source_ssl_xxx">
</a>
<a class="link" href="change-replication-source-to.html#crs-opt-source_ssl_xxx">
<code class="literal">
SOURCE_SSL_
<em class="replaceable">
<code>
xxx
</code>
</em>
</code>
</a>
,
<a class="link" href="change-replication-source-to.html#crs-opt-source_ssl_xxx">
<code class="literal">
SOURCE_TLS_
<em class="replaceable">
<code>
xxx
</code>
</em>
</code>
</a>
</p>
<p>
Specify how the replica uses encryption and ciphers to
secure the replication connection. These options can be
changed even on replicas that are compiled without SSL
support. They are saved to the source metadata repository,
but are ignored if the replica does not have SSL support
enabled. The maximum length of the value for the
string-valued
<code class="literal">
SOURCE_SSL_
<em class="replaceable">
<code>
xxx
</code>
</em>
</code>
and
<code class="literal">
SOURCE_TLS_
<em class="replaceable">
<code>
xxx
</code>
</em>
</code>
options is 511 characters, with the exception of
<a class="link" href="change-replication-source-to.html#crs-opt-source_ssl_xxx">
<code class="literal">
SOURCE_TLS_CIPHERSUITES
</code>
</a>
,
for which it is 4000 characters.
</p>
<p>
The
<code class="literal">
SOURCE_SSL_
<em class="replaceable">
<code>
xxx
</code>
</em>
</code>
and
<code class="literal">
SOURCE_TLS_
<em class="replaceable">
<code>
xxx
</code>
</em>
</code>
options perform the same functions as the
<code class="option">
--ssl-
<em class="replaceable">
<code>
xxx
</code>
</em>
</code>
and
<code class="option">
--tls-
<em class="replaceable">
<code>
xxx
</code>
</em>
</code>
client
options described in
<a class="xref" href="connection-options.html#encrypted-connection-options" title="Command Options for Encrypted Connections">
Command Options for Encrypted Connections
</a>
. The
correspondence between the two sets of options, and the use
of the
<code class="literal">
SOURCE_SSL_
<em class="replaceable">
<code>
xxx
</code>
</em>
</code>
and
<code class="literal">
SOURCE_TLS_
<em class="replaceable">
<code>
xxx
</code>
</em>
</code>
options to set up a secure connection, is explained in
<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>
<a name="crs-opt-source_user">
</a>
<a class="link" href="change-replication-source-to.html#crs-opt-source_user">
<code class="literal">
SOURCE_USER =
'
<em class="replaceable">
<code>
user_name
</code>
</em>
'
</code>
</a>
</p>
<p>
The user name for the replication user account to use for
connecting to the replication source server. The maximum
length of the string value is 96 characters.
</p>
<p>
For Group Replication, this account must exist on every
member of the replication group. It is used for distributed
recovery if the XCom communication stack is in use for the
group, and also used for group communication connections if
the MySQL communication stack is in use for the group. With
the MySQL communication stack, the account must have the
<a class="link" href="privileges-provided.html#priv_group-replication-stream">
<code class="literal">
GROUP_REPLICATION_STREAM
</code>
</a>
permission.
</p>
<p>
It is possible to set an empty user name by specifying
<code class="literal">
SOURCE_USER=''
</code>
, but the replication
channel cannot be started with an empty user name. It is
valid to set an empty
<code class="literal">
SOURCE_USER
</code>
user
name and use the channel afterwards if you always provide
user credentials using the
<a class="link" href="start-replica.html" title="15.4.2.4 START REPLICA Statement">
<code class="literal">
START
REPLICA
</code>
</a>
statement or
<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>
statement that starts the
replication channel. This approach means that the
replication channel always needs operator intervention to
restart, but the user credentials are not recorded in the
replication metadata repositories.
</p>
<div class="important" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Important
</div>
<p>
To connect to the source using a replication user account
that authenticates with the
<code class="literal">
caching_sha2_password
</code>
plugin, you must
either set up a secure connection as described in
<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>
, or
enable the unencrypted connection to support password
exchange using an RSA key pair. The
<code class="literal">
caching_sha2_password
</code>
authentication
plugin is the default for new users (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>
).
If the user account that you create or use for replication
uses this authentication plugin, and you are not using a
secure connection, you must enable RSA key pair-based
password exchange for a successful connection. You can do
this using either the
<code class="literal">
SOURCE_PUBLIC_KEY_PATH
</code>
option or the
<code class="literal">
GET_SOURCE_PUBLIC_KEY=1
</code>
option for this
statement.
</p>
</div>
</li>
<li class="listitem">
<p>
<a name="crs-opt-source_zstd_compression_level">
</a>
<a class="link" href="change-replication-source-to.html#crs-opt-source_zstd_compression_level">
<code class="literal">
SOURCE_ZSTD_COMPRESSION_LEVEL =
<em class="replaceable">
<code>
level
</code>
</em>
</code>
</a>
</p>
<p>
The compression level to use for connections to the
replication source 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 level is 3.
</p>
<p>
The compression level setting has no effect on connections
that do not use
<code class="literal">
zstd
</code>
compression. 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>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="idm46045177168160">
</a>
Examples
</h5>
</div>
</div>
</div>
<p>
<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>
is
useful for setting up a replica when you have the snapshot of
the source and have recorded the source's binary log
coordinates corresponding to the time of the snapshot. After
loading the snapshot into the replica to synchronize it with
the source, you can run
<code class="literal">
CHANGE REPLICATION SOURCE TO
SOURCE_LOG_FILE='
<em class="replaceable">
<code>
log_name
</code>
</em>
',
SOURCE_LOG_POS=
<em class="replaceable">
<code>
log_pos
</code>
</em>
</code>
on
the replica to specify the coordinates at which the replica
should begin reading the source's binary log. The following
example changes the source server the replica uses and
establishes the source's binary log coordinates from which the
replica begins reading:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa12723896"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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">SOURCE</span> <span class="token keyword">TO</span>
<span class="token keyword">SOURCE_HOST</span><span class="token operator">=</span><span class="token string">'source2.example.com'</span><span class="token punctuation">,</span>
<span class="token keyword">SOURCE_USER</span><span class="token operator">=</span><span class="token string">'replication'</span><span class="token punctuation">,</span>
<span class="token keyword">SOURCE_PASSWORD</span><span class="token operator">=</span><span class="token string">'<em class="replaceable">password</em>'</span><span class="token punctuation">,</span>
<span class="token keyword">SOURCE_PORT</span><span class="token operator">=</span><span class="token number">3306</span><span class="token punctuation">,</span>
<span class="token keyword">SOURCE_LOG_FILE</span><span class="token operator">=</span><span class="token string">'source2-bin.001'</span><span class="token punctuation">,</span>
<span class="token keyword">SOURCE_LOG_POS</span><span class="token operator">=</span><span class="token number">4</span><span class="token punctuation">,</span>
<span class="token keyword">SOURCE_CONNECT_RETRY</span><span class="token operator">=</span><span class="token number">10</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
For the procedure to switch an existing replica to a new
source during failover, see
<a class="xref" href="replication-solutions-switch.html" title="19.4.8 Switching Sources During Failover">
Section 19.4.8, “Switching Sources During Failover”
</a>
.
</p>
<p>
When GTIDs are in use on the source and the replica, specify
GTID auto-positioning instead of giving the binary log file
position, as in the following example. For full instructions
to configure and start GTID-based replication on new or
stopped servers, online servers, or additional replicas, see
<a class="xref" href="replication-gtids.html" title="19.1.3 Replication with Global Transaction Identifiers">
Section 19.1.3, “Replication with Global Transaction Identifiers”
</a>
.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa73266379"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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">SOURCE</span> <span class="token keyword">TO</span>
<span class="token keyword">SOURCE_HOST</span><span class="token operator">=</span><span class="token string">'source3.example.com'</span><span class="token punctuation">,</span>
<span class="token keyword">SOURCE_USER</span><span class="token operator">=</span><span class="token string">'replication'</span><span class="token punctuation">,</span>
<span class="token keyword">SOURCE_PASSWORD</span><span class="token operator">=</span><span class="token string">'<em class="replaceable">password</em>'</span><span class="token punctuation">,</span>
<span class="token keyword">SOURCE_PORT</span><span class="token operator">=</span><span class="token number">3306</span><span class="token punctuation">,</span>
<span class="token keyword">SOURCE_AUTO_POSITION</span> <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">,</span>
<span class="token keyword">FOR</span> <span class="token keyword">CHANNEL</span> <span class="token string">"source_3"</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
In this example, multi-source replication is in use, and 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 applied to the replication channel
<code class="literal">
"source_3"
</code>
that connects the replica to the
specified host. For guidance on setting up multi-source
replication, see
<a class="xref" href="replication-multi-source.html" title="19.1.5 MySQL Multi-Source Replication">
Section 19.1.5, “MySQL Multi-Source Replication”
</a>
.
</p>
<p>
The next example shows how to make the replica apply
transactions from relay log files that you want to repeat. To
do this, the source need not be reachable. You can use
<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>
to
locate the relay log position where you want the replica to
start reapplying transactions, and then start the SQL thread:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa33778499"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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">SOURCE</span> <span class="token keyword">TO</span>
<span class="token keyword">RELAY_LOG_FILE</span><span class="token operator">=</span><span class="token string">'replica-relay-bin.006'</span><span class="token punctuation">,</span>
<span class="token keyword">RELAY_LOG_POS</span><span class="token operator">=</span><span class="token number">4025</span><span class="token punctuation">;</span>
<span class="token keyword">START</span> <span class="token keyword">REPLICA</span> <span class="token keyword">SQL_THREAD</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
<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>
can also be used to skip over transactions in the binary log
that are causing replication to stop. The appropriate method
to do this depends on whether GTIDs are in use or not. For
instructions to skip transactions using
<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>
or
another method, see
<a class="xref" href="replication-administration-skip.html" title="19.1.7.3 Skipping Transactions">
Section 19.1.7.3, “Skipping Transactions”
</a>
.
</p>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/sys-io-global-by-wait-by-latency.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="sys-io-global-by-wait-by-latency">
</a>
30.4.3.14 The io_global_by_wait_by_latency and x$io_global_by_wait_by_latency
Views
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045062933232">
</a>
<a class="indexterm" name="idm46045062931776">
</a>
<a class="indexterm" name="idm46045062930272">
</a>
<a class="indexterm" name="idm46045062928768">
</a>
<p>
These views summarize global I/O consumers to display amount
of I/O and time waiting for I/O, grouped by event. By default,
rows are sorted by descending total latency.
</p>
<p>
The
<a class="link" href="sys-io-global-by-wait-by-latency.html" title="30.4.3.14 The io_global_by_wait_by_latency and x$io_global_by_wait_by_latency Views">
<code class="literal">
io_global_by_wait_by_latency
</code>
</a>
and
<a class="link" href="sys-io-global-by-wait-by-latency.html" title="30.4.3.14 The io_global_by_wait_by_latency and x$io_global_by_wait_by_latency Views">
<code class="literal">
x$io_global_by_wait_by_latency
</code>
</a>
views have these columns:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
event_name
</code>
</p>
<p>
The I/O event name, with the
<code class="literal">
wait/io/file/
</code>
prefix stripped.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
total
</code>
</p>
<p>
The total number of occurrences of the I/O event.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
total_latency
</code>
</p>
<p>
The total wait time of timed occurrences of the I/O event.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
avg_latency
</code>
</p>
<p>
The average wait time per timed occurrence of the I/O
event.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
max_latency
</code>
</p>
<p>
The maximum single wait time of timed occurrences of the
I/O event.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
read_latency
</code>
</p>
<p>
The total wait time of timed read occurrences of the I/O
event.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
write_latency
</code>
</p>
<p>
The total wait time of timed write occurrences of the I/O
event.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
misc_latency
</code>
</p>
<p>
The total wait time of timed other occurrences of the I/O
event.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
count_read
</code>
</p>
<p>
The number of read requests for the I/O event.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
total_read
</code>
</p>
<p>
The number of bytes read for the I/O event.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
avg_read
</code>
</p>
<p>
The average number of bytes per read for the I/O event.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
count_write
</code>
</p>
<p>
The number of write requests for the I/O event.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
total_written
</code>
</p>
<p>
The number of bytes written for the I/O event.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
avg_written
</code>
</p>
<p>
The average number of bytes per write for the I/O event.
</p>
</li>
</ul>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/mysql-batch-commands.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="mysql-batch-commands">
</a>
6.5.1.5 Executing SQL Statements from a Text File
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045317349712">
</a>
<a class="indexterm" name="idm46045317348640">
</a>
<a class="indexterm" name="idm46045317347152">
</a>
<a class="indexterm" name="idm46045317345664">
</a>
<a class="indexterm" name="idm46045317344176">
</a>
<a class="indexterm" name="idm46045317342688">
</a>
<a class="indexterm" name="idm46045317341600">
</a>
<a class="indexterm" name="idm46045317340512">
</a>
<a class="indexterm" name="idm46045317339408">
</a>
<p>
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 typically is used
interactively, like this:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa75154790"><div class="copy-help left">Press ⌘+C to 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>
However, it is also possible to put your SQL statements in a
file and then tell
<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 read its input
from that file. To do so, create a text file
<em class="replaceable">
<code>
text_file
</code>
</em>
that contains the
statements you wish to execute. Then invoke
<a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
<span class="command">
<strong>
mysql
</strong>
</span>
</a>
as shown here:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa88779498"><div class="copy-help left">Press ⌘+C to 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">text_file</em></code></pre>
</div>
<p>
If you place a
<code class="literal">
USE
<em class="replaceable">
<code>
db_name
</code>
</em>
</code>
statement as the
first statement in the file, it is unnecessary to specify the
database name on the command line:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa96425436"><div class="copy-help left">Press ⌘+C to 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 < text_file</code></pre>
</div>
<p>
If you are already running
<a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
<span class="command">
<strong>
mysql
</strong>
</span>
</a>
, you can
execute an SQL script file using the
<code class="literal">
source
</code>
command or
<code class="literal">
\.
</code>
command:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa68181178"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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">source</span> <em class="replaceable">file_name</em>
<span class="token prompt">mysql></span> \<span class="token punctuation">.</span> <em class="replaceable">file_name</em></code></pre>
</div>
<p>
Sometimes you may want your script to display progress
information to the user. For this you can insert statements like
this:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa4827551"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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 string">'<info_to_display>'</span> <span class="token keyword">AS</span> <span class="token string">' '</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
The statement shown outputs
<code class="literal">
<info_to_display>
</code>
.
</p>
<p>
You can also invoke
<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_verbose">
<code class="option">
--verbose
</code>
</a>
option, which causes
each statement to be displayed before the result that it
produces.
</p>
<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>
ignores Unicode byte order mark (BOM)
characters at the beginning of input files. Previously, it read
them and sent them to the server, resulting in a syntax error.
Presence of a BOM does not cause
<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
change its default character set. To do that, invoke
<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 an option such as
<a class="link" href="mysql-command-options.html#option_mysql_default-character-set">
<code class="option">
--default-character-set=utf8mb4
</code>
</a>
.
</p>
<p>
For more information about batch mode, see
<a class="xref" href="batch-mode.html" title="5.5 Using mysql in Batch Mode">
Section 5.5, “Using mysql in Batch Mode”
</a>
.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/replication-administration.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="replication-administration">
</a>
19.1.7 Common Replication Administration Tasks
</h3>
</div>
</div>
</div>
<div class="toc">
<dl class="toc">
<dt>
<span class="section">
<a href="replication-administration-status.html">
19.1.7.1 Checking Replication Status
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="replication-administration-pausing.html">
19.1.7.2 Pausing Replication on the Replica
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="replication-administration-skip.html">
19.1.7.3 Skipping Transactions
</a>
</span>
</dt>
</dl>
</div>
<p>
Once replication has been started it executes without requiring
much regular administration. This section describes how to check
the status of replication, how to pause a replica, and how to skip
a failed transaction on a replica.
</p>
<div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Tip
</div>
<p>
To deploy multiple instances of MySQL, you can use
<a class="ulink" href="/doc/mysql-shell/8.4/en/mysql-innodb-cluster.html" target="_top">
InnoDB Cluster
</a>
which enables you to easily administer a group of MySQL server instances in
<a class="ulink" href="/doc/mysql-shell/8.4/en/" target="_top">
MySQL Shell
</a>
. InnoDB Cluster wraps MySQL Group Replication in a programmatic environment that enables you easily deploy a cluster of MySQL instances to achieve high availability. In addition, InnoDB Cluster interfaces seamlessly with
<a class="ulink" href="/doc/mysql-router/8.4/en/" target="_top">
MySQL Router
</a>
, which enables your applications to connect to the cluster without writing your own failover process. For similar use cases that do not require high availability, however, you can use
<a class="ulink" href="/doc/mysql-shell/8.4/en/mysql-innodb-replicaset.html" target="_top">
InnoDB ReplicaSet
</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>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/bit-type.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="bit-type">
</a>
13.1.5 Bit-Value Type - BIT
</h3>
</div>
</div>
</div>
<p>
The
<code class="literal">
BIT
</code>
data type is used to store bit
values. A type of
<code class="literal">
BIT(
<em class="replaceable">
<code>
M
</code>
</em>
)
</code>
enables
storage of
<em class="replaceable">
<code>
M
</code>
</em>
-bit values.
<em class="replaceable">
<code>
M
</code>
</em>
can range from 1 to 64.
</p>
<p>
To specify bit values,
<code class="literal">
b'
<em class="replaceable">
<code>
value
</code>
</em>
'
</code>
notation
can be used.
<em class="replaceable">
<code>
value
</code>
</em>
is a binary value
written using zeros and ones. For example,
<code class="literal">
b'111'
</code>
and
<code class="literal">
b'10000000'
</code>
represent 7 and 128, respectively. See
<a class="xref" href="bit-value-literals.html" title="11.1.5 Bit-Value Literals">
Section 11.1.5, “Bit-Value Literals”
</a>
.
</p>
<p>
If you assign a value to a
<code class="literal">
BIT(
<em class="replaceable">
<code>
M
</code>
</em>
)
</code>
column that
is less than
<em class="replaceable">
<code>
M
</code>
</em>
bits long, the value
is padded on the left with zeros. For example, assigning a value
of
<code class="literal">
b'101'
</code>
to a
<code class="literal">
BIT(6)
</code>
column is, in effect, the same as assigning
<code class="literal">
b'000101'
</code>
.
</p>
<p>
<b>
NDB Cluster.
</b>
The maximum combined size of all
<code class="literal">
BIT
</code>
columns used in a given
<a class="link" href="mysql-cluster.html" title="Chapter 25 MySQL NDB Cluster 8.4">
<code class="literal">
NDB
</code>
</a>
table
must not exceed 4096 bits.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/adding-collation.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h2 class="title">
<a name="adding-collation">
</a>
12.14 Adding a Collation to a Character Set
</h2>
</div>
</div>
</div>
<div class="toc">
<dl class="toc">
<dt>
<span class="section">
<a href="charset-collation-implementations.html">
12.14.1 Collation Implementation Types
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="adding-collation-choosing-id.html">
12.14.2 Choosing a Collation ID
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="adding-collation-simple-8bit.html">
12.14.3 Adding a Simple Collation to an 8-Bit Character Set
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="adding-collation-unicode-uca.html">
12.14.4 Adding a UCA Collation to a Unicode Character Set
</a>
</span>
</dt>
</dl>
</div>
<a class="indexterm" name="idm46045215283088">
</a>
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Warning
</div>
<p>
User-defined collations are deprecated; you should expect
support for them to be removed in a future version of MySQL. The
MySQL 8.4 server issues a warning for any use of
<code class="literal">
COLLATE
<em class="replaceable">
<code>
user_defined_collation
</code>
</em>
</code>
in
an SQL statement; a warning is also issued when the server is
started with
<a class="link" href="server-system-variables.html#sysvar_collation_server">
<code class="option">
--collation-server
</code>
</a>
set equal to the name of a user-defined collation.
</p>
</div>
<p>
A collation is a set of rules that defines how to compare and sort
character strings. Each collation in MySQL belongs to a single
character set. Every character set has at least one collation, and
most have two or more collations.
</p>
<p>
A collation orders characters based on weights. Each character in
a character set maps to a weight. Characters with equal weights
compare as equal, and characters with unequal weights compare
according to the relative magnitude of their weights.
</p>
<p>
The
<a class="link" href="string-functions.html#function_weight-string">
<code class="literal">
WEIGHT_STRING()
</code>
</a>
function can be
used to see the weights for the characters in a string. The value
that it returns to indicate weights is a binary string, so it is
convenient to use
<code class="literal">
HEX(WEIGHT_STRING(
<em class="replaceable">
<code>
str
</code>
</em>
))
</code>
to display the weights in printable form. The following example
shows that weights do not differ for lettercase for the letters in
<code class="literal">
'AaBb'
</code>
if it is a nonbinary case-insensitive
string, but do differ if it is a binary string:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa37251663"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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">HEX</span><span class="token punctuation">(</span><span class="token function">WEIGHT_STRING</span><span class="token punctuation">(</span><span class="token string">'AaBb'</span> <span class="token keyword">COLLATE</span> latin1_swedish_ci<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>
<span class="token output"><span class="token punctuation">|</span> HEX(WEIGHT_STRING('AaBb' COLLATE latin1_swedish_ci)) <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>
<span class="token output"><span class="token punctuation">|</span> 41414242 <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>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token function">HEX</span><span class="token punctuation">(</span><span class="token function">WEIGHT_STRING</span><span class="token punctuation">(</span><span class="token datatype">BINARY</span> <span class="token string">'AaBb'</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>
<span class="token output"><span class="token punctuation">|</span> HEX(WEIGHT_STRING(BINARY 'AaBb')) <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>
<span class="token output"><span class="token punctuation">|</span> 41614262 <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></code></pre>
</div>
<p>
MySQL supports several collation implementations, as discussed in
<a class="xref" href="charset-collation-implementations.html" title="12.14.1 Collation Implementation Types">
Section 12.14.1, “Collation Implementation Types”
</a>
. Some of these
can be added to MySQL without recompiling:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Simple collations for 8-bit character sets.
</p>
</li>
<li class="listitem">
<p>
UCA-based collations for Unicode character sets.
</p>
</li>
<li class="listitem">
<p>
Binary (
<code class="literal">
<em class="replaceable">
<code>
xxx
</code>
</em>
_bin
</code>
)
collations.
</p>
</li>
</ul>
</div>
<p>
The following sections describe how to add user-defined collations
of the first two types to existing character sets. All existing
character sets already have a binary collation, so there is no
need here to describe how to add one.
</p>
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Warning
</div>
<p>
Redefining built-in collations is not supported and may result
in unexpected server behavior.
</p>
</div>
<p>
Summary of the procedure for adding a new user-defined collation:
</p>
<div class="orderedlist">
<ol class="orderedlist" type="1">
<li class="listitem">
<p>
Choose a collation ID.
</p>
</li>
<li class="listitem">
<p>
Add configuration information that names the collation and
describes the character-ordering rules.
</p>
</li>
<li class="listitem">
<p>
Restart the server.
</p>
</li>
<li class="listitem">
<p>
Verify that the server recognizes the collation.
</p>
</li>
</ol>
</div>
<p>
The instructions here cover only user-defined collations that can
be added without recompiling MySQL. To add a collation that does
require recompiling (as implemented by means of functions in a C
source file), use the instructions in
<a class="xref" href="adding-character-set.html" title="12.13 Adding a Character Set">
Section 12.13, “Adding a Character Set”
</a>
. However, instead of adding
all the information required for a complete character set, just
modify the appropriate files for an existing character set. That
is, based on what is already present for the character set's
current collations, add data structures, functions, and
configuration information for the new collation.
</p>
<a class="indexterm" name="idm46045215255920">
</a>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
If you modify an existing user-defined collation, that may
affect the ordering of rows for indexes on columns that use the
collation. In this case, rebuild any such indexes to avoid
problems such as incorrect query results. 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>
</div>
<h3>
<a name="idm46045215252736">
</a>
Additional Resources
</h3>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Example showing how to add a collation for full-text searches:
<a class="xref" href="full-text-adding-collation.html" title="14.9.7 Adding a User-Defined Collation for Full-Text Indexing">
Section 14.9.7, “Adding a User-Defined Collation for Full-Text Indexing”
</a>
</p>
</li>
<li class="listitem">
<p>
The Unicode Collation Algorithm (UCA) specification:
<a class="ulink" href="http://www.unicode.org/reports/tr10/" target="_blank">
http://www.unicode.org/reports/tr10/
</a>
</p>
</li>
<li class="listitem">
<p>
The Locale Data Markup Language (LDML) specification:
<a class="ulink" href="http://www.unicode.org/reports/tr35/" target="_blank">
http://www.unicode.org/reports/tr35/
</a>
</p>
</li>
</ul>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/derived-condition-pushdown-optimization.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="derived-condition-pushdown-optimization">
</a>
10.2.2.5 Derived Condition Pushdown Optimization
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045227846928">
</a>
<a class="indexterm" name="idm46045227845840">
</a>
<p>
MySQL supports derived condition pushdown for eligible
subqueries. For a query such as
<code class="literal">
SELECT * FROM (SELECT
i, j FROM t1) AS dt WHERE i >
<em class="replaceable">
<code>
constant
</code>
</em>
</code>
, it is possible
in many cases to push the outer
<code class="literal">
WHERE
</code>
condition down to the derived table, in this case resulting in
<code class="literal">
SELECT * FROM (SELECT i, j FROM t1 WHERE i >
<em class="replaceable">
<code>
constant
</code>
</em>
) AS dt
</code>
. When a
derived table cannot be merged into the outer query (for
example, if the derived table uses aggregation), pushing the
outer
<code class="literal">
WHERE
</code>
condition down to the derived
table should decrease the number of rows that need to be
processed and thus speed up execution of the query.
</p>
<p>
Outer
<code class="literal">
WHERE
</code>
conditions can be pushed down
to derived materialized tables under the following
circumstances:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
When the derived table uses no aggregate or window
functions, the outer
<code class="literal">
WHERE
</code>
condition
can be pushed down to it directly. This includes
<code class="literal">
WHERE
</code>
conditions having multiple
predicates joined with
<code class="literal">
AND
</code>
,
<code class="literal">
OR
</code>
, or both.
</p>
<p>
For example, the query
<code class="literal">
SELECT * FROM (SELECT f1,
f2 FROM t1) AS dt WHERE f1 < 3 AND f2 > 11
</code>
is rewritten as
<code class="literal">
SELECT f1, f2 FROM (SELECT f1, f2
FROM t1 WHERE f1 < 3 AND f2 > 11) AS dt
</code>
.
</p>
</li>
<li class="listitem">
<p>
When the derived table has a
<code class="literal">
GROUP BY
</code>
and uses no window functions, an outer
<code class="literal">
WHERE
</code>
condition referencing one or more
columns which are not part of the
<code class="literal">
GROUP
BY
</code>
can be pushed down to the derived table as a
<code class="literal">
HAVING
</code>
condition.
</p>
<p>
For example,
<code class="literal">
SELECT * FROM (SELECT i, j, SUM(k)
AS sum FROM t1 GROUP BY i, j) AS dt WHERE sum >
100
</code>
is rewritten following derived condition
pushdown as
<code class="literal">
SELECT * FROM (SELECT i, j, SUM(k) AS
sum FROM t1 GROUP BY i, j HAVING sum > 100) AS
dt
</code>
.
</p>
</li>
<li class="listitem">
<p>
When the derived table uses a
<code class="literal">
GROUP BY
</code>
and the columns in the outer
<code class="literal">
WHERE
</code>
condition are
<code class="literal">
GROUP BY
</code>
columns, the
<code class="literal">
WHERE
</code>
conditions referencing those
columns can be pushed down directly to the derived table.
</p>
<p>
For example, the query
<code class="literal">
SELECT * FROM (SELECT i,j,
SUM(k) AS sum FROM t1 GROUP BY i,j) AS dt WHERE i >
10
</code>
is rewritten as
<code class="literal">
SELECT * FROM
(SELECT i,j, SUM(k) AS sum FROM t1 WHERE i > 10 GROUP
BY i,j) AS dt
</code>
.
</p>
<p>
In the event that the outer
<code class="literal">
WHERE
</code>
condition has predicates referencing columns which are
part of the
<code class="literal">
GROUP BY
</code>
as well as
predicates referencing columns which are not, predicates
of the former sort are pushed down as
<code class="literal">
WHERE
</code>
conditions, while those of the
latter type are pushed down as
<code class="literal">
HAVING
</code>
conditions. For example, in the query
<code class="literal">
SELECT *
FROM (SELECT i, j, SUM(k) AS sum FROM t1 GROUP BY i,j) AS
dt WHERE i > 10 AND sum > 100
</code>
, the
predicate
<code class="literal">
i > 10
</code>
in the outer
<code class="literal">
WHERE
</code>
clause references a
<code class="literal">
GROUP BY
</code>
column, whereas the predicate
<code class="literal">
sum > 100
</code>
does not reference any
<code class="literal">
GROUP BY
</code>
column. Thus the derived table
pushdown optimization causes the query to be rewritten in
a manner similar to what is shown here:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa94714223"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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">SELECT</span> i<span class="token punctuation">,</span> j<span class="token punctuation">,</span> <span class="token function">SUM</span><span class="token punctuation">(</span>k<span class="token punctuation">)</span> <span class="token keyword">AS</span> sum <span class="token keyword">FROM</span> t1
<span class="token keyword">WHERE</span> i <span class="token operator">></span> <span class="token number">10</span>
<span class="token keyword">GROUP</span> <span class="token keyword">BY</span> i<span class="token punctuation">,</span> j
<span class="token keyword">HAVING</span> sum <span class="token operator">></span> <span class="token number">100</span>
<span class="token punctuation">)</span> <span class="token keyword">AS</span> dt<span class="token punctuation">;</span></code></pre>
</div>
</li>
</ul>
</div>
<p>
To enable derived condition pushdown, the
<a class="link" href="server-system-variables.html#sysvar_optimizer_switch">
<code class="literal">
optimizer_switch
</code>
</a>
system
variable's
<a class="link" href="switchable-optimizations.html#optflag_derived-condition-pushdown">
<code class="literal">
derived_condition_pushdown
</code>
</a>
flag (added in this release) must be set to
<code class="literal">
on
</code>
, which is the default setting. If this
optimization is disabled by
<code class="literal">
optimizer_switch
</code>
, you can enable it for a
specific query using the
<a class="link" href="optimizer-hints.html#optimizer-hints-table-level" title="Table-Level Optimizer Hints">
<code class="literal">
DERIVED_CONDITION_PUSHDOWN
</code>
</a>
optimizer hint. To disable the optimization for a given query,
use the
<a class="link" href="optimizer-hints.html#optimizer-hints-table-level" title="Table-Level Optimizer Hints">
<code class="literal">
NO_DERIVED_CONDITION_PUSHDOWN
</code>
</a>
optimizer hint.
</p>
<p>
The following restrictions and limitations apply to the
derived table condition pushdown optimization:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
The derived table condition pushdown optimization can be
employed with
<code class="literal">
UNION
</code>
queries, with the
following exceptions:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
Condition pushdown cannot be used with a
<code class="literal">
UNION
</code>
query if any materialized
derived table that is part of the
<code class="literal">
UNION
</code>
is a recursive common table
expression (see
<a class="xref" href="with.html#common-table-expressions-recursive" title="Recursive Common Table Expressions">
Recursive Common Table Expressions
</a>
).
</p>
</li>
<li class="listitem">
<p>
Conditions containing nondeterministic expressions
cannot be pushed down to a derived table.
</p>
</li>
</ul>
</div>
</li>
<li class="listitem">
<p>
The derived table cannot use a
<code class="literal">
LIMIT
</code>
clause.
</p>
</li>
<li class="listitem">
<p>
Conditions containing subqueries cannot be pushed down.
</p>
</li>
<li class="listitem">
<p>
The optimization cannot be used if the derived table is an
inner table of an outer join.
</p>
</li>
<li class="listitem">
<p>
If a materialized derived table is a common table
expression, conditions are not pushed down to it if it is
referenced multiple times.
</p>
</li>
<li class="listitem">
<p>
Conditions using parameters can be pushed down if the
condition is of the form
<code class="literal">
<em class="replaceable">
<code>
derived_column
</code>
</em>
>
?
</code>
. If a derived column in an outer
<code class="literal">
WHERE
</code>
condition is an expression having
a
<code class="literal">
?
</code>
in the underlying derived table,
this condition cannot be pushed down.
</p>
</li>
<li class="listitem">
<p>
For a query in which the condition is on the tables of a
view created using
<code class="literal">
ALGORITHM=TEMPTABLE
</code>
instead of on the view itself, the multiple equality is
not recognized at resolution, and thus the condition
cannot be not pushed down. This because, when optimizing a
query, condition pushdown takes place during resolution
phase while multiple equality propagation occurs during
optimization.
</p>
<p>
This is not an issue in such cases for a view using
<code class="literal">
ALGORITHM=MERGE
</code>
, where the equality can
be propagated and the condition pushed down.
</p>
</li>
<li class="listitem">
<p>
A condition cannot be pushed down if the derived
table's
<code class="literal">
SELECT
</code>
list contain any
assignments to user variables.
</p>
</li>
</ul>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/general-thread-states.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="general-thread-states">
</a>
10.14.3 General Thread States
</h3>
</div>
</div>
</div>
<a class="indexterm" name="idm46045221803744">
</a>
<p>
The following list describes thread
<code class="literal">
State
</code>
values that are associated with general query processing and not
more specialized activities such as replication. Many of these
are useful only for finding bugs in the server.
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="indexterm" name="idm46045221800128">
</a>
<a class="indexterm" name="idm46045221798640">
</a>
<code class="literal">
After create
</code>
</p>
<p>
This occurs when the thread creates a table (including
internal temporary tables), at the end of the function that
creates the table. This state is used even if the table
could not be created due to some error.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045221795024">
</a>
<a class="indexterm" name="idm46045221793536">
</a>
<code class="literal">
altering table
</code>
</p>
<p>
The server is in the process of executing an in-place
<a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
<code class="literal">
ALTER TABLE
</code>
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045221788880">
</a>
<a class="indexterm" name="idm46045221787392">
</a>
<code class="literal">
Analyzing
</code>
</p>
<p>
The thread is calculating a
<code class="literal">
MyISAM
</code>
table
key distributions (for example, for
<a class="link" href="analyze-table.html" title="15.7.3.1 ANALYZE TABLE Statement">
<code class="literal">
ANALYZE TABLE
</code>
</a>
).
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045221782000">
</a>
<a class="indexterm" name="idm46045221780512">
</a>
<code class="literal">
checking permissions
</code>
</p>
<p>
The thread is checking whether the server has the required
privileges to execute the statement.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045221777040">
</a>
<a class="indexterm" name="idm46045221775552">
</a>
<code class="literal">
Checking table
</code>
</p>
<p>
The thread is performing a table check operation.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045221772128">
</a>
<a class="indexterm" name="idm46045221770640">
</a>
<code class="literal">
cleaning up
</code>
</p>
<p>
The thread has processed one command and is preparing to
free memory and reset certain state variables.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045221767152">
</a>
<a class="indexterm" name="idm46045221765664">
</a>
<code class="literal">
closing tables
</code>
</p>
<p>
The thread is flushing the changed table data to disk and
closing the used tables. This should be a fast operation. If
not, verify that you do not have a full disk and that the
disk is not in very heavy use.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045221762048">
</a>
<a class="indexterm" name="idm46045221760528">
</a>
<code class="literal">
committing alter table to storage engine
</code>
</p>
<p>
The server has finished an in-place
<a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
<code class="literal">
ALTER TABLE
</code>
</a>
and is committing
the result.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045221755792">
</a>
<a class="indexterm" name="idm46045221754288">
</a>
<code class="literal">
converting HEAP to ondisk
</code>
</p>
<p>
The thread is converting an internal temporary table from a
<code class="literal">
MEMORY
</code>
table to an on-disk table.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045221750096">
</a>
<a class="indexterm" name="idm46045221748608">
</a>
<code class="literal">
copy to tmp table
</code>
</p>
<p>
The thread is processing an
<a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
<code class="literal">
ALTER
TABLE
</code>
</a>
statement. This state occurs after the table
with the new structure has been created but before rows are
copied into it.
</p>
<p>
For a thread in this state, the Performance Schema can be
used to obtain about the progress of the copy operation. See
<a class="xref" href="performance-schema-stage-tables.html" title="29.12.5 Performance Schema Stage Event Tables">
Section 29.12.5, “Performance Schema Stage Event Tables”
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045221742528">
</a>
<a class="indexterm" name="idm46045221741040">
</a>
<code class="literal">
Copying to group table
</code>
</p>
<p>
If a statement has different
<code class="literal">
ORDER BY
</code>
and
<code class="literal">
GROUP BY
</code>
criteria, the rows are sorted by
group and copied to a temporary table.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045221736128">
</a>
<a class="indexterm" name="idm46045221734640">
</a>
<code class="literal">
Copying to tmp table
</code>
</p>
<p>
The server is copying to a temporary table in memory.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045221731216">
</a>
<a class="indexterm" name="idm46045221729760">
</a>
<code class="literal">
Copying to tmp table on disk
</code>
</p>
<p>
The server is copying to a temporary table on disk. The
temporary result set has become too large (see
<a class="xref" href="internal-temporary-tables.html" title="10.4.4 Internal Temporary Table Use in MySQL">
Section 10.4.4, “Internal Temporary Table Use in MySQL”
</a>
). Consequently,
the thread is changing the temporary table from in-memory to
disk-based format to save memory.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045221725360">
</a>
<a class="indexterm" name="idm46045221723872">
</a>
<code class="literal">
Creating index
</code>
</p>
<p>
The thread is processing
<code class="literal">
ALTER TABLE ... ENABLE
KEYS
</code>
for a
<code class="literal">
MyISAM
</code>
table.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045221719088">
</a>
<a class="indexterm" name="idm46045221717600">
</a>
<code class="literal">
Creating sort index
</code>
</p>
<p>
The thread is processing a
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
that is resolved using
an internal temporary table.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045221712912">
</a>
<a class="indexterm" name="idm46045221711424">
</a>
<code class="literal">
creating table
</code>
</p>
<p>
The thread is creating a table. This includes creation of
temporary tables.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045221707968">
</a>
<a class="indexterm" name="idm46045221706480">
</a>
<code class="literal">
Creating tmp table
</code>
</p>
<p>
The thread is creating a temporary table in memory or on
disk. If the table is created in memory but later is
converted to an on-disk table, the state during that
operation is
<code class="literal">
Copying to tmp table on
disk
</code>
.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045221702160">
</a>
<a class="indexterm" name="idm46045221700656">
</a>
<code class="literal">
deleting from main table
</code>
</p>
<p>
The server is executing the first part of a multiple-table
delete. It is deleting only from the first table, and saving
columns and offsets to be used for deleting from the other
(reference) tables.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045221697024">
</a>
<a class="indexterm" name="idm46045221695520">
</a>
<code class="literal">
deleting from reference tables
</code>
</p>
<p>
The server is executing the second part of a multiple-table
delete and deleting the matched rows from the other tables.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045221691984">
</a>
<a class="indexterm" name="idm46045221690480">
</a>
<code class="literal">
discard_or_import_tablespace
</code>
</p>
<p>
The thread is processing an
<code class="literal">
ALTER TABLE ... DISCARD
TABLESPACE
</code>
or
<code class="literal">
ALTER TABLE ... IMPORT
TABLESPACE
</code>
statement.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045221685552">
</a>
<a class="indexterm" name="idm46045221684096">
</a>
<code class="literal">
end
</code>
</p>
<p>
This occurs at the end but before the cleanup of
<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-view.html" title="15.1.23 CREATE VIEW Statement">
<code class="literal">
CREATE VIEW
</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="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
, or
<a class="link" href="update.html" title="15.2.17 UPDATE Statement">
<code class="literal">
UPDATE
</code>
</a>
statements.
</p>
<p>
For the
<code class="literal">
end
</code>
state, the following
operations could be happening:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
Writing an event to the binary log
</p>
</li>
<li class="listitem">
<p>
Freeing memory buffers, including for blobs
</p>
</li>
</ul>
</div>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045221670080">
</a>
<a class="indexterm" name="idm46045221668592">
</a>
<code class="literal">
executing
</code>
</p>
<p>
The thread has begun executing a statement.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045221665184">
</a>
<a class="indexterm" name="idm46045221663680">
</a>
<code class="literal">
Execution of init_command
</code>
</p>
<p>
The thread is executing statements in the value of the
<code class="literal">
init_command
</code>
system variable.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045221659488">
</a>
<a class="indexterm" name="idm46045221658000">
</a>
<code class="literal">
freeing items
</code>
</p>
<p>
The thread has executed a command. This state is usually
followed by
<code class="literal">
cleaning up
</code>
.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045221653840">
</a>
<a class="indexterm" name="idm46045221652352">
</a>
<code class="literal">
FULLTEXT initialization
</code>
</p>
<p>
The server is preparing to perform a natural-language
full-text search.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045221648896">
</a>
<a class="indexterm" name="idm46045221647408">
</a>
<code class="literal">
init
</code>
</p>
<p>
This occurs before the initialization of
<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="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="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
, or
<a class="link" href="update.html" title="15.2.17 UPDATE Statement">
<code class="literal">
UPDATE
</code>
</a>
statements. Actions
taken by the server in this state include flushing the
binary log and the
<code class="literal">
InnoDB
</code>
log.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045221637024">
</a>
<a class="indexterm" name="idm46045221635536">
</a>
<code class="literal">
Killed
</code>
</p>
<p>
Someone has sent a
<a class="link" href="kill.html" title="15.7.8.4 KILL Statement">
<code class="literal">
KILL
</code>
</a>
statement to the thread and it should abort next time it
checks the kill flag. The flag is checked in each major loop
in MySQL, but in some cases it might still take a short time
for the thread to die. If the thread is locked by some other
thread, the kill takes effect as soon as the other thread
releases its lock.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045221630544">
</a>
<a class="indexterm" name="idm46045221629056">
</a>
<code class="literal">
Locking system tables
</code>
</p>
<p>
The thread is trying to lock a system table (for example, a
time zone or log table).
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045221625584">
</a>
<a class="indexterm" name="idm46045221624096">
</a>
<code class="literal">
logging slow query
</code>
</p>
<p>
The thread is writing a statement to the slow-query log.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045221620672">
</a>
<a class="indexterm" name="idm46045221619184">
</a>
<code class="literal">
login
</code>
</p>
<p>
The initial state for a connection thread until the client
has been authenticated successfully.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045221615712">
</a>
<a class="indexterm" name="idm46045221614224">
</a>
<code class="literal">
manage keys
</code>
</p>
<p>
The server is enabling or disabling a table index.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045221610800">
</a>
<a class="indexterm" name="idm46045221609312">
</a>
<code class="literal">
Opening system tables
</code>
</p>
<p>
The thread is trying to open a system table (for example, a
time zone or log table).
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045221605840">
</a>
<a class="indexterm" name="idm46045221604352">
</a>
<code class="literal">
Opening tables
</code>
</p>
<p>
The thread is trying to open a table. This is should be very
fast procedure, unless something prevents opening. For
example, an
<a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
<code class="literal">
ALTER TABLE
</code>
</a>
or a
<a class="link" href="lock-tables.html" title="15.3.6 LOCK TABLES and UNLOCK TABLES Statements">
<code class="literal">
LOCK
TABLE
</code>
</a>
statement can prevent opening a table until
the statement is finished. It is also worth checking that
your
<a class="link" href="server-system-variables.html#sysvar_table_open_cache">
<code class="literal">
table_open_cache
</code>
</a>
value
is large enough.
</p>
<p>
For system tables, the
<code class="literal">
Opening system
tables
</code>
state is used instead.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045221595824">
</a>
<a class="indexterm" name="idm46045221594336">
</a>
<code class="literal">
optimizing
</code>
</p>
<p>
The server is performing initial optimizations for a query.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045221590912">
</a>
<a class="indexterm" name="idm46045221589424">
</a>
<code class="literal">
preparing
</code>
</p>
<p>
This state occurs during query optimization.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045221586016">
</a>
<a class="indexterm" name="idm46045221584512">
</a>
<code class="literal">
preparing for alter table
</code>
</p>
<p>
The server is preparing to execute an in-place
<a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
<code class="literal">
ALTER TABLE
</code>
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045221579824">
</a>
<a class="indexterm" name="idm46045221578336">
</a>
<code class="literal">
Purging old relay logs
</code>
</p>
<p>
The thread is removing unneeded relay log files.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045221574912">
</a>
<a class="indexterm" name="idm46045221573424">
</a>
<code class="literal">
query end
</code>
</p>
<p>
This state occurs after processing a query but before the
<code class="literal">
freeing items
</code>
state.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045221569280">
</a>
<a class="indexterm" name="idm46045221567792">
</a>
<code class="literal">
Receiving from client
</code>
</p>
<p>
The server is reading a packet from the client.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045221564384">
</a>
<a class="indexterm" name="idm46045221562896">
</a>
<code class="literal">
Removing duplicates
</code>
</p>
<p>
The query was using
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
DISTINCT
</code>
</a>
in such a way that MySQL could not
optimize away the distinct operation at an early stage.
Because of this, MySQL requires an extra stage to remove all
duplicated rows before sending the result to the client.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045221558016">
</a>
<a class="indexterm" name="idm46045221556528">
</a>
<code class="literal">
removing tmp table
</code>
</p>
<p>
The thread is removing an internal temporary table after
processing a
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
statement. This state is not used if no temporary table was
created.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045221551760">
</a>
<a class="indexterm" name="idm46045221550272">
</a>
<code class="literal">
rename
</code>
</p>
<p>
The thread is renaming a table.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045221546880">
</a>
<a class="indexterm" name="idm46045221545392">
</a>
<code class="literal">
rename result table
</code>
</p>
<p>
The thread is processing an
<a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
<code class="literal">
ALTER
TABLE
</code>
</a>
statement, has created the new table, and is
renaming it to replace the original table.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045221540672">
</a>
<a class="indexterm" name="idm46045221539184">
</a>
<code class="literal">
Reopen tables
</code>
</p>
<p>
The thread got a lock for the table, but noticed after
getting the lock that the underlying table structure
changed. It has freed the lock, closed the table, and is
trying to reopen it.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045221535600">
</a>
<a class="indexterm" name="idm46045221534112">
</a>
<code class="literal">
Repair by sorting
</code>
</p>
<p>
The repair code is using a sort to create indexes.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045221530688">
</a>
<a class="indexterm" name="idm46045221529200">
</a>
<code class="literal">
Repair done
</code>
</p>
<p>
The thread has completed a multithreaded repair for a
<code class="literal">
MyISAM
</code>
table.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045221525056">
</a>
<a class="indexterm" name="idm46045221523568">
</a>
<code class="literal">
Repair with keycache
</code>
</p>
<p>
The repair code is using creating keys one by one through
the key cache. This is much slower than
<code class="literal">
Repair by
sorting
</code>
.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045221519360">
</a>
<a class="indexterm" name="idm46045221517872">
</a>
<code class="literal">
Rolling back
</code>
</p>
<p>
The thread is rolling back a transaction.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045221514464">
</a>
<a class="indexterm" name="idm46045221512976">
</a>
<code class="literal">
Saving state
</code>
</p>
<p>
For
<code class="literal">
MyISAM
</code>
table operations such as
repair or analysis, the thread is saving the new table state
to the
<code class="filename">
.MYI
</code>
file header. State includes
information such as number of rows, the
<code class="literal">
AUTO_INCREMENT
</code>
counter, and key
distributions.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045221507248">
</a>
<a class="indexterm" name="idm46045221505744">
</a>
<code class="literal">
Searching rows for update
</code>
</p>
<p>
The thread is doing a first phase to find all matching rows
before updating them. This has to be done if the
<a class="link" href="update.html" title="15.2.17 UPDATE Statement">
<code class="literal">
UPDATE
</code>
</a>
is changing the index
that is used to find the involved rows.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
Sending data
</code>
</p>
<p>
This state is now included in the
<code class="literal">
Executing
</code>
state.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045221498288">
</a>
<a class="indexterm" name="idm46045221496800">
</a>
<code class="literal">
Sending to client
</code>
</p>
<p>
The server is writing a packet to the client.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045221493392">
</a>
<a class="indexterm" name="idm46045221491904">
</a>
<code class="literal">
setup
</code>
</p>
<p>
The thread is beginning an
<a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
<code class="literal">
ALTER
TABLE
</code>
</a>
operation.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045221487280">
</a>
<a class="indexterm" name="idm46045221485792">
</a>
<code class="literal">
Sorting for group
</code>
</p>
<p>
The thread is doing a sort to satisfy a
<code class="literal">
GROUP
BY
</code>
.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045221481680">
</a>
<a class="indexterm" name="idm46045221480192">
</a>
<code class="literal">
Sorting for order
</code>
</p>
<p>
The thread is doing a sort to satisfy an
<code class="literal">
ORDER
BY
</code>
.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045221476080">
</a>
<a class="indexterm" name="idm46045221474592">
</a>
<code class="literal">
Sorting index
</code>
</p>
<p>
The thread is sorting index pages for more efficient access
during a
<code class="literal">
MyISAM
</code>
table optimization
operation.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045221470400">
</a>
<a class="indexterm" name="idm46045221468912">
</a>
<code class="literal">
Sorting result
</code>
</p>
<p>
For a
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
statement, this
is similar to
<code class="literal">
Creating sort index
</code>
, but
for nontemporary tables.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045221463536">
</a>
<a class="indexterm" name="idm46045221462048">
</a>
<code class="literal">
starting
</code>
</p>
<p>
The first stage at the beginning of statement execution.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045221458624">
</a>
<a class="indexterm" name="idm46045221457136">
</a>
<code class="literal">
statistics
</code>
</p>
<p>
The server is calculating statistics to develop a query
execution plan. If a thread is in this state for a long
time, the server is probably disk-bound performing other
work.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045221453552">
</a>
<a class="indexterm" name="idm46045221452480">
</a>
<a class="indexterm" name="idm46045221450992">
</a>
<a class="indexterm" name="idm46045221449504">
</a>
<code class="literal">
System lock
</code>
</p>
<p>
The thread has called
<code class="literal">
mysql_lock_tables()
</code>
and the thread state has not been updated since. This is a
very general state that can occur for many reasons.
</p>
<p>
For example, the thread is going to request or is waiting
for an internal or external system lock for the table. This
can occur when
<a class="link" href="innodb-storage-engine.html" title="Chapter 17 The InnoDB Storage Engine">
<code class="literal">
InnoDB
</code>
</a>
waits for
a table-level lock during execution 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>
. If this state is
being caused by requests for external locks and you are not
using multiple
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
servers that are
accessing the same
<a class="link" href="myisam-storage-engine.html" title="18.2 The MyISAM Storage Engine">
<code class="literal">
MyISAM
</code>
</a>
tables, you can disable external system locks with the
<a class="link" href="server-options.html#option_mysqld_external-locking">
<code class="option">
--skip-external-locking
</code>
</a>
option. However, external locking is disabled by default, so
it is likely that this option has no effect. For
<a class="link" href="show-profile.html" title="15.7.7.32 SHOW PROFILE Statement">
<code class="literal">
SHOW PROFILE
</code>
</a>
, this state
means the thread is requesting the lock (not waiting for
it).
</p>
<p>
For system tables, the
<code class="literal">
Locking system
tables
</code>
state is used instead.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045221435888">
</a>
<a class="indexterm" name="idm46045221434400">
</a>
<code class="literal">
update
</code>
</p>
<p>
The thread is getting ready to start updating the table.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045221430976">
</a>
<a class="indexterm" name="idm46045221429488">
</a>
<code class="literal">
Updating
</code>
</p>
<p>
The thread is searching for rows to update and is updating
them.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045221426048">
</a>
<a class="indexterm" name="idm46045221424560">
</a>
<code class="literal">
updating main table
</code>
</p>
<p>
The server is executing the first part of a multiple-table
update. It is updating only the first table, and saving
columns and offsets to be used for updating the other
(reference) tables.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045221420960">
</a>
<a class="indexterm" name="idm46045221419456">
</a>
<code class="literal">
updating reference tables
</code>
</p>
<p>
The server is executing the second part of a multiple-table
update and updating the matched rows from the other tables.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045221415920">
</a>
<a class="indexterm" name="idm46045221414432">
</a>
<code class="literal">
User lock
</code>
</p>
<p>
The thread is going to request or is waiting for an advisory
lock requested with a
<a class="link" href="locking-functions.html#function_get-lock">
<code class="literal">
GET_LOCK()
</code>
</a>
call. For
<a class="link" href="show-profile.html" title="15.7.7.32 SHOW PROFILE Statement">
<code class="literal">
SHOW PROFILE
</code>
</a>
, this state
means the thread is requesting the lock (not waiting for
it).
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045221408400">
</a>
<a class="indexterm" name="idm46045221406912">
</a>
<code class="literal">
User sleep
</code>
</p>
<p>
The thread has invoked a
<a class="link" href="miscellaneous-functions.html#function_sleep">
<code class="literal">
SLEEP()
</code>
</a>
call.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045221402112">
</a>
<a class="indexterm" name="idm46045221400624">
</a>
<code class="literal">
Waiting for commit lock
</code>
</p>
<p>
<a class="link" href="flush.html#flush-tables-with-read-lock">
<code class="literal">
FLUSH TABLES WITH READ LOCK
</code>
</a>
is waiting for a commit lock.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045221395984">
</a>
<a class="indexterm" name="idm46045221394480">
</a>
<code class="literal">
waiting for handler commit
</code>
</p>
<p>
The thread is waiting for a transaction to commit versus
other parts of query processing.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045221390976">
</a>
<a class="indexterm" name="idm46045221389488">
</a>
<code class="literal">
Waiting for tables
</code>
</p>
<p>
The thread got a notification that the underlying structure
for a table has changed and it needs to reopen the table to
get the new structure. However, to reopen the table, it must
wait until all other threads have closed the table in
question.
</p>
<p>
This notification takes place if another thread has used
<a class="link" href="flush.html#flush-tables">
<code class="literal">
FLUSH TABLES
</code>
</a>
or one of the
following statements on the table in question:
<code class="literal">
FLUSH TABLES
<em class="replaceable">
<code>
tbl_name
</code>
</em>
</code>
,
<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="rename-table.html" title="15.1.36 RENAME TABLE Statement">
<code class="literal">
RENAME TABLE
</code>
</a>
,
<a class="link" href="repair-table.html" title="15.7.3.5 REPAIR TABLE Statement">
<code class="literal">
REPAIR TABLE
</code>
</a>
,
<a class="link" href="analyze-table.html" title="15.7.3.1 ANALYZE TABLE Statement">
<code class="literal">
ANALYZE TABLE
</code>
</a>
, or
<a class="link" href="optimize-table.html" title="15.7.3.4 OPTIMIZE TABLE Statement">
<code class="literal">
OPTIMIZE TABLE
</code>
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045221376864">
</a>
<a class="indexterm" name="idm46045221375376">
</a>
<code class="literal">
Waiting for table flush
</code>
</p>
<p>
The thread is executing
<a class="link" href="flush.html#flush-tables">
<code class="literal">
FLUSH
TABLES
</code>
</a>
and is waiting for all threads to close
their tables, or the thread got a notification that the
underlying structure for a table has changed and it needs to
reopen the table to get the new structure. However, to
reopen the table, it must wait until all other threads have
closed the table in question.
</p>
<p>
This notification takes place if another thread has used
<a class="link" href="flush.html#flush-tables">
<code class="literal">
FLUSH TABLES
</code>
</a>
or one of the
following statements on the table in question:
<code class="literal">
FLUSH TABLES
<em class="replaceable">
<code>
tbl_name
</code>
</em>
</code>
,
<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="rename-table.html" title="15.1.36 RENAME TABLE Statement">
<code class="literal">
RENAME TABLE
</code>
</a>
,
<a class="link" href="repair-table.html" title="15.7.3.5 REPAIR TABLE Statement">
<code class="literal">
REPAIR TABLE
</code>
</a>
,
<a class="link" href="analyze-table.html" title="15.7.3.1 ANALYZE TABLE Statement">
<code class="literal">
ANALYZE TABLE
</code>
</a>
, or
<a class="link" href="optimize-table.html" title="15.7.3.4 OPTIMIZE TABLE Statement">
<code class="literal">
OPTIMIZE TABLE
</code>
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045221361440">
</a>
<a class="indexterm" name="idm46045221359936">
</a>
<a class="indexterm" name="idm46045221358432">
</a>
<a class="indexterm" name="idm46045221356928">
</a>
<a class="indexterm" name="idm46045221355424">
</a>
<a class="indexterm" name="idm46045221353920">
</a>
<a class="indexterm" name="idm46045221352400">
</a>
<a class="indexterm" name="idm46045221350880">
</a>
<a class="indexterm" name="idm46045221349360">
</a>
<a class="indexterm" name="idm46045221347840">
</a>
<a class="indexterm" name="idm46045221346336">
</a>
<a class="indexterm" name="idm46045221344832">
</a>
<a class="indexterm" name="idm46045221343328">
</a>
<a class="indexterm" name="idm46045221341824">
</a>
<a class="indexterm" name="idm46045221340320">
</a>
<code class="literal">
Waiting for
<em class="replaceable">
<code>
lock_type
</code>
</em>
lock
</code>
</p>
<p>
The server is waiting to acquire a
<code class="literal">
THR_LOCK
</code>
lock or a lock from the metadata
locking subsystem, where
<em class="replaceable">
<code>
lock_type
</code>
</em>
indicates the type of
lock.
</p>
<p>
This state indicates a wait for a
<code class="literal">
THR_LOCK
</code>
:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
<code class="literal">
Waiting for table level lock
</code>
</p>
</li>
</ul>
</div>
<p>
These states indicate a wait for a metadata lock:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
<code class="literal">
Waiting for event metadata lock
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
Waiting for global read lock
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
Waiting for schema metadata lock
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
Waiting for stored function metadata
lock
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
Waiting for stored procedure metadata
lock
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
Waiting for table metadata lock
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
Waiting for trigger metadata lock
</code>
</p>
</li>
</ul>
</div>
<p>
For information about table lock indicators, see
<a class="xref" href="internal-locking.html" title="10.11.1 Internal Locking Methods">
Section 10.11.1, “Internal Locking Methods”
</a>
. For information about
metadata locking, see
<a class="xref" href="metadata-locking.html" title="10.11.4 Metadata Locking">
Section 10.11.4, “Metadata Locking”
</a>
. To
see which locks are blocking lock requests, use the
Performance Schema lock tables described at
<a class="xref" href="performance-schema-lock-tables.html" title="29.12.13 Performance Schema Lock Tables">
Section 29.12.13, “Performance Schema Lock Tables”
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045221318032">
</a>
<a class="indexterm" name="idm46045221316544">
</a>
<code class="literal">
Waiting on cond
</code>
</p>
<p>
A generic state in which the thread is waiting for a
condition to become true. No specific state information is
available.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045221313024">
</a>
<a class="indexterm" name="idm46045221311536">
</a>
<code class="literal">
Writing to net
</code>
</p>
<p>
The server is writing a packet to the network.
</p>
</li>
</ul>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/sys-ps-thread-trx-info.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="sys-ps-thread-trx-info">
</a>
30.4.5.17 The ps_thread_trx_info() Function
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045060742720">
</a>
<a class="indexterm" name="idm46045060741248">
</a>
<p>
Returns a JSON object containing information about a given
thread. The information includes the current transaction, and
the statements it has already executed, derived from the
Performance Schema
<a class="link" href="performance-schema-events-transactions-current-table.html" title="29.12.7.1 The events_transactions_current Table">
<code class="literal">
events_transactions_current
</code>
</a>
and
<a class="link" href="performance-schema-events-statements-history-table.html" title="29.12.6.2 The events_statements_history Table">
<code class="literal">
events_statements_history
</code>
</a>
tables.
(The consumers for those tables must be enabled to obtain full
data in the JSON object.)
</p>
<p>
If the output exceeds the truncation length (65535 by
default), a JSON error object is returned, such as:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-json"><div class="docs-select-all right" id="sa57822690"><div class="copy-help left">Press ⌘+C to 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">"error"</span><span class="token operator">:</span> <span class="token string">"Trx info truncated: Row 6 was cut by GROUP_CONCAT()"</span> <span class="token punctuation">}</span></code></pre>
</div>
<p>
Similar error objects are returned for other warnings and
exceptions raised during function execution.
</p>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="sys-ps-thread-trx-info-parameters">
</a>
Parameters
</h5>
</div>
</div>
</div>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
in_thread_id BIGINT UNSIGNED
</code>
: The
thread ID for which to return transaction information.
The value should match the
<code class="literal">
THREAD_ID
</code>
column from some Performance Schema
<a class="link" href="performance-schema-threads-table.html" title="29.12.22.8 The threads Table">
<code class="literal">
threads
</code>
</a>
table row.
</p>
</li>
</ul>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="sys-ps-thread-trx-info-configuration-options">
</a>
Configuration Options
</h5>
</div>
</div>
</div>
<p>
<a class="link" href="sys-ps-thread-trx-info.html" title="30.4.5.17 The ps_thread_trx_info() Function">
<code class="literal">
ps_thread_trx_info()
</code>
</a>
operation
can be modified using the following configuration options or
their corresponding user-defined variables (see
<a class="xref" href="sys-sys-config.html" title="30.4.2.1 The sys_config Table">
Section 30.4.2.1, “The sys_config Table”
</a>
):
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
ps_thread_trx_info.max_length
</code>
,
<code class="literal">
@sys.ps_thread_trx_info.max_length
</code>
</p>
<p>
The maximum length of the output. The default is 65535.
</p>
</li>
</ul>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="sys-ps-thread-trx-info-return-value">
</a>
Return Value
</h5>
</div>
</div>
</div>
<p>
A
<code class="literal">
LONGTEXT
</code>
value.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="sys-ps-thread-trx-info-example">
</a>
Example
</h5>
</div>
</div>
</div>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa620448"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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> sys<span class="token punctuation">.</span>ps_thread_trx_info<span class="token punctuation">(</span><span class="token number">48</span><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>
sys.ps_thread_trx_info(48)<span class="token punctuation">:</span> [
{
"time"<span class="token punctuation">:</span> "790.70 us",
"state"<span class="token punctuation">:</span> "COMMITTED",
"mode"<span class="token punctuation">:</span> "READ WRITE",
"autocommitted"<span class="token punctuation">:</span> "NO",
"gtid"<span class="token punctuation">:</span> "AUTOMATIC",
"isolation"<span class="token punctuation">:</span> "REPEATABLE READ",
"statements_executed"<span class="token punctuation">:</span> [
{
"sql_text"<span class="token punctuation">:</span> "INSERT INTO info VALUES (1, \'foo\')",
"time"<span class="token punctuation">:</span> "471.02 us",
"schema"<span class="token punctuation">:</span> "trx",
"rows_examined"<span class="token punctuation">:</span> 0,
"rows_affected"<span class="token punctuation">:</span> 1,
"rows_sent"<span class="token punctuation">:</span> 0,
"tmp_tables"<span class="token punctuation">:</span> 0,
"tmp_disk_tables"<span class="token punctuation">:</span> 0,
"sort_rows"<span class="token punctuation">:</span> 0,
"sort_merge_passes"<span class="token punctuation">:</span> 0
},
{
"sql_text"<span class="token punctuation">:</span> "COMMIT",
"time"<span class="token punctuation">:</span> "254.42 us",
"schema"<span class="token punctuation">:</span> "trx",
"rows_examined"<span class="token punctuation">:</span> 0,
"rows_affected"<span class="token punctuation">:</span> 0,
"rows_sent"<span class="token punctuation">:</span> 0,
"tmp_tables"<span class="token punctuation">:</span> 0,
"tmp_disk_tables"<span class="token punctuation">:</span> 0,
"sort_rows"<span class="token punctuation">:</span> 0,
"sort_merge_passes"<span class="token punctuation">:</span> 0
}
]
},
{
"time"<span class="token punctuation">:</span> "426.20 us",
"state"<span class="token punctuation">:</span> "COMMITTED",
"mode"<span class="token punctuation">:</span> "READ WRITE",
"autocommitted"<span class="token punctuation">:</span> "NO",
"gtid"<span class="token punctuation">:</span> "AUTOMATIC",
"isolation"<span class="token punctuation">:</span> "REPEATABLE READ",
"statements_executed"<span class="token punctuation">:</span> [
{
"sql_text"<span class="token punctuation">:</span> "INSERT INTO info VALUES (2, \'bar\')",
"time"<span class="token punctuation">:</span> "107.33 us",
"schema"<span class="token punctuation">:</span> "trx",
"rows_examined"<span class="token punctuation">:</span> 0,
"rows_affected"<span class="token punctuation">:</span> 1,
"rows_sent"<span class="token punctuation">:</span> 0,
"tmp_tables"<span class="token punctuation">:</span> 0,
"tmp_disk_tables"<span class="token punctuation">:</span> 0,
"sort_rows"<span class="token punctuation">:</span> 0,
"sort_merge_passes"<span class="token punctuation">:</span> 0
},
{
"sql_text"<span class="token punctuation">:</span> "COMMIT",
"time"<span class="token punctuation">:</span> "213.23 us",
"schema"<span class="token punctuation">:</span> "trx",
"rows_examined"<span class="token punctuation">:</span> 0,
"rows_affected"<span class="token punctuation">:</span> 0,
"rows_sent"<span class="token punctuation">:</span> 0,
"tmp_tables"<span class="token punctuation">:</span> 0,
"tmp_disk_tables"<span class="token punctuation">:</span> 0,
"sort_rows"<span class="token punctuation">:</span> 0,
"sort_merge_passes"<span class="token punctuation">:</span> 0
}
]
}
]</span></code></pre>
</div>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/multiple-key-caches.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="multiple-key-caches">
</a>
10.10.2.2 Multiple Key Caches
</h4>
</div>
</div>
</div>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
As of MySQL 8.4, the compound-part
structured-variable syntax discussed here for referring to
multiple
<code class="literal">
MyISAM
</code>
key caches is deprecated.
</p>
</div>
<p>
Shared access to the key cache improves performance but does
not eliminate contention among sessions entirely. They still
compete for control structures that manage access to the key
cache buffers. To reduce key cache access contention further,
MySQL also provides multiple key caches. This feature enables
you to assign different table indexes to different key caches.
</p>
<p>
Where there are multiple key caches, the server must know
which cache to use when processing queries for a given
<code class="literal">
MyISAM
</code>
table. By default, all
<code class="literal">
MyISAM
</code>
table indexes are cached in the
default key cache. To assign table indexes to a specific key
cache, use the
<a class="link" href="cache-index.html" title="15.7.8.2 CACHE INDEX Statement">
<code class="literal">
CACHE INDEX
</code>
</a>
statement (see
<a class="xref" href="cache-index.html" title="15.7.8.2 CACHE INDEX Statement">
Section 15.7.8.2, “CACHE INDEX Statement”
</a>
). For example,
the following statement assigns indexes from the tables
<code class="literal">
t1
</code>
,
<code class="literal">
t2
</code>
, and
<code class="literal">
t3
</code>
to the key cache named
<code class="literal">
hot_cache
</code>
:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa28579336"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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">CACHE</span> <span class="token keyword">INDEX</span> t1<span class="token punctuation">,</span> t2<span class="token punctuation">,</span> t3 <span class="token keyword">IN</span> hot_cache<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> Table <span class="token punctuation">|</span> Op <span class="token punctuation">|</span> Msg_type <span class="token punctuation">|</span> Msg_text <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> test.t1 <span class="token punctuation">|</span> assign_to_keycache <span class="token punctuation">|</span> status <span class="token punctuation">|</span> OK <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> test.t2 <span class="token punctuation">|</span> assign_to_keycache <span class="token punctuation">|</span> status <span class="token punctuation">|</span> OK <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> test.t3 <span class="token punctuation">|</span> assign_to_keycache <span class="token punctuation">|</span> status <span class="token punctuation">|</span> OK <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>
The key cache referred to in a
<a class="link" href="cache-index.html" title="15.7.8.2 CACHE INDEX Statement">
<code class="literal">
CACHE
INDEX
</code>
</a>
statement can be created by setting its size
with 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>
parameter setting statement or by using
server startup options. For example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa93282367"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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> keycache1<span class="token punctuation">.</span>key_buffer_size<span class="token operator">=</span><span class="token number">128</span><span class="token operator">*</span><span class="token number">1024</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
To destroy a key cache, set its size to zero:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa90103379"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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> keycache1<span class="token punctuation">.</span>key_buffer_size<span class="token operator">=</span><span class="token number">0</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
You cannot destroy the default key cache. Any attempt to do
this is ignored:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa4638184"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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> key_buffer_size <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">SHOW</span> <span class="token keyword">VARIABLES</span> <span class="token operator">LIKE</span> <span class="token string">'key_buffer_size'</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>
<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>
<span class="token output"><span class="token punctuation">|</span> key_buffer_size <span class="token punctuation">|</span> 8384512 <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></code></pre>
</div>
<p>
Key cache variables are structured system variables that have
a name and components. For
<code class="literal">
keycache1.key_buffer_size
</code>
,
<code class="literal">
keycache1
</code>
is the cache variable name and
<a class="link" href="server-system-variables.html#sysvar_key_buffer_size">
<code class="literal">
key_buffer_size
</code>
</a>
is the cache
component. See
<a class="xref" href="structured-system-variables.html" title="7.1.9.5 Structured System Variables">
Section 7.1.9.5, “Structured System Variables”
</a>
,
for a description of the syntax used for referring to
structured key cache system variables.
</p>
<p>
By default, table indexes are assigned to the main (default)
key cache created at the server startup. When a key cache is
destroyed, all indexes assigned to it are reassigned to the
default key cache.
</p>
<p>
For a busy server, you can use a strategy that involves three
key caches:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
A
<span class="quote">
“
<span class="quote">
hot
</span>
”
</span>
key cache that takes up 20% of the
space allocated for all key caches. Use this for tables
that are heavily used for searches but that are not
updated.
</p>
</li>
<li class="listitem">
<p>
A
<span class="quote">
“
<span class="quote">
cold
</span>
”
</span>
key cache that takes up 20% of the
space allocated for all key caches. Use this cache for
medium-sized, intensively modified tables, such as
temporary tables.
</p>
</li>
<li class="listitem">
<p>
A
<span class="quote">
“
<span class="quote">
warm
</span>
”
</span>
key cache that takes up 60% of the
key cache space. Employ this as the default key cache, to
be used by default for all other tables.
</p>
</li>
</ul>
</div>
<p>
One reason the use of three key caches is beneficial is that
access to one key cache structure does not block access to the
others. Statements that access tables assigned to one cache do
not compete with statements that access tables assigned to
another cache. Performance gains occur for other reasons as
well:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
The hot cache is used only for retrieval queries, so its
contents are never modified. Consequently, whenever an
index block needs to be pulled in from disk, the contents
of the cache block chosen for replacement need not be
flushed first.
</p>
</li>
<li class="listitem">
<p>
For an index assigned to the hot cache, if there are no
queries requiring an index scan, there is a high
probability that the index blocks corresponding to nonleaf
nodes of the index B-tree remain in the cache.
</p>
</li>
<li class="listitem">
<p>
An update operation most frequently executed for temporary
tables is performed much faster when the updated node is
in the cache and need not be read from disk first. If the
size of the indexes of the temporary tables are comparable
with the size of cold key cache, the probability is very
high that the updated node is in the cache.
</p>
</li>
</ul>
</div>
<p>
The
<a class="link" href="cache-index.html" title="15.7.8.2 CACHE INDEX Statement">
<code class="literal">
CACHE INDEX
</code>
</a>
statement sets
up an association between a table and a key cache, but the
association is lost each time the server restarts. If you want
the association to take effect each time the server starts,
one way to accomplish this is to use an option file: Include
variable settings that configure your key caches, and an
<a class="link" href="server-system-variables.html#sysvar_init_file">
<code class="literal">
init_file
</code>
</a>
system variable
that names a file containing
<a class="link" href="cache-index.html" title="15.7.8.2 CACHE INDEX Statement">
<code class="literal">
CACHE
INDEX
</code>
</a>
statements to be executed. For example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-ini"><div class="docs-select-all right" id="sa23052202"><div class="copy-help left">Press ⌘+C to 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">key_buffer_size</span> <span class="token attr-value"><span class="token punctuation">=</span> 4G</span>
<span class="token constant">hot_cache.key_buffer_size</span> <span class="token attr-value"><span class="token punctuation">=</span> 2G</span>
<span class="token constant">cold_cache.key_buffer_size</span> <span class="token attr-value"><span class="token punctuation">=</span> 2G</span>
<span class="token constant">init_file</span><span class="token attr-value"><span class="token punctuation">=</span>/<em class="replaceable">path</em>/<em class="replaceable">to</em>/<em class="replaceable">data-directory</em>/mysqld_init.sql</span></code></pre>
</div>
<p>
The statements in
<code class="filename">
mysqld_init.sql
</code>
are
executed each time the server starts. The file should contain
one SQL statement per line. The following example assigns
several tables each to
<code class="literal">
hot_cache
</code>
and
<code class="literal">
cold_cache
</code>
:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa87934981"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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">CACHE</span> <span class="token keyword">INDEX</span> db1<span class="token punctuation">.</span>t1<span class="token punctuation">,</span> db1<span class="token punctuation">.</span>t2<span class="token punctuation">,</span> db2<span class="token punctuation">.</span>t3 <span class="token keyword">IN</span> hot_cache
<span class="token keyword">CACHE</span> <span class="token keyword">INDEX</span> db1<span class="token punctuation">.</span>t4<span class="token punctuation">,</span> db2<span class="token punctuation">.</span>t5<span class="token punctuation">,</span> db2<span class="token punctuation">.</span>t6 <span class="token keyword">IN</span> cold_cache</code></pre>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/mysql-cluster-replication-general.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="mysql-cluster-replication-general">
</a>
25.7.2 General Requirements for NDB Cluster Replication
</h3>
</div>
</div>
</div>
<a class="indexterm" name="idm46045086768752">
</a>
<a class="indexterm" name="idm46045086767264">
</a>
<p>
A replication channel requires two MySQL servers acting as
replication servers (one each for the source and replica). For
example, this means that in the case of a replication setup with
two replication channels (to provide an extra channel for
redundancy), there should be a total of four replication nodes,
two per cluster.
</p>
<p>
Replication of an NDB Cluster as described in this section and
those following is dependent on row-based replication. This means
that the replication source MySQL server must be running with
<a class="link" href="replication-options-binary-log.html#sysvar_binlog_format">
<code class="option">
--binlog-format=ROW
</code>
</a>
or
<a class="link" href="replication-options-binary-log.html#sysvar_binlog_format">
<code class="option">
--binlog-format=MIXED
</code>
</a>
, as described
in
<a class="xref" href="mysql-cluster-replication-starting.html" title="25.7.6 Starting NDB Cluster Replication (Single Replication Channel)">
Section 25.7.6, “Starting NDB Cluster Replication (Single Replication Channel)”
</a>
. For
general information about row-based replication, see
<a class="xref" href="replication-formats.html" title="19.2.1 Replication Formats">
Section 19.2.1, “Replication Formats”
</a>
.
</p>
<div class="important" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Important
</div>
<p>
If you attempt to use NDB Cluster Replication with
<a class="link" href="replication-options-binary-log.html#sysvar_binlog_format">
<code class="option">
--binlog-format=STATEMENT
</code>
</a>
,
replication fails to work properly because the
<code class="literal">
ndb_binlog_index
</code>
table on the source cluster
and the
<code class="literal">
epoch
</code>
column of the
<code class="literal">
ndb_apply_status
</code>
table on the replica cluster
are not updated (see
<a class="xref" href="mysql-cluster-replication-schema.html" title="25.7.4 NDB Cluster Replication Schema and Tables">
Section 25.7.4, “NDB Cluster Replication Schema and Tables”
</a>
). Instead,
only updates on the MySQL server acting as the replication
source propagate to the replica, and no updates from any other
SQL nodes in the source cluster are replicated.
</p>
<p>
The default value for the
<a class="link" href="replication-options-binary-log.html#sysvar_binlog_format">
<code class="option">
--binlog-format
</code>
</a>
option is
<code class="literal">
MIXED
</code>
.
</p>
</div>
<p>
Each MySQL server used for replication in either cluster must be
uniquely identified among all the MySQL replication servers
participating in either cluster (you cannot have replication
servers on both the source and replica clusters sharing the same
ID). This can be done by starting each SQL node using the
<code class="option">
--server-id=
<em class="replaceable">
<code>
id
</code>
</em>
</code>
option,
where
<em class="replaceable">
<code>
id
</code>
</em>
is a unique integer. Although
it is not strictly necessary, we assume for purposes of this
discussion that all NDB Cluster binaries are of the same release
version.
</p>
<p>
It is generally true in MySQL Replication that both MySQL servers
(
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
processes) involved must be compatible
with one another with respect to both the version of the
replication protocol used and the SQL feature sets which they
support (see
<a class="xref" href="replication-compatibility.html" title="19.5.2 Replication Compatibility Between MySQL Versions">
Section 19.5.2, “Replication Compatibility Between MySQL Versions”
</a>
). It is
due to such differences between the binaries in the NDB Cluster
and MySQL Server 8.4 distributions that NDB Cluster
Replication has the additional requirement that both
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
binaries come from an NDB Cluster
distribution. The simplest and easiest way to assure that the
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
servers are compatible is to use the
same NDB Cluster distribution for all source and replica
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
binaries.
</p>
<p>
We assume that the replica server or cluster is dedicated to
replication of the source cluster, and that no other data is being
stored on it.
</p>
<a class="indexterm" name="idm46045086744656">
</a>
<a class="indexterm" name="idm46045086743152">
</a>
<p>
All
<code class="literal">
NDB
</code>
tables being replicated must be created
using a MySQL server and client. Tables and other database objects
created using the NDB API (with, for example,
<a class="ulink" href="/doc/ndbapi/en/ndb-dictionary.html#ndb-dictionary-createtable" target="_top">
<code class="literal">
Dictionary::createTable()
</code>
</a>
) are
not visible to a MySQL server and so are not replicated. Updates
by NDB API applications to existing tables that were created using
a MySQL server can be replicated.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
It is possible to replicate an NDB Cluster using statement-based
replication. However, in this case, the following restrictions
apply:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
All updates to data rows on the cluster acting as the source
must be directed to a single MySQL server.
</p>
</li>
<li class="listitem">
<p>
It is not possible to replicate a cluster using multiple
simultaneous MySQL replication processes.
</p>
</li>
<li class="listitem">
<p>
Only changes made at the SQL level are replicated.
</p>
</li>
</ul>
</div>
<p>
These are in addition to the other limitations of
statement-based replication as opposed to row-based replication;
see
<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>
, for more specific
information concerning the differences between the two
replication formats.
</p>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/docker-mysql-more-topics.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="docker-mysql-more-topics">
</a>
2.5.6.2 More Topics on Deploying MySQL Server with Docker
</h4>
</div>
</div>
</div>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
Most of the following sample commands have
<code class="literal">
container-registry.oracle.com/mysql/community-server
</code>
as the Docker image being used (like with the
<span class="command">
<strong>
docker
pull
</strong>
</span>
and
<span class="command">
<strong>
docker run
</strong>
</span>
commands);
change that if your image is from another repository—for
example, replace it with
<code class="literal">
container-registry.oracle.com/mysql/enterprise-server
</code>
for MySQL Enterprise Edition images downloaded from the Oracle Container Registry
(OCR), or
<code class="literal">
mysql/enterprise-server
</code>
for MySQL Enterprise Edition
images downloaded from
<a class="ulink" href="https://support.oracle.com/" target="_blank">
My Oracle
Support
</a>
.
</p>
</div>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="xref" href="docker-mysql-more-topics.html#docker-optimized-installation" title="The Optimized MySQL Installation for Docker">
The Optimized MySQL Installation for Docker
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="docker-mysql-more-topics.html#docker-configuring-server" title="Configuring the MySQL Server">
Configuring the MySQL Server
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="docker-mysql-more-topics.html#docker-persisting-data-configuration" title="Persisting Data and Configuration Changes">
Persisting Data and Configuration Changes
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="docker-mysql-more-topics.html#docker-additional-init" title="Running Additional Initialization Scripts">
Running Additional Initialization Scripts
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="docker-mysql-more-topics.html#docker-app-in-another-container" title="Connect to MySQL from an Application in Another Docker Container">
Connect to MySQL from an Application in Another Docker Container
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="docker-mysql-more-topics.html#docker-server-error-log" title="Server Error Log">
Server Error Log
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="docker-mysql-more-topics.html#docker-meb" title="Using MySQL Enterprise Backup with Docker">
Using MySQL Enterprise Backup with Docker
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="docker-mysql-more-topics.html#docker-mysqldump" title="Using mysqldump with Docker">
Using mysqldump with Docker
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="docker-mysql-more-topics.html#docker-known-issues" title="Known Issues">
Known Issues
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="docker-mysql-more-topics.html#docker-environment-variables" title="Docker Environment Variables">
Docker Environment Variables
</a>
</p>
</li>
</ul>
</div>
<h5>
<a name="docker-optimized-installation">
</a>
The Optimized MySQL Installation for Docker
</h5>
<p>
Docker images for MySQL are optimized for code size, which means
they only include crucial components that are expected to be
relevant for the majority of users who run MySQL instances in
Docker containers. A MySQL Docker installation is different from
a common, non-Docker installation in the following aspects:
</p>
<p>
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Only a limited number of binaries are included.
</p>
</li>
<li class="listitem">
<p>
All binaries are stripped; they contain no debug
information.
</p>
</li>
</ul>
</div>
<p>
</p>
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Warning
</div>
<p>
Any software updates or installations users perform to the
Docker container (including those for MySQL components) may
conflict with the optimized MySQL installation created by the
Docker image. Oracle does not provide support for MySQL
products running in such an altered container, or a container
created from an altered Docker image.
</p>
</div>
<h5>
<a name="docker-configuring-server">
</a>
Configuring the MySQL Server
</h5>
<p>
When you start the MySQL Docker container, you can pass
configuration options to the server through the
<span class="command">
<strong>
docker
run
</strong>
</span>
command. For example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa10145275"><div class="copy-help left">Press ⌘+C to 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">docker run <span class="token property">--name</span> mysql1 <span class="token property">-d</span> container-registry<span class="token punctuation">.</span>oracle<span class="token punctuation">.</span>com/mysql/community-server<span class="token punctuation">:</span><em class="replaceable">tag</em> <span class="token constant">--character-set-server</span><span class="token attr-value"><span class="token punctuation">=</span>utf8mb4</span> <span class="token constant">--collation-server</span><span class="token attr-value"><span class="token punctuation">=</span>utf8mb4_col</span></code></pre>
</div>
<p>
The command starts the MySQL Server with
<code class="literal">
utf8mb4
</code>
as the default character set and
<code class="literal">
utf8mb4_col
</code>
as the default collation for
databases.
</p>
<p>
Another way to configure the MySQL Server is to prepare a
configuration file and mount it at the location of the server
configuration file inside the container. See
<a class="xref" href="docker-mysql-more-topics.html#docker-persisting-data-configuration" title="Persisting Data and Configuration Changes">
Persisting Data and Configuration Changes
</a>
for
details.
</p>
<h5>
<a name="docker-persisting-data-configuration">
</a>
Persisting Data and Configuration Changes
</h5>
<p>
Docker containers are in principle ephemeral, and any data or
configuration are expected to be lost if the container is
deleted or corrupted (see discussions
<a class="ulink" href="https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/" target="_blank">
here
</a>
).
<a class="ulink" href="https://docs.docker.com/engine/admin/volumes/volumes/" target="_blank">
Docker
volumes
</a>
provides a mechanism to persist data created
inside a Docker container. At its initialization, the MySQL
Server container creates a Docker volume for the server data
directory. The JSON output from the
<span class="command">
<strong>
docker
inspect
</strong>
</span>
command on the container includes a
<code class="literal">
Mount
</code>
key, whose value provides information
on the data directory volume:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa82076562"><div class="copy-help left">Press ⌘+C to 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">docker</span> inspect mysql1
<span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
<span class="token atrule">"Mounts"</span><span class="token punctuation">:</span> <span class="token punctuation">[</span>
<span class="token inlinejson"> <span class="token punctuation">{</span>
<span class="token property">"Type"</span><span class="token operator">:</span> <span class="token string">"volume"</span><span class="token punctuation">,</span>
<span class="token property">"Name"</span><span class="token operator">:</span> <span class="token string">"4f2d463cfc4bdd4baebcb098c97d7da3337195ed2c6572bc0b89f7e845d27652"</span><span class="token punctuation">,</span>
<span class="token property">"Source"</span><span class="token operator">:</span> <span class="token string">"/var/lib/docker/volumes/4f2d463cfc4bdd4baebcb098c97d7da3337195ed2c6572bc0b89f7e845d27652/_data"</span><span class="token punctuation">,</span>
<span class="token property">"Destination"</span><span class="token operator">:</span> <span class="token string">"/var/lib/mysql"</span><span class="token punctuation">,</span>
<span class="token property">"Driver"</span><span class="token operator">:</span> <span class="token string">"local"</span><span class="token punctuation">,</span>
<span class="token property">"Mode"</span><span class="token operator">:</span> <span class="token string">""</span><span class="token punctuation">,</span>
<span class="token property">"RW"</span><span class="token operator">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span>
<span class="token property">"Propagation"</span><span class="token operator">:</span> <span class="token string">""</span>
<span class="token punctuation">}</span></span>
<span 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 output shows that the source directory
<code class="filename">
/var/lib/docker/volumes/4f2d463cfc4bdd4baebcb098c97d7da3337195ed2c6572bc0b89f7e845d27652/_data
</code>
,
in which data is persisted on the host, has been mounted at
<code class="filename">
/var/lib/mysql
</code>
, the server data directory
inside the container.
</p>
<p>
Another way to preserve data is to
<a class="ulink" href="https://docs.docker.com/engine/reference/commandline/service_create/#add-bind-mounts-volumes-or-memory-filesystems" target="_blank">
bind-mount
</a>
a host directory using the
<code class="option">
--mount
</code>
option when
creating the container. The same technique can be used to
persist the configuration of the server. The following command
creates a MySQL Server container and bind-mounts both the data
directory and the server configuration file:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa12138508"><div class="copy-help left">Press ⌘+C to 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">docker run <span class="token constant">--name</span><span class="token attr-value"><span class="token punctuation">=</span>mysql1</span> \
<span class="token property">--mount</span> type<span class="token attr-value"><span class="token punctuation">=</span>bind,src=</span><em class="replaceable"><span class="token attr-value">/path</span><span class="token constant">-on-host-machine/my.cnf</span></em><span class="token constant">,dst</span><span class="token attr-value"><span class="token punctuation">=</span>/etc/my.cnf</span> \
<span class="token property">--mount</span> type<span class="token attr-value"><span class="token punctuation">=</span>bind,src=</span><em class="replaceable"><span class="token attr-value">/path</span><span class="token constant">-on-host-machine/datadir</span></em><span class="token constant">,dst</span><span class="token attr-value"><span class="token punctuation">=</span>/var/lib/mysql</span> \
<span class="token property">-d</span> container-registry<span class="token punctuation">.</span>oracle<span class="token punctuation">.</span>com/mysql/community-server<span class="token punctuation">:</span><em class="replaceable">tag</em></code></pre>
</div>
<p>
The command mounts
<code class="filename">
<em class="replaceable">
<code>
path-on-host-machine/my.cnf
</code>
</em>
</code>
at
<code class="filename">
<code class="filename">
/etc/my.cnf
</code>
</code>
(the
server configuration file inside the container), and
<code class="filename">
<em class="replaceable">
<code>
path-on-host-machine/datadir
</code>
</em>
</code>
at
<code class="filename">
/var/lib/mysql
</code>
(the data directory
inside the container). The following conditions must be met for
the bind-mounting to work:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
The configuration file
<code class="filename">
<em class="replaceable">
<code>
path-on-host-machine/my.cnf
</code>
</em>
</code>
must already exist, and it must contain the specification
for starting the server by the user
<code class="literal">
mysql
</code>
:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-ini"><div class="docs-select-all right" id="sa46894309"><div class="copy-help left">Press ⌘+C to 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">user</span><span class="token attr-value"><span class="token punctuation">=</span>mysql</span></code></pre>
</div>
<p>
You can also include other server configuration options in
the file.
</p>
</li>
<li class="listitem">
<p>
The data directory
<code class="filename">
<em class="replaceable">
<code>
path-on-host-machine/datadir
</code>
</em>
</code>
must already exist. For server initialization to happen,
the directory must be empty. You can also mount a
directory prepopulated with data and start the server with
it; however, you must make sure you start the Docker
container with the same configuration as the server that
created the data, and any host files or directories
required are mounted when starting the container.
</p>
</li>
</ul>
</div>
<p>
</p>
<h5>
<a name="docker-additional-init">
</a>
Running Additional Initialization Scripts
</h5>
<p>
If there are any
<code class="filename">
.sh
</code>
or
<code class="filename">
.sql
</code>
scripts you want to run on the
database immediately after it has been created, you can put them
into a host directory and then mount the directory at
<code class="filename">
/docker-entrypoint-initdb.d/
</code>
inside the
container. For example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa62518177"><div class="copy-help left">Press ⌘+C to 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">docker run <span class="token constant">--name</span><span class="token attr-value"><span class="token punctuation">=</span>mysql1</span> \
<span class="token property">--mount</span> type<span class="token attr-value"><span class="token punctuation">=</span>bind,src=</span><em class="replaceable"><span class="token attr-value">/path</span><span class="token constant">-on-host-machine/scripts/</span></em><span class="token constant">,dst</span><span class="token attr-value"><span class="token punctuation">=</span>/docker-entrypoint-initdb.d/</span> \
<span class="token property">-d</span> container-registry<span class="token punctuation">.</span>oracle<span class="token punctuation">.</span>com/mysql/community-server<span class="token punctuation">:</span><em class="replaceable">tag</em></code></pre>
</div>
<h5>
<a name="docker-app-in-another-container">
</a>
Connect to MySQL from an Application in Another Docker Container
</h5>
<p>
By setting up a Docker network, you can allow multiple Docker
containers to communicate with each other, so that a client
application in another Docker container can access the MySQL
Server in the server container. First, create a Docker network:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa61407296"><div class="copy-help left">Press ⌘+C to 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">docker network create <em class="replaceable">my-custom-net</em></code></pre>
</div>
<p>
Then, when you are creating and starting the server and the
client containers, use the
<code class="option">
--network
</code>
option to
put them on network you created. For example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa39882164"><div class="copy-help left">Press ⌘+C to 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">docker run <span class="token constant">--name</span><span class="token attr-value"><span class="token punctuation">=</span>mysql1</span> <span class="token constant">--network</span><span class="token attr-value"><span class="token punctuation">=</span><em class="replaceable">my-custom-net</em></span> <span class="token property">-d</span> container-registry<span class="token punctuation">.</span>oracle<span class="token punctuation">.</span>com/mysql/community-server</code></pre>
</div>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa31617757"><div class="copy-help left">Press ⌘+C to 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">docker run <span class="token constant">--name</span><span class="token attr-value"><span class="token punctuation">=</span>myapp1</span> <span class="token constant">--network</span><span class="token attr-value"><span class="token punctuation">=</span><em class="replaceable">my-custom-net</em></span> <span class="token property">-d</span> myapp</code></pre>
</div>
<p>
The
<code class="literal">
myapp1
</code>
container can then connect to the
<code class="literal">
mysql1
</code>
container with the
<code class="literal">
mysql1
</code>
hostname and vice versa, as Docker
automatically sets up a DNS for the given container names. In
the following example, we run 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 from inside the
<code class="literal">
myapp1
</code>
container to
connect to host
<code class="literal">
mysql1
</code>
in its own container:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa55511078"><div class="copy-help left">Press ⌘+C to 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">docker exec <span class="token property">-it</span> myapp1 mysql <span class="token constant">--host</span><span class="token attr-value"><span class="token punctuation">=</span>mysql1</span> <span class="token constant">--user</span><span class="token attr-value"><span class="token punctuation">=</span>myuser</span> <span class="token property">--password</span></code></pre>
</div>
<p>
For other networking techniques for containers, see the
<a class="ulink" href="https://docs.docker.com/engine/userguide/networking/" target="_blank">
Docker
container networking
</a>
section in the Docker
Documentation.
</p>
<h5>
<a name="docker-server-error-log">
</a>
Server Error Log
</h5>
<p>
When the MySQL Server is first started with your server
container, a
<a class="link" href="error-log.html" title="7.4.2 The Error Log">
server error log
</a>
is NOT generated if either of the following conditions is true:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
A server configuration file from the host has been mounted,
but the file does not contain the system variable
<a class="link" href="server-system-variables.html#sysvar_log_error">
<code class="literal">
log_error
</code>
</a>
(see
<a class="xref" href="docker-mysql-more-topics.html#docker-persisting-data-configuration" title="Persisting Data and Configuration Changes">
Persisting Data and Configuration Changes
</a>
on
bind-mounting a server configuration file).
</p>
</li>
<li class="listitem">
<p>
A server configuration file from the host has not been
mounted, but the Docker environment variable
<a class="link" href="docker-mysql-more-topics.html#docker_var_mysql-log-console">
<code class="option">
MYSQL_LOG_CONSOLE
</code>
</a>
is
<code class="literal">
true
</code>
(which is the variable's default
state for MySQL 8.4 server containers). The
MySQL Server's error log is then redirected to
<code class="literal">
stderr
</code>
, so that the error log goes into
the Docker container's log and is viewable using the
<span class="command">
<strong>
docker logs
<em class="replaceable">
<code>
mysqld-container
</code>
</em>
</strong>
</span>
command.
</p>
</li>
</ul>
</div>
<p>
To make MySQL Server generate an error log when either of the
two conditions is true, use the
<a class="link" href="server-options.html#option_mysqld_log-error">
<code class="option">
--log-error
</code>
</a>
option to
<a class="link" href="docker-mysql-more-topics.html#docker-configuring-server" title="Configuring the MySQL Server">
configure the
server
</a>
to generate the error log at a specific location
inside the container. To persist the error log, mount a host
file at the location of the error log inside the container as
explained in
<a class="xref" href="docker-mysql-more-topics.html#docker-persisting-data-configuration" title="Persisting Data and Configuration Changes">
Persisting Data and Configuration Changes
</a>
. However,
you must make sure your MySQL Server inside its container has
write access to the mounted host file.
</p>
<h5>
<a name="docker-meb">
</a>
Using MySQL Enterprise Backup with Docker
</h5>
<p>
<a class="link" href="mysql-enterprise-backup.html" title="32.1 MySQL Enterprise Backup Overview">
MySQL Enterprise Backup
</a>
is a
commercially-licensed backup utility for MySQL Server, available
with
<a class="ulink" href="https://www.mysql.com/products/enterprise/" target="_blank">
MySQL Enterprise Edition
</a>
.
MySQL Enterprise Backup is included in the Docker installation of MySQL Enterprise Edition.
</p>
<p>
In the following example, we assume that you already have a
MySQL Server running in a Docker container (see
<a class="xref" href="docker-mysql-getting-started.html" title="2.5.6.1 Basic Steps for MySQL Server Deployment with Docker">
Section 2.5.6.1, “Basic Steps for MySQL Server Deployment with Docker”
</a>
on how to start a
MySQL Server instance with Docker). For MySQL Enterprise Backup to back up the
MySQL Server, it must have access to the server's data
directory. This can be achieved by, for example,
<a class="link" href="docker-mysql-more-topics.html#docker-persisting-data-configuration" title="Persisting Data and Configuration Changes">
bind-mounting
a host directory on the data directory of the MySQL
Server
</a>
when you start the server:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa17902398"><div class="copy-help left">Press ⌘+C to 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">docker run <span class="token constant">--name</span><span class="token attr-value"><span class="token punctuation">=</span>mysqlserver</span> \
<span class="token property">--mount</span> type<span class="token attr-value"><span class="token punctuation">=</span>bind,src=</span><em class="replaceable"><span class="token attr-value">/path</span><span class="token constant">-on-host-machine/datadir/</span></em><span class="token constant">,dst</span><span class="token attr-value"><span class="token punctuation">=</span>/var/lib/mysql</span> \
<span class="token property">-d</span> mysql/enterprise-server<span class="token punctuation">:</span>8<span class="token punctuation">.</span>4</code></pre>
</div>
<p>
</p>
<p>
With this command, the MySQL Server is started with a Docker
image of the MySQL Enterprise Edition, and the host directory
<em class="replaceable">
<code>
/path-on-host-machine/datadir/
</code>
</em>
has
been mounted onto the server's data directory
(
<code class="filename">
/var/lib/mysql
</code>
) inside the server
container. We also assume that, after the server has been
started, the required privileges have also been set up for MySQL Enterprise Backup
to access the server (see
<a class="ulink" href="/doc/mysql-enterprise-backup/8.4/en/mysqlbackup.privileges.html" target="_top">
Grant MySQL Privileges to Backup Administrator
</a>
, for details). Use the
following steps to back up and restore a MySQL Server instance.
</p>
<p>
To back up a MySQL Server instance running in a Docker container
using MySQL Enterprise Backup with Docker, follow the steps listed here:
</p>
<div class="orderedlist">
<ol class="orderedlist" type="1">
<li class="listitem">
<p>
On the same host where the MySQL Server container is
running, start another container with an image of MySQL Enterprise Edition to
perform a back up with the MySQL Enterprise Backup command
<a class="ulink" href="/doc/mysql-enterprise-backup/8.4/en/backup-commands-backup.html#option_meb_backup-to-image" target="_top">
<code class="option">
backup-to-image
</code>
</a>
. Provide access
to the server's data directory using the bind mount we
created in the last step. Also, mount a host directory
(
<em class="replaceable">
<code>
/path-on-host-machine/backups/
</code>
</em>
in this example) onto the storage folder for backups in the
container (
<code class="filename">
/data/backups
</code>
in the
example) to persist the backups we are creating. Here is a
sample command for this step, in which MySQL Enterprise Backup is started with
a Docker image downloaded from
<a class="ulink" href="https://support.oracle.com/" target="_blank">
My
Oracle Support
</a>
:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa97012680"><div class="copy-help left">Press ⌘+C to 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">docker</span> run \
<span class="token property">--mount</span> type<span class="token attr-value"><span class="token punctuation">=</span>bind,src=</span><em class="replaceable"><span class="token attr-value">/path</span><span class="token constant">-on-host-machine/datadir/</span></em><span class="token constant">,dst</span><span class="token attr-value"><span class="token punctuation">=</span>/var/lib/mysql</span> \
<span class="token property">--mount</span> type<span class="token attr-value"><span class="token punctuation">=</span>bind,src=</span><em class="replaceable"><span class="token attr-value">/path</span><span class="token constant">-on-host-machine/backups/</span></em><span class="token constant">,dst</span><span class="token attr-value"><span class="token punctuation">=</span>/data/backups</span> \
<span class="token property">--rm</span> mysql/enterprise-server<span class="token punctuation">:</span>8<span class="token punctuation">.</span>4 \
mysqlbackup <span class="token property">-u<em class="replaceable">mysqlbackup</em></span> <span class="token property">-p<em class="replaceable">password</em></span> <span class="token constant">--backup-dir</span><span class="token attr-value"><span class="token punctuation">=</span>/tmp/backup-tmp</span> <span class="token property">--with-timestamp</span> \
<span class="token constant">--backup-image</span><span class="token attr-value"><span class="token punctuation">=</span>/data/backups/db.mbi</span> backup-to-image</code></pre>
</div>
<p>
It is important to check the end of the output by
<span class="command">
<strong>
mysqlbackup
</strong>
</span>
to make sure the backup has
been completed successfully.
</p>
</li>
<li class="listitem">
<p>
The container exits once the backup job is finished and,
with the
<code class="literal">
--rm
</code>
option used to start it, it
is removed after it exits. An image backup has been created,
and can be found in the host directory mounted in the last
step for storing backups, as shown here:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa1017724"><div class="copy-help left">Press ⌘+C to 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">ls</span> /tmp/backups
db<span class="token punctuation">.</span>mbi</code></pre>
</div>
<p>
</p>
</li>
</ol>
</div>
<p>
To restore a MySQL Server instance in a Docker container using
MySQL Enterprise Backup with Docker, follow the steps listed here:
</p>
<div class="orderedlist">
<ol class="orderedlist" type="1">
<li class="listitem">
<p>
Stop the MySQL Server container, which also stops the MySQL
Server running inside:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa52553183"><div class="copy-help left">Press ⌘+C to 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">docker stop mysqlserver</code></pre>
</div>
</li>
<li class="listitem">
<p>
On the host, delete all contents in the bind mount for the
MySQL Server data directory:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa67121652"><div class="copy-help left">Press ⌘+C to 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">rm <span class="token property">-rf</span> <em class="replaceable">/path-on-host-machine/datadir</em>/*</code></pre>
</div>
</li>
<li class="listitem">
<p>
Start a container with an image of MySQL Enterprise Edition to perform the
restore with the MySQL Enterprise Backup command
<a class="ulink" href="/doc/mysql-enterprise-backup/8.4/en/backup-commands-restore.html#option_meb_copy-back-and-apply-log" target="_top">
<code class="option">
copy-back-and-apply-log
</code>
</a>
.
Bind-mount the server's data directory and the storage
folder for the backups, like what we did when we backed up
the server:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa4980852"><div class="copy-help left">Press ⌘+C to 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">docker</span> run \
<span class="token property">--mount</span> type<span class="token attr-value"><span class="token punctuation">=</span>bind,src=</span><em class="replaceable"><span class="token attr-value">/path</span><span class="token constant">-on-host-machine/datadir/</span></em><span class="token constant">,dst</span><span class="token attr-value"><span class="token punctuation">=</span>/var/lib/mysql</span> \
<span class="token property">--mount</span> type<span class="token attr-value"><span class="token punctuation">=</span>bind,src=</span><em class="replaceable"><span class="token attr-value">/path</span><span class="token constant">-on-host-machine/backups/</span></em><span class="token constant">,dst</span><span class="token attr-value"><span class="token punctuation">=</span>/data/backups</span> \
<span class="token property">--rm</span> mysql/enterprise-server<span class="token punctuation">:</span>8<span class="token punctuation">.</span>4 \
mysqlbackup <span class="token constant">--backup-dir</span><span class="token attr-value"><span class="token punctuation">=</span>/tmp/backup-tmp</span> <span class="token property">--with-timestamp</span> \
<span class="token constant">--datadir</span><span class="token attr-value"><span class="token punctuation">=</span>/var/lib/mysql</span> <span class="token constant">--backup-image</span><span class="token attr-value"><span class="token punctuation">=</span>/data/backups/db.mbi</span> copy-back-and-apply-log
mysqlbackup completed OK! with 3 warnings</code></pre>
</div>
<p>
The container exits with the message "
<code class="literal">
mysqlbackup
completed OK!
</code>
" once the backup job is finished
and, with the
<code class="option">
--rm
</code>
option used when
starting it, it is removed after it exits.
</p>
</li>
<li class="listitem">
<p>
Restart the server container, which also restarts the
restored server, using the following command:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa45862268"><div class="copy-help left">Press ⌘+C to 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">docker restart mysqlserver</code></pre>
</div>
<p>
Or, start a new MySQL Server on the restored data directory,
as shown here:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa67290853"><div class="copy-help left">Press ⌘+C to 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">docker run <span class="token constant">--name</span><span class="token attr-value"><span class="token punctuation">=</span>mysqlserver2</span> \
<span class="token property">--mount</span> type<span class="token attr-value"><span class="token punctuation">=</span>bind,src=</span><em class="replaceable"><span class="token attr-value">/path</span><span class="token constant">-on-host-machine/datadir/</span></em><span class="token constant">,dst</span><span class="token attr-value"><span class="token punctuation">=</span>/var/lib/mysql</span> \
<span class="token property">-d</span> mysql/enterprise-server<span class="token punctuation">:</span>8<span class="token punctuation">.</span>4</code></pre>
</div>
<p>
Log on to the server to check that the server is running
with the restored data.
</p>
</li>
</ol>
</div>
<h5>
<a name="docker-mysqldump">
</a>
Using
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
with Docker
</h5>
<p>
Besides
<a class="link" href="docker-mysql-more-topics.html#docker-meb" title="Using MySQL Enterprise Backup with Docker">
using MySQL Enterprise Backup to back up a
MySQL Server running in a Docker container
</a>
, you can
perform a logical backup of your server by using the
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
utility, run inside a Docker
container.
</p>
<p>
The following instructions assume that you already have a MySQL
Server running in a Docker container and, when the container was
first started, a host directory
<em class="replaceable">
<code>
/path-on-host-machine/datadir/
</code>
</em>
has
been mounted onto the server's data directory
<code class="filename">
/var/lib/mysql
</code>
(see
<a class="link" href="docker-mysql-more-topics.html#docker-persisting-data-configuration" title="Persisting Data and Configuration Changes">
bind-mounting
a host directory on the data directory of the MySQL
Server
</a>
for details), which contains the Unix socket file
by which
<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="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
<span class="command">
<strong>
mysql
</strong>
</span>
</a>
can connect to the server. We also
assume that, after the server has been started, a user with the
proper privileges (
<code class="literal">
admin
</code>
in this example) has
been created, with which
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
can access
the server. Use the following steps to back up and restore MySQL
Server data:
</p>
<p>
<span class="emphasis">
<em>
Backing up MySQL Server data using
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
with Docker
</em>
</span>
:
</p>
<div class="orderedlist">
<ol class="orderedlist" type="1">
<li class="listitem">
<p>
On the same host where the MySQL Server container is
running, start another container with an image of MySQL
Server to perform a backup with the
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
utility (see documentation of
the utility for its functionality, options, and
limitations). Provide access to the server's data
directory by bind mounting
<em class="replaceable">
<code>
/path-on-host-machine/datadir/
</code>
</em>
.
Also, mount a host directory
(
<em class="replaceable">
<code>
/path-on-host-machine/backups/
</code>
</em>
in this example) onto a storage folder for backups inside
the container (
<code class="filename">
/data/backups
</code>
is used in
this example) to persist the backups you are creating. Here
is a sample command for backing up all databases on the
server using this setup:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa37252493"><div class="copy-help left">Press ⌘+C to 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">docker</span> run <span class="token property">--entrypoint</span> <span class="token atrule">"/bin/sh"</span> \
<span class="token property">--mount</span> type<span class="token attr-value"><span class="token punctuation">=</span>bind,src=<em class="replaceable">/path-on-host-machine/datadir/</em>,dst=/var/lib/mysql</span> \
<span class="token property">--mount</span> type<span class="token attr-value"><span class="token punctuation">=</span>bind,src=</span><em class="replaceable"><span class="token attr-value">/path</span><span class="token constant">-on-host-machine/backups/</span></em><span class="token constant">,dst</span><span class="token attr-value"><span class="token punctuation">=</span>/data/backups</span> \
<span class="token property">--rm</span> container-registry<span class="token punctuation">.</span>oracle<span class="token punctuation">.</span>com/mysql/community-server<span class="token punctuation">:</span>8<span class="token punctuation">.</span>4 \
<span class="token property">-c</span> <span class="token atrule">"mysqldump -u<em class="replaceable">admin</em> --password='<em class="replaceable">password</em>' --all-databases > /data/backups/all-databases.sql"</span></code></pre>
</div>
<p>
In the command, the
<code class="literal">
--entrypoint
</code>
option
is used so that the system shell is invoked after the
container is started, and the
<code class="literal">
-c
</code>
option
is used to specify 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
to be run in the shell, whose output is redirected to the
file
<code class="filename">
all-databases.sql
</code>
in the backup
directory.
</p>
</li>
<li class="listitem">
<p>
The container exits once the backup job is finished and,
with the
<code class="literal">
--rm
</code>
option used to start it, it
is removed after it exits. A logical backup been created,
and can be found in the host directory mounted for storing
the backup, as shown here:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa73845891"><div class="copy-help left">Press ⌘+C to 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">ls</span> <em class="replaceable">/path-on-host-machine/backups/</em>
all-databases<span class="token punctuation">.</span>sql</code></pre>
</div>
<p>
</p>
</li>
</ol>
</div>
<p>
<span class="emphasis">
<em>
Restoring MySQL Server data using
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
with Docker
</em>
</span>
:
</p>
<div class="orderedlist">
<ol class="orderedlist" type="1">
<li class="listitem">
<p>
Make sure you have a MySQL Server running in a container,
onto which you want your backed-up data to be restored.
</p>
</li>
<li class="listitem">
<p>
Start a container with an image of MySQL Server to perform
the restore with a
<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.
Bind-mount the server's data directory, as well as the
storage folder that contains your backup:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa49983152"><div class="copy-help left">Press ⌘+C to 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">docker</span> run \
<span class="token property">--mount</span> type<span class="token attr-value"><span class="token punctuation">=</span>bind,src=</span><em class="replaceable"><span class="token attr-value">/path</span><span class="token constant">-on-host-machine/datadir/</span></em><span class="token constant">,dst</span><span class="token attr-value"><span class="token punctuation">=</span>/var/lib/mysql</span> \
<span class="token property">--mount</span> type<span class="token attr-value"><span class="token punctuation">=</span>bind,src=</span><em class="replaceable"><span class="token attr-value">/path</span><span class="token constant">-on-host-machine/backups/</span></em><span class="token constant">,dst</span><span class="token attr-value"><span class="token punctuation">=</span>/data/backups</span> \
<span class="token property">--rm</span> container-registry<span class="token punctuation">.</span>oracle<span class="token punctuation">.</span>com/mysql/community-server<span class="token punctuation">:</span>8<span class="token punctuation">.</span>4 \
mysql <span class="token property">-u<em class="replaceable">admin</em></span> <span class="token constant">--password</span>=<span class="token atrule">'<em class="replaceable">password</em>'</span> <span class="token property">-e</span> <span class="token atrule">"source /data/backups/all-databases.sql"</span></code></pre>
</div>
<p>
The container exits once the backup job is finished and,
with the
<code class="option">
--rm
</code>
option used when starting it,
it is removed after it exits.
</p>
</li>
<li class="listitem">
<p>
Log on to the server to check that the restored data is now
on the server.
</p>
</li>
</ol>
</div>
<h5>
<a name="docker-known-issues">
</a>
Known Issues
</h5>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
When using the server system variable
<a class="link" href="audit-log-reference.html#sysvar_audit_log_file">
<code class="literal">
audit_log_file
</code>
</a>
to configure
the audit log file name, use the
<code class="literal">
loose
</code>
<a class="link" href="option-modifiers.html" title="6.2.2.4 Program Option Modifiers">
option modifier
</a>
with
it; otherwise, Docker cannot start the server.
</p>
</li>
</ul>
</div>
<h5>
<a name="docker-environment-variables">
</a>
Docker Environment Variables
</h5>
<p>
When you create a MySQL Server container, you can configure the
MySQL instance by using the
<code class="option">
--env
</code>
option (short
form
<code class="option">
-e
</code>
) and specifying one or more environment
variables. No server initialization is performed if the mounted
data directory is not empty, in which case setting any of these
variables has no effect (see
<a class="xref" href="docker-mysql-more-topics.html#docker-persisting-data-configuration" title="Persisting Data and Configuration Changes">
Persisting Data and Configuration Changes
</a>
), and no
existing contents of the directory, including server settings,
are modified during container startup.
</p>
<p>
Environment variables which can be used to configure a MySQL
instance are listed here:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
The boolean variables including
<a class="link" href="docker-mysql-more-topics.html#docker_var_mysql_random_root_password">
<code class="option">
MYSQL_RANDOM_ROOT_PASSWORD
</code>
</a>
,
<a class="link" href="docker-mysql-more-topics.html#docker_var_mysql_onetime_password">
<code class="option">
MYSQL_ONETIME_PASSWORD
</code>
</a>
,
<a class="link" href="docker-mysql-more-topics.html#docker_var_mysql-allow-empty-password">
<code class="option">
MYSQL_ALLOW_EMPTY_PASSWORD
</code>
</a>
,
and
<a class="link" href="docker-mysql-more-topics.html#docker_var_mysql-log-console">
<code class="option">
MYSQL_LOG_CONSOLE
</code>
</a>
are made true by setting them with any strings of nonzero
lengths.
Therefore, setting them to, for example,
<span class="quote">
“
<span class="quote">
0
</span>
”
</span>
,
<span class="quote">
“
<span class="quote">
false
</span>
”
</span>
, or
<span class="quote">
“
<span class="quote">
no
</span>
”
</span>
does not make
them false, but actually makes them true. This is a known
issue.
</p>
</li>
<li class="listitem">
<p>
<a name="docker_var_mysql_random_root_password">
</a>
<a class="link" href="docker-mysql-more-topics.html#docker_var_mysql_random_root_password">
<code class="option">
MYSQL_RANDOM_ROOT_PASSWORD
</code>
</a>
:
When this variable is true (which is its default state,
unless
<a class="link" href="docker-mysql-more-topics.html#docker_var_mysql-root-password">
<code class="option">
MYSQL_ROOT_PASSWORD
</code>
</a>
is set or
<a class="link" href="docker-mysql-more-topics.html#docker_var_mysql-allow-empty-password">
<code class="option">
MYSQL_ALLOW_EMPTY_PASSWORD
</code>
</a>
is set to true), a random password for the server's root
user is generated when the Docker container is started. The
password is printed to
<code class="literal">
stdout
</code>
of the
container and can be found by looking at the container’s
log (see
<a class="xref" href="docker-mysql-getting-started.html#docker-starting-mysql-server" title="Starting a MySQL Server Instance">
Starting a MySQL Server Instance
</a>
).
</p>
</li>
<li class="listitem">
<p>
<a name="docker_var_mysql_onetime_password">
</a>
<a class="link" href="docker-mysql-more-topics.html#docker_var_mysql_onetime_password">
<code class="option">
MYSQL_ONETIME_PASSWORD
</code>
</a>
:
When the variable is true (which is its default state,
unless
<a class="link" href="docker-mysql-more-topics.html#docker_var_mysql-root-password">
<code class="option">
MYSQL_ROOT_PASSWORD
</code>
</a>
is set or
<a class="link" href="docker-mysql-more-topics.html#docker_var_mysql-allow-empty-password">
<code class="option">
MYSQL_ALLOW_EMPTY_PASSWORD
</code>
</a>
is set to true), the root user's password is set as expired
and must be changed before MySQL can be used normally.
</p>
</li>
<li class="listitem">
<p>
<a name="docker_var_mysql_database">
</a>
<a class="link" href="docker-mysql-more-topics.html#docker_var_mysql_database">
<code class="option">
MYSQL_DATABASE
</code>
</a>
:
This variable allows you to specify the name of a database
to be created on image startup. If a user name and a
password are supplied with
<a class="link" href="docker-mysql-more-topics.html#docker_var_mysql_user_password">
<code class="option">
MYSQL_USER
</code>
</a>
and
<a class="link" href="docker-mysql-more-topics.html#docker_var_mysql_user_password">
<code class="option">
MYSQL_PASSWORD
</code>
</a>
,
the user is created and granted superuser access to this
database (corresponding to
<code class="literal">
GRANT ALL
</code>
).
The specified database is created by a
<a class="link" href="create-database.html" title="15.1.12 CREATE DATABASE Statement">
CREATE DATABASE IF NOT
EXIST
</a>
statement, so that the variable has no effect
if the database already exists.
</p>
</li>
<li class="listitem">
<p>
<a name="docker_var_mysql_user_password">
</a>
<a class="link" href="docker-mysql-more-topics.html#docker_var_mysql_user_password">
<code class="option">
MYSQL_USER
</code>
</a>
,
<a class="link" href="docker-mysql-more-topics.html#docker_var_mysql_user_password">
<code class="option">
MYSQL_PASSWORD
</code>
</a>
:
These variables are used in conjunction to create a user and
set that user's password, and the user is granted superuser
permissions for the database specified by the
<a class="link" href="docker-mysql-more-topics.html#docker_var_mysql_database">
<code class="option">
MYSQL_DATABASE
</code>
</a>
variable. Both
<a class="link" href="docker-mysql-more-topics.html#docker_var_mysql_user_password">
<code class="option">
MYSQL_USER
</code>
</a>
and
<a class="link" href="docker-mysql-more-topics.html#docker_var_mysql_user_password">
<code class="option">
MYSQL_PASSWORD
</code>
</a>
are required for a user to be created—if any of the
two variables is not set, the other is ignored. If both
variables are set but
<a class="link" href="docker-mysql-more-topics.html#docker_var_mysql_database">
<code class="option">
MYSQL_DATABASE
</code>
</a>
is not, the user is created without any privileges.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
There is no need to use this mechanism to create the
root superuser, which is created by default with the
password set by either one of the mechanisms discussed
in the descriptions for
<a class="link" href="docker-mysql-more-topics.html#docker_var_mysql-root-password">
<code class="option">
MYSQL_ROOT_PASSWORD
</code>
</a>
and
<a class="link" href="docker-mysql-more-topics.html#docker_var_mysql_random_root_password">
<code class="option">
MYSQL_RANDOM_ROOT_PASSWORD
</code>
</a>
,
unless
<a class="link" href="docker-mysql-more-topics.html#docker_var_mysql-allow-empty-password">
<code class="option">
MYSQL_ALLOW_EMPTY_PASSWORD
</code>
</a>
is true.
</p>
</div>
<p>
</p>
</li>
<li class="listitem">
<p>
<a name="docker_var_mysql-root-host">
</a>
<a class="link" href="docker-mysql-more-topics.html#docker_var_mysql-root-host">
<code class="option">
MYSQL_ROOT_HOST
</code>
</a>
:
By default, MySQL creates the
<code class="literal">
'root'@'localhost'
</code>
account. This account
can only be connected to from inside the container as
described in
<a class="xref" href="docker-mysql-getting-started.html#docker-connecting-within-container" title="Connecting to MySQL Server from within the Container">
Connecting to MySQL Server from within the Container
</a>
. To
allow root connections from other hosts, set this
environment variable. For example, the value
<code class="literal">
172.17.0.1
</code>
, which is the default Docker
gateway IP, allows connections from the host machine that
runs the container. The option accepts only one entry, but
wildcards are allowed (for example,
<code class="option">
MYSQL_ROOT_HOST=172.*.*.*
</code>
or
<code class="option">
MYSQL_ROOT_HOST=%
</code>
).
</p>
</li>
<li class="listitem">
<p>
<a name="docker_var_mysql-log-console">
</a>
<a class="link" href="docker-mysql-more-topics.html#docker_var_mysql-log-console">
<code class="option">
MYSQL_LOG_CONSOLE
</code>
</a>
:
When the variable is true (which is its default state for
MySQL 8.4 server containers), the MySQL
Server's error log is redirected to
<code class="literal">
stderr
</code>
, so that the error log goes into
the Docker container's log and is viewable using the
<span class="command">
<strong>
docker logs
<em class="replaceable">
<code>
mysqld-container
</code>
</em>
</strong>
</span>
command.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
The variable has no effect if a server configuration file
from the host has been mounted (see
<a class="xref" href="docker-mysql-more-topics.html#docker-persisting-data-configuration" title="Persisting Data and Configuration Changes">
Persisting Data and Configuration Changes
</a>
on
bind-mounting a configuration file).
</p>
</div>
</li>
<li class="listitem">
<p>
<a name="docker_var_mysql-root-password">
</a>
<a class="link" href="docker-mysql-more-topics.html#docker_var_mysql-root-password">
<code class="option">
MYSQL_ROOT_PASSWORD
</code>
</a>
:
This variable specifies a password that is set for the MySQL
root account.
</p>
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Warning
</div>
<p>
Setting the MySQL root user password on the command line
is insecure. As an alternative to specifying the password
explicitly, you can set the variable with a container file
path for a password file, and then mount a file from your
host that contains the password at the container file
path. This is still not very secure, as the location of
the password file is still exposed. It is preferable to
use the default settings of
<a class="link" href="docker-mysql-more-topics.html#docker_var_mysql_random_root_password">
<code class="option">
MYSQL_RANDOM_ROOT_PASSWORD
</code>
</a>
and
<a class="link" href="docker-mysql-more-topics.html#docker_var_mysql_onetime_password">
<code class="option">
MYSQL_ONETIME_PASSWORD
</code>
</a>
both being true.
</p>
</div>
</li>
<li class="listitem">
<p>
<a name="docker_var_mysql-allow-empty-password">
</a>
<a class="link" href="docker-mysql-more-topics.html#docker_var_mysql-allow-empty-password">
<code class="option">
MYSQL_ALLOW_EMPTY_PASSWORD
</code>
</a>
.
Set it to true to allow the container to be started with a
blank password for the root user.
</p>
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Warning
</div>
<p>
Setting this variable to true is insecure, because it is
going to leave your MySQL instance completely
unprotected, allowing anyone to gain complete superuser
access. It is preferable to use the default settings of
<a class="link" href="docker-mysql-more-topics.html#docker_var_mysql_random_root_password">
<code class="option">
MYSQL_RANDOM_ROOT_PASSWORD
</code>
</a>
and
<a class="link" href="docker-mysql-more-topics.html#docker_var_mysql_onetime_password">
<code class="option">
MYSQL_ONETIME_PASSWORD
</code>
</a>
both being true.
</p>
</div>
<p>
</p>
</li>
</ul>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/null-values.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="null-values">
</a>
11.1.7 NULL Values
</h3>
</div>
</div>
</div>
<a class="indexterm" name="idm46045220097296">
</a>
<a class="indexterm" name="idm46045220096224">
</a>
<a class="indexterm" name="idm46045220094736">
</a>
<p>
The
<code class="literal">
NULL
</code>
value means
<span class="quote">
“
<span class="quote">
no data.
</span>
”
</span>
<code class="literal">
NULL
</code>
can be written in any lettercase.
</p>
<p>
Be aware that the
<code class="literal">
NULL
</code>
value is different
from values such as
<code class="literal">
0
</code>
for numeric types or
the empty string for string types. For more information, see
<a class="xref" href="problems-with-null.html" title="B.3.4.3 Problems with NULL Values">
Section B.3.4.3, “Problems with NULL Values”
</a>
.
</p>
<p>
For text file import or export operations performed with
<a class="link" href="load-data.html" title="15.2.9 LOAD DATA Statement">
<code class="literal">
LOAD DATA
</code>
</a>
or
<a class="link" href="select-into.html" title="15.2.13.1 SELECT ... INTO Statement">
<code class="literal">
SELECT ... INTO
OUTFILE
</code>
</a>
,
<code class="literal">
NULL
</code>
is represented by the
<code class="literal">
\N
</code>
sequence. 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>
For sorting with
<code class="literal">
ORDER BY
</code>
,
<code class="literal">
NULL
</code>
values sort before other values for
ascending sorts, after other values for descending sorts.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/replication-threads.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="replication-threads">
</a>
19.2.3 Replication Threads
</h3>
</div>
</div>
</div>
<div class="toc">
<dl class="toc">
<dt>
<span class="section">
<a href="replication-threads-monitor-main.html">
19.2.3.1 Monitoring Replication Main Threads
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="replication-threads-monitor-worker.html">
19.2.3.2 Monitoring Replication Applier Worker Threads
</a>
</span>
</dt>
</dl>
</div>
<p>
MySQL replication capabilities are implemented using the following
types of threads:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<b>
Binary log dump thread.
</b>
The source creates a thread to send the binary log contents
to a replica when the replica connects. This thread can be
identified in the output of
<a class="link" href="show-processlist.html" title="15.7.7.31 SHOW PROCESSLIST Statement">
<code class="literal">
SHOW
PROCESSLIST
</code>
</a>
on the source as the
<code class="literal">
Binlog
Dump
</code>
thread.
</p>
</li>
<li class="listitem">
<p>
<b>
Replication I/O receiver thread.
</b>
When a
<a class="link" href="start-replica.html" title="15.4.2.4 START REPLICA Statement">
<code class="literal">
START REPLICA
</code>
</a>
statement is issued on a replica server, the replica creates
an I/O (receiver) thread, which connects to the source and
asks it to send the updates recorded in its binary logs.
</p>
<p>
The replication receiver thread reads the updates that the
source's
<code class="literal">
Binlog Dump
</code>
thread sends (see
previous item) and copies them to local files that comprise
the replica's relay log.
</p>
<p>
The state of this thread is shown as
<code class="literal">
Slave_IO_running
</code>
in the output of
<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>
.
</p>
</li>
<li class="listitem">
<p>
<b>
Replication SQL applier thread.
</b>
When
<a class="link" href="replication-options-replica.html#sysvar_replica_parallel_workers">
<code class="literal">
replica_parallel_workers
</code>
</a>
is
equal to 0, the replica creates an SQL (applier) thread to
read the relay log that is written by the replication
receiver thread and execute the transactions contained in
it. When
<code class="literal">
replica_parallel_workers
</code>
is
<code class="literal">
<em class="replaceable">
<code>
N
</code>
</em>
>= 1
</code>
,
there are
<em class="replaceable">
<code>
N
</code>
</em>
applier threads and
one coordinator thread, which reads transactions
sequentially from the relay log, and schedules them to be
applied by worker threads. Each worker applies the
transactions that the coordinator has assigned to it.
</p>
</li>
</ul>
</div>
<p>
You can enable further parallelization for tasks on a replica by
setting the system variable
<code class="literal">
replica_parallel_workers
</code>
to a value greater
than 0. When this is done, the replica creates the specified
number of worker threads to apply transactions, plus a coordinator
thread which reads transactions from the relay log and assigns
them to workers. A replica with
<code class="literal">
replica_parallel_workers
</code>
(
<code class="literal">
slave_parallel_workers
</code>
) set to a value greater
than 0 is called a multithreaded replica. If you are using
multiple replication channels, each channel has the number of
threads specified using this variable.
</p>
<p>
Multithreaded replicas are also supported by NDB Cluster. See
<a class="xref" href="mysql-cluster-replication-mta.html" title="25.7.11 NDB Cluster Replication Using the Multithreaded Applier">
Section 25.7.11, “NDB Cluster Replication Using the Multithreaded Applier”
</a>
, for more
information.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/mysql-cluster-upgrade-downgrade.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="mysql-cluster-upgrade-downgrade">
</a>
25.3.7 Upgrading and Downgrading NDB Cluster
</h3>
</div>
</div>
</div>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="xref" href="mysql-cluster-upgrade-downgrade.html#mysql-cluster-upgrade-versions" title="Versions Supported for Upgrade to NDB 8.4">
Versions Supported for Upgrade to NDB 8.4
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="mysql-cluster-upgrade-downgrade.html#mysql-cluster-updowngrade-issues" title="Known Issues When Upgrading or Downgrading NDB Cluster">
Known Issues When Upgrading or Downgrading NDB Cluster
</a>
</p>
</li>
</ul>
</div>
<a class="indexterm" name="idm46045122053360">
</a>
<a class="indexterm" name="idm46045122051872">
</a>
<a class="indexterm" name="idm46045122050384">
</a>
<a class="indexterm" name="idm46045122048896">
</a>
<p>
This section provides information about NDB Cluster software and
compatibility between different NDB Cluster releases with regard
to performing upgrades and downgrades. You should already be
familiar with installing and configuring NDB Cluster prior to
attempting an upgrade or downgrade. See
<a class="xref" href="mysql-cluster-configuration.html" title="25.4 Configuration of NDB Cluster">
Section 25.4, “Configuration of NDB Cluster”
</a>
.
</p>
<p>
For information about upgrades to NDB 8.4 from
previous versions, see
<a class="xref" href="mysql-cluster-upgrade-downgrade.html#mysql-cluster-upgrade-versions" title="Versions Supported for Upgrade to NDB 8.4">
Versions Supported for Upgrade to NDB 8.4
</a>
.
</p>
<p>
For information about known issues and problems encountered when
upgrading or downgrading NDB 8.4, see
<a class="xref" href="mysql-cluster-upgrade-downgrade.html#mysql-cluster-updowngrade-issues" title="Known Issues When Upgrading or Downgrading NDB Cluster">
Known Issues When Upgrading or Downgrading NDB Cluster
</a>
.
</p>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h4 class="title">
<a name="mysql-cluster-upgrade-versions">
</a>
Versions Supported for Upgrade to NDB 8.4
</h4>
</div>
</div>
</div>
<p>
The following versions of NDB Cluster are supported for upgrades
to NDB Cluster 8.4:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
NDB Cluster 8.0: NDB 8.0.19 and later
</p>
</li>
<li class="listitem">
<p>
NDB Cluster 8.1 (8.1.0)
</p>
</li>
<li class="listitem">
<p>
NDB Cluster 8.2 (8.2.0)
</p>
</li>
<li class="listitem">
<p>
NDB Cluster 8.3 (8.3.0)
</p>
</li>
</ul>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h4 class="title">
<a name="mysql-cluster-updowngrade-issues">
</a>
Known Issues When Upgrading or Downgrading NDB Cluster
</h4>
</div>
</div>
</div>
<p>
In this section, provide information about issues known to occur
when upgrading or downgrading to or from NDB 8.4.
</p>
<p>
We recommend that you not attempt any schema changes during any
NDB Cluster software upgrade or downgrade. Some of the reasons
for this are listed here:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
DDL statements on
<code class="literal">
NDB
</code>
tables are not
possible during some phases of data node startup.
</p>
</li>
<li class="listitem">
<p>
DDL statements on
<code class="literal">
NDB
</code>
tables may be
rejected if any data nodes are stopped during execution;
stopping each data node binary (so it can be replaced with a
binary from the target version) is required as part of the
upgrade or downgrade process.
</p>
</li>
<li class="listitem">
<p>
DDL statements on
<code class="literal">
NDB
</code>
tables are not
allowed while there are data nodes in the same cluster
running different release versions of the NDB Cluster
software.
</p>
</li>
</ul>
</div>
<p>
For additional information regarding the rolling restart
procedure used to perform an online upgrade or downgrade of the
data nodes, 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>
.
</p>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/innodb-information-schema-system-tables.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="innodb-information-schema-system-tables">
</a>
17.15.3 InnoDB INFORMATION_SCHEMA Schema Object Tables
</h3>
</div>
</div>
</div>
<p>
You can extract metadata about schema objects managed by
<code class="literal">
InnoDB
</code>
using
<code class="literal">
InnoDB
</code>
<code class="literal">
INFORMATION_SCHEMA
</code>
tables. This information
comes from the data dictionary. Traditionally, you would get this
type of information using the techniques from
<a class="xref" href="innodb-monitors.html" title="17.17 InnoDB Monitors">
Section 17.17, “InnoDB Monitors”
</a>
, setting up
<code class="literal">
InnoDB
</code>
monitors and parsing the output from the
<a class="link" href="show-engine.html" title="15.7.7.16 SHOW ENGINE Statement">
<code class="literal">
SHOW ENGINE INNODB
STATUS
</code>
</a>
statement. The
<code class="literal">
InnoDB
</code>
<code class="literal">
INFORMATION_SCHEMA
</code>
table interface allows you
to query this data using SQL.
</p>
<p>
<code class="literal">
InnoDB
</code>
<code class="literal">
INFORMATION_SCHEMA
</code>
schema object tables include the tables listed here:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
INNODB_DATAFILES
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
INNODB_TABLESTATS
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
INNODB_FOREIGN
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
INNODB_COLUMNS
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
INNODB_INDEXES
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
INNODB_FIELDS
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
INNODB_TABLESPACES
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
INNODB_TABLESPACES_BRIEF
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
INNODB_FOREIGN_COLS
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
INNODB_TABLES
</code>
</p>
</li>
</ul>
</div>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-none"><div class="docs-select-all right" id="sa92279881"><div class="copy-help left">Press ⌘+C to 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"></code></pre>
</div>
<p>
The table names are indicative of the type of data provided:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<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>
provides metadata
about
<code class="literal">
InnoDB
</code>
tables.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="information-schema-innodb-columns-table.html" title="28.4.9 The INFORMATION_SCHEMA INNODB_COLUMNS Table">
<code class="literal">
INNODB_COLUMNS
</code>
</a>
provides metadata
about
<code class="literal">
InnoDB
</code>
table columns.
</p>
</li>
<li class="listitem">
<p>
<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>
provides metadata
about
<code class="literal">
InnoDB
</code>
indexes.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="information-schema-innodb-fields-table.html" title="28.4.11 The INFORMATION_SCHEMA INNODB_FIELDS Table">
<code class="literal">
INNODB_FIELDS
</code>
</a>
provides metadata
about the key columns (fields) of
<code class="literal">
InnoDB
</code>
indexes.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="information-schema-innodb-tablestats-table.html" title="28.4.26 The INFORMATION_SCHEMA INNODB_TABLESTATS View">
<code class="literal">
INNODB_TABLESTATS
</code>
</a>
provides a view
of low-level status information about
<code class="literal">
InnoDB
</code>
tables that is derived from
in-memory data structures.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="information-schema-innodb-datafiles-table.html" title="28.4.10 The INFORMATION_SCHEMA INNODB_DATAFILES Table">
<code class="literal">
INNODB_DATAFILES
</code>
</a>
provides data
file path information for
<code class="literal">
InnoDB
</code>
file-per-table and general tablespaces.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="information-schema-innodb-tablespaces-table.html" title="28.4.24 The INFORMATION_SCHEMA INNODB_TABLESPACES Table">
<code class="literal">
INNODB_TABLESPACES
</code>
</a>
provides
metadata about
<code class="literal">
InnoDB
</code>
file-per-table,
general, and undo tablespaces.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="information-schema-innodb-tablespaces-brief-table.html" title="28.4.25 The INFORMATION_SCHEMA INNODB_TABLESPACES_BRIEF Table">
<code class="literal">
INNODB_TABLESPACES_BRIEF
</code>
</a>
provides
a subset of metadata about
<code class="literal">
InnoDB
</code>
tablespaces.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="information-schema-innodb-foreign-table.html" title="28.4.12 The INFORMATION_SCHEMA INNODB_FOREIGN Table">
<code class="literal">
INNODB_FOREIGN
</code>
</a>
provides metadata
about foreign keys defined on
<code class="literal">
InnoDB
</code>
tables.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="information-schema-innodb-foreign-cols-table.html" title="28.4.13 The INFORMATION_SCHEMA INNODB_FOREIGN_COLS Table">
<code class="literal">
INNODB_FOREIGN_COLS
</code>
</a>
provides
metadata about the columns of foreign keys that are defined on
<code class="literal">
InnoDB
</code>
tables.
</p>
</li>
</ul>
</div>
<p>
<code class="literal">
InnoDB
</code>
<code class="literal">
INFORMATION_SCHEMA
</code>
schema object tables can be joined together through fields such as
<code class="literal">
TABLE_ID
</code>
,
<code class="literal">
INDEX_ID
</code>
, and
<code class="literal">
SPACE
</code>
, allowing you to easily retrieve all
available data for an object you want to study or monitor.
</p>
<p>
Refer to the
<code class="literal">
InnoDB
</code>
<a class="link" href="innodb-information-schema-tables.html" title="28.4 INFORMATION_SCHEMA InnoDB Tables">
INFORMATION_SCHEMA
</a>
documentation for information about the columns of each table.
</p>
<div class="example">
<a name="innodb-information-schema-system-tables-example">
</a>
<p class="title">
<b>
Example 17.2 InnoDB INFORMATION_SCHEMA Schema Object Tables
</b>
</p>
<div class="example-contents">
<p>
This example uses a simple table (
<code class="literal">
t1
</code>
) with a
single index (
<code class="literal">
i1
</code>
) to demonstrate the type of
metadata found in the
<code class="literal">
InnoDB
</code>
<code class="literal">
INFORMATION_SCHEMA
</code>
schema object tables.
</p>
<div class="orderedlist">
<ol class="orderedlist" type="1">
<li class="listitem">
<p>
Create a test database and table
<code class="literal">
t1
</code>
:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa70175881"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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> test<span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">USE</span> test<span class="token punctuation">;</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>
col1 <span class="token datatype">INT</span><span class="token punctuation">,</span>
col2 <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 punctuation">,</span>
col3 <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 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">CREATE</span> <span class="token keyword">INDEX</span> i1 <span class="token keyword">ON</span> t1<span class="token punctuation">(</span>col1<span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
After creating the table
<code class="literal">
t1
</code>
, query
<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>
to locate the
metadata for
<code class="literal">
test/t1
</code>
:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa9048394"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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> 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">=</span><span class="token string">'test/t1'</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>
TABLE_ID<span class="token punctuation">:</span> 71
NAME<span class="token punctuation">:</span> test/t1
FLAG<span class="token punctuation">:</span> 1
N_COLS<span class="token punctuation">:</span> 6
SPACE<span class="token punctuation">:</span> 57
ROW_FORMAT<span class="token punctuation">:</span> Compact
ZIP_PAGE_SIZE<span class="token punctuation">:</span> 0
INSTANT_COLS<span class="token punctuation">:</span> 0</span></code></pre>
</div>
<p>
Table
<code class="literal">
t1
</code>
has a
<code class="literal">
TABLE_ID
</code>
of 71. The
<code class="literal">
FLAG
</code>
field provides bit level information
about table format and storage characteristics. There are
six columns, three of which are hidden columns created by
<code class="literal">
InnoDB
</code>
(
<code class="literal">
DB_ROW_ID
</code>
,
<code class="literal">
DB_TRX_ID
</code>
, and
<code class="literal">
DB_ROLL_PTR
</code>
). The ID of the table's
<code class="literal">
SPACE
</code>
is 57 (a value of 0 would indicate
that the table resides in the system tablespace). The
<code class="literal">
ROW_FORMAT
</code>
is Compact.
<code class="literal">
ZIP_PAGE_SIZE
</code>
only applies to tables with
a
<code class="literal">
Compressed
</code>
row format.
<code class="literal">
INSTANT_COLS
</code>
shows number of columns in
the table prior to adding the first instant column using
<code class="literal">
ALTER TABLE ... ADD
COLUMN
</code>
with
<code class="literal">
ALGORITHM=INSTANT
</code>
.
</p>
</li>
<li class="listitem">
<p>
Using the
<code class="literal">
TABLE_ID
</code>
information from
<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>
, query the
<a class="link" href="information-schema-innodb-columns-table.html" title="28.4.9 The INFORMATION_SCHEMA INNODB_COLUMNS Table">
<code class="literal">
INNODB_COLUMNS
</code>
</a>
table for
information about the table's columns.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa90810923"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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> INFORMATION_SCHEMA<span class="token punctuation">.</span>INNODB_COLUMNS <span class="token keyword">where</span> TABLE_ID <span class="token operator">=</span> <span class="token number">71</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>
TABLE_ID<span class="token punctuation">:</span> 71
NAME<span class="token punctuation">:</span> col1
POS<span class="token punctuation">:</span> 0
MTYPE<span class="token punctuation">:</span> 6
PRTYPE<span class="token punctuation">:</span> 1027
LEN<span class="token punctuation">:</span> 4
HAS_DEFAULT<span class="token punctuation">:</span> 0
DEFAULT_VALUE<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>
TABLE_ID<span class="token punctuation">:</span> 71
NAME<span class="token punctuation">:</span> col2
POS<span class="token punctuation">:</span> 1
MTYPE<span class="token punctuation">:</span> 2
PRTYPE<span class="token punctuation">:</span> 524542
LEN<span class="token punctuation">:</span> 10
HAS_DEFAULT<span class="token punctuation">:</span> 0
DEFAULT_VALUE<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> 3. 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_ID<span class="token punctuation">:</span> 71
NAME<span class="token punctuation">:</span> col3
POS<span class="token punctuation">:</span> 2
MTYPE<span class="token punctuation">:</span> 1
PRTYPE<span class="token punctuation">:</span> 524303
LEN<span class="token punctuation">:</span> 10
HAS_DEFAULT<span class="token punctuation">:</span> 0
DEFAULT_VALUE<span class="token punctuation">:</span> NULL</span></code></pre>
</div>
<p>
In addition to the
<code class="literal">
TABLE_ID
</code>
and column
<code class="literal">
NAME
</code>
,
<a class="link" href="information-schema-innodb-columns-table.html" title="28.4.9 The INFORMATION_SCHEMA INNODB_COLUMNS Table">
<code class="literal">
INNODB_COLUMNS
</code>
</a>
provides the
ordinal position (
<code class="literal">
POS
</code>
) of each column
(starting from 0 and incrementing sequentially), the column
<code class="literal">
MTYPE
</code>
or
<span class="quote">
“
<span class="quote">
main type
</span>
”
</span>
(6 =
INT, 2 = CHAR, 1 = VARCHAR), the
<code class="literal">
PRTYPE
</code>
or
<span class="quote">
“
<span class="quote">
precise type
</span>
”
</span>
(a binary value with bits
that represent the MySQL data type, character set code, and
nullability), and the column length
(
<code class="literal">
LEN
</code>
). The
<code class="literal">
HAS_DEFAULT
</code>
and
<code class="literal">
DEFAULT_VALUE
</code>
columns only apply to
columns added instantly using
<code class="literal">
ALTER TABLE ... ADD
COLUMN
</code>
with
<code class="literal">
ALGORITHM=INSTANT
</code>
.
</p>
</li>
<li class="listitem">
<p>
Using the
<code class="literal">
TABLE_ID
</code>
information from
<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>
once again, query
<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>
for information
about the indexes associated with table
<code class="literal">
t1
</code>
.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa8886539"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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> INFORMATION_SCHEMA<span class="token punctuation">.</span>INNODB_INDEXES <span class="token keyword">WHERE</span> TABLE_ID <span class="token operator">=</span> <span class="token number">71</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>
INDEX_ID<span class="token punctuation">:</span> 111
NAME<span class="token punctuation">:</span> GEN_CLUST_INDEX
TABLE_ID<span class="token punctuation">:</span> 71
TYPE<span class="token punctuation">:</span> 1
N_FIELDS<span class="token punctuation">:</span> 0
PAGE_NO<span class="token punctuation">:</span> 3
SPACE<span class="token punctuation">:</span> 57
MERGE_THRESHOLD<span class="token punctuation">:</span> 50
<span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span 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>
INDEX_ID<span class="token punctuation">:</span> 112
NAME<span class="token punctuation">:</span> i1
TABLE_ID<span class="token punctuation">:</span> 71
TYPE<span class="token punctuation">:</span> 0
N_FIELDS<span class="token punctuation">:</span> 1
PAGE_NO<span class="token punctuation">:</span> 4
SPACE<span class="token punctuation">:</span> 57
MERGE_THRESHOLD<span class="token punctuation">:</span> 50</span></code></pre>
</div>
<p>
<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>
returns data for
two indexes. The first index is
<code class="literal">
GEN_CLUST_INDEX
</code>
, which is a clustered
index created by
<code class="literal">
InnoDB
</code>
if the table does
not have a user-defined clustered index. The second index
(
<code class="literal">
i1
</code>
) is the user-defined secondary index.
</p>
<p>
The
<code class="literal">
INDEX_ID
</code>
is an identifier for the
index that is unique across all databases in an instance.
The
<code class="literal">
TABLE_ID
</code>
identifies the table that
the index is associated with. The index
<code class="literal">
TYPE
</code>
value indicates the type of index (1
= Clustered Index, 0 = Secondary index). The
<code class="literal">
N_FILEDS
</code>
value is the number of fields
that comprise the index.
<code class="literal">
PAGE_NO
</code>
is the
root page number of the index B-tree, and
<code class="literal">
SPACE
</code>
is the ID of the tablespace where
the index resides. A nonzero value indicates that the index
does not reside in the system tablespace.
<code class="literal">
MERGE_THRESHOLD
</code>
defines a percentage
threshold value for the amount of data in an index page. If
the amount of data in an index page falls below the this
value (the default is 50%) when a row is deleted or when a
row is shortened by an update operation,
<code class="literal">
InnoDB
</code>
attempts to merge the index page
with a neighboring index page.
</p>
</li>
<li class="listitem">
<p>
Using the
<code class="literal">
INDEX_ID
</code>
information from
<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>
, query
<a class="link" href="information-schema-innodb-fields-table.html" title="28.4.11 The INFORMATION_SCHEMA INNODB_FIELDS Table">
<code class="literal">
INNODB_FIELDS
</code>
</a>
for information
about the fields of index
<code class="literal">
i1
</code>
.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa91521515"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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> INFORMATION_SCHEMA<span class="token punctuation">.</span>INNODB_FIELDS <span class="token keyword">where</span> INDEX_ID <span class="token operator">=</span> <span class="token number">112</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>
INDEX_ID<span class="token punctuation">:</span> 112
NAME<span class="token punctuation">:</span> col1
POS<span class="token punctuation">:</span> 0</span></code></pre>
</div>
<p>
<a class="link" href="information-schema-innodb-fields-table.html" title="28.4.11 The INFORMATION_SCHEMA INNODB_FIELDS Table">
<code class="literal">
INNODB_FIELDS
</code>
</a>
provides the
<code class="literal">
NAME
</code>
of the indexed field and its ordinal
position within the index. If the index (i1) had been
defined on multiple fields,
<a class="link" href="information-schema-innodb-fields-table.html" title="28.4.11 The INFORMATION_SCHEMA INNODB_FIELDS Table">
<code class="literal">
INNODB_FIELDS
</code>
</a>
would provide
metadata for each of the indexed fields.
</p>
</li>
<li class="listitem">
<p>
Using the
<code class="literal">
SPACE
</code>
information from
<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>
, query
<a class="link" href="information-schema-innodb-tablespaces-table.html" title="28.4.24 The INFORMATION_SCHEMA INNODB_TABLESPACES Table">
<code class="literal">
INNODB_TABLESPACES
</code>
</a>
table for
information about the table's tablespace.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa93238760"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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> INFORMATION_SCHEMA<span class="token punctuation">.</span>INNODB_TABLESPACES <span class="token keyword">WHERE</span> SPACE <span class="token operator">=</span> <span class="token number">57</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>
SPACE<span class="token punctuation">:</span> 57
NAME<span class="token punctuation">:</span> test/t1
FLAG<span class="token punctuation">:</span> 16417
ROW_FORMAT<span class="token punctuation">:</span> Dynamic
PAGE_SIZE<span class="token punctuation">:</span> 16384
ZIP_PAGE_SIZE<span class="token punctuation">:</span> 0
SPACE_TYPE<span class="token punctuation">:</span> Single
FS_BLOCK_SIZE<span class="token punctuation">:</span> 4096
FILE_SIZE<span class="token punctuation">:</span> 114688
ALLOCATED_SIZE<span class="token punctuation">:</span> 98304
AUTOEXTEND_SIZE<span class="token punctuation">:</span> 0
SERVER_VERSION<span class="token punctuation">:</span> 8.4.0
SPACE_VERSION<span class="token punctuation">:</span> 1
ENCRYPTION<span class="token punctuation">:</span> N
STATE<span class="token punctuation">:</span> normal</span></code></pre>
</div>
<p>
In addition to the
<code class="literal">
SPACE
</code>
ID of the
tablespace and the
<code class="literal">
NAME
</code>
of the associated
table,
<a class="link" href="information-schema-innodb-tablespaces-table.html" title="28.4.24 The INFORMATION_SCHEMA INNODB_TABLESPACES Table">
<code class="literal">
INNODB_TABLESPACES
</code>
</a>
provides tablespace
<code class="literal">
FLAG
</code>
data, which is
bit level information about tablespace format and storage
characteristics. Also provided are tablespace
<code class="literal">
ROW_FORMAT
</code>
,
<code class="literal">
PAGE_SIZE
</code>
,
and several other tablespace metadata items.
</p>
</li>
<li class="listitem">
<p>
Using the
<code class="literal">
SPACE
</code>
information from
<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>
once again, query
<a class="link" href="information-schema-innodb-datafiles-table.html" title="28.4.10 The INFORMATION_SCHEMA INNODB_DATAFILES Table">
<code class="literal">
INNODB_DATAFILES
</code>
</a>
for the
location of the tablespace data file.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa87016474"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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> INFORMATION_SCHEMA<span class="token punctuation">.</span>INNODB_DATAFILES <span class="token keyword">WHERE</span> SPACE <span class="token operator">=</span> <span class="token number">57</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>
SPACE<span class="token punctuation">:</span> 57
PATH<span class="token punctuation">:</span> ./test/t1.ibd</span></code></pre>
</div>
<p>
The datafile is located in the
<code class="literal">
test
</code>
directory under MySQL's
<code class="literal">
data
</code>
directory.
If a
<a class="link" href="glossary.html#glos_file_per_table" title="file-per-table">
file-per-table
</a>
tablespace were created in a location outside the MySQL data
directory using the
<code class="literal">
DATA DIRECTORY
</code>
clause
of the
<a class="link" href="create-table.html" title="15.1.20 CREATE TABLE Statement">
<code class="literal">
CREATE TABLE
</code>
</a>
statement, the tablespace
<code class="literal">
PATH
</code>
would be a
fully qualified directory path.
</p>
</li>
<li class="listitem">
<p>
As a final step, insert a row into table
<code class="literal">
t1
</code>
(
<code class="literal">
TABLE_ID = 71
</code>
) and
view the data in the
<a class="link" href="information-schema-innodb-tablestats-table.html" title="28.4.26 The INFORMATION_SCHEMA INNODB_TABLESTATS View">
<code class="literal">
INNODB_TABLESTATS
</code>
</a>
table. The
data in this table is used by the MySQL optimizer to
calculate which index to use when querying an
<code class="literal">
InnoDB
</code>
table. This information is derived
from in-memory data structures.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa76122606"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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> t1 <span class="token keyword">VALUES</span><span class="token punctuation">(</span><span class="token number">5</span><span class="token punctuation">,</span> <span class="token string">'abc'</span><span class="token punctuation">,</span> <span class="token string">'def'</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> INFORMATION_SCHEMA<span class="token punctuation">.</span>INNODB_TABLESTATS <span class="token keyword">where</span> TABLE_ID <span class="token operator">=</span> <span class="token number">71</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>
TABLE_ID<span class="token punctuation">:</span> 71
NAME<span class="token punctuation">:</span> test/t1
STATS_INITIALIZED<span class="token punctuation">:</span> Initialized
NUM_ROWS<span class="token punctuation">:</span> 1
CLUST_INDEX_SIZE<span class="token punctuation">:</span> 1
OTHER_INDEX_SIZE<span class="token punctuation">:</span> 0
MODIFIED_COUNTER<span class="token punctuation">:</span> 1
AUTOINC<span class="token punctuation">:</span> 0
REF_COUNT<span class="token punctuation">:</span> 1</span></code></pre>
</div>
<p>
The
<code class="literal">
STATS_INITIALIZED
</code>
field indicates
whether or not statistics have been collected for the table.
<code class="literal">
NUM_ROWS
</code>
is the current estimated number
of rows in the table. The
<code class="literal">
CLUST_INDEX_SIZE
</code>
and
<code class="literal">
OTHER_INDEX_SIZE
</code>
fields report the number
of pages on disk that store clustered and secondary indexes
for the table, respectively. The
<code class="literal">
MODIFIED_COUNTER
</code>
value shows the number
of rows modified by DML operations and cascade operations
from foreign keys. The
<code class="literal">
AUTOINC
</code>
value is
the next number to be issued for any autoincrement-based
operation. There are no autoincrement columns defined on
table
<code class="literal">
t1
</code>
, so the value is 0. The
<code class="literal">
REF_COUNT
</code>
value is a counter. When the
counter reaches 0, it signifies that the table metadata can
be evicted from the table cache.
</p>
</li>
</ol>
</div>
</div>
</div>
<br class="example-break"/>
<div class="example">
<a name="innodb-information-schema-fk-system-tables-example">
</a>
<p class="title">
<b>
Example 17.3 Foreign Key INFORMATION_SCHEMA Schema Object Tables
</b>
</p>
<div class="example-contents">
<p>
The
<a class="link" href="information-schema-innodb-foreign-table.html" title="28.4.12 The INFORMATION_SCHEMA INNODB_FOREIGN Table">
<code class="literal">
INNODB_FOREIGN
</code>
</a>
and
<a class="link" href="information-schema-innodb-foreign-cols-table.html" title="28.4.13 The INFORMATION_SCHEMA INNODB_FOREIGN_COLS Table">
<code class="literal">
INNODB_FOREIGN_COLS
</code>
</a>
tables provide
data about foreign key relationships. This example uses a parent
table and child table with a foreign key relationship to
demonstrate the data found in the
<a class="link" href="information-schema-innodb-foreign-table.html" title="28.4.12 The INFORMATION_SCHEMA INNODB_FOREIGN Table">
<code class="literal">
INNODB_FOREIGN
</code>
</a>
and
<a class="link" href="information-schema-innodb-foreign-cols-table.html" title="28.4.13 The INFORMATION_SCHEMA INNODB_FOREIGN_COLS Table">
<code class="literal">
INNODB_FOREIGN_COLS
</code>
</a>
tables.
</p>
<div class="orderedlist">
<ol class="orderedlist" type="1">
<li class="listitem">
<p>
Create the test database with parent and child tables:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa30544941"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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> test<span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">USE</span> test<span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> parent <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>
<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">ENGINE</span><span class="token operator">=</span>INNODB<span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> child <span class="token punctuation">(</span>id <span class="token datatype">INT</span><span class="token punctuation">,</span> parent_id <span class="token datatype">INT</span><span class="token punctuation">,</span>
<span class="token prompt"> -></span> <span class="token keyword">INDEX</span> par_ind <span class="token punctuation">(</span>parent_id<span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token prompt"> -></span> <span class="token keyword">CONSTRAINT</span> fk1
<span class="token prompt"> -></span> <span class="token keyword">FOREIGN</span> <span class="token keyword">KEY</span> <span class="token punctuation">(</span>parent_id<span class="token punctuation">)</span> <span class="token keyword">REFERENCES</span> parent<span class="token punctuation">(</span>id<span class="token punctuation">)</span>
<span class="token prompt"> -></span> <span class="token keyword">ON</span> <span class="token keyword">DELETE</span> <span class="token keyword">CASCADE</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>
</li>
<li class="listitem">
<p>
After the parent and child tables are created, query
<a class="link" href="information-schema-innodb-foreign-table.html" title="28.4.12 The INFORMATION_SCHEMA INNODB_FOREIGN Table">
<code class="literal">
INNODB_FOREIGN
</code>
</a>
and locate the
foreign key data for the
<code class="literal">
test/child
</code>
and
<code class="literal">
test/parent
</code>
foreign key relationship:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa11050637"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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> INFORMATION_SCHEMA<span class="token punctuation">.</span>INNODB_FOREIGN \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> test/fk1
FOR_NAME<span class="token punctuation">:</span> test/child
REF_NAME<span class="token punctuation">:</span> test/parent
N_COLS<span class="token punctuation">:</span> 1
TYPE<span class="token punctuation">:</span> 1</span></code></pre>
</div>
<p>
Metadata includes the foreign key
<code class="literal">
ID
</code>
(
<code class="literal">
fk1
</code>
), which is named for the
<code class="literal">
CONSTRAINT
</code>
that was defined on the child
table. The
<code class="literal">
FOR_NAME
</code>
is the name of the
child table where the foreign key is defined.
<code class="literal">
REF_NAME
</code>
is the name of the parent table
(the
<span class="quote">
“
<span class="quote">
referenced
</span>
”
</span>
table).
<code class="literal">
N_COLS
</code>
is the number of columns in the
foreign key index.
<code class="literal">
TYPE
</code>
is a numerical
value representing bit flags that provide additional
information about the foreign key column. In this case, the
<code class="literal">
TYPE
</code>
value is 1, which indicates that the
<code class="literal">
ON DELETE CASCADE
</code>
option was specified
for the foreign key. See the
<a class="link" href="information-schema-innodb-foreign-table.html" title="28.4.12 The INFORMATION_SCHEMA INNODB_FOREIGN Table">
<code class="literal">
INNODB_FOREIGN
</code>
</a>
table definition
for more information about
<code class="literal">
TYPE
</code>
values.
</p>
</li>
<li class="listitem">
<p>
Using the foreign key
<code class="literal">
ID
</code>
, query
<a class="link" href="information-schema-innodb-foreign-cols-table.html" title="28.4.13 The INFORMATION_SCHEMA INNODB_FOREIGN_COLS Table">
<code class="literal">
INNODB_FOREIGN_COLS
</code>
</a>
to view
data about the columns of the foreign key.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa77390249"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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> INFORMATION_SCHEMA<span class="token punctuation">.</span>INNODB_FOREIGN_COLS <span class="token keyword">WHERE</span> ID <span class="token operator">=</span> <span class="token string">'test/fk1'</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>
ID<span class="token punctuation">:</span> test/fk1
FOR_COL_NAME<span class="token punctuation">:</span> parent_id
REF_COL_NAME<span class="token punctuation">:</span> id
POS<span class="token punctuation">:</span> 0</span></code></pre>
</div>
<p>
<code class="literal">
FOR_COL_NAME
</code>
is the name of the foreign
key column in the child table, and
<code class="literal">
REF_COL_NAME
</code>
is the name of the
referenced column in the parent table. The
<code class="literal">
POS
</code>
value is the ordinal position of the
key field within the foreign key index, starting at zero.
</p>
</li>
</ol>
</div>
</div>
</div>
<br class="example-break"/>
<div class="example">
<a name="innodb-information-schema-system-tables-join-example">
</a>
<p class="title">
<b>
Example 17.4 Joining InnoDB INFORMATION_SCHEMA Schema Object Tables
</b>
</p>
<div class="example-contents">
<p>
This example demonstrates joining three
<code class="literal">
InnoDB
</code>
<code class="literal">
INFORMATION_SCHEMA
</code>
schema object tables
(
<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>
,
<a class="link" href="information-schema-innodb-tablespaces-table.html" title="28.4.24 The INFORMATION_SCHEMA INNODB_TABLESPACES Table">
<code class="literal">
INNODB_TABLESPACES
</code>
</a>
, and
<a class="link" href="information-schema-innodb-tablestats-table.html" title="28.4.26 The INFORMATION_SCHEMA INNODB_TABLESTATS View">
<code class="literal">
INNODB_TABLESTATS
</code>
</a>
) to gather file
format, row format, page size, and index size information about
tables in the employees sample database.
</p>
<p>
The following table aliases are used to shorten the query
string:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<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>
:
a
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="information-schema-innodb-tablespaces-table.html" title="28.4.24 The INFORMATION_SCHEMA INNODB_TABLESPACES Table">
<code class="literal">
INFORMATION_SCHEMA.INNODB_TABLESPACES
</code>
</a>
:
b
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="information-schema-innodb-tablestats-table.html" title="28.4.26 The INFORMATION_SCHEMA INNODB_TABLESTATS View">
<code class="literal">
INFORMATION_SCHEMA.INNODB_TABLESTATS
</code>
</a>
:
c
</p>
</li>
</ul>
</div>
<p>
An
<a class="link" href="flow-control-functions.html#function_if">
<code class="literal">
IF()
</code>
</a>
control flow function is
used to account for compressed tables. If a table is compressed,
the index size is calculated using
<code class="literal">
ZIP_PAGE_SIZE
</code>
rather than
<code class="literal">
PAGE_SIZE
</code>
.
<code class="literal">
CLUST_INDEX_SIZE
</code>
and
<code class="literal">
OTHER_INDEX_SIZE
</code>
, which are reported in
bytes, are divided by
<code class="literal">
1024*1024
</code>
to provide
index sizes in megabytes (MBs). MB values are rounded to zero
decimal spaces using the
<a class="link" href="mathematical-functions.html#function_round">
<code class="literal">
ROUND()
</code>
</a>
function.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa29549940"><div class="copy-help left">Press ⌘+C to copy</div> <div class="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> a<span class="token punctuation">.</span><span class="token keyword">NAME</span><span class="token punctuation">,</span> a<span class="token punctuation">.</span><span class="token keyword">ROW_FORMAT</span><span class="token punctuation">,</span>
<span class="token variable">@page_size</span> <span class="token operator">:=</span>
<span class="token function">IF</span><span class="token punctuation">(</span>a<span class="token punctuation">.</span><span class="token keyword">ROW_FORMAT</span><span class="token operator">=</span><span class="token string">'Compressed'</span><span class="token punctuation">,</span>
b<span class="token punctuation">.</span>ZIP_PAGE_SIZE<span class="token punctuation">,</span> b<span class="token punctuation">.</span>PAGE_SIZE<span class="token punctuation">)</span>
<span class="token keyword">AS</span> page_size<span class="token punctuation">,</span>
<span class="token function">ROUND</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token variable">@page_size</span> <span class="token operator">*</span> c<span class="token punctuation">.</span>CLUST_INDEX_SIZE<span class="token punctuation">)</span>
<span class="token operator">/</span><span class="token punctuation">(</span><span class="token number">1024</span><span class="token operator">*</span><span class="token number">1024</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token keyword">AS</span> pk_mb<span class="token punctuation">,</span>
<span class="token function">ROUND</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token variable">@page_size</span> <span class="token operator">*</span> c<span class="token punctuation">.</span>OTHER_INDEX_SIZE<span class="token punctuation">)</span>
<span class="token operator">/</span><span class="token punctuation">(</span><span class="token number">1024</span><span class="token operator">*</span><span class="token number">1024</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token keyword">AS</span> secidx_mb
<span class="token keyword">FROM</span> INFORMATION_SCHEMA<span class="token punctuation">.</span>INNODB_TABLES a
<span class="token keyword">INNER</span> <span class="token keyword">JOIN</span> INFORMATION_SCHEMA<span class="token punctuation">.</span>INNODB_TABLESPACES b <span class="token keyword">on</span> a<span class="token punctuation">.</span><span class="token keyword">NAME</span> <span class="token operator">=</span> b<span class="token punctuation">.</span><span class="token keyword">NAME</span>
<span class="token keyword">INNER</span> <span class="token keyword">JOIN</span> INFORMATION_SCHEMA<span class="token punctuation">.</span>INNODB_TABLESTATS c <span class="token keyword">on</span> b<span class="token punctuation">.</span><span class="token keyword">NAME</span> <span class="token operator">=</span> c<span class="token punctuation">.</span><span class="token keyword">NAME</span>
<span class="token keyword">WHERE</span> a<span class="token punctuation">.</span><span class="token keyword">NAME</span> <span class="token operator">LIKE</span> <span class="token string">'employees/%'</span>
<span class="token keyword">ORDER</span> <span class="token keyword">BY</span> a<span class="token punctuation">.</span><span class="token keyword">NAME</span> <span class="token keyword">DESC</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> NAME <span class="token punctuation">|</span> ROW_FORMAT <span class="token punctuation">|</span> page_size <span class="token punctuation">|</span> pk_mb <span class="token punctuation">|</span> secidx_mb <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> employees/titles <span class="token punctuation">|</span> Dynamic <span class="token punctuation">|</span> 16384 <span class="token punctuation">|</span> 20 <span class="token punctuation">|</span> 11 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> employees/salaries <span class="token punctuation">|</span> Dynamic <span class="token punctuation">|</span> 16384 <span class="token punctuation">|</span> 93 <span class="token punctuation">|</span> 34 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> employees/employees <span class="token punctuation">|</span> Dynamic <span class="token punctuation">|</span> 16384 <span class="token punctuation">|</span> 15 <span class="token punctuation">|</span> 0 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> employees/dept_manager <span class="token punctuation">|</span> Dynamic <span class="token punctuation">|</span> 16384 <span class="token punctuation">|</span> 0 <span class="token punctuation">|</span> 0 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> employees/dept_emp <span class="token punctuation">|</span> Dynamic <span class="token punctuation">|</span> 16384 <span class="token punctuation">|</span> 12 <span class="token punctuation">|</span> 10 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> employees/departments <span class="token punctuation">|</span> Dynamic <span class="token punctuation">|</span> 16384 <span class="token punctuation">|</span> 0 <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 class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="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 class="example-break"/>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/multiple-unix-servers.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="multiple-unix-servers">
</a>
7.8.3 Running Multiple MySQL Instances on Unix
</h3>
</div>
</div>
</div>
<a class="indexterm" name="idm46045253960384">
</a>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
The discussion here uses
<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>
to
launch multiple instances of MySQL. For MySQL installation using
an RPM distribution, server startup and shutdown is managed by
systemd on several Linux platforms. On these platforms,
<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>
is not installed because it is
unnecessary. For information about using systemd to handle
multiple MySQL instances, see
<a class="xref" href="using-systemd.html" title="2.5.9 Managing MySQL Server with systemd">
Section 2.5.9, “Managing MySQL Server with systemd”
</a>
.
</p>
</div>
<p>
One way is to run multiple MySQL instances on Unix is to compile
different servers with different default TCP/IP ports and Unix
socket files so that each one listens on different network
interfaces. Compiling in different base directories for each
installation also results automatically in a separate, compiled-in
data directory, log file, and PID file location for each server.
</p>
<p>
Assume that an existing 8.3 server is configured for
the default TCP/IP port number (3306) and Unix socket file
(
<code class="filename">
/tmp/mysql.sock
</code>
). To configure a new
8.4.3 server to have different operating parameters,
use a
<span class="command">
<strong>
CMake
</strong>
</span>
command something like this:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa92641615"><div class="copy-help left">Press ⌘+C to 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">cmake</span> <span class="token punctuation">.</span> <span class="token constant">-DMYSQL_TCP_PORT</span><span class="token attr-value"><span class="token punctuation">=</span><em class="replaceable">port_number</em></span> \
<span class="token constant">-DMYSQL_UNIX_ADDR</span><span class="token attr-value"><span class="token punctuation">=</span><em class="replaceable">file_name</em></span> \
<span class="token constant">-DCMAKE_INSTALL_PREFIX</span><span class="token attr-value"><span class="token punctuation">=</span>/usr/local/mysql-8.4.3</span></code></pre>
</div>
<p>
Here,
<em class="replaceable">
<code>
port_number
</code>
</em>
and
<em class="replaceable">
<code>
file_name
</code>
</em>
must be different from the
default TCP/IP port number and Unix socket file path name, and the
<a class="link" href="source-configuration-options.html#option_cmake_cmake_install_prefix">
<code class="option">
CMAKE_INSTALL_PREFIX
</code>
</a>
value should
specify an installation directory different from the one under
which the existing MySQL installation is located.
</p>
<p>
If you have a MySQL server listening on a given port number, you
can use the following command to find out what operating
parameters it is using for several important configurable
variables, including the base directory and Unix socket file name:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa45463704"><div class="copy-help left">Press ⌘+C to 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 constant">--host</span><span class="token attr-value"><span class="token punctuation">=</span><em class="replaceable">host_name</em></span> <span class="token constant">--port</span><span class="token attr-value"><span class="token punctuation">=</span><em class="replaceable">port_number</em></span> variables</code></pre>
</div>
<p>
With the information displayed by that command, you can tell what
option values
<span class="emphasis">
<em>
not
</em>
</span>
to use when configuring an
additional server.
</p>
<p>
If you specify
<code class="literal">
localhost
</code>
as the host name,
<a class="link" href="mysqladmin.html" title="6.5.2 mysqladmin — A MySQL Server Administration Program">
<span class="command">
<strong>
mysqladmin
</strong>
</span>
</a>
defaults to using a Unix socket file
rather than TCP/IP. To explicitly specify the transport protocol,
use the
<a class="link" href="connection-options.html#option_general_protocol">
<code class="option">
--protocol={TCP|SOCKET|PIPE|MEMORY}
</code>
</a>
option.
</p>
<p>
You need not compile a new MySQL server just to start with a
different Unix socket file and TCP/IP port number. It is also
possible to use the same server binary and start each invocation
of it with different parameter values at runtime. One way to do so
is by using command-line options:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa46374488"><div class="copy-help left">Press ⌘+C to 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_safe</span> <span class="token constant">--socket</span><span class="token attr-value"><span class="token punctuation">=</span><em class="replaceable">file_name</em></span> <span class="token constant">--port</span><span class="token attr-value"><span class="token punctuation">=</span><em class="replaceable">port_number</em></span></code></pre>
</div>
<p>
To start a second server, provide different
<a class="link" href="server-options.html#option_mysqld_socket">
<code class="option">
--socket
</code>
</a>
and
<a class="link" href="server-options.html#option_mysqld_port">
<code class="option">
--port
</code>
</a>
option values, and pass a
<a class="link" href="server-system-variables.html#sysvar_datadir">
<code class="option">
--datadir=
<em class="replaceable">
<code>
dir_name
</code>
</em>
</code>
</a>
option to
<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>
so that the server uses a
different data directory.
</p>
<p>
Alternatively, put the options for each server in a different
option file, then start each server using a
<a class="link" href="option-file-options.html#option_general_defaults-file">
<code class="option">
--defaults-file
</code>
</a>
option that
specifies the path to the appropriate option file. For example, if
the option files for two server instances are named
<code class="filename">
/usr/local/mysql/my.cnf
</code>
and
<code class="filename">
/usr/local/mysql/my.cnf2
</code>
, start the servers
like this: command:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa16395977"><div class="copy-help left">Press ⌘+C to 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_safe</span> <span class="token constant">--defaults-file</span><span class="token attr-value"><span class="token punctuation">=</span>/usr/local/mysql/my.cnf</span>
<span class="token prompt">$> </span><span class="token command">mysqld_safe</span> <span class="token constant">--defaults-file</span><span class="token attr-value"><span class="token punctuation">=</span>/usr/local/mysql/my.cnf2</span></code></pre>
</div>
<p>
Another way to achieve a similar effect is to use environment
variables to set the Unix socket file name and TCP/IP port number:
</p>
<a class="indexterm" name="idm46045253923856">
</a>
<a class="indexterm" name="idm46045253922768">
</a>
<a class="indexterm" name="idm46045253921680">
</a>
<a class="indexterm" name="idm46045253920192">
</a>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa73795151"><div class="copy-help left">Press ⌘+C to 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_UNIX_PORT</span><span class="token attr-value"><span class="token punctuation">=</span>/tmp/mysqld-new.sock</span>
<span class="token prompt">$> </span><span class="token command">MYSQL_TCP_PORT</span><span class="token attr-value"><span class="token punctuation">=</span>3307</span>
<span class="token prompt">$> </span><span class="token command">export</span> MYSQL_UNIX_PORT MYSQL_TCP_PORT
<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">mysqld_safe</span> <span class="token constant">--datadir</span><span class="token attr-value"><span class="token punctuation">=</span>/path/to/datadir</span> &</code></pre>
</div>
<p>
This is a quick way of starting a second server to use for
testing. The nice thing about this method is that the environment
variable settings apply to any client programs that you invoke
from the same shell. Thus, connections for those clients are
automatically directed to the second server.
</p>
<p>
<a class="xref" href="environment-variables.html" title="6.9 Environment Variables">
Section 6.9, “Environment Variables”
</a>
, includes a list of other
environment variables you can use to affect MySQL programs.
</p>
<p>
On Unix, the
<a class="link" href="mysqld-multi.html" title="6.3.4 mysqld_multi — Manage Multiple MySQL Servers">
<span class="command">
<strong>
mysqld_multi
</strong>
</span>
</a>
script provides
another way to start multiple servers. See
<a class="xref" href="mysqld-multi.html" title="6.3.4 mysqld_multi — Manage Multiple MySQL Servers">
Section 6.3.4, “mysqld_multi — Manage Multiple MySQL Servers”
</a>
.
</p>
</div>
<br/>
</div>
|