0% found this document useful (0 votes)
12 views9 pages

Lab No 1

Uploaded by

farwinoor9
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views9 pages

Lab No 1

Uploaded by

farwinoor9
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Department of IT and Computer Science

Pak-Austria Fachhochschule: Institute of Applied Sciences & Technology

Lab No. 1
Setting Up Environments
Objectives:
The objective of this lab is to make the students learn how to install MySQL
workbench and import the database in it. Also the students would learn how to
show the database and run simple SELECT queries.

MySQL Workbench
MySQL Workbench is a unified visual tool for database architects, developers, and
DBAs. MySQL Workbench provides data modeling, SQL development, and
comprehensive administration tools for server configuration, user administration,
backup, and much more. MySQL Workbench is available on Windows, Linux and
Mac OS X.

RUNNING the MySQL Server


1) Click on windows Start button
2) Type xampp
3) Click on Xamp Control Panel
4) Against MySQL option, click on Start button

HOW to CONNECT MySQL Workbench with MySQL


1) Make sure your MySQL is already running (MySQL is highlighted green in
xamp control panel)
2) Open MySQLWorkbench folder and click on blue colored
MySQLWorkbench.exe file
3) If there is no connection shown, then click on Click on “plus shaped” icon to
create new connection.
4) Input a connection name “mycon”
5) User name should be ‘root’

Database Systems (COMP-231L) Lab 1


Department of IT and Computer Science
Pak-Austria Fachhochschule: Institute of Applied Sciences & Technology
6) Password should be blank and click save, click test to see the response. If
response is “connection parameters are correct” your connection is
successful.
7) Now double click on the “mycon” connection icon, MySQLWorkbench
should be connected with the MySQL, and existing databases should be
shown at the left side.
8) Go to Edit -> Preferences
9) Click on “Sql Editor” and at the below of page uncheck option under “Safe
Updates”
10) Click “Close” button on top right corner of MySQLWorkbench to exit
program
11) After the program is exit, re-open MySQLWorkbench

Database Systems (COMP-231L) Lab 1


Department of IT and Computer Science
Pak-Austria Fachhochschule: Institute of Applied Sciences & Technology

After you write the connection name and click on ok, your connection would be
created. Once you double click on the connection, a dialog box would be there as
shown below.

Database Systems (COMP-231L) Lab 1


Department of IT and Computer Science
Pak-Austria Fachhochschule: Institute of Applied Sciences & Technology

Importing Sample database in MySQL


The following steps are needed to be performed
1) Open MySQLWorkbench folder and click on File -> New query tab. Or click on plus file
icon just below the File, this will open a new query window.
2) Write the following query to see the existing databases
3) Click on Data import/Restore

Check the setting shown for the windows

Database Systems (COMP-231L) Lab 1


Department of IT and Computer Science
Pak-Austria Fachhochschule: Institute of Applied Sciences & Technology

4) Select option “Import from self-contained file “and give path of sample present named
“northwind.sql”. after that, click on start import.

Show database in MySQL Workbench


We can use the show databases query to check whether our database has been
imported or not.

Database Systems (COMP-231L) Lab 1


Department of IT and Computer Science
Pak-Austria Fachhochschule: Institute of Applied Sciences & Technology

Show tables in a database


We can see the tables in a respective database by using show tables query.

Database Systems (COMP-231L) Lab 1


Department of IT and Computer Science
Pak-Austria Fachhochschule: Institute of Applied Sciences & Technology

Show data of a table


We can show all the data from a table through the select query.

Select a record to view


Select * from customer where custId = 5;
Displays the detail of the customer whose Id is 5;

Database Systems (COMP-231L) Lab 1


Department of IT and Computer Science
Pak-Austria Fachhochschule: Institute of Applied Sciences & Technology

Lab Assignment
Task 1: Setting Up MySQL Workbench Connection

• Install MySQL Workbench on your system.


• Start the MySQL server using XAMPP.
• Create a new connection named "mycon" with the following details:
o Username: root
o Password: (Leave blank)
• Test the connection to ensure it's successful.

Task 2: Importing a Sample Database

• Download the northwind.sql sample database.


• Open MySQL Workbench and go to Data Import/Restore.
• Select Import from self-contained file and provide the path of northwind.sql.
• Click Start Import and verify that the database has been imported.

Task 3: Displaying Databases and Tables

• Write an SQL query to list all available databases in MySQL Workbench.


• Write another SQL query to show all tables in the northwind database.

Database Systems (COMP-231L) Lab 1


Department of IT and Computer Science
Pak-Austria Fachhochschule: Institute of Applied Sciences & Technology
Task 4: Retrieving Data from Tables

• Write a SELECT query to display all customer records.


• Modify the query to only display CustomerID, ContactName, and CompanyName.
• Write a query to display all orders where ShipCountry = 'USA'.

Database Systems (COMP-231L) Lab 1

You might also like