This Tutorial
- Using SQL to create a MySQL database
- Using SQL to access MySQL databases
- Using SQL to describe MySQL database tables

Related Pages
Microsoft Access Workgroup tutorial
Microsoft Access Database Splitter tutorial
Microsoft Access Build Your Own Database manual
- SQL tutorial for Microsoft Access
- SQL tutorial for SQL Server
SQL database comparisons
- Comparison of the commands and operators used in WHERE clauses in Oracle, Microsoft Access, MySQL and SQL Server, and how to limit the number of rows returned
- Comparison of useful functions in Oracle, MySQL, Microsoft Access and SQL Server

Structured Query Language (SQL) tutorial

Using SQL to Create a MySQL Database

We'll create a database called bus that contains details of bookings for our company XYZ Transport. The details we plan to store include customer names, dates and times, buses, destinations, customer and drivers' addresses, phone numbers etc.

Both the MySQL server and client need to be running for you to work with your database. The MySQL server started when you logged in to Windows because it was installed as a service. The MySQL client (called mysql from now on) has to be started. To do this:

  • Select Start > MySQL > MySQL Server 4.1 > MySQL Command Line Client.  The console window will appear.
  • Enter your password (and all following commands) into this window. Once this is successfully entered, you are connected to the MySQL server.

After you connect to the server, you can create a database, as follows:

  • Type

   create database bus;

remembering that all SQL commands must end with a semi-colon (;). The MySQL server responds with something like

   Query OK, 1 row affected (0.00 sec)

This means that you have successfully created the database.

Now let's see how many databases you have on your system.

  • Type and run the following command.

   show databases;

The server responds with a list of databases:

   +----------------+
   | Database       |
   +----------------+
   | bus            |
   | mysql          |
   | test           |
   +----------------+
   3 rows in set (0.00 sec)

Here we have three databases, two created by MySQL during installation and our bus database.


  • Home
  • |
  • Sitemap
  • |
  • Databases
  • |
  • Web development
  • |
  • Delphi development
  • |
  • Image manipulation
  • |
  • KaSaB
  • |
  • Contact