Accessing the Database from the Command Line

One way of communicating with MySQL is through the MySQL command line client. Depending on which operating system you're using, you need to eitehr open a command shell for Windows (type cmd from the Run dialog) or open a terminal session in Unix/Linux or Mac OX X environments.

Type mysql in the command line.

cmd line

Prompt Meaning
mysql> Waiting for a command
-< Waiting for the next line of a command
'< Waiting for the next line of a string that starts with a single quote
"< Waiting for the next line of a string that starts with a double quote

The following commands allow you to perform tasks such as executing SQL commands that are stored in a script file using the source.

Command Parameter Meaning
quit   Exit the command-line utility
use Database name Use a specific database
show tables or databases Show lists such as tables or databases available
describe Table name Describe a table's columns
status   Display database version and status
source Filename Execute commands from a file as a script


MySQL | Introduction | Relational Database Concepts | The Database Schema | MySQL Database | Accessing the Database from the Command Line | Using phpMyAdmin | Naming Database Elements | Data types
© 2008: Hann So
email: hso@voyager.deanza.edu