This topic is mainly for Windows machine. I setup successfully for Windows XP (SP2) PC.
A) Install MySQL DB Server:
- Download latest MySQL 5.0 (GA - General Release) and install with default settings from: http://dev.mysql.com/downloads/mysql/5.0.html #win32
B) Install ActiveState Perl:
- Download latest ActiveState 5.10.x Perl and install using all default settings from: http://www.activestate.com/Products/activeper l/
C) Install Net-mysql module for your new Perl:
- Run C:\ppm search mysql
D) Setup the password for 'root' account on MySQL DB Server:
- Setup MySQL on localhost and root passwd as follows:
- Run 'mysql -u root' (blank passwd by default)
mysql->SET PASSWORD FOR 'root'@'localhost' = PASSWORD('pass');
E) Setup the 'test' db for testing:
- Log into the MySQL server as root
- Run 'use test' to use the 'test' db given (it's empty by default)
- Run 'create table mytable(ColA int(3), ColB char(128));'
- Now you have a table named 'mytable' in the database 'test' on your new MySQL server. The table has 2 columns named 'ColA' and 'ColB'. Column 'ColA' is storing digits up to 3 digits in length and Column 'ColB' stores text string up to 128 characters in length.
F) Test the Perl script with connection to the new DB server:
- Hookup in Perl script as:
#!C:\Perl\bin\perl
use Net::MySQL;
my $mysql = Net::MySQL->new(
hostname => 'localhost',
database => 'test',
user => 'root',
password => "pass",
debug => 0
);
$mysql->query("INSERT INTO mytable (ColA, ColB) VALUES (1, 'Hello World')");
$mysql->query("SELECT * from mytable");
my $a_record_iterator = $mysql->create_record_iterator();