Mysql:--init-file && --init-connect

  • init_file

    PropertyValue
    Command-Line Format --init-file=file_name
    System Variable init_file
    Scope Global
    Dynamic No
    SET_VAR Hint Applies No
    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 as CREATE USER or GRANT), replication, and global transaction identifiers. See Section 17.1.3, “Replication with Global Transaction Identifiers”.

 

  • init_connect

    PropertyValue
    Command-Line Format --init-connect=name
    System Variable init_connect
    Scope Global
    Dynamic Yes
    SET_VAR Hint Applies No
    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 or SUPER privilege, the content of init_connect is not executed. This is done so that an erroneous value for init_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 executing init_connect for users that have the CONNECTION_ADMIN or SUPER privilege enables them to open a connection and fix the init_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 thus init_connect execution will fail, leaving the client unable to connect. Skipping init_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.

 

posted on 2020-03-13 21:33  jinzhenshui  阅读(343)  评论(0编辑  收藏  举报