There are more ways to show list a MySQL databases in PHP. PDO (PHP Data Objects) is the best of them.
Advantages of
PDO is a consistent interface across many different types of database, uses an object-oriented approach, and supports more features offered by newer databases.
Using a PDO recommends wherever possible.
<?php
$host ="localhost";
$user = "your_username";
$password = "your_password";
$dbh = new PDO( "mysql:host=$host", $user, $password );
$dbs = $dbh->query( "SHOW DATABASES" );
while( ( $db = $dbs->fetchColumn( 0 ) ) !== false )
{
echo $db."<br>";
}
?>