SPUG: installing perl mysql DBD - need C compiler?

Meryll Larkin humbaba9 at yahoo.com
Tue Oct 22 14:32:17 CDT 2002


10/22/02

Thank you all for your help.  I'm pretty sure by now that mysql never
installed fully because I don't have a C++ compiler.  I'm still working
on this and I'll keep you updated - later this week.

http://www.mysql.com/doc/en/configure_options.html

  If you don't have a C++ compiler, mysql will not compile 
  (it is the one client program that requires C++). In this 
  case, you can remove the code in configure that tests for 
  the C++ compiler and then run ./configure with the 
  --without-server    option. The compile step will still 
  try to build mysql, but you can ignore any warnings about 
  `mysql.cc'. (If make stops, try make -k to tell it to 
  continue with the rest of the build even if errors occur.)

I've been running into all kinds of trouble, found files missing (
mysql.socks for one ), error messages about bootstrap, hostname...

So, thank you, William, the command didn't work, but you put me on the
right track.  Find displayed my egcs compiler on my dev machine, but
even that was absent from my server, so I have no C++ compiler there.

Aaron, THANK YOU for your script, I'll be able to run it again later. 
Right now it shows this error message:
install_driver(mysql) failed: Can't locate loadable object for module
DBD::mysql in @INC (@INC contains: (long path here, and yes, it is
there)
Compilation failed in require at (eval 1) line 3
Perhaps a module that DBD::mysql requires hasn't been fully installed
at testDBI.pl line 15.

Line 15 is the DBI-> connect   line.

To answer your other question, I went into a loading frenzy and didn't
keep track....  Well, that's almost true.  On mysql.com there are a
bunch of rpm files.  I downloaded those off the Web (http, and ftp,
mostly ftp)
and used rpm -i filename from /, just like the mysq.com instructions
say to install.  But I got stuck on the steps after that - never could
run configure - lots of error messages.  But the funny thing was that I
was able to use the mysql on the command line and that I had use of my
old databases.  On CPAN I used perl -MCPAN -e shell.

I think I wasn't installing fully because I don't have the C++
compiler.

Okay, now scripts:
When I used this script (which I got from About):

#!
use strict; use DBI;
print "Here's a list of DBI drivers:\n";
my @available_drivers = DBI->available_drivers('quiet');
my $driver;
foreach $driver(@available_drivers) {
   print "$driver\n";
}

Here is what I got:
ADO
ExampleP
Multiplex
Mysql
Pg
Proxy
mSQL
mysql

So I am puzzled as to why it can find DBD/mysql.pm with the script
above but not with DBI->connect

Peter, you wanted to see my script:

#!/usr/bin/perl

use strict;
use DBI;
use Data::Dumper;

my $DATA_BASE = 'dbi:mysql:phonebook';

my $password = "deleted";
my $user = "deleted";

my $sql = qq|SELECT *
          FROM
          phonebook |;

print "Content-type: text/html\n\n";

print qq|<html><head><title>Phonebook Test</title></head>
    <body><table width="100%" cellpadding="16" cellspacing="0"><tr><td>
    <table>|;

# connect to the db
my $dbh = DBI->connect ($DATA_BASE, $user, $password) || print ("can\'t
connect
 to database: $!" . $DATA_BASE->errstr);

my $sql_st = $dbh->prepare($sql) || print ("can\'t prepare $sql");
$sql_st->execute || print ("can\'t execute sql statement:<br>" .
$sql_st->errstr);

while (my $record = $sql_st->fetchrow_hashref) {
   print qq|
         <tr><td>  $record->{'id'} </td>
             <td>  $record->{'name'} </td>
             <td>  $record->{'phone'} </td>
             <td>  $record->{'department'}</td>
         </tr>|;
}

print qq|</table></td></tr><tr><table>

<br /><br /><br />
</body>
</html>

|;

$dbh->disconnect || print ("can\'t disconnect<br>");

exit 0;


When I look through a browser at the results, it gets as far as the
second table and then stops (so it displays a blank page).

When I run it on the command line, I get that far and then the same
error message as I got with Aaron's script.

Thank you all, I'll keep you posted.

Meryll


--- Meryll Larkin <humbaba9 at yahoo.com> wrote:
> 10/21/02
> 
> Greetings SPUGsters,
> 
> I recently set up an Apache Web server on Red Hat Linux and I'm
> hoping
> someone can help me with some advice on how to get Perl and MySQL to
> work together on it.  
> 
> step 1.  I'm successfully serving Perl-CGI (and static HTML) web
> pages.
>  
> step 2.  I installed MySQL and I can successfully view and update the
> MySQL database on the mysql> command line.
> 
> step 3 failed:
> I copied a script I had working on Windows Apache with MySQL and
> Active
> Perl (which works with the databases I already tested on Red Hat). 
> This did not work.  
> 
> Do I need a C compiler (gcc?) on my server in order to get MySQL and
> Perl to communicate?  Or rather to run the "make" for the various
> drivers?
> 
> I spent a day on the Web at CPAN and MySQL yesterday, reading
> documentation, downloading and installing .rpm files (DBI modules,
> DBD
> modules) that are supposed to work with Perl-MySQL, DBI-DBD-MySQL,
> Perl-DBI-DBD-MySQL.  I continued to get an error message (running the
> Web page from the command line) saying that I am probably missing a
> driver for MySQL.  It doesn't seem to be finding or using files I
> installed, although they are in @INC.  The web-page generating script
> works fine until it gets to the DBI->connect  line (run time error). 
> I
> have Carp and DynaLoader in the @INC path.
> 
> I finally tried installing Perl 5.8 (I was using 5.6) and Makefile.PL
> worked, but "make" gave me 
>   gcc: command not found  
> and did not complete.
> 
> For security I started out with a very stripped-down installation of
> RedHat7.2 to build this server.  I'm thinking I stripped down too
> much.
>  Because "make" seems to require the C compiler.
> 
> Can I "make" the files on my development Linux box and then secure
> copy
> them to my Apache server or do they need to "make" on the same
> machine
> where they will be working?
> 
> When I run a script to find out what DBI drivers I have installed, it
> lists mSQL, mysql, and Mysql (like I said, I spent a day on CPAN)....
> 
> Other suggestions?  
> 
> TIA,
> 
> Meryll Larkin
> 
> 
> 
> __________________________________________________
> Do you Yahoo!?
> Y! Web Hosting - Let the expert host your web site
> http://webhosting.yahoo.com/
> 
>  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
> - - -
>      POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
>       Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
>   Replace ACTION by subscribe or unsubscribe, EMAIL by your
> Email-address
>  For daily traffic, use spug-list for LIST ;  for weekly,
> spug-list-digest
>      Seattle Perl Users Group (SPUG) Home Page:
> http://seattleperl.org
> 


__________________________________________________
Do you Yahoo!?
Y! Web Hosting - Let the expert host your web site
http://webhosting.yahoo.com/

 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
      Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
  Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
 For daily traffic, use spug-list for LIST ;  for weekly, spug-list-digest
     Seattle Perl Users Group (SPUG) Home Page: http://seattleperl.org




More information about the spug-list mailing list