You are viewing [info]komputeron's journal

Fri, Sep. 24th, 2010, 03:58 pm
PostgreSQL Tutorial


PostgreSQL Tutorial

Instalasi untuk Windows
1. Download postgresql-8.2.1-1.zip dari http://www.postgresql.org/ftp/binary/v8.2.1/win32/
2. Extract & execute postgresql-8.2.msi, saat instalasi terima saja default untuk semua option. Buat PostgreSQL sebagai service dgn user account postgres. Pilihan ini otomatis membuat satu superuser (root) untuk PostgreSQL dgn nama postgres.

Akses PostgreSQL
1. Start - All Programs - PostgreSQL 8.2 - Command Prompt
2. ketik: psql -U postgres
    Untuk user lain, ketik juga nama database dimana user ybs punya hak akses. Misal: psql -U nama_user nama_database

Perintah Utama
\l Untuk melihat daftar semua database yg ada
\du Untuk melihat daftar semua user yg ada
\dp Untuk melihat daftar privileges dari setiap object database
\d [NAME] Untuk melihat keterangan (describe) dari suatu tabel atau object lainnya
\dt Untuk melihat daftar semua tabel
\c [DBNAME] Untuk membuat koneksi ke suatu database agar bisa bekerja di database tsb
select version(); Untuk mengetahui versi PostgreSQL

User Management
User dalam PostgreSQL digantikan dgn konsep ROLE. Untuk suatu aplikasi, buatlah suatu database misal XYZ oleh superuser postgres. Kemudian buat ROLE baru khusus untuk database tsb dgn status non superuser dgn privilege terbatas (tidak bisa membuat ROLE, tidak bisa membuat database, dsb). Contoh SQL command: CREATE ROLE xyz_user LOGIN ENCRYPTED PASSWORD 'xyz_password'. Untuk menghapus: DROP ROLE xyz_user

Database Management
Membuat database: CREATE DATABASE db_name TEMPLATE  template0
Option TEMPLATE bisa dipakai juga untuk copy suatu database. Untuk menghapus database: DROP DATABASE db_name
Membuat struktur database bisa dari file text. Misal dari shell:
C:\Program Files\PostgreSQL\8.2\bin>psql -f "D:\Projects\DPRIN\Documents\DB\dms.sql" -U postgres dms_template
Untuk membuat suatu database sebagai template, ketik perintah ini:
update pg_database set datistemplate = true, datallowconn = false where datname = 'nama_database';

Backup Database
Backup one database from shell command: pg_dump -U postgres db_name > outfile_name.sql
Jika ada OID (object identifier) maka tambahkan option -o. Misal: pg_dump -U postgres -o db_name > outfile_name.sql
Untuk backup semua database termasuk ROLE(s): pg_dumpall -U postgres > outfile-name.sql
Jika ada OID (object identifier) maka tambahkan option -o

Restore Database
Untuk restore suatu database harus buat database kosong terlebih dahulu: CREATE DATABASE db_name TEMPLATE  template0
Semua user yg ada di database tsb menurut file dump harus sudah ada. Perintah restore: psql -U postgres db_name < infile_name.sql
Untuk restore dari pg_dumpall: psql -f infile_name.sql postgres


Fri, Sep. 24th, 2010, 03:54 pm
MySQL Tutorial



MySQL Tutorial

Display Help and Version Information

shell> mysql --help

or

shell> mysql -?

^ Top

Connect to MySQL

Some MySQL installations allow users to connect as the anonymous (unnamed) user to the server running on the local host. If this is the case on your machine, you should be able to connect to that server by invoking mysql without any options:

shell> mysql

Standard syntax :

shell> mysql -h host -u user -p
Enter password: ********

If you are logging in on the same machine that MySQL is running on, you can omit the host, and simply use the following:

shell> mysql -u user -p

default installation : hanya ada satu user yaitu root dimana root ini adl system administrator yg mempunyai hak tak terbatas terhadap MySQL.

^ Top

Display databases in MySQL instance

mysql> show databases;
^ Top
Open a database

USE db_name

The USE db_name statement tells MySQL to use the db_name database as the default (current) database for subsequent statements. The database remains the default until the end of the session or another USE statement is issued:

