Brethren and sistren,

Having no other language available, I wrote about 6K lines of VB6 to take some accounting spreadsheets, put their contents into a MySQL database and manipulate the database to produce reports. The CodeReaper, aka Bill Door, announced not long ago that VB6 will no longer be supported, and that future versions of MessWare may cause VB6 programmes to crash. I took this as a wonderful excuse to teach myself Perl, so that I can port the programme to a more portable language. Lest this sound like an overdose of hubris, this was the first application I ever wrote using either VB6 or MySQL, and it works. At least, it crashes no more frequently than I can convincingly blame on MessWare.

The first thing the VB programme does is try to connect to a server. This, therefore, is the first thing I have tried to teach myself in Perl. Sad to relate, I have come a cropper, and would appreciate some help.

I can connect to the server using the following code:
use strict; use DBI; use warnings; use diagnostics; my $dsn = 'MySQL'; my $user = 'JHD'; my $password = 'JHD'; my $dbh = DBI->connect("DBI:ODBC:$dsn",$user,$password) || die "Got error $DBI::errstr when connecting to $dsn\n" +; exit (0);
However, in the various manual pages I have read, ISTR reading that connecting via ODBC is deprecated. I understand that TIMTOWTDI, so if I should give up and use whatever works, please let me know. Attempting to to it the BEST way, I have tried several variants on the following code:
use strict; use DBI; use warnings; use diagnostics; my $sqlhost = 'localhost'; my $sqlbase = 'debloat'; my $user = 'JHD'; my $password = 'JHD'; my $dbh = DBI->connect("DBI:mysql:database=$sqlbase;host=$sqlhost", $user, $password, {RaiseError => 1}); exit (0);
This crashes as follows:
C:\Perl\bin>perl -w practice\sqltest.pl Uncaught exception from user code: DBI connect('database=debloat;host=localhost;port=3306', 'JHD',...) failed: Client does not support authentication protocol requested by server; consider upgrading MySQL client at practice\sqltest.pl line 11 DBI::__ANON__('undef', 'undef') called at C:/Perl/site/lib/DBI.pm line 664 DBI::connect('DBI', 'DBI:mysql:database=debloat;host=localhost;port=3306 ', 'JHD', 'JHD', 'HASH(0x15d4f58)') called at practice\sqltest.pl line 11

Full – possibly too full, but please flame gently – details of my configuration appear at the end. There are two things that concern me in this report. One is the “upgrade” advice. I believe that I am using the latest version, but I am far from sure that I have understood everything I need to. My concern here is that the manual says things like

I recommend using the win32clients package for installing DBD::mysql under Win32, available for download on www.tcx.se. The following steps have been required for me: - The current Perl versions (5.6, as of this writing) do have a problem with detecting the C libraries. I recommend to apply the following patch:

Since I am using v5.8.something, as detailed below, I am scared that the documentation (which came with the installation) is out of date, and that my time R’ing TFM is wasted because I’m R’ing T wrong FM. Any pointers in this regard would be greatly appreciated. I am also concerned that my installation of MySQL may be to blame. The system started with 4.0.12, but I have recently upgraded to 4.1.7, which uses different passwords. I think I have applied the patches correctly, and the start of the DESCRIBE USER output is as follows:
FieldType NullKeyDefaultExtra
Hostvarchar(60)PRI
Uservarchar(16)PRI
Passwordvarchar(41)
Select_privenum('N','Y')N

My second concern is the __ANON__ call in the crash report. This makes me fear that I have formatted the userid and password worngly. Wrnogly. Incorrectly. Again, pointers would be appreciated, especially those that indicate how I should interpret the output and work out for myself what the problem is.

As a prat^wnovice, I get only five votes per day, which may not be enough to ++ helpful responses as quickly as they deserve. It’s only a number, though, isn’t it? :-)

TIA,

John Davies

System configuration
Dell Latitude 2.4 GHz, 512Mb RAM, 20Gb Hard disc
Losedows 2000
File system is FAT
ActiveState Perl 5.8
ppm output:
ppm> query *
Querying target 1 (ActivePerl 5.8.4.810)
1.ActivePerl-DocTools0.04Perl extension for Documentation TOC Gene~
2.ActiveState-Relocat~0.03Relocate a Perl installation
3.ActiveState-Rx0.60Regular Expression Debugger
4.Archive-Tar1.07Manipulates TAR archives
5.Compress-Zlib1.22Interface to zlib compression library
6.Data-Dump1.01Pretty printing of data structures
7.DBD-mysql2.9003MySQL driver for the Perl5 Database Inter~
8.DBD-ODBC1.11ODBC Driver for DBI
9.DBI1.47Database independent interface for Perl
10.Digest-HMAC1.01Keyed-Hashing for Message Authentication
11.Digest-MD22.03Perl interface to the MD2 Algorithm
12.Digest-MD41.1Perl interface to the MD4 Algorithm
13.Digest-SHA12.06Perl interface to the SHA-1 Algorithm
14.File-CounterFile1.01Persistent counter class
15.Font-AFM1.18Interface to Adobe Font Metrics files
16.HTML-Parser3.34HTML parser class
17.HTML-Tagset3.03Data tables useful in parsing HTML
18.HTML-Tree3.18build and scan parse-trees of HTML
19.IO-Zlib1.01IO:: style interface to Compress::Zlib
20.libwin320.21A collection of extensions that aims to p~
21.libwww-perl5.75Library for WWW access in Perl
22.MD52.02Perl interface to the MD5 Algorithm (obso~
23.PPM33.1Perl Package Manager: locate, install, up~
24.SOAP-Lite0.55Library for Simple Object Access Protocol~
25.Tk800.024A Graphical User Interface Toolkit
26.URI1.27Uniform Resource Identifiers (absolute an~
27.Win32-AuthenticateU~0.02Win32 User authentication for domains
28.Win32-OLE0.1403OLE Automation extensions
29.XML-Parser2.34A Perl module for parsing XML documents
30.XML-Simple2.09Easy API to read/write XML (esp config fi~

The MySQL monitor launches with:
Your MySQL connection id is 18 to server version: 4.1.7-nt

Please let me know if further configuration data would help.

In reply to Connecting to MySQL by davies

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.