COMMAND
PROMPT
Dasar-dasar MYSQL
Jalankan DOS
prompt
Aktifka
direktori dimana file MYSQL.exe berada.pada xampp
Cd c:\xampp\MYSQL\bin\
Kemudian
ketikan: MYSQL
–h localhost –u root
CARA MEMBUAT DATA BASE
Create database nama_data_base;
CARA MEMBUKA DATA BASE YANG PERNAH
KALIAN KAU BUAT
Use nama_data _base;
CARA MELIHAT DATA BASES YANG TELAH
ADA
Show databases;
PERINTAH UNTUK MEMBUAT TABEL BARU
Creat table namatable
(
Struktur
);
Contoh:creat table tbl_mahasiswa (nim char(9), nama
varchar(40), alamat varchar(50), tempat lahir varchar(25), nohp char(12), usia
int);
Cara melihat table yang
telah di buat
Desc namatabel;
Cara memasukan data ke
table:
insert into namatabel
values(‘kolom1,’kolom2’,’kolom3’);
contoh:insert into mahasiswa values(‘131313003’,’alfanfandy_pratama_kasim’,’jl.beringin’,’limboto’,’085340212226’,’17’);
Cara melihat table yang
telah ter isi
Select * from namatable;
Cara melihat filed
tertentu
Select namafiled namatable;
Cara melihat data
record tertentu
Selec * from namatabel where FILED=RECORD;
Cara melihat data dengan range tertentu
Select * from namatabel where namakolom between x
and y;
praktek
Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\lab software>cd c:\xampp\mysql\bin
c:\xampp\mysql\bin>mysql -h localhost -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.8 MySQL Community Server (GPL)
Copyright (c) 2000, 2010, 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 db_poligon;
Query OK, 1 row affected (0.00 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| cdcol |
| coba |
| db_poligon |
| mysql |
| performance_schema |
| phpmyadmin |
| test |
| webauth |
+--------------------+
9 rows in set (0.19 sec)
mysql> creat table tbl_mahasiswa (nim char(9), nama
varchar(40), alamat varchar(
50), tempat_lahir varchar(25), nohp char(12), usia char(2));
ERROR 1064 (42000): You have an error in your SQL syntax;
check the manual that
corresponds to your MySQL server version for the right
syntax to use near 'creat
table tbl_mahasiswa
(nim char(9), nama varchar(40), alamat varchar(50), te' at
line 1
mysql> create table tbl_mahasiswa (nim char(9), nama
varchar(40), alamat varchar
(50), tempat_lahir varchar(25), nohp char(12), usia
char(2));
ERROR 1046 (3D000): No database selected
mysql> creat table _mahasiswa (nim char(9), nama
varchar(40), alamat varchar(50)
, tempatlahir varchar(25), nohp char(12), usia char(2));
ERROR 1064 (42000): You have an error in your SQL syntax;
check the manual that
corresponds to your MySQL server version for the right
syntax to use near 'creat
table _mahasiswa (nim
char(9), nama varchar(40), alamat varchar(50), tempa' at
line 1
mysql> create table mahasiswa (nim char(9), nama
varchar(40), alamat varchar(50)
, tempatlahir varchar(25), nohp char(12), usia char(2));
ERROR 1046 (3D000): No database selected
mysql> create table mahasiswa (nim char(9), nama
varchar(40), alamat varchar(50)
, tempatlahir varchar(25), nohp char(12), usia char(2));
ERROR 1046 (3D000): No database selected
mysql> use db_poligon
Database changed
mysql> create table mahasiswa (nim char(9), nama
varchar(40), alamat varchar(50)
, tempatlahir varchar(25), nohp char(12), usia char(2));
Query OK, 0 rows affected (0.30 sec)
mysql> desc mahasiswa
-> desc
mahasiswa;
ERROR 1064 (42000): You have an error in your SQL syntax;
check the manual that
corresponds to your MySQL server version for the right
syntax to use near 'desc
mahasiswa' at line 2
mysql> desc mahasiswa;
+-------------+-------------+------+-----+---------+-------+
| Field |
Type | Null | Key | Default |
Extra |
+-------------+-------------+------+-----+---------+-------+
| nim |
char(9) | YES | |
NULL | |
| nama |
varchar(40) | YES | | NULL
| |
| alamat |
varchar(50) | YES | | NULL
| |
| tempatlahir | varchar(25) | YES | |
NULL | |
| nohp |
char(12) | YES | |
NULL | |
| usia |
char(2) | YES | |
NULL | |
+-------------+-------------+------+-----+---------+-------+
6 rows in set (0.08 sec)
mysql> insert into mahasiswa
values('131313003'alfandy_pratama_kasim','jl.bering
in','limboto','085340212226','17');
'> insert into
mahasiswa values('131313003'alfandy_pratama_kasim','jl.bering
in','limboto','085340212226','17');
ERROR 1064 (42000): You have an error in your SQL syntax;
check the manual that
corresponds to your MySQL server version for the right
syntax to use near 'alfan
dy_pratama_kasim','jl.beringin','limboto','085340212226','17');
insert into' at line 1
mysql> insert into mahasiswa
values('131313003','alfandy_pratama_kasim','jl.beri
ngin','limboto','085340212226','17');
Query OK, 1 row affected (0.03 sec)
mysql> select * from mahasiswa
->
-> select *
from mahasiswa;
ERROR 1064 (42000): You have an error in your SQL syntax;
check the manual that
corresponds to your MySQL server version for the right
syntax to use near 'selec
t * from mahasiswa' at line 3
mysql> select * from mahasiswa;
+-----------+-----------------------+-------------+-------------+--------------+
------+
| nim |
nama | alamat | tempatlahir | nohp |
usia |
+-----------+-----------------------+-------------+-------------+--------------+
------+
| 131313003 | alfandy_pratama_kasim | jl.beringin |
limboto | 085340212226 |
17 |
+-----------+-----------------------+-------------+-------------+--------------+
------+
1 row in set (0.00 sec)
mysql>
1 komentar:
komentarPagi mau tanya,, kenapa saat saya mau create database sesudah dienter.. mucul tulissan" ERROR 1044 <42000>: Acces denied for user ''@'localhost' to databese 'db_kampus'
Replybaru mucul
msql>