^ Top
Display tables in a database
mysql> show tables;
^ Top
First Time MySQL
Instalasi default MySQL akan membuat satu user account yaitu root. Pastikan hanya ada satu user account pada MySQL, yaitu root. Pastikan user root sebagai system administrator mempunyai akses (privileges) tak terbatas. Data user tersimpan di database mysql tabel user.

mysql> use mysql
mysql> select * from user \G

Untuk menampilkan privileges dari user gunakan GRANT
SHOW GRANTS FOR user
mysql> SHOW GRANTS FOR 'root'@'localhost';

To list the privileges granted to the account that you are using to connect to the server, you can use any of the following statements:

SHOW GRANTS;
SHOW GRANTS FOR CURRENT_USER;
SHOW GRANTS FOR CURRENT_USER();

Sebelum menggunakan MySQL untuk membuat database, ubah dahulu password dari root.
mysql> SET PASSWORD = PASSWORD('new_password');
^ Top
Miscellaneous Functions

To find out which database is currently selected, use the DATABASE() function:

mysql> SELECT DATABASE();

A simple command that asks the server to tell you its version number :

mysql> SELECT VERSION();
Server current date :
mysql> SELECT CURRENT_DATE;

If you want to find out about the structure of a table, the DESCRIBE command is useful; it displays information about each of a table's columns:

mysql> DESCRIBE table_name;

Displays status information about the server's storage engines :
mysql> SHOW ENGINES \G
Displays extensive information about the state of the InnoDB storage engine :
mysql> SHOW ENGINE INNODB STATUS;
Display information including storage engine used for table(s) :

mysql> SHOW TABLE STATUS;

^ Top

Backing Up and Recovering an InnoDB Database
Binary Backup
If you are able to shut down your MySQL server, you can make a binary backup that consists of all files used by InnoDB to manage its tables. Use the following procedure:
  1. Shut down your MySQL server and make sure that it shuts down without errors.
  2. Copy all your data files (ibdata files and .ibd files) into a safe place.
  3. Copy all your ib_logfile files to a safe place.
  4. Copy your my.cnf configuration file or files to a safe place.
  5. Copy all the .frm files for your InnoDB tables to a safe place.
To recover your database, just shut down your MySQL server and copy this binary backup files back to it's original place.

To be able to recover your InnoDB database to the present from the binary backup just described, you have to run your MySQL server with binary logging turned on. Then you can apply the binary log to the backup database to achieve point-in-time recovery:

mysqlbinlog yourhostname-bin.123 | mysql

where yourhostname-bin.123 is binary log file(s) name
mysqldump
Use mysqldump for regular database backup

The most common use of mysqldump is probably for making a backup of an entire database:

    shell> mysqldump --opt db_name > backup_file_name.sql

or for making a back up of all databases:
    shell> mysqldump --all-databases --single-transaction > backup_file_name.sql
To add option user, password and host name:
    shell> mysqldump --all-databases --single-transaction --user=root --host=localhost -p > backup_file_name.sql
    you will be prompted for password
To flush the binary log and write the name of the new current binary log in to the dump file:
    shell> mysqldump --single-transaction --flush-logs --master-data=2 --all-databases > backup_file_name.sql
To purge old binary log files that are no longer needed:

    shell> mysqldump --single-transaction --flush-logs --master-data=2 --all-databases --delete-master-logs > backup_file_name.sql

You can read the dump file back into the server (recovery or restore) like this:

    shell> mysql db_name < backup_file_name.sql

or to restore from dump file that contain all databases:
    shell> mysql < backup_file_name.sql
To add option user, password and host name:
    shell> mysql -u root -p -h localhost < backup_file_name.sql
    you will be prompted for password
If you want to restore incremental changes (from binary log file(s)) execute this:
    shell> mysqlbinlog binary_log_file-bin.000001 binary_log_file-bin.000002 | mysql

where binary_log_file-bin.000001 and binary_log_file-bin.000002 are binary log file names.

^ Top

Table Operation
To change column type:
    ALTER TABLE table_name MODIFY column_name new_column_type;
To rename a column:
    ALTER TABLE table_name CHANGE old_name new_name column_type;
^ Top

Sat, Apr. 10th, 2010, 05:08 pm
Menghilangkan Windows Activation Technologies pada Windows 7

