实例代码如下:

<?php

   mysql_connect(\"127.0.0.1\",\"root\",\"password\");
   $dbs = mysql_list_dbs();
   echo \"服务器上所有数据库名称: <br />\";
   while (list($db) = mysql_fetch_row($dbs)) {
      echo \"$db <br />\";
   }

?>

运行结果:

服务器上所有数据库名称: 
information_schema 
myapp 
mysql 
performance_schema 
school 
test 
收藏 打印