Using MySQL Command Line Client Using MySQL Command Line Client database database

Using MySQL Command Line Client


To see all databases:

show databases;

To switch to a specific database (note that the trailing ; is optional here):

use databasename

To see the tables within the current database:

show tables;

To see the create table statement for a specific table:

show create table tablename;

To see other misc info about a specific table:

describe tablename;

Additionally, all kinds of other interesting meta information is contained within the information_schema database. You can use information_schema and explore those tables for a wealth of information about your databases.

Another useful trick in the MySQL command line console is to terminate your queries with \G instead of ;. This causes output to be displayed all vertically rather than in a table, which is useful for tables that are wider than your screen display.