1. Pergi ke Start Menu > Run > taip "services.msc" [Enter]
2. Paparan seperti di bawah akan terhasil
3. Pilih MySQL (1) kemudian klik butang "Start Services"(2). Jika dah start, tak perlu buat apa2
4. Pergi semua ke Start Menu > Run > taip "cmd" [Enter]
5. Lakukan arahan berikut pada paparan DOSC:\mysql\bin>mysql -u root -p
Enter password: ******
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4 to server version: 5.0.26-community-nt
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>use dahlia;
Database changed
mysql>
Jika semasa install tidak di setkan username dan password, cuma taipkan mysql sahaja tanpa di ikuti dgn "-u root -p".
Run MySQL pada antaramuka DOS
Wednesday, November 22, 2006
Posted by ayus at 2:20 AM 0 comments
BASIC PERL DI WINDOWS
Wednesday, November 15, 2006
Windows support arahan perl
1. Masuk website: http://aspn.activestate.com/ASPN/Downloads/ActivePerl/ , kemudian download fail ActivePerl
2. Setup (Install) fail yang telah didownload tadi
3. DOS telah support PERL. Arahan Perl boleh di run di mana2 dalam DOS
Run Perl
1. Buat satu fail, diberikan nama "test.pl"
2. Isi code di bawah dan save dlm folder "C:\Perl\perlscript"#!/usr/bin/perl
use strict; # important pragma
use warnings; # another important pragma
print "What is your username? "; # print out the question
my $username; # \declare" the variable
$username =
chomp($username); # remove \new line"
print "Hello, $username.\n"; # print out the greeting
4. Taip
C:\>cd perl\perlscript [Enter]
5. Setelah masuk dlm folder tersebut, taip
C:\Perl\perlscript>perl test.pl [Enter]
Perl + MySQL
1. Sebelum Perl dapat sambung(connect) dengan Database, perlu install supporter terlebih dahulu
2. Pergi Start Menu > Programs > ActivePerl X.X.X Build XXX > Perl Package Manager
4. Klik butang "View all package[Ctrl+1]" (no.3)
5. Cari satu lagi ikon Package bernama "DBD-mysql" dan pilih butang "Mark for install[+]" (no.2) tadi.
6. Kemudian klik butang "Run marked actions [Ctrl+Enter]"(no.4)
ps: merujuk pada langkah ketiga, walaupun DBI telah diinstall, tapi ia dipilih untuk meng"update"kan versionnya.
Connect Database MySQL
1. Bina satu fail dlm folder C:\Perl\perlscript dan diberikan nama "cuba_dbase.pl"
2. Masukkan code di bawah dan save...........................
#!/usr/bin/perl
use DBI;
my $dsn = 'DBI:mysql:try_and_error:localhost';
my $db_user_name = 'root';
my $db_password = 'sakura';
my ($id, $password);
my $dbh = DBI->connect($dsn, $db_user_name, $db_password);
my $sql = qq{ SELECT cuba_id, cuba_code, cuba_desc FROM cuba };
my $sth = $dbh->prepare( $sql );
$sth->execute();
my( $id, $code, $desc );
$sth->bind_columns( undef, \$id, \$code, \$desc );
print "ID. \tCODE \tDesc\n";
while( $sth->fetch() ) {
print "$id. \t$code, \t$desc\n";
}
$sth->finish();
$dbh->disconnect();
#try_and_error = nama database
...........................
3. Pada cmd command, taip
C:\Perl\perlscript>perl cuba_dbase.pl [Enter]
4. Hasilnya
C:\Perl\perlscript>perl cuba_dbase.pl
ID. CODE Desc
1. 832, apa kejadahnya
2. 560, takde apa nak dikatakan sekarang
Posted by ayus at 9:41 PM 0 comments