After you install MySQL, give the Command Line Client a try. The following steps walk you through some simple database actions.
- Start the Command Line Client: Assuming you used a typical installation in Windows, open the Start menu and select
All Programs -> MySQL -> MySQL Server 5.0 -> MySQL Command Line Client.
When it prompts you for the database's password, enter the password you used when you installed MySQL.
- List the available databases: Enter the command SHOW DATABASES;. (Remember to end each command with a semicolon and press Enter.)
The Client should list the available databases running in MySQL.
- Select the mysql database: Enter the command USE mysql;. This makes the Client use the database named mysql.
- List the database's tables: Enter the command SHOW TABLES;. This makes the Client list the tables in the mysql database.
- Select some data: Most of the mysql database's tables will be empty, but the user table should hold one record for the root user that was created when you installed MySQL. Enter the command
SELECT user, password FROM user;
The Client should list a single record showing the user name root and that user's password.
You will not be able to read the password because it is encrypted.
- Create a new database: enter the command CREATE DATABASE testdb;.
To select the new database, enter the command USE testdb;. If you execute the SHOW TABLES command now, you should find that the new database contains no tables.
- Create a table by using a SQL CREATE TABLE statement. This is a long, potentially complex statement that can span several lines. For this example, enter the command: