if($stmt = $connection->query("SHOW DATABASES")){
echo "No of records : ".$stmt->num_rows."<br>";
while ($row = $stmt->fetch_assoc()) {
echo $row['Database']."<br>";
}
}else{
echo $connection->error;
}
This old MySQL extension was deprecated in PHP 5.4.0 and was removed in PHP 7
Use SHOW DATABASE query in place of mysql_db_list().
By using mysql_db_list() function we can get the result set and by using a pointer to this result set we can get the list of all the database. With this and using the code below we can list all the databases hosted on the mysql server. Here is the code, ensure that connection is available to the server.