The removed mysql_list_dbs() API is unnecessary in modern PHP. MySQL provides the SHOW DATABASES statement, which can be executed through PDO, MySQLi, the command-line client or GUI tools.
SHOW DATABASES;
The databases visible in the result depend on the current account's privileges and server configuration.
<?php
$stmt = $dbo->query('SHOW DATABASES');
foreach ($stmt as $row) {
echo htmlspecialchars($row[0]) . '<br>';
}
?>
<?php
$result = $connection->query('SHOW DATABASES');
while ($row = $result->fetch_assoc()) {
echo htmlspecialchars($row['Database']) . '<br>';
}
?>
<?php
// Historical only: mysql_list_dbs() and mysql_db_name() were removed with mysql_*.
$list = mysql_list_dbs();
?>
To create a database, see CREATE DATABASE from PHP. For table-level discovery, continue with SHOW TABLES.
Create database · SHOW TABLES · Database tutorial · PHP/MySQL overview · MySQL front-end tools
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.