Current Location: Home> Function Categories> mysql_list_processes

mysql_list_processes

Lists MySQL processes.
Name:mysql_list_processes
Category:Uncategorized
Programming Language:php
One-line Description:Get the list of active processes on the current database server

Function name: mysql_list_processes()

Function version: PHP 4, PHP 5, PHP 7

Function description: The mysql_list_processes() function is used to obtain the list of active processes on the current database server.

Syntax: resource mysql_list_processes ( [resource $link_identifier = NULL] )

parameter:

  • link_identifier (optional): MySQL connection identifier. If this parameter is not provided, the last opened connection is used by default.

Return value: If successful, the function returns a result resource identifier to get the process list. If it fails, FALSE is returned.

Example:

 // 连接到数据库服务器$link = mysql_connect("localhost", "username", "password"); // 检查连接是否成功if (!$link) { die("连接失败:" . mysql_error()); } // 获取进程列表$result = mysql_list_processes($link); // 检查获取结果是否成功if (!$result) { die("获取进程列表失败:" . mysql_error()); } // 打印进程列表while ($row = mysql_fetch_assoc($result)) { echo "ID: " . $row['Id'] . ", 用户: " . $row['User'] . ", 主机: " . $row['Host'] . ", 数据库: " . $row['db'] . "\n"; } // 释放结果资源mysql_free_result($result); // 关闭数据库连接mysql_close($link);

Notes:

  • This function has been deprecated in PHP 5.5.0 and has been removed in PHP 7.0.0. It is recommended to use mysqli or PDO extensions to connect to and operate databases.
  • If you are using PHP 5.5.0 or later, it is recommended to use the mysqli_list_processes() function to get the process list.
Similar Functions
Popular Articles