0% found this document useful (0 votes)
25 views4 pages

Chapter4 PDF

The document discusses importing student data from a Notepad file into a MySQL database table, backing up the database with mysqldump, restoring the backup after dropping the table, and verifying the backup process. Specifically, it creates a database and student table, loads student data from a text file, backs up the database to a SQL file, drops and recreates the table, and restores the data from the backup file.
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)
25 views4 pages

Chapter4 PDF

The document discusses importing student data from a Notepad file into a MySQL database table, backing up the database with mysqldump, restoring the backup after dropping the table, and verifying the backup process. Specifically, it creates a database and student table, loads student data from a text file, backs up the database to a SQL file, drops and recreates the table, and restores the data from the backup file.
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/ 4

CHAPTER 4

MENGINPUT DATA DARI NOTEPAD

mysql> create database 3B4;


mysql> use 3B4
mysql> create table STUDENT (nim char(4),nama
varchar(20),alamat varchar(30));
mysql> show tables;
+---------------+
| Tables_in_3B4 |
+---------------+
| student |
+---------------+
1 row in set (0.06 sec)

AKTIFKAN NOTEPAD
Ketikkanlah data berikut :

Simpan dengan nama mhs1.txt di drive D:\

Jalankan LOAD DATA

mysql> load data local infile "d:/mhs1.txt" into table


STUDENT;
Query OK, 3 rows affected, 2 warnings (0.08 sec)
Records: 3 Deleted: 0 Skipped: 0 Warnings: 2
mysql> select * from student;
+------+------------------+-----------------+
| nim | nama | alamat |
+------+------------------+-----------------+
| 0001 | Andi Prabu | Jl. Cempedak II |
| 0002 | Budi Prayogi | Jl. Mahoni Raya |
| 0003 | Chelly Triwily s | Mandala |
+------+------------------+-----------------+
3 rows in set (0.00 sec)

MEMBACKUP DATA
Buka DOS pada jendela lain, lalu jalankan MYSQLDUMP Sbb:

- START + RUN
- Ketikkan CMD
- OK
- CD\apache2triad\mysql\bin
- C:\apache2triad\mysql\bin>mysqldump --opt 3b4 > d:\data1.sql
- C:\apache2triad\mysql\bin>

Lihat hasil di Explorer :

Untuk menggunakan file backup coba hapus file table pelajar :


mysql> drop table STUDENT;
Query OK, 0 rows affected (0.03 sec)

mysql> show tables;


Empty set (0.02 sec)

PANGGIL KEMBALI FILE DATA2.SQL SEBAGAI FILE BACKUP


- START + RUN
- Ketikkan CMD
- Ok
- CD\apache2triad\mysql\bin
- C:\apache2triad\mysql\bin>mysql 3b4 < d:\data1.sql
- C:\apache2triad\mysql\bin>

KEMBALI KE MYSQL

mysql> show tables;


Empty set (0.02 sec)

mysql> select * from student;


+------+------------------+-----------------+
| nim | nama | alamat |
+------+------------------+-----------------+
| 0001 | Andi Prabu | Jl. Cempedak II |
| 0002 | Budi Prayogi | Jl. Mahoni Raya |
| 0003 | Chelly Triwily s | Mandala |
+------+------------------+-----------------+
3 rows in set (0.00 sec)

mysql> \. d:\data1.sql
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
mysql> show tables;
+----------------+
| Tables_in_izul |
+----------------+
| student |
+----------------+
1 row in set (0.00 sec)

mysql>

You might also like