Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

How to get development headers and mysql client libraries for DBD::mysql installation

by Perl300 (Friar)
on Dec 12, 2016 at 23:23 UTC ( [id://1177678]=perlquestion: print w/replies, xml ) Need Help??

Perl300 has asked for the wisdom of the Perl Monks concerning the following question:

Please forgive me for asking yet another DBD::mysql installation related question.

I already have a system perl (v5.10.1) installed on GNU/Linux under /usr/bin/perl and a MySQL server and client are running on same host under /usr/bin/mysql.

mysql> SELECT VERSION(); +-----------+ | VERSION() | +-----------+ | 5.1.73 | +-----------+

I have installed local perl (v5.24.0) under application owned directory ~/localperl/bin/perl and have installed CPAN, cpanm and other required modules using them. But when I am trying to install DBD::mysql using cpanm or cpan shell (after installing DBI for local perl) I get error as below:

Running make for M/MI/MICHIELB/DBD-mysql-4.041.tar.gz cp lib/DBD/mysql/GetInfo.pm blib/lib/DBD/mysql/GetInfo.pm cp lib/DBD/mysql.pm blib/lib/DBD/mysql.pm cp lib/Bundle/DBD/mysql.pm blib/lib/Bundle/DBD/mysql.pm cp lib/DBD/mysql/INSTALL.pod blib/lib/DBD/mysql/INSTALL.pod Running Mkbootstrap for DBD::mysql () chmod 644 "mysql.bs" cc -c -I/~/localperl/lib/site_perl/5.24.0/x86_64-linux/auto/DBI -I/us +r/include/mysql -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstac +k-protector --param=ssp-buffer-size=4 -m64 -D_GNU_SOURCE -D_FILE_OFFS +ET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fwrapv -fPIC - +DUNIV_LINUX -DUNIV_LINUX -DDBD_MYSQL_WITH_SSL -DDBD_MYSQL_INSERT_ID_I +S_GOOD -g -fwrapv -fno-strict-aliasing -pipe -fstack-protector -I/us +r/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY +_SOURCE=2 -O2 -DVERSION=\"4.041\" -DXS_VERSION=\"4.041\" -fPIC "-I/ +~/localperl/lib/5.24.0/x86_64-linux/CORE" dbdimp.c In file included from dbdimp.c:20: dbdimp.h:21:49: error: mysql.h: No such file or directory dbdimp.h:22:45: error: mysqld_error.h: No such file or directory dbdimp.h:24:49: error: errmsg.h: No such file or directory In file included from dbdimp.c:20:

I found from some old posts on PM that this means I need to have the development headers and mysql client libraries available on my system. I have already checked for mysql.h, mysqld_error.h and errmsg.h files on my machine but they are not present.

Per documentation I think I can install these using yum as:

yum -y install make gcc mysql-devel mysql-libs mysql-server yum -y install "perl(Test::Deep)" "perl(Test::More)" systemctl start mysql.service

But won't this again install it for system perl instead of local perl? So few questions I have are:

1) How to get development headers and mysql client libraries for local perl?

2) Are there any reference docs I can follow for this specific need to install DBD::mysql on GNU/LINUX for local perl where system perl is also installed and MySQL server and client are on the same host.

Thank you for bearing with my long post.

Replies are listed 'Best First'.
Re: How to get development headers and mysql client libraries for DBD::mysql installation
by huck (Prior) on Dec 13, 2016 at 02:26 UTC

    I suspect that the sudo yum -y install mysql-devel will install the headers into /usr/include/mysql which is searched in the cc command via -I/usr/include/mysql. you would not need a specific copy for "local perl". The same can be said about the client libraries

Re: How to get development headers and mysql client libraries for DBD::mysql installation
by kcott (Archbishop) on Dec 13, 2016 at 04:00 UTC

    G'day Perl300,

    In the first instance, I would check DBD::mysql::INSTALL. This has a lot of information, including "How to get development headers and mysql client libraries".

    While I'm very much guessing here, I suspect the source of your problem occurs before make is run. It could be the value of environment variables, the location or content of mysql_config, or something else like that. DBD::mysql::INSTALL discusses these things.

    I'd also check your $PATH. A common problem (using cpan as an example) is that `which cpan` returns /system/path/bin/cpan instead of /local/path/bin/cpan.

    I'm also a little concerned about seeing pathnames starting with '~/'. At one point you talk about an "application owned directory"; I assume you have your own account; and perhaps, at times, you're operating as the superuser. Does '~/' equal '/home/application/', '/home/perl300/' or '/home/root/'? I'm not saying don't use '~/', I use it myself a lot on the command line; however, there are times when an absolute pathname makes it unequivocally obvious what file(s) you're referencing.

    You might also consider using perlbrew. I know many people here use and recommend it (including myself). It's a very easy way of keeping your local and system Perl installations separate. It also allows you to have multiple Perl versions installed locally and to quickly switch from one to another with a single, short command.

    — Ken

