Home  >  Article  >  Database  >  What are the Differences Between `init_connect` and `init-connect` in MySQL?

What are the Differences Between `init_connect` and `init-connect` in MySQL?

Susan Sarandon
Susan SarandonOriginal
2024-11-04 07:47:30887browse

What are the Differences Between `init_connect` and `init-connect` in MySQL?

Understanding the Optional Sections of the MySQL Configuration File (my.ini)

The MySQL configuration file (my.ini) contains various sections that customize the behavior of the MySQL server and its clients. Each section serves a specific purpose and can include multiple options.

Optional Sections:

  • [mysql] (or [mysql.server]): Applies to the MySQL command-line client (mysql).
  • [client] (or [mysql_client]): Applies to all client connections, including the MySQL command-line client.
  • [mysqld] (or [mysqld_server]): Applies to the MySQL server.
  • [mysqldump] (or [mysqldump_options]): Applies to the mysqldump utility.
  • [mysqladmin] (or [mysqladmin_options]): Applies to the mysqladmin utility.

init_connect vs. init-connect:

The difference between init_connect and init-connect lies in the context of their usage.

  • init_connect: Used as a command-line parameter (with a hyphen) to specify an SQL script to execute at the start of each new connection.
  • init-connect: Used as an option in the my.ini configuration file (with an underscore) to set a global SQL script to execute at the start of each connection.

Reference:

For more detailed information on the MySQL configuration file sections and options, refer to the official documentation: https://dev.mysql.com/doc/refman/5.5/en/option-files.html

The above is the detailed content of What are the Differences Between `init_connect` and `init-connect` in MySQL?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn