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:
| Field | Type | Null | Key | Default | Extra |
| Host | varchar(60) | | PRI | | |
| User | varchar(16) | | PRI | | |
| Password | varchar(41) | | | | |
| Select_priv | enum('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-DocTools | 0.04 | Perl extension for Documentation TOC Gene~ |
| 2. | ActiveState-Relocat~ | 0.03 | Relocate a Perl installation |
| 3. | ActiveState-Rx | 0.60 | Regular Expression Debugger |
| 4. | Archive-Tar | 1.07 | Manipulates TAR archives |
5. | Compress-Zlib | 1.22 | Interface to zlib compression library |
| 6. | Data-Dump | 1.01 | Pretty printing of data structures |
| 7. | DBD-mysql | 2.9003 | MySQL driver for the Perl5 Database Inter~ |
| 8. | DBD-ODBC | 1.11 | ODBC Driver for DBI |
| 9. | DBI | 1.47 | Database independent interface for Perl |
| 10. | Digest-HMAC | 1.01 | Keyed-Hashing for Message Authentication |
| 11. | Digest-MD2 | 2.03 | Perl interface to the MD2 Algorithm |
| 12. | Digest-MD4 | 1.1 | Perl interface to the MD4 Algorithm |
| 13. | Digest-SHA1 | 2.06 | Perl interface to the SHA-1 Algorithm |
| 14. | File-CounterFile | 1.01 | Persistent counter class |
| 15. | Font-AFM | 1.18 | Interface to Adobe Font Metrics files |
| 16. | HTML-Parser | 3.34 | HTML parser class |
| 17. | HTML-Tagset | 3.03 | Data tables useful in parsing HTML |
| 18. | HTML-Tree | 3.18 | build and scan parse-trees of HTML |
| 19. | IO-Zlib | 1.01 | IO:: style interface to Compress::Zlib |
| 20. | libwin32 | 0.21 | A collection of extensions that aims to p~ |
| 21. | libwww-perl | 5.75 | Library for WWW access in Perl |
| 22. | MD5 | 2.02 | Perl interface to the MD5 Algorithm (obso~ |
| 23. | PPM3 | 3.1 | Perl Package Manager: locate, install, up~ |
| 24. | SOAP-Lite | 0.55 | Library for Simple Object Access Protocol~ |
| 25. | Tk | 800.024 | A Graphical User Interface Toolkit |
| 26. | URI | 1.27 | Uniform Resource Identifiers (absolute an~ |
| 27. | Win32-AuthenticateU~ | 0.02 | Win32 User authentication for domains |
| 28. | Win32-OLE | 0.1403 | OLE Automation extensions |
| 29. | XML-Parser | 2.34 | A Perl module for parsing XML documents |
| 30. | XML-Simple | 2.09 | Easy 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.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.