Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,471
There are 1184 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     Programming     PHP and MySQL :

Counting mysql databases

Thread title: Counting mysql databases
Reply    
    Thread tools Search this thread Display Modes  
09-22-2009, 09:09 PM
#1
Stellarchase is offline Stellarchase
Stellarchase's Avatar
Status: I'm new around here
Join date: Jun 2009
Location:
Expertise:
Software:
 
Posts: 15
iTrader: 0 / 0%
 

Stellarchase is on a distinguished road

Send a message via AIM to Stellarchase Send a message via MSN to Stellarchase

  Old  Counting mysql databases

I understand how to count the amount of tables in a mysql database, but how about counting how many mysql databases exist (or at least the user has access to)

Reply With Quote
09-22-2009, 10:54 PM
#2
Salathe is offline Salathe
Salathe's Avatar
Status: Community Archaeologist
Join date: Jul 2004
Location: Scotland
Expertise: Software Development
Software: vim, PHP
 
Posts: 3,820
iTrader: 25 / 100%
 

Salathe will become famous soon enough

Send a message via MSN to Salathe

  Old

You could use a query on the magic INFORMATION_SCHEMA database to get the number (see below), or just count the number of rows returned from SHOW DATABASES.

Example Query:
Code:
SELECT COUNT(SCHEMA_NAME) AS `Databases` FROM INFORMATION_SCHEMA.SCHEMATA;
Example Returns:
Code:
+-----------+
| Databases |
+-----------+
|         2 | 
+-----------+

Reply With Quote
Reply    


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed