Re: Need help with Perl and MySQL database data load

From: Oscar (oscar_at_nowhere.com)
Date: 01/18/05


Date: Tue, 18 Jan 2005 00:50:56 GMT

Tore Aursand wrote:
> Oscar wrote:
>
>> I'm not sure what top-post refers to. Hope I'm not doing it now.
>
>
> You are. Top-posting means that you are posting your answer in front of
> the part you are answering. That's a bad habit; it's like answering
> someone before you've even heard the question.
>
>> #!/perl/bin/perl -w
>> #insert data into mysql
>> use strict;
>> use DBI;
>
>
> If you're running a newer version of Perl, you should change this to:
>
> #!/usr/bin/perl
> #
> use strict;
> use warnings;
>
>> package MySQL;
>
>
> Don't do that. You are telling Perl that you're creating a package named
> 'MySQL' with this line. You aren't doing that, are you?
>
>> my $dsn = 'DBI:mysql:database=sd_tst;host=localhost;port=3306';
>> my $user = 'root';
>> my $pass = 'xxxxxxx';
>> my %args = ( RaiseError => 1,
>> AutoCommit => 1 );
>>
>> my $dbh = DBI->connect( $dns, $user, $pass, \%args )
>> or die "Can't connect; $DBI:errstr";
>>
>> $dbh->do("LOAD DATA LOCAL INFILE '/sd_data/audit_20041208.txt' INTO TABLE
>> sd_tst FIELDS TERMINATED BY '\|' LINES TERMINATED BY '\r\n';");
>>
>> $dbh->disconnect ();
>
>
> What error message(s) do you get? I haven't imported files this way in a
> long time, so I'm not sure if the syntax is right, but I'm sure you've
> read the documentation?
>
>

Hello,

When I remove the line
use DBI; I get the error message "Can't locate object method "connect"
via packge "DBI" (perhaps you forgot to load "DBI"?) at sqltst2.pl line 12."

When I put that line, use DBI;, back in I then get an authentication
procotol error message:
"DBI connect
('database=sds_tst;host=localhost;port=3306,'root',....)failed: Client
does not support authentication protocol requested by server;consider
upgrading MYSQL client at sqltst2.pl line 13."
I have the latest MySQL client installed.

I have reviewed the DBI documentation however just about all of the
examples contained refer to Perl on a UNIX box connecting to an Oracle
database. I use the path /perl/bin/perl as this is where my executables
are located. I don't have the usual USR directory since I am not using
UNIX/Linux.

My PC is WindowsXP connecting to MySQL (4.1). Here is the latest
version of the Perl script:

Thanks,
Oscar

#!/perl/bin/perl -w
#insert data into mysql
use strict;
use warnings;
use DBI;

my $dsn = 'DBI:mysql:database=sd_tst;host=localhost;port=3306';
my $user = 'root';
my $pass = 'xxxxxxx';
my %args = ( RaiseError => 1,
               AutoCommit => 1 );

my $dbh = DBI->connect( $dsn, $user, $pass, \%args )
           or die "Can't connect:". dbi->errstr;

$dbh->do("LOAD DATA LOCAL INFILE '/sd_data/audit_20041208.txt' INTO TABLE
sd_tst FIELDS TERMINATED BY '\|' LINES TERMINATED BY '\r\n';");

$dbh->disconnect ();
#EOF



Relevant Pages

  • Re: getting DBI and ODBC to work with PERL and MYSQL data source
    ... and installed DBI and DBD::ODBC perl modules. ... experience issuing a SQL query through PERL to Mysql.. ...
    (comp.lang.perl.misc)
  • DBI / DBD / MySQL installation problem
    ... I used to run Red Hat 9, and had a perfect relationship with Perl, DBI, ... able to connect to MySQL from Perl via DBI. ... Running install for module Mysql ...
    (perl.dbi.users)
  • Re: quer y about dbi
    ... If you plan to do a project with Perl / DBI / MySQL, ... And if you don't have yourself a good book on MySQL yet, ... Mail has the best spam protection around ...
    (perl.dbi.users)
  • Error while running DBI with Perl and MySQL
    ... I am learning Perl and using the book from apress called Beginning ... There is a section showing Perl and DBI. ... I installed MySQL and was able to build the database as per the books ... MySql 5.0 and Lastest Perl downloaded from the Perl.ORG website. ...
    (perl.dbi.users)
  • Re: Stored Procedure using perl
    ... > I am trying to execute a stored procedure in Sybase database using perl ... > DBI and I am getting the following error message. ...
    (perl.dbi.users)