Category Archives: Perl

Install Perl DBD::mysql on Oracle Linux/Centos

Install CPAN

yum -y install cpan
cpan App::cpanminus

Install C compiler

[root@yogya ~]# yum -y install cpp

Install MySql developer libraries

[root@yogya mysql-database-stuff]# yum -y install msql-devel

Install DBI and YAML

[root@yogya mysql-database-stuff]# cpan DBI
[root@yogya mysql-database-stuff]# cpan
cpan[2]> install YAML

Om de een of andere reden lukt installeren van DBD::mysql niet met CPAN.
Dus MySql installation from source. Download source distro.

http://search.cpan.org/dist/DBD-mysql/lib/DBD/mysql/INSTALL.pod#Manual_installation


[root@yogya ~]# wget http://cpan.metacpan.org/authors/id/C/CA/CAPTTOFU/DBD-mysql-4.028.tar.gz
[root@yogya ~]# gunzip DBD-mysql-4.028.tar.gz
[root@yogya ~]# tar xvf DBD-mysql-4.028.tar 
[root@yogya ~]# cd DBD-mysql-4.028

Maak even de test database en zet een password voor de root user

mysql> create database test;
mysql> use mysql;
mysql> update user set password = password ( 's3kr1t' ) where user = 'root'

Make sure options match, dus kijk even wat je in moet vullen om de Makefile te bouwen met.

[root@yogya DBD-mysql-4.028]# perl Makefile.PL --help
Usage: perl Makefile.PL [options]

Possible options are:

--cflags= Use for running the C compiler; defaults
to the value of "mysql_config --cflags" or a guessed
value
--libs= Use for running the linker; defaults
to the value of "mysql_config --libs" or a gussed
value
--force-embedded Build version of driver supporting mysqlEmb
--embedded= Use these libs when building the embedded version of
DBD (with --force-embedded). Defaults to the value of
"mysql_config --embedded".
--testdb= Use the database for running the test suite;
defaults to test
--testuser= Use the username for running the test suite;
defaults to no username
--testpassword= Use the password for running the test suite;
defaults to no password
--testhost= Use as a database server for running the
test suite; defaults to localhost.
--testport= Use as the port number of the database;
by default the port number is choosen from the
mysqlclient library
--mysql_config= Specify for mysql_config script
--with-mysql= Specify for the root of the MySQL installation.
--nocatchstderr Supress using the "myld" script that redirects
STDERR while running the linker.
--nofoundrows Change the behavior of $sth->rows() so that it
returns the number of rows physically modified
instead of the rows matched
--ps-protocol Toggle the use of driver emulated prepared statements
prepare, requires MySQL server >= 4.1.3 for
server side prepared statements, off by default
--bind-type-guessing Toggle the use of driver attribute mysql_bind_type_guessing
This feature makes it so driver-emulated prepared statements
try to "guess" if a value being bound is numeric, in which
case, quotes will not be put around the value.
--ssl Enable SSL support
--help Print this message and exit

All options may be configured on the command line. If they are
not present on the command line, then mysql_config is called (if
it can be found):

mysql_config --cflags
mysql_config --libs
mysql_config --embedded
mysql_config --testdb

and so on. See DBD::mysql::INSTALL for details.

Finish installation. In dit geval hoef je alleen het password op te geven.


[root@yogya DBD-mysql-4.028]# perl Makefile.PL --testpassword=s3kr1t
[root@yogya DBD-mysql-4.028]# make
[root@yogya DBD-mysql-4.028]# make test
[root@yogya DBD-mysql-4.028]# make install

					

perl DBD::mysql Mac OS X 10.8.5

At the moment of this writing there is no MySQL for Mac OS X 10.8, instead use the MySql for 10.7.

When trying to open a connection via Perl the system complains about dylib not being installed in the right place.

su root
find / -name "libmysqlclient.18.dylib" -print 
cp /usr/local/mysql-5.6.14-osx10.7-x86_64/lib/libmysqlclient.18.dylib /usr/lib

How to Install Perl Modules on Mac OS X in 4 Easy Steps

http://triopter.com/archive/how-to-install-perl-modules-on-mac-os-x-in-4-easy-steps/

You see, for the past couple of years, I’ve been a bit frustrated because OS X does not come with a whole lot of Perl modules pre-installed, and for all I googled, I couldn’t find an “idiot’s” guide for moderately-savvy-but-not-expert users like myself to install modules and dependencies on demand.

The only instructions I could find point to Fink, which basically installs modules in a path that isn’t included in the Perl @INC variable, meaning you have to manually specify the full path to the modules in every script — which is not a lot of fun if you’re developing on OS X and deploying on Red Hat, for instance.

Moreover, Fink doesn’t seem to make every module available, and it’s not very easy to determine which Fink package you need to install if you need a particular module.

So, with a script that called on several apparently unavailable modules, and a deadline looming, I finally decided to suck it up and figure out how to use CPAN to install them:
1) Make sure you have the Apple Developer Tools (XCode) installed.

These are on one of your install discs, or available as a huge but free download from the Apple Developer Connection [free registration required] or the Mac App Store. I thought I had them, but apparently when we upgraded that computer to Tiger, they went missing.

If you don’t have this stuff installed, your installation will fail with errors about unavailable commands.
1.5) Install Command Line Tools (Recent XCode versions only)

(Thank you to Tom Marchioro for informing me about this step.)

Older versions of XCode installed the command line tools (which are required to properly install CPAN modules) by default, but apparently newer ones do not. To check whether you have the command line tools already installed, run the following from the Terminal:

$ which make

This command checks the system for the “make” tool. If it spits out something like /usr/bin/make you’re golden and can skip ahead to Step 2. If you just get a new prompt and no output, you’ll need to install the tools:

Launch XCode and bring up the Preferences panel.
Click on the Downloads tab
Click to install the Command Line Tools

If you like, you can run which make again to confirm that everything’s installed correctly.
2) Configure CPAN.

$ sudo perl -MCPAN -e shell

perl> o conf init

This will prompt you for some settings. You can accept the defaults for almost everything (just hit “return”). The two things you must fill in are the path to make (which should be /usr/bin/make or the value returned when you run which make from the command line) and your choice of CPAN mirrors (which you actually choose don’t really matter, but it won’t let you finish until you select at least one). If you use a proxy or a very restrictive firewall, you may have to configure those settings as well.

If you skip Step 2, you may get errors about make being unavailable.
3) Upgrade CPAN

$ sudo perl -MCPAN -e ‘install Bundle::CPAN’

Don’t forget the sudo, or it’ll fail with permissions errors, probably when doing something relatively unimportant like installing man files.

This will spend a long time downloading, testing, and compiling various files and dependencies. Bear with it. It will prompt you a few times about dependencies. You probably want to enter “yes”. I agreed to everything it asked me, and everything turned out fine. YMMV of course. If everything installs properly, it’ll give you an “OK” at the end.
4) Install your modules. For each module….

$ sudo perl -MCPAN -e ‘install Bundle::Name’

or

$ sudo perl -MCPAN -e ‘install Module::Name’

This will install the module and its dependencies. Nice, eh? Again, don’t forget the sudo.

The first time you run this after upgrading CPAN, it may prompt you to configure again (see Step 2). If you accept its offer to try to configure itself automatically, it may just run through everything without a problem.

There are a couple of potential pitfalls with specific modules (such as the LWP::UserAgent / HEAD issue), but most have workarounds, and I haven’t run into anything that wasn’t easily recoverable.

And that’s it!

Did you find this useful? Is there anything I missed?