Sample Project (Creating Sample Data)

Installing MySql

MySql Download

MySql is downloaded at MySql Homepage (http://www.mysql.com/). This sample describes based on MySql 5.1 Windows MSI Installer (x86).

Installing MySql

Activating mysql-5.1.xx-win32.msi downloaded.

Options among the process of installation can be selected to be met individual settings.

Confirming MySql Installation

Confirming whether MySql is properly installed using following commands.

mysqlshow –u root –p
mysqladmin –u root –p version

Registering Sample Data

Adding MySql Demo

Referring to “Adding User Demos”of MySql 5.1 Manual, add demo for the sample.

CREATE USER 'demo'@'localhost' IDENTIFIED BY '1234';
GRANT ALL PRIVILEGES ON *.* TO 'demo'@'localhost' WITH GRANT OPTION;
CREATE USER 'demo'@'%' IDENTIFIED BY '1234';
GRANT ALL PRIVILEGES ON *.* TO 'demo'@'%' WITH GRANT OPTION;

Registering Sample Data

Sample data is registered to MySql uwing SQL script file. The methods activating SQL script files are as follow.

Create database demo;
mysql -u demo -p demo < C:\demo.sql

The SQL script registering sample data is as follows:

DROP TABLE IF EXISTS customer;

CREATE TABLE customer (
id INT NOT NULL AUTO_INCREMENT
, name VARCHAR(16) NOT NULL
, phone VARCHAR(16)
, email VARCHAR(32)
,birthday VARCHAR(8)
, home_phone VARCHAR(16)
, home_addr VARCHAR(256)
, company VARCHAR(32)
, jobtitle VARCHAR(32)
, busi_phone VARCHAR(16)
, busi_addr VARCHAR(256)
, busi_fax VARCHAR(16)
, company_website VARCHAR(64)
, remark VARCHAR(1024)
, PRIMARY KEY (id)
);

INSERT INTO customer
(name, phone, email, birthday, home_phone, home_addr
, company, jobtitle, busi_phone, busi_addr, busi_fax
, company_website, remark)
VALUES
('James Carman', '012-345-7890', 'carman@live.com', '20000101', '619-987-6543', '1234 Bonnie Ct. San Diego'
, 'Oracle Corporation', '5', '+1.650.506.7000', '500 Oracle Parkway Redwood Shores', ''
, 'http://www.oracle.com/', '');

INSERT INTO customer
(name, phone, email, birthday, home_phone, home_addr
, company, jobtitle, busi_phone, busi_addr, busi_fax
, company_website, remark)
VALUES
('Steven Caswell', '707-944-1234', 'caswell@hotmail.com', '20010202', '619-283-1429', '10924 Hefner Pointe Dr. Oklahoma'
, 'Sun Microsystems', '6', '+1-800-555-9SUN', '4150 Network Circle Santa Clara', '', 'http://www.sun.com/', '');

INSERT INTO customer
(name, phone, email, birthday, home_phone, home_addr
, company, jobtitle, busi_phone, busi_addr, busi_fax
, company_website, remark)
VALUES
('James Strachan', '900-5555-8888', 'strachan@gmail.com', '20030303', '604-234-5678', '8-1551 Johnston Street Granville Island Vancouver BC'
, 'IBM Corporation', '8', '877-426-6006', '1 New Orchard Road Armonk, New York', '800-314-1092', 'http://www.ibm.com/', '');

Confirming Sample Data

Confirm whether sample data is being registered or not by activating search SQL.

mysql -u demo -p -e "SELECT id, name, email FROM customer" demo