Introduction to MySQL
Week 1b - Database
Hendra Dinata
2017. Teknik Informatika | Universitas Surabaya
What will you learn?
You will learn what MySQL is
How to get MySQL
How to deploy a database in MySQL using tools
How to create data in MySQL
2017. Teknik Informatika | Universitas Surabaya
What is MySQL
MySQL is a database system used on the web
MySQL is a database system that runs on a server
MySQL is ideal for both small and large applications
MySQL is very fast, reliable, and easy to use
MySQL uses standard SQL
MySQL compiles on a number of platforms
MySQL is free to download and use
MySQL is developed, distributed, and supported by
Oracle Corporation
2017. Teknik Informatika | Universitas Surabaya
Accessing MySQL
How?
Using Tools, such as:
a. phpMyAdmin
b. MySQL Workbench
2017. Teknik Informatika | Universitas Surabaya
What is PhpMyAdmin ?
phpMyAdmin is a free software tool written in PHP,
intended to handle the administration of MySQL over
the Web.
phpMyAdmin supports a wide range of operations on
MySQL, MariaDB and Drizzle. Frequently used
operations (managing databases, tables, columns,
relations, indexes, users, permissions, etc) can be
performed via the user interface, while you still have
the ability to directly execute any SQL statement.
2017. Teknik Informatika | Universitas Surabaya
2017. Teknik Informatika | Universitas Surabaya
Installing phpMyAdmin
By Installing Xampp: you will get Apache server, php,
phpMyAdmin, and even the MySQL itself
2017. Teknik Informatika | Universitas Surabaya
Working with phpMyAdmin
You need to log in using the
given username and
password.
The username and password is
used to authenticate yourself
to access the MySQL instead
of the phpMyAdmin.
phpMyAdmin itself does not
store any credential
information, but the MySQL
does.
2017. Teknik Informatika | Universitas Surabaya
Working with phpMyAdmin
2017. Teknik Informatika | Universitas Surabaya
Working with phpMyAdmin
Now create a new database. and name it dota_p
(if your are in class P).
In that database, make a new table teams, and the fields are:
Field Name Data Type Description
team_id int Primary Key, Auto Increment
name varchar(20)
and then try to insert the data. There are two teams in DotA, they are:
Sentinel and Scourge. Let the team_id inserted automatically
2017. Teknik Informatika | Universitas Surabaya
Working with phpMyAdmin
Now create another table heroes (dont insert any data), with fields:
Field Name Data Type Description
hero_id int Primary Key, Auto Increment
name varchar(20)
type enum (Strength, Agility, Intelligence)
strength smallint
agility smallint
intelligence smallint
damage smallint
armor smallint
is_ranged bool
2017. Teknik Informatika | Universitas Surabaya
Export & Import Database using
phpMyAdmin
Export: to save the database into another form as a backup
Import: to create a database in MySQL from another source
2017. Teknik Informatika | Universitas Surabaya
Export
Enter into Database Level
2017. Teknik Informatika | Universitas Surabaya
Export
Enter into Database Level and then click Export
2017. Teknik Informatika | Universitas Surabaya
Export
Choose custom
2017. Teknik Informatika | Universitas Surabaya
Export
Scroll down, unchecked Display comments and check
Disable foreign key checks
2017. Teknik Informatika | Universitas Surabaya
Export
Scroll down, unchecked Dump and click Go Button
2017. Teknik Informatika | Universitas Surabaya
Other things you can do
Renaming table
Altering table
Drop table
2017. Teknik Informatika | Universitas Surabaya
Workbench
Workbench is a desktop based tools developed by
MySQL.
You can download it at
http://dev.mysql.com/downloads/workbench/
2017. Teknik Informatika | Universitas Surabaya
Working with Workbench
Connect to MySQL
Create database
Create table
Insert data
Update data
Delete Data
Altering table
Drop table
2017. Teknik Informatika | Universitas Surabaya
Any Question?
2017. Teknik Informatika | Universitas Surabaya