Download - Ws 01-install appserv+xampp+konfigurasi file
Worksheet -01 BASIS DATA
1 | P a g e [email protected]
STANDAR KOMPETENSI
Membuat Program Basis Data menggunakan MySQL/PostgreSQL
KOMPETENSI DASAR
Menjelaskan kebutuhan software
DASAR TEORI
1. APA ITU MySQL
MySQL (bisa dibaca dengan mai-es-ki-el atau bisa juga mai-se-kuel) adalah suatu perangkat
lunak database relasi (Relational Database Management System atau RDBMS), seperti
halnya ORACLE, Postgresql, MS SQL, dan sebagainya. Jangan disalah-artikan MySQL
dengan SQL. SQL (singkatan dari Structured Query Language) sendiri adalah suatu sintaks
perintah-perintah tertentu atau bahasa (pemrograman) yang digunakan untuk mengelola
suatu database. Jadi, MySQL dan SQL adalah dua 'mahluk' yang berbeda. Mudahnya,
MySQL adalah softwarenya, dan SQL adalah bahasa perintahnya
2. MySQL SEBAGAI DATABASE SERVER
Software database mulai bermunculan seiring dengan bertambahnya kebutuan akan database
server. Salah satu dari pendatang baru dalam dunia database ialah MySQL, sebuah
server/klien database SQL yang berasal dari Skandinavia. MySQL terdiri atas server SQL,
klien program untuk mengakses server, tools untuk administrasi, dan interface program
untuk menulis program sendiri. Pengembangan MySQL dimulai pada tahun 1979 dengan
tool database UNIREG yang dibuat oleh Michael “Monty” Widenius untuk perusahaan TcX
di Swedia. Kemudian pada tahun 1994, TcX mulai mencari server SQL untuk
mengembangkan aplikasi Web. Mereka menguji beberapa server komersial namun
semuanya masih terlalu lambat untuk table-tabel TcX yang besar. Tahun 1995 David
Axmark dari Detro HB berusaha menekan TcX untuk merelease MySQL di Internet. Ia juga
membuat dokumentasi MySQL yang di-build untuk GNU configure utility. MySQL 3.11.1
dipublikasikan di dunia tahun 1996 dan didistribusikan untuk Linux dan Solaris. Sekarang
ini MySQL bekerja untuk banyakplatform serta tersedia source codenya.
3. KEUNGGULAN MySQL
Jika anda mencari system manajemen database yang murah atau bahkan gratis, ada beberapa
pilihan antara lain MySQL, mSQL, PostgresSQL, atau salah satu dari produk vendor
komersial yang gratis. Ketika dibandingkan antara MySQL dengan system databae yang
lain, maka perlu dipikirkan apa yang paling penting untuk anda. Apakah performa, support,
fitur-fitur SQL, kondisi keamanan dalam lisensi, atau masalah harga. Dengan pertimbangan
tersebut, MySQL memiliki banyak hal yang bisa ditawarkan, antara lain :
Kecepatan
Banyak ahli berpendapat MySQL merupakan server tercepat.
Kemudahan penggunaan
MySQL punya performa tinggi namun merupakan database yang simple sehingga
mudah disetup dan dikonfigurasi
Harga
MySQL cenderung gratis untuk penggunaan terntentu.
Mendukung query language
MySQL mengerti bahasa SQL (Structured Query Language) yang merupakan pilihan
system database modern. Anda juga dapat mengakses MySQL lewat protocol ODBC
(Open Database Connectivity) buatan Microsoft.
Kapabilitas
Banyak klien dapat mengakses server dalam satu waktu. Mereka dapat menggunakan
banyak database secara simultan.
Konektifitas dan sekuritas
Database MySQL dapat diakses dari semua tempat di Internet dengan hak akses
tertentu.
Pertabilitas
MySQL dapat berjalan dalam banyak varian UNIX dengan baik, sebaik seperti saat
berjalan di system non-UNIX.
Distribusi yang terbuka
MySQL mudah didapatkan dan memiliki source code yang boleh disebarluaskan
sehingga bisa dikembangkan lebih lanjut.
Worksheet -01 BASIS DATA
2 | P a g e [email protected]
ALAT DAN BAHAN
Alat
No Alat Spesifikasi Qty
1 PC Intel PIV 1.7 GHz, RAM 128 MB, HD 20 GB, VGA
32 MB
Sistem Operasi : Windows XP / Vista
1
2 Software Database xampp-win32-1.7.1-installer /
appserv-win32-2.5.8
1
4 Software
Document
MS Word XP / MS. Word 2003 / MS Word 2007 1
Bahan
No Bahan Spesifikasi Qty
1 Worksheet ws-01-install appserv+xampp+konfigurasi file.pdf 1
2 File / buku referensi n
LANGKAH KERJA INSTALL APPSERV
Download software AppServ di : http://www.AppServNetwork.com
a. Double click file appserv-win32-2.5.8.exe
FFile appserv-win32-2.5.8.exe
Tampilan Splash AppServ 2.5.8
b. Click tombol Next untuk melanjutkan.
AppServ Welcome Screen
Worksheet -01 BASIS DATA
3 | P a g e [email protected]
c. Persetujuan Lisensi, pilih tombol I Agree
License Agreement Screen
d. Lokasi Instalasi
Tentukan lokasi folder untuk hasil
instalasi appserv. Secara default :
c:\AppServ
e. Memilih Komponen
Memilih paket-paket yang akan diinstal, disarankan pilih semua paket yang tersedia!
f. Informasi Apache HTTP Server
Informasi Apache HTTP Server :
Hostname : localhost
Admin Email : admin@localhost
HTTP Port : 80
Worksheet -01 BASIS DATA
4 | P a g e [email protected]
g. Konfigurasi MySQL Server
Konfigurasi MySQL Server :
Root Password : stembayo
Character set : UTF-8 Unicode
Enable InnoDB : Yes
h. Proses Instalasi
Proses instalasi sedang berjalan
Instalasi selesai
Worksheet -01 BASIS DATA
5 | P a g e [email protected]
LANGKAH KERJA INSTALL XAMPP
Download http://www.apachefriends.org/en/xampp-windows.html
Instal software XAMPP xampp-win32-1.7.1-installer
a. Double click file xampp-win32-1.7.1-installer.exe
b. Memilih bahasa Click OK untuk melanjutkan instalasi
c. Click NEXT untuk melanjutkan instalasi
d. Memilih lokasi instalasi, secara default lokasi instalasi berada di C:\xampp tetapi
bisa diubah sesuai keinginan.
Worksheet -01 BASIS DATA
6 | P a g e [email protected]
e. Memilih XAMPP Option instalasi dengan click cek box
f. Proses instalasi
g. Instalasi selesai sukses
h. Tampilan XAMPP Control Panel Aplication
Worksheet -01 BASIS DATA
7 | P a g e [email protected]
2. Menguji instalasi MySQL dengan command line ( text mode )
Buka command prompt dengan cara click StartAccesoriesCommand
Prompt atau dengan cara click StartRunketik cmdEnter
Masuk ke lokasi instalasi MySQL yang berada di C:\xampp\mysql\bin
Login ke MySQL server dengan perintah mysql –u root –p. Secara default user
adalah root tanpa password
Cobalah ketih perintah show databases; untuk mengecek apakah database sudah
berjalan dengan baik. Jika perintah benar dan database berjalan dengan baik maka
akan tampil nama database yang ada di mysql.
Untuk keluar dari mysql ketik perintah quit; atau /q; atau dengan mengklik
tombol close .
Worksheet -01 BASIS DATA
8 | P a g e [email protected]
Mengganti password user root
Update user set password=password(„tkj‟) where user=‟root‟;
Struktur file MySQL
File Name Description
mysql/bin Main MySQL database execution file, berisi file
binary
mysql/data MySQL database store, berisi database mysql.
Disini file database dan tabel yang kita buat
disimpan.
mysql/share
MySQL Error Message
Sintak Stop dan Start servive MySQL server
C:\Users >net start mysql
The mysql service is starting.
The mysql service was started successfully.
C:\Users>net stop mysql
The mysql service is stopping.
The mysql service was stopped successfully.
Konfigurasi ulang file instalasi MySQL Server.
Untuk mengkonfigurasikan ulang server MySQL file yang perlu kita edit atau kita
konfigurasi adalah my.ini. Letak dari file ini biasanya terletak di directory
MySQL.
File : my.ini
# MySQL Server Instance Configuration File
# ----------------------------------------------------------
------------
# Generated by the MySQL Server Instance Configuration
Wizard
#
#
# Installation Instructions
# ----------------------------------------------------------
------------
#
# On Linux you can copy this file to /etc/my.cnf to set
global options,
# mysql-data-dir/my.cnf to set server-specific options
# (@localstatedir@ for this installation) or to
# ~/.my.cnf to set user-specific options.
#
# On Windows you should keep this file in the installation
directory
# of your server (e.g. C:\Program Files\MySQL\MySQL Server
X.Y). To
# make sure the server reads the config file use the startup
option
# "--defaults-file".
#
# To run run the server from the command line, execute this
in a
# command line shell, e.g.
# mysqld --defaults-file="C:\Program Files\MySQL\MySQL
Server X.Y\my.ini"
#
Worksheet -01 BASIS DATA
9 | P a g e [email protected]
# To install the server as a Windows service manually,
execute this in a
# command line shell, e.g.
# mysqld --install MySQLXY --defaults-file="C:\Program
Files\MySQL\MySQL Server X.Y\my.ini"
#
# And then execute this in a command line shell to start the
server, e.g.
# net start MySQLXY
#
#
# Guildlines for editing this file
# ----------------------------------------------------------
------------
#
# In this file, you can use all long options that the
program supports.
# If you want to know the options a program supports, start
the program
# with the "--help" option.
#
# More detailed information about the individual options can
also be
# found in the manual.
#
#
# CLIENT SECTION
# ----------------------------------------------------------
------------
#
# The following options will be read by MySQL client
applications.
# Note that only client applications shipped by MySQL are
guaranteed
# to read this section. If you want your own MySQL client
program to
# honor these values, you need to specify it as an option
during the
# MySQL client library initialization.
#
[client]
port=3306
[mysql]
default-character-set = utf8
# SERVER SECTION
# ----------------------------------------------------------
------------
#
# The following options will be read by the MySQL Server.
Make sure that
# you have installed the server correctly (see above) so it
reads this
# file.
#
[mysqld]
# The TCP/IP Port the MySQL Server will listen on
port=3306
#bind-address=192.168.1.4
#Path to installation directory. All paths are usually
resolved relative to this.
basedir="C:\AppServ/MySQL"
Worksheet -01 BASIS DATA
10 | P a g e [email protected]
#Path to the database root
datadir="C:\AppServ/MySQL/data/"
# The default character set that will be used when a new
schema or table is
# created and no character set is defined
default-character-set = utf8
character-set-server = utf8
collation-server = utf8_general_ci
init_connect = 'SET collation_connection = utf8_general_ci'
init_connect = 'SET NAMES utf8'
# The default storage engine that will be used when create
new tables when
#default-storage-engine=INNODB
# Set the SQL mode to strict
# sql-
mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBS
TITUTION"
sql-mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
# The maximum amount of concurrent sessions the MySQL server
will
# allow. One of these connections will be reserved for a
user with
# SUPER privileges to allow the administrator to login even
if the
# connection limit has been reached.
max_connections=16384
#
# For compatibility to other PHP MySQL function that still
use old mysql connect.
#
#old_passwords = 1
# Query cache is used to cache SELECT results and later
return them
# without actual executing the same query once again. Having
the query
# cache enabled may result in significant speed
improvements, if your
# have a lot of identical queries and rarely changing
tables. See the
# "Qcache_lowmem_prunes" status variable to check if the
current value
# is high enough for your load.
# Note: In case your tables change very often or if your
queries are
# textually different every time, the query cache may result
in a
# slowdown instead of a performance improvement.
query_cache_size=0
# The number of open tables for all threads. Increasing this
value
# increases the number of file descriptors that mysqld
requires.
# Therefore you have to make sure to set the amount of open
files
# allowed to at least 4096 in the variable "open-files-
limit" in
# section [mysqld_safe]
table_cache=256
Worksheet -01 BASIS DATA
11 | P a g e [email protected]
# Maximum size for internal (in-memory) temporary tables. If
a table
# grows larger than this value, it is automatically
converted to disk
# based table This limitation is for a single table. There
can be many
# of them.
tmp_table_size=9M
# How many threads we should keep in a cache for reuse. When
a client
# disconnects, the client's threads are put in the cache if
there aren't
# more than thread_cache_size threads from before. This
greatly reduces
# the amount of thread creations needed if you have a lot of
new
# connections. (Normally this doesn't give a notable
performance
# improvement if you have a good thread implementation.)
thread_cache_size=8
#*** MyISAM Specific options
# The maximum size of the temporary file MySQL is allowed to
use while
# recreating the index (during REPAIR, ALTER TABLE or LOAD
DATA INFILE.
# If the file-size would be bigger than this, the index will
be created
# through the key cache (which is slower).
myisam_max_sort_file_size=100G
# If the temporary file used for fast index creation would
be bigger
# than using the key cache by the amount specified here,
then prefer the
# key cache method. This is mainly used to force long
character keys in
# large tables to use the slower key cache method to create
the index.
myisam_max_extra_sort_file_size=100G
# If the temporary file used for fast index creation would
be bigger
# than using the key cache by the amount specified here,
then prefer the
# key cache method. This is mainly used to force long
character keys in
# large tables to use the slower key cache method to create
the index.
myisam_sort_buffer_size=17M
# Size of the Key Buffer, used to cache index blocks for
MyISAM tables.
# Do not set it larger than 30% of your available memory, as
some memory
# is also required by the OS to cache rows. Even if you're
not using
# MyISAM tables, you should still set it to 8-64M as it will
also be
# used for internal temporary disk tables.
key_buffer_size=10M
# Size of the buffer used for doing full table scans of
MyISAM tables.
Worksheet -01 BASIS DATA
12 | P a g e [email protected]
# Allocated per thread, if a full scan is needed.
read_buffer_size=64K
read_rnd_buffer_size=256K
# This buffer is allocated when MySQL needs to rebuild the
index in
# REPAIR, OPTIMZE, ALTER table statements as well as in LOAD
DATA INFILE
# into an empty table. It is allocated per thread so be
careful with
# large settings.
sort_buffer_size=256K
log-slow-queries=mysql-slow.log
log-error=mysql.err
#*** INNODB Specific options ***
# Use this option if you have a MySQL server with InnoDB
support enabled
# but you do not plan to use it. This will save memory and
disk space
# and speed up some things.
skip-innodb
# Additional memory pool that is used by InnoDB to store
metadata
# information. If InnoDB requires more memory for this
purpose it will
# start to allocate it from the OS. As this is fast enough
on most
# recent operating systems, you normally do not need to
change this
# value. SHOW INNODB STATUS will display the current amount
used.
innodb_additional_mem_pool_size=2M
# If set to 1, InnoDB will flush (fsync) the transaction
logs to the
# disk at each commit, which offers full ACID behavior. If
you are
# willing to compromise this safety, and you are running
small
# transactions, you may set this to 0 or 2 to reduce disk
I/O to the
# logs. Value 0 means that the log is only written to the
log file and
# the log file flushed to disk approximately once per
second. Value 2
# means the log is written to the log file at each commit,
but the log
# file is only flushed to disk approximately once per
second.
innodb_flush_log_at_trx_commit=1
# The size of the buffer InnoDB uses for buffering log data.
As soon as
# it is full, InnoDB will have to flush it to disk. As it is
flushed
# once per second anyway, it does not make sense to have it
very large
# (even with long transactions).
innodb_log_buffer_size=1M
# InnoDB, unlike MyISAM, uses a buffer pool to cache both
indexes and
Worksheet -01 BASIS DATA
13 | P a g e [email protected]
# row data. The bigger you set this the less disk I/O is
needed to
# access data in tables. On a dedicated database server you
may set this
# parameter up to 80% of the machine physical memory size.
Do not set it
# too large, though, because competition of the physical
memory may
# cause paging in the operating system. Note that on 32bit
systems you
# might be limited to 2-3.5G of user level memory per
process, so do not
# set it too high.
innodb_buffer_pool_size=17M
# Size of each log file in a log group. You should set the
combined size
# of log files to about 25%-100% of your buffer pool size to
avoid
# unneeded buffer pool flush activity on log file overwrite.
However,
# note that a larger logfile size will increase the time
needed for the
# recovery process.
innodb_log_file_size=10M
# Number of threads allowed inside the InnoDB kernel. The
optimal value
# depends highly on the application, hardware as well as the
OS
# scheduler properties. A too high value may lead to thread
thrashing.
innodb_thread_concurrency=8
max_connections max_connections adalah maksimum sambungan yang dapat dilakukan dalam
waktu sekaligus, kalau website anda sangat sibuk, semakin besar tentunya akan
semakin bagus, akan tetapi sudah pasti bahwa karena resource server akan
semakin banyak dipakai maka CPU atau memory anda akan semakin termakan
oleh proses mysql. Karena itu, nilai max_connections dapat anda sinkronkan
dengan besar memory anda dan akses maksimum Apache anda, di MaxClient.
Tidak ada artinya anda perbesar akan tetapi MaxClient di Apache anda sangat
kecil, misalnya hanya sekitar 50 sambungan saja.
query_cache_size Apabila MySQL anda sibuk dan selalu mengulang-ulang query yang sama, maka
settting query_cache_size anda perlu anda perhatikan. query_cache_size akan
menyimpan query yang berulang, sehingga akan mempercepat kerja MySQL anda
untuk query yang sama. Karena query yang sebelumnya disimpan dalam memory
cache.
key_buffer_size Data base menggunakan key index. Karena itu apabila index ini tersimpan dalam
satu memori secara utuh, maka sudah tentu proses MySQL anda akan semakin
cepat mendapatkan hasil dari query yang diinginkan. Secara ideal semua index
akan bagus tersimpan dalam memory ini, akan tetapi anda perlu juga melihat
kemampuan kapasitas memory anda.
table_cache Apabila MySQL anda banyak menggunakan table query, maka besar memori ini
juga perlu anda perhatikan. Karena akan mempercepat proses query yang
berhubungan dengan table. Default memory ini adalah 64Kb.
sort_buffer Apakah MySQL anda memiliki query atau operasi myisamchk atau sort ? Maka
option ini sangat penting untuk anda perhatikan. Dengan memasang buffer yang
Worksheet -01 BASIS DATA
14 | P a g e [email protected]
besar tentunya anda akan melakukan sorting secara besar juga. Nah sudah pasti
sorting anda akan semakin cepat selesai.
read_rnd_buffer_size read_rnd_buffer_size digunakan setelah kita melakukan sorting. Yaitu untuk
memproses row dari query sorting yang telah kita lakukan. Apabila query anda
sering memakai ORDER BY, maka option ini perlu anda perhatikan. Anda dapat
menghitung besar buffer ini dengan logika 1 MB adalah 1KB, jadi apabila
memory server anda adalah 1GB, maka anda dapat mengesetnya sebesar 1MB.
thread_cache Apabila server anda sibuk dengan banyaknya query dan memerlukan respon yang
sangat cepat, maka thread_cache adalah option yang perlu anda perhatikan.
Karena itu semakin besar nilai ini, akan semakin tinggi load CPU anda.
tmp_table_size tmp_table_size akan memberikan kesempatan kepada MySQL untuk menyimpan
table ke dalam harddisk yang dianggap sebagai memory. Sudah tentu
tmp_table_size akan memperlambat kecepatan MySQL. Apabila anda mempunyai
memory yang minim dan kecepatan MySQL tidak begitu diperhitungkan,
barangkali ini adalah option yang anda kehendaki.
Contoh Konfigurasi Ulang :
Merubah direktori penyimpanan database MySQL Server
datadir="C:\AppServ/MySQL/data/"
1. Buat path direktori baru, misalnya di E:\data
2. Ubah baris konfigurasi datadir diatas menjadi
datadir="E:\data"
3. Simpan kemudian restart service MySQL
4. Login ke MySQL kemudian buat database baru dengan perintah
CREATE DATABASE [nama_database]
5. Jika konfogurasi benar maka database baru akan tersimpan di E:\data
Mensetting Limit koneksi ke MySQL Server
max_connections=16384
1. Login ke MySQL Server kemudian buat 3 user baru dengan perintah :
CREATE USER ‘[nama_user]’@’[host]’;
2. Ubah baris konfigurasi max_connections=2
3. Login ketiga user yang telah kita buat tadi maka saat user ketiga login akan
muncul pesan error :
ERROR 1040 (08004): Too many connections
TEMUAN
............................................................................................................................................................
............................................................................................................................................................
............................................................................................................................................................
............................................................................................................................................................
...........................................................................................................................................................
FUNGSI-FUNGSI di MYSQL
1. Menampilkan tanggal
2. Menampilkan versi MySQL
3. ..............................................
4. Aritmatika
Penjumlahan
Pengurangan
.......................
Worksheet -01 BASIS DATA
15 | P a g e [email protected]
DAFTAR PUSTAKA
http://id.wikipedia.org/wiki/MySQL
http://www.apachefriends.org/en/xampp-windows.html
http://www.mysql.com