Mysql:--init-file && --init-connect
-
Property Value Command-Line Format --init-file=file_name
System Variable init_file
Scope Global Dynamic No SET_VAR
Hint AppliesNo Type File name If specified, this variable names a file containing SQL statements to be read and executed during the startup process. Prior to MySQL 8.0.18, each statement must be on a single line and should not include comments. As of MySQL 8.0.18, the acceptable format for statements in the file is expanded to support these constructs:
-
delimiter ;
, to set the statement delimiter to the;
character. -
delimiter $$
, to set the statement delimiter to the$$
character sequence. -
Multiple statements on the same line, delimited by the current delimiter.
-
Multiple-line statements.
-
Comments from a
#
character to the end of the line. -
Comments from a
--
sequence to the end of the line. -
C-style comments from a
/*
sequence to the following*/
sequence, including over multiple lines. -
Multiple-line string literals enclosed within either single quote (
'
) or double quote ("
) characters.
If the server is started with the
--initialize
or--initialize-insecure
option, it operates in bootstap mode and some functionality is unavailable that limits the statements permitted in the file. These include statements that relate to account management (such asCREATE USER
orGRANT
), replication, and global transaction identifiers. See Section 17.1.3, “Replication with Global Transaction Identifiers”. -
-
Property Value Command-Line Format --init-connect=name
System Variable init_connect
Scope Global Dynamic Yes SET_VAR
Hint AppliesNo Type String A string to be executed by the server for each client that connects. The string consists of one or more SQL statements, separated by semicolon characters.
For users that have the
CONNECTION_ADMIN
orSUPER
privilege, the content ofinit_connect
is not executed. This is done so that an erroneous value forinit_connect
does not prevent all clients from connecting. For example, the value might contain a statement that has a syntax error, thus causing client connections to fail. Not executinginit_connect
for users that have theCONNECTION_ADMIN
orSUPER
privilege enables them to open a connection and fix theinit_connect
value.init_connect
execution is skipped for any client user with an expired password. This is done because such a user cannot execute arbitrary statements, and thusinit_connect
execution will fail, leaving the client unable to connect. Skippinginit_connect
execution enables the user to connect and change password.The server discards any result sets produced by statements in the value of
init_connect
.