Rabu, 10 Oktober 2012

Membuat Database Menggunakan Console

C:\Users\Adam User>cd\

C:\>cd xampp

C:\xampp>cd mysql

C:\xampp\mysql>cd bin

C:\xampp\mysql\bin>mysql -u root -p
Enter password: ********
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.16 MySQL Community Server (GPL)

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> exit;
Bye

C:\xampp\mysql\bin>mysql -u root -p
Enter password: ********
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.16 MySQL Community Server (GPL)

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> CREATE DATABASE dbku;
Query OK, 1 row affected (0.00 sec)

mysql> USE dbku;
Database changed
mysql> CREATE table tbl_bukutamu(
-> id int(4) not null auto_increment,
-> nama varchar(50) not null,
-> email varchar(50) not null,
-> pesan varchar(50) not null,
-> primary key(id));
Query OK, 0 rows affected (0.21 sec)

mysql> INSERT INTO tbl_bukutamu VALUES('','tomy','tomy@yahoo.com','pesan');
Query OK, 1 row affected, 1 warning (0.13 sec)

mysql> SELECT * FROM tbl_bukutamu;
+----+------+----------------+-------+
| id | nama | email | pesan |
+----+------+----------------+-------+
| 1 | tomy | tomy@yahoo.com | pesan |
+----+------+----------------+-------+
1 row in set (0.08 sec)

mysql> INSERT INTO tbl_bukutamu VALUES('','misnary','mis@yahoo.com','pesan');
Query OK, 1 row affected, 1 warning (0.09 sec)

mysql> INSERT INTO tbl_bukutamu VALUES('','ajat','azat@yahoo.com','pesan');
Query OK, 1 row affected, 1 warning (0.05 sec)

mysql> SELECT * FROM tbl_bukutamu;
+----+---------+----------------+-------+
| id | nama | email | pesan |
+----+---------+----------------+-------+
| 1 | tomy | tomy@yahoo.com | pesan |
| 2 | misnary | mis@yahoo.com | pesan |
| 3 | ajat | azat@yahoo.com | pesan |
+----+---------+----------------+-------+
3 rows in set (0.00 sec)


mysql> SELECT * FROM tbl_bukutamu;
+----+---------+----------------+---------+
| id | nama | email | pesan |
+----+---------+----------------+---------+
| 1 | tomy | tomy@yahoo.com | pesan |
| 2 | misnary | mis@yahoo.com | pesan |
| 3 | Azat | azat@gmail.com | belajar |
+----+---------+----------------+---------+
3 rows in set (0.00 sec)

mysql> UPDATE tbl_bukutamu SET nama='hizkia mastomi bagus saputra' WHERE id='1';
Query OK, 1 row affected (0.08 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> SELECT * FROM tbl_bukutamu;
+----+------------------------------+----------------+---------+
| id | nama | email | pesan |
+----+------------------------------+----------------+---------+
| 1 | hizkia mastomi bagus saputra | tomy@yahoo.com | pesan |
| 2 | misnary | mis@yahoo.com | pesan |
| 3 | Azat | azat@gmail.com | belajar |
+----+------------------------------+----------------+---------+
3 rows in set (0.00 sec)

mysql> DELETE FROM tbl_bukutamu WHERE id='1';
Query OK, 1 row affected (0.08 sec)

mysql> SELECT * FROM tbl_bukutamu;
+----+---------+----------------+---------+
| id | nama | email | pesan |
+----+---------+----------------+---------+
| 2 | misnary | mis@yahoo.com | pesan |
| 3 | Azat | azat@gmail.com | belajar |
+----+---------+----------------+---------+
2 rows in set (0.00 sec)

mysql> SELECT * FROM tbl_bukutamu WHERE id ='3';
+----+------+----------------+---------+
| id | nama | email | pesan |
+----+------+----------------+---------+
| 3 | Azat | azat@gmail.com | belajar |
+----+------+----------------+---------+
1 row in set (0.00 sec)

mysql> INSERT INTO tbl_bukutamu VALUES('','mis','mis@yahoo.com','pesan');
Query OK, 1 row affected, 1 warning (0.06 sec)

mysql> INSERT INTO tbl_bukutamu VALUES('','iis','mis@yahoo.com','pesan');
Query OK, 1 row affected, 1 warning (0.05 sec)

mysql> INSERT INTO tbl_bukutamu VALUES('','budi','mis@yahoo.com','pesan');
Query OK, 1 row affected, 1 warning (0.07 sec)

mysql> INSERT INTO tbl_bukutamu VALUES('','ani','mis@yahoo.com','pesan');
Query OK, 1 row affected, 1 warning (0.05 sec)

mysql> INSERT INTO tbl_bukutamu VALUES('','ayu','mis@yahoo.com','pesan');
Query OK, 1 row affected, 1 warning (0.06 sec)

mysql> SELECT * FROM tbl_bukutamu;
+----+---------+----------------+---------+
| id | nama | email | pesan |
+----+---------+----------------+---------+
| 2 | misnary | mis@yahoo.com | pesan |
| 3 | Azat | azat@gmail.com | belajar |
| 4 | mis | mis@yahoo.com | pesan |
| 5 | iis | mis@yahoo.com | pesan |
| 6 | budi | mis@yahoo.com | pesan |
| 7 | ani | mis@yahoo.com | pesan |
| 8 | ayu | mis@yahoo.com | pesan |
+----+---------+----------------+---------+
7 rows in set (0.00 sec)

mysql> SELECT * FROM tbl_bukutamu WHERE nama like '%is%';
+----+---------+---------------+-------+
| id | nama | email | pesan |
+----+---------+---------------+-------+
| 2 | misnary | mis@yahoo.com | pesan |
| 4 | mis | mis@yahoo.com | pesan |
| 5 | iis | mis@yahoo.com | pesan |
+----+---------+---------------+-------+
3 rows in set (0.02 sec)

mysql> 

....INI ADALAH PELAJARAN WEB PROGREMING YANG SAAT INI SEDANG SAYA PELAJARI, SAYA MAU BERBAGI SEDIKIT TENTANG PELAJARAN INI...