samuelhauser
4/9/2015 - 11:49 AM

Mysql list databases

Connect to database

$ mysql

You may need to provide mysql username, password and hostname, use:

$ mysql —u[user] —p[password]

List databases

show databases;

Output:

+——————————+
| Database           |
+——————————+
| information_schema |
| mysql              |
+——————————+
2 rows in set (0.00 sec)

information_schema and mysql are name of databases. To use these database and to list available tables type the following two commands:

use mysql;

Output:

Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed

List tables:

show tables;

Output:

+—————————————+
| Tables_in_mysql           |
+—————————————+
| columns_priv              |
| db                        |
| func                      |
| help_category             |
| help_keyword              |
| help_relation             |
| help_topic                |
| host                      |
| proc                      |
| procs_priv                |
| tables_priv               |
| time_zone                 |
| time_zone_leap_second     |
| time_zone_name            |
| time_zone_transition      |
| time_zone_transition_type |
| user                      |
+—————————————+
17 rows in set (0.00 sec)
mysql>