MySQL Basic commands

Start mysql with:

mysql -u user -pPASSWORD

To choose a database:

USE mysql;

where mysql is the db name

To display all tables in the chosen database


To display all columns in a table:


where user is the table name

Or a single step command:

SHOW COLUMNS FROM `user` FROM `databasename`;[/code]
To display data in a coloumn or field:
SELECT `gamma` FROM `user`;

Where user is the table name and gamma is the field or coloumn name

To display two coloumns or fields side by side, you do:

mysql> SELECT `user`,`password` FROM `user`;

where user and password are two columns in the table user.

You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.