Vinetop
 
{ Guest } - Login Browse 
:: Browse Topic Focus
Journal
General
How-To & DIY
Tips & Tricks
Reviews
 

ActiveState Perl 5.10 Connecting to MySQL 5.0 with Net::MySQL module - Atom8 - Jan 21, 2008 9:47pm
How-To & DIY @ Technology / Computers / Progamming Languages / Perl - Views (8457) - Ratings(1): ( 5.00 )
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

    Downloading ActiveState Package Repository packlist...not modified
    1: ApacheMysql v0.3
    2: CGI-Session-FlexMySQL v0.2
    3: Crypt-MySQL v0.04
    4: DBA-Backup-MySQL v0.8
    5: DBD-mysql-SimpleMySQL v0.5
    6: DBD-mysql-informationschema v0
    7: DBD-mysqlPP v0.04
    8: DBIx-Mysql-InformationSchema v0.04
    9: Data-Validate-MySQL v0.03
    10: DateTime-Format-MySQL v0.04
    11: Finance-Shares-MySQL v0.03
    12: MySQL-Config v1.03
    13: MySQL-DateFormat v1.01
    14: MySQL-Packet v0.2007054
    15: Mysql-Locker v1.00
    16: Mysql-NameLocker v1.00
    17: Net-MySQL v0.09
    18: Time-Piece-MySQL v0.05

- Run 'ppm install Net-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();

while (my $record = $a_record_iterator->each()) {
print "Column1 = $record->[0], Column2: $record->[1]\n";
}

Last Edit: Jan 22, 2008 7:30pm - by Atom8        Comments | Report




Comments and Ratings:( Post Your Comments )

No Comments...

How-To & DIY

Recent Posts
Most Viewed
How to embed Picasa Slideshow in your posts
:: VineTop - Jul 13, 2008 2:19pm

Sony PS3 250GB Upgrade on a 40GB System
:: Atom8 - Mar 03, 2008 12:58am

How to configure Apache server to run CGI scripts outside of cgi...
:: Atom8 - Jan 22, 2008 8:19pm

How to install ActiveState Perl 5.10 on Windows XP
:: Atom8 - Jan 22, 2008 5:26pm

How to install Apache web server (v2.2.x) on Windows XP
:: Atom8 - Jan 22, 2008 6:58pm

How to create new post for text-only topic
:: VineTop - Jan 09, 2008 12:33am

How to embed YouTube videos in your posts
:: VineTop - Jan 19, 2008 12:52pm

How to export & import table using mysqldump and mysql commands
:: Atom8 - Jan 23, 2008 4:45am

How to install MySQL 5.0 Server on Windows XP
:: Atom8 - Jan 22, 2008 3:32pm

ActiveState Perl 5.10 Connecting to MySQL 5.0 with Net::MySQL mo...
:: Atom8 - Jan 21, 2008 9:47pm

Most Commented
Top Rated

© 2007 - 3000 vinetop.com [ Terms & Policy :: Contact Us :: About ]