Page 1 of 1

getting the list of all the databased and there table

Posted: Mon Mar 22, 2004 5:50 am
by pelegk2
how can i get the list of all databases and tables on mysql server?
thanks in advance
peleg

Posted: Mon Mar 22, 2004 11:03 am
by xisle
install an admin tool like phpMyAdmin
http://sourceforge.net/project/showfile ... _id=220762

Posted: Mon Mar 22, 2004 11:27 am
by pickle
Command-line wise you can login as root, then type "show databases". Then in each db, type "show tables".

Posted: Mon Mar 22, 2004 3:07 pm
by pelegk2
what?
i asked hhow to do it in php!

Posted: Mon Mar 22, 2004 3:11 pm
by Draco_03
mysql_list_dbs
mysql_list_tables

and humm well look for other mysql_list_"whatever"....

Posted: Mon Mar 22, 2004 3:14 pm
by m3mn0n
pelegk2 wrote:what?
i asked hhow to do it in php!
Both the previously mentioned ways are/can be done in PHP...heh :wink:

Posted: Mon Mar 22, 2004 3:17 pm
by markl999
Can also do it like this.

Code: Select all

<?php

$db = mysql_connect('localhost', 'root', 'password') or die(mysql_error());
$sql = 'SHOW DATABASES';
$res = mysql_query($sql) or die(mysql_error());
while($row = mysql_fetch_assoc($res)){
  echo '<b>'.$row['Database'].'</b><br />';
  mysql_select_db($row['Database']) or die(mysql_error());
  $sql = "SHOW TABLES";
  $res2 = mysql_query($sql) or die(mysql_error());
  while($row2 = mysql_fetch_assoc($res2)){
    $tblname = 'Tables_in_'.$row['Database'];
    echo '&nbsp;&nbsp;'.$row2[$tblname].'<br />';
  }
}

?>
Loads of different ways really :o

Posted: Mon Mar 22, 2004 3:21 pm
by m3mn0n
...and that's what I was referring too. :)

Posted: Tue Mar 23, 2004 1:03 am
by pelegk2
thnaks all of u:)