MySQL Forums
Forum List  »  Perl

Solution: Cygwin and DBD::mysql
Posted by: Emanuel VonAnkh
Date: October 13, 2010 08:47AM

Not sure where else to post this info, but I am sure that it is needed, particularly in the README files of both MySQL and DBD::mysql sources.

_______________________________________________________________________________
Installation Instructions for: DBD::mysql on Cygwin
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Date: 2010-10-13
Cygwin: 1.7.5 (0.22553)
Perl: 5.10.1
MySQL: mysql-5.1.51
DBI: 1.615
DBD::mysql 4.017

Most other modules are the latest binaries available for Cygwin at this time.
_______________________________________________________________________________
In order to use MySQL with Perl on Cygwin you have to install both some
additional cygwin libraries/tools and the appropriate Perl packages.

a) DBI
b) DBD::mysql

As for (a) you need to make sure your g++ compiler and libraries are installed
in order to use CPAN. As for (b), unfortunately you HAVE TO compile your own
MySQL binaries to obtain the library needed to install DBD::mysql.

However, there is one other option for (b), althought without any guarantees.
That is to use the Cygwin ported libraries from:

http://sourceware.org/cygwinports/
ftp://sourceware.org/pub/cygwinports/portslist.txt

and install their current libraries (2010-10-13):

libmysqlclient16 5.1.47-1
libmysqlclient-devel 5.1.47-1
libmysqld-devel 5.1.47-1

However, we suggest to use the sources compilation, unless you run into
extreme problems.

Finally, if you are running any kind of firewall while doing this, you must
closely follow the entire procedure, so that you can respond to various
firewall complaints, should there be any.
_______________________________________________________________________________
Preparing Cygwin
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Lets prepare Cygwin for installation. You need at least the following, but
very likely also others, if you are stating with a minimal Cygwin installation.
However, the ones listed below are the less obvious ones, given the wide and
usless errors their lack can generate...

To install (a) you need:

make
cmake
gcc4-core
gcc4-g++

To install (b) you need:

libncurses-devel
libncursesw-devel
readline

There may be more...
_______________________________________________________________________________
Installing: DBI
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
This should be straight forward, as all required Cygwin utilities and libraries
should be available.

perl -MCPAN -e 'install DBI'

_______________________________________________________________________________
Compiling MySQL client
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Download the latest MySQL source code and put it in a source directory that is
NOT in your normal path. The one most pupolar is "/usr/local/src/". The
installation directory will then be in "/usr/local/mysql".

Download from: http://www.mysql.com/downloads/index.html or use "wget" with
your favourite MySQL depository.


mkdir /usr/local/mysql
cd /usr/local/src
wget http://ftp.sunet.se/pub/unix/databases/relational/mysql/Downloads/MySQL-5.1/mysql-5.1.51.tar.gz
tar -zxvf mysql-5.1.51.tar.gz
cd mysql-5.1.51
./configure --prefix=/usr/local/mysql --without-server --without-readline CFLAGS=-O2
make
make install

PS. You don't need to do a "make test" unless you make the server part and
already have a server running (to test on). [???]

Potential problems:
-------------------
Running "make install" on Cygwin and Windows Vista, may take a long time to
finish, while using nearly 100% of a dual core CPU. After it is complete,
something is still running the CPU at a very high load.
(Not sure what this is!) But a reboot will get rid of this problem.
_______________________________________________________________________________
Test the MySQL binaries
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
You need a running MySQL DB for this. I use the MySQL found in Xampplite for
this, as it works out of the box, with nothing to install. (Just run the
setup-script and answer a few questions, and start the MySQL server.) But any
MySQL installation should work.

Also, to make sure you're actually using THIS binary and not something else
in your path, use the "./" sytax to start it.

cd /usr/local/mysql/bin
./mysql -h 127.0.0.1 -u root

mysql> use mysql
mysql> show tables;
mysql> select * from db;
mysql> exit

NOTE! On some installations, you may need to use
<CTRL-RETURN> instead of just <RETURN> to send commands!
_______________________________________________________________________________
Installing: DBD::mysql
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Download the latest version of DBD::mysql from CPAN to a suitable directory.
(E.g. "/usr/local/src".) Unpack it there and "cd" into it.

cd /usr/local/src
tar -zxvf DBD-mysql-4.017.tar.gz
cd DBD-mysql-4.017

Compile the sources and specify where your "mysql_config" file is. The answer
is, somewhere in your installation "--prefix" path.

perl Makefile.PL --mysql_config=/usr/local/mysql/bin/mysql_config --testhost=127.0.0.1 --testuser=root
make
make test
make install

Check that your installation is registered by Perl.

cpan -D DBD::mysql

NOTE! Just copying the "../mysql_config" to "." is not always working. Then its
better to specify where it is, as shown above.
_______________________________________________________________________________

Options: ReplyQuote


Subject
Written By
Posted
Solution: Cygwin and DBD::mysql
October 13, 2010 08:47AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.