PHP mysqli_dump_debug_info() Function

Beginner
5 min read
Updated: Nov 2026
3 examples
MySQLi

Definition

In PHP, mysqli_dump_debug_info() asks the MySQL server to dump debug information related to the current connection.

Object-oriented style uses $mysqli->dump_debug_info(). This is a server-side diagnostic call (COM_DEBUG) and usually requires SUPER privilege. Everyday applications rarely need it.

Syntax

Call mysqli_dump_debug_info() with the values you need. Start with this line.

PHP
mysqli_dump_debug_info($mysqli);
CallWhat it does
mysqli_dump_debug_info($mysqli)Requests a server debug dump for this connection.
$mysqli->dump_debug_info()Object-oriented form.
mysqli_dump_debug_info($mysqli) ? "ok" : "failed"Checks whether the server accepted the request.

Success means the server accepted the debug command, not that you will see output in PHP. Server logs or the MySQL error log may receive the dump, depending on server configuration.

Library declarations
PHP
mysqli_dump_debug_info(mysqli $mysql): bool

Parameters

ParameterDescription
mysqlRequired. An open mysqli connection.

Return Value

Return ValueDescription
booltrue if the server accepted the debug dump request, otherwise false.

PHP Examples

Example 1 — Call dump_debug_info on a Demo Link

Attempt the call and print the boolean result. Sample output when connected to a privileged demo database.

PHP
<?php
$mysqli = mysqli_connect("localhost", "demo", "secret", "shop");
$ok = mysqli_dump_debug_info($mysqli);
echo $ok ? "dump requested" : "dump denied", PHP_EOL;
mysqli_close($mysqli);

How It Works

  1. Connect with a demo account that is allowed to run COM_DEBUG.
  2. mysqli_dump_debug_info() sends the request.
  3. true means the server accepted it.
  4. Sample output prints dump requested.

Example 2 — Object Style Call

Use the method form and show a failure path message.

PHP
<?php
$mysqli = new mysqli("localhost", "limited", "secret", "shop");
if (!$mysqli->dump_debug_info()) {
    echo "Not allowed: ", $mysqli->error, PHP_EOL;
}
$mysqli->close();

How It Works

  1. A limited user connects successfully.
  2. dump_debug_info() fails without SUPER.
  3. error explains the privilege problem.
  4. This is the usual result on locked-down servers.

Example 3 — Prefer Clear SQL Errors Instead

For application bugs, print errno/error rather than server debug dumps.

PHP
<?php
$mysqli = mysqli_connect("localhost", "demo", "secret", "shop");
mysqli_query($mysqli, "INSERT INTO products(name) VALUES");
echo mysqli_sqlstate($mysqli), " ", mysqli_error($mysqli), PHP_EOL;
mysqli_close($mysqli);

How It Works

  1. An intentionally broken INSERT is executed.
  2. sqlstate and error describe the syntax problem.
  3. Beginners get actionable feedback without SUPER privileges.
  4. Sample output shows a typical syntax error string.

Frequently Asked Questions

It asks the MySQL server to produce debug information for the connection. It is a diagnostic tool, not a general-purpose logger.
Often the MySQL user lacks SUPER (or the modern equivalent privilege). Check mysqli_error() for details.
Usually into server-side logs configured by MySQL, not into a PHP return value.
Call $mysqli->dump_debug_info() with no arguments.
No. Learn connect_error, errno, error and explain plans first. Use dump_debug_info only when diagnosing the server itself.

Next: mysqli_errno()

mysqli_errno() returns the error code for the most recent function call on a MySQLi connec.

mysqli_errno() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful