Print Logo

Listing Available MySQL Databases and Tables




<<  <   >  >>

To determine what databases and tables are stored in your MySQL database, log in using the mysql client:

[usr-1@srv-1 ~]$ mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 6 to server version: 4.1.12
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> 

Use the show databases command to list the databases:

mysql> show databases;
+-----------+
| Database  |
+-----------+
| arewedown |
| mysql     |
| test      |
+-----------+
3 rows in set (0.00 sec)
mysql>

If you want to list the tables in one of the databases, connect to it and use the show tables command:

mysql> connect mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Connection id:    10
Current database: mysql
mysql> show tables;
+---------------------------+
| Tables_in_mysql           |
+---------------------------+
| columns_priv              |
| db                        |
| func                      |
| help_category             |
| help_keyword              |
| help_relation             |
| help_topic                |
| host                      |
| tables_priv               |
| time_zone                 |
| time_zone_leap_second     |
| time_zone_name            |
| time_zone_transition      |
| time_zone_transition_type |
| user                      |
+---------------------------+
15 rows in set (0.00 sec)
mysql> 





This article comes from NetAdminTools:
http://www.netadmintools.com/

The URL for this story is:
http://www.netadmintools.com/art519.html

Copyright 1997-2012 NetAdminTools.com. Read our Terms of Use.