Bagi Anda pengguna Microsoft Windows XP pasti sudah mengenal dengan Windows Genuine Advantage (WGA) yang otomatis terdownload jika mengaktifkan Windows Update. Untuk menghilangkan WGA relatif mudah karena jika Anda cari melalui situs pencarian seperti Google maka akan cukup banyak situs web yang memberikan petunjuk untuk menghilangkan WGA tersebut.

Bagaimana dengan Windows 7? Walaupun sama mudahnya tetapi bagi Anda yang baru pertama kali menggunakan Windows 7 mungkin cukup terkejut karena penampilan dari "polisi" ini berbeda dan sedikit "menipu" dari Windows XP sehingga mungkin saja Anda "kecolongan" mendapati "polisi" ini sudah terinstall dengan suksesnya di komputer Anda.

Micosoft tidak lagi menggunakan WGA pada Windows 7 tetapi menggantinya dengan Windows Activation Technologies (WAT). WAT termasuk update jenis "Important" sehingga jika Anda set Windows Update menjadi "Install updates automatically (recommended)" maka "polisi" ini akan otomatis terinstall pada komputer Anda. Apalagi nama dari update ini tidak mengandung "Windows Genuine Advantage" maupun "Windows Activation Technologies" melainkan "Update for Windows 7 for x86-based Systems (KB971033)" sehingga bagi Anda yang tidak hati-hati membaca detail keterangan update ini bisa saja melewatkan checkboxnya tetap tercentang.

Jika WAT sudah terinstall maka akan muncul kotak peringatan pada komputer Anda yang berjudul "This copy of Windows is not genuine". Wallpaper desktop Anda akan menghilang digantikan dengan layar hitam yang di pojok kanan bawah bertuliskan:
Windows 7
Build 7600
This copy of Windows is not genuine

Untuk menghilangkan dan menyingkirkan (unistall) WTA ini yang harus Anda lakukan adalah:
1. Buka Control Panel kemudian pilih Windows Update.
2. Pilih "Installed Updates" yang berada di pojok kiri bawah.
3. Cari "Update for Windows 7 for x86-based Systems (KB971033)". Klik kanan dan pilih Uninstall.
4. Setelah selesai uninstall silahkan restart komputer Anda.

Setelah Anda login maka desktop masih tetap menampilkan layar hitam dan tulisan "This copy of Windows is not genuine" masih ada di pojok kanan bawah. Untuk menghilangkannya yang harus Anda lakukan adalah:
1. Buka windows explorer dan browse ke C:\Windows\System32. C: adalah drive dimana system Windows 7 Anda berada.
2. Cari file cmd atau cmd.exe dengan tipe Application. Klik kanan kemudian pilih "Run as administrator".
3. Pada window cmd yang telah terbuka ketik perintah berikut: slmgr.vbs -rearm
4. Silahkan restart komputer Anda.

Setelah Anda login seharusnya tulisan "This copy of Windows is not genuine" sudah menghilang dari desktop Anda. Namun karena Anda telah uninstall "Update for Windows 7 for x86-based Systems (KB971033)" maka Windows Update akan otomatis mendownload kembali update ini ke komputer Anda. Sebaiknya Anda ubah settingan Windows Update menjadi "Check for updates but let me choose whether to download and install them". Dan jika Windows Update menampilkan "Update for Windows 7 for x86-based Systems (KB971033)" yang Anda harus lakukan adalah klik KANAN dan pilih "Hide update" untuk memastikan update WAT ini tidak pernah terinstall lagi.

Sumber: http://www.geekmontage.com/how-to-uninstall-windows-7-activation-update-kb971033/

DISCLAIMER: postingan ini hanya untuk berbagi pengetahuan dan tidak disarankan untuk dilakukan terhadap penggunaan Windows 7 bajakan.

Sat, Jan. 30th, 2010, 10:48 pm
Masalah koneksi modem Axesstel

Penulis pernah menggunakan beberapa jenis koneksi untuk internet. Salah satunya adalah dengan dial-up menggunakan operator Smart. Modem yang digunakan adalah Axesstel model MV140B dengan versi VP11SMIN 1 [Apr 04 2008 14:00:30].

Masalah klasik yang sudah dimaklumi dengan koneksi internet dial-up adalah kadang-kadang hubungannya terputus sendiri. Dengan sistem operasi Windows XP, biasanya penulis cukup mencabut modem dari kabel USB yang terpasang pada notebook atau PC, mematikan modem, lalu memasangnya kembali. Setelah terpasang, modem akan otomatis menyala karena mendapat aliran listrik dan kemudian bisa dial kembali terhubung ke internet.

Namun dengan sistem operasi Windows Server 2003 entah kenapa cara diatas selalu tidak bisa. Ketika sudah terpasang kembali dan mencoba dial, selalu muncul pesan:
"Error: The modem (or other connecting device) is already in use or is not configured properly."

Setelah mencoba-coba dengan merestart beberapa service, akhirnya bisa diambil kesimpulan sementara yaitu perlu restart service "Application Layer Gateway Service" sebelum memasangkan kembali modem ke komputer.

Semoga postingan kali ini bisa membantu rekan-rekan yang mengalami masalah sama dengan modem Axesstel. Salam Komputeron.com :)

Fri, Nov. 27th, 2009, 03:31 pm
Trouble in ReInstall MySQL on Windows


If you just uninstall the previous MySQL and then install the new MySQL and when you Execute (last step) on installation process you found error like this:

Execute Process (these commands are not exact):
1. Prepare writing system [success]
2. writing system [success]
3. starting services [success]
4. apply security [ERROR]

try to use different password for root than the old password from the previous MySQL installation

Fri, Nov. 27th, 2009, 03:28 pm
Install PHP 5.0.4 for Windows

1) Download php-5.0.4-Win32.zip (7.488 KB) dari www.php.net
2) Extract ke C:\PHP
3) Tambahkan C:\PHP ke PATH di Environment Variables
4) Buka file php.ini-recommended dan Save As php.ini di C:\WINNT
5) Edit php.ini seperlunya. Yang penting extension_dir = "C:\PHP\ext", doc_root = "c:\Inetpub\wwwroot"
6) Buka Internet Services Manager. Klik kanan Default Web Site, pilih Properties. Tab Home Directory, klik Configuration... Tab App Mappings klik Add. Browse ke C:\PHP\php5isapi.dll kemudian ketik Extension: php.
7) Stop dan Start IIS

Fri, Nov. 27th, 2009, 03:24 pm
Instruksi setting Apache web server untuk Windows dan PHP


1. Edit file C:\Program Files\Apache Software Foundation\Apache2.2\conf\httpd.conf
a. Uncomment jika ingin menggunakan .htaccess:
LoadModule rewrite_module modules/mod_rewrite.so
b. Load PHP sebagai module
LoadModule php5_module "c:/php/php5apache2_2.dll"
AddType application/x-httpd-php .php
c. Option berikut untuk server development dan enable .htaccess
<Directory />
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
d. Tambahkan settingan untuk virtual host
Include conf/virtual-hosts.conf
2. Buat file C:\Program Files\Apache Software Foundation\Apache2.2\conf\virtual-hosts.conf yang akan menyimpan settingan dari masing-masing virtual host
Contoh isinya:
NameVirtualHost *:80

<VirtualHost *:80>

ServerName vvv.mysite.com
DocumentRoot "C:/mysite"

CustomLog logs/vvv.mysite.com.access.log combined
ErrorLog logs/vvv.mysite.com.error.log

</VirtualHost>

tambahkan <VirtualHost untuk masing-masing virtual host

Jangan lupa untuk menambahkan di file C:\Windows\System32\drivers\etc\hosts alamat situs local Anda yaitu:
127.0.0.1      vvv.mysite.com

Sat, May. 9th, 2009, 04:52 pm
Selamat Hari Raya Waisak 2553 BE

Komputeron.com mengucapkan Selamat Hari Raya Waisak 2553 BE / 2009 bagi Anda yang merayakannya

Mon, Jan. 26th, 2009, 04:03 pm
Selamat Tahun Baru Imlek 2560


Komputeron.com mengucapkan selamat tahun baru imlek bagi Anda yang merayakannya. Semoga di tahun kerbau tanah ini kita semua diberkati dengan banyak rejeki.

Xin Nian Kuaile
happy new year

Gong Xi Fa Cai
congratulations and be prosperous

Thu, Dec. 25th, 2008, 07:33 pm
Selamat Hari Natal dan Tahun Baru


Komputeron.com mengucapkan
 
Selamat Hari Raya Natal 2008
&
Tahun Baru 2009

10 most recent