mysqli_driver::embedded_server_start
Initialize and start embedded server
Function name: mysqli_driver::embedded_server_start()
Applicable version: PHP 5 >= 5.3.0, PHP 7, PHP 8
Function Description: The mysqli_driver::embedded_server_start() function is used to start an embedded MySQL server.
usage:
public static mysqli_driver::embedded_server_start(array $start_options = [], array $shutdown_options = [])
parameter:
$start_options
(optional): An associative array that specifies startup options. The following keys can be included:mysql_port
: Specifies the port number of the MySQL server, the default is 0 (automatically allocated ports).mysql_unix_port
: Specifies the path to a Unix socket, which is null by default (using TCP/IP).mysql_socket
: Specifies the path to a Unix socket, defaults to null (using TCP/IP).mysqld
: Specifies the path to the mysqld executable file, which is null by default (automatically look up executable file).mysqladmin
: Specifies the path to the mysqladmin executable file, which is null by default (automatically look up executable file).skip_networking
: If set to true, disable network connection, default is false.skip_federated
: If set to true, the Federated storage engine is disabled, default to false.$shutdown_options
(optional): An associative array that specifies the shutdown option. The following keys can be included:mysql_port
: Specifies the port number of the MySQL server, the default is 0 (automatically allocated ports).mysql_unix_port
: Specifies the path to a Unix socket, which is null by default (using TCP/IP).mysql_socket
: Specifies the path to a Unix socket, defaults to null (using TCP/IP).mysqladmin
: Specifies the path to the mysqladmin executable file, which is null by default (automatically look up executable file).Return value: No return value.
Example:
// 启动嵌入式MySQL 服务器mysqli_driver::embedded_server_start(); // 连接到嵌入式MySQL 服务器$mysqli = new mysqli(); // 执行SQL 查询$result = $mysqli->query("SELECT * FROM users"); // 输出查询结果while ($row = $result->fetch_assoc()) { echo $row['username'] . '<br>'; } // 关闭连接$mysqli->close(); // 关闭嵌入式MySQL 服务器mysqli_driver::embedded_server_shutdown();
Notes:
mysqli_driver::embedded_server_shutdown()
function to shut down the server.