Fri, 17 May 2024


How to get the list of available databases on your MySQL server?

By: Anton, NetArt Media
Wed, 13 October 2021

<?php

// Connect to the database
$svrConn = @mysql_connect("localhost", "root", "")
or die("Couldn't connect to database server");

$myDatabases = mysql_list_dbs($svrConn);
$i = 0;

while($row = mysql_fetch_object($myDatabases))
{
echo ++$i . ". " . $row->Database . "<br>";
}
?>


Category: PHP Examples
Share this post:



See All Scripts






Subscribe for our newsletter

Receive the latest blog posts direct in your mailbox