PHPMyAdmin: Import data using CSV file

This entry is part 2 of 2 in the series PHPMyAdmin

In our previous post, we have created table and inserted a record using the statement below:

INSERT INTO `album`(`Name`, `Title`, `Year`) VALUES ('Rod Stewart','Every Picture Tells A Story',1969)

This is a 3 column table and it is ok to use an sql statement if we need only to insert a few records.

Say we have  1000 records and they are all in a file.  We would have to import them by using PHPMyAdmin.

I used to work with Sybase or Oracle and normally, I would import them using bcp or bulk copy through the command line.

p10

 

To import them using PHPMyAdmin, you can prepare a CSV file using MS Excel.  This can be done easily by saving the file as CSV file in MS Excel.

In the PHPMyAdmin, as shown in the screenshot above, click on Choose File and select the CSV file.

p11

In the format of the file, we need to select CSV and click on GO.

The 3 records will be appended into the album table.

p12

 

MySQL Clients: PHPMyAdmin

This entry is part 2 of 8 in the series MySQL Clients

First, start the WAMP server and make sure that it appears in the far right of the task bar in your Windows Desktop.

Click on it and look for PHPMyAdmin.  Start PHPMyAdmin and you will be brought to localhost/phpmyadmin in the web browser.

phpmyadmin

If this is the first time you have started using PHPMyAdmin, login as root without a password.  You will be brought to this page.

phpmyadmin1

Create Database

Click on Databases tab.

database

We will now create a database called allartist.  Type in allartist in the create database textbox and click on create.  A database allartist will be successfully created.

Create A Table

Using the code below, we will now create a table.

CREATE TABLE artist
    (
 id int auto_increment primary key, 
 artiste varchar(30), 
 album varchar(50),
 price decimal(3, 2) 
 );
 
INSERT INTO artist
(artiste, album, price)
VALUES
('Rod Stewart', 'Maggie May', 8.90 ),
('New Order', 'Substance', 7.50),
('Nirvana', 'Smell Like Teen Spirit', 9.80);

First click on allartist on the left column of the page.  Click on SQL and paste the code to the SQL query box.  Click on Go.

createtable

Go back to SQL tab and use the following query to display the table.  

select * from artist

A page will be shown as below.

query1

MySQL Clients: Client Access

This entry is part 1 of 8 in the series MySQL Clients

This series is a short introduction to using PHPMyAdmin or Toad for MySQL to access MySQL DB.

In an earlier post, I have mentioned about downloading WAMP server and install it into your PC.  With WAMP, you will get an Apache web server, PHP, MySQL and also PHPMyAdmin.

PHPMyAdmin is a web based client access to MySQL.  As it is web based, it is not as user-friendly as other client access programs such as HeidiSQL and Toad for MySQL.

We will use Toad for MySQL throughout this tutorial but first, let’s go through some simple steps where you could create a database and a table using PHPMyAdmin.