MySQL command line – quick tips
Database
From Bash
Login (localhost access)
mysql -u <userid> -p
From the MySQL command prompt
List all databases on the current server
mysql> show databases;
Switch to a database
mysql> use <db name>;
Show all tables in the currently selected database
mysql> show tables;
View a table’s schema
mysql> describe <table name>;
Issue a select statement (example)
mysql> select * from <table name>;
Limit number of rows returned in a select
(TOP doesn’t work in MySQL…)
mysql> select * from <table name> limit 0,10;