[Solved]: How to get development headers and mysql client libraries for DBD::mysql installation
by Perl300 (Friar) on Dec 13, 2016 at 17:53 UTC

    UPDATE: First I added /www/application/localperl/bin to my $PATH:
    I added it to ~/.bashrc file by adding following line:
    export PATH=$PATH:/www/application/localperl/bin
    Then ran:
    source ~/.bashrc

    Then I followed huck's advise to get devel package using sudo yum -y install make gcc mysql-devel mysql-libs mysql-server I tried to install DBD::mysql from CPAN shell (/www/application/localperl/bin/cpan).

    It was failing during make test and the log entries just before failure are:

    Running make test Running Mkbootstrap for DBD::mysql () chmod 644 "mysql.bs" PERL_DL_NONLAZY=1 "/www/application/localperl/bin/perl" "-MExtUtils::C +ommand::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; t +est_harness(0, 'blib/lib', 'blib/arch')" t/*.t t/00base.t .............................. 1/6 # Driver version is 4.04 +1 t/00base.t .............................. ok t/05dbcreate.t .......................... 1/2 # Database 'test' access +ible t/05dbcreate.t .......................... ok t/10connect.t ........................... 1/? # mysql_clientinfo is: 5 +.1.73 # mysql_clientversion is: 50173 # mysql_serverversion is: 50173 # mysql_hostinfo is: Localhost via UNIX socket # mysql_serverinfo is: 5.1.73 # mysql_stat is: Uptime: 4761821 Threads: 1 Questions: 4535919 Slow + queries: 2 Opens: 357 Flush tables: 1 Open tables: 41 Queries pe +r second avg: 0.952 # mysql_protoinfo is: 10 # SQL_DBMS_VER is 5.1.73 # Default storage engine is: MyISAM t/10connect.t ........................... ok t/15reconnect.t ......................... ok t/16dbi-get_info.t ...................... ok t/20createdrop.t ........................ ok t/25lockunlock.t ........................ ok t/29warnings.t .......................... ok t/30insertfetch.t ....................... ok t/31insertid.t .......................... ok t/32insert_error.t ...................... ok t/35limit.t ............................. ok t/35prepare.t ........................... ok t/40bindparam.t ......................... ok t/40bindparam2.t ........................ ok t/40bit.t ............................... ok t/40blobs.t ............................. ok t/40catalog.t ........................... ok t/40keyinfo.t ........................... ok t/40listfields.t ........................ ok t/40nulls.t ............................. ok t/40nulls_prepare.t ..................... ok t/40numrows.t ........................... ok t/40server_prepare.t .................... 1/31 DBD::mysql::st DESTROY +failed: MySQL server has gone away at t/40server_prepare.t line 98. (in cleanup) DBD::mysql::st DESTROY failed: MySQL server has g +one away at t/40server_prepare.t line 98. t/40server_prepare.t .................... ok t/40server_prepare_crash.t .............. ok

    So I sudo as root and tried to install DBD::mysql using CPAN shell (/www/application/localperl/bin/cpan) and the installation completed successfully. many tests from make test were skipped with message skipped: no database connection but I think that was because I didn't add db password by setting environment variable. I was not very comfortable doing it so I tried installation with setting environment variable and it still completed successfully.

    Thank you again Ken and huck for your inputs. I am marking this as Solved.

Re: How to get development headers and mysql client libraries for DBD::mysql installation
by Perl300 (Friar) on Dec 13, 2016 at 16:37 UTC
    Thank you for your response Ken and huck. My $PATH has:
    $ echo $PATH /usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/us +r/sbin:/sbin:/www/application/bin

    And as you suspected which cpan returns /usr/bin/cpan instead of /www/application/localperl/bin/cpan

    Also, '~/' is equal to '/www/application/'. I did check DBD::mysql::INSTALL and saw the yum option there to install devel but was not sure if it would install it for system perl.

    So this is what I'll try next: I'll add /www/application/localperl/bin to my $PATH and follow huck's advise to get devel package and see how it goes from there.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1177678]
Approved by Paladin
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2024-04-19 08:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found