Your first MySQL Database
Hoping that you've successfully installed the MySQL distribution onto your system, let's start creating your first MySQL database. Last month we used Microsoft Access to create a simple Clients database which contained two tables -- we'll recreate that pleasantly simple structure here in MySQL. Although this is a simple example, it should lay the groundwork for any other relational database you wish to create and manage in MySQL.
To recap from last month, let's look once again at the Clients database, and the two tables it consists of:
We'll assume that the data for these tables now resides in tab-delimited text files; in other words, the text file containing the data for billing would look like:
Loganberry Inc. firstname.lastname@example.org 099050101 50.00 1
As summarized earlier, we need to first establish this database in MySQL and create the skeletal structure for the tables -- then we can import the raw data.
Step 1: Create a new database using mysqladmin.
/path/to/mysql/bin/mysqladmin -u root -p rootpassword create Clients
By default, the MySQL server will create a subdirectory for the new database, Clients, in mysql/data. If you would like to store your databases somewhere other than the MySQL installation path, you need to start mysqld with the --datadir parameter; simply execute mysqld --help on a command line to view usage details.