Obtaining MySQL and Related Software


If you're going to access a MySQL server run by somebody else, you need only the MySQL client software on your own machine. To run your own server, you'll need a full MySQL distribution.

To write your own MySQL-based programs, you'll need to communicate with the server through a language-specific API. The Perl, Ruby, PHP, and Python interfaces rely on the MySQL C API client library to handle the low-level client-server protocol. For Perl, Ruby, and Python, you must install the C client library and header files first. PHP includes the MySQL client support files, but must be compiled with MySQL support enabled or you won't be able to use it. The Java JDBC driver for MySQL implements the client-server protocol itself, so it does not require the MySQL C client library.

You may not need to install the client software yourselfit might already have been built and installed for you by others. This is a common situation if you have an account with an Internet Service Provider (ISP) for computing services such as a web server that is already enabled to provide access to MySQL. Under such circumstances, the MySQL libraries and header files will already have been installed by the ISP staff.

MySQL

Visit the following site to obtain a MySQL distribution:

http://dev.mysql.com/

MySQL distributions include installation instructions, and the MySQL Reference Manual also provides extensive installation information. The manual is available online at the MySQL site and in printed form from MySQL Press.

If you need to install the MySQL C client library and header files, they're available if you install MySQL from a source distribution, or if you install MySQL using a binary (precompiled) distribution other than an RPM binary distribution. Under Linux, you have the option of installing MySQL using RPM files, but be aware that the client library and header files are not installed unless you install the development RPM. (There are separate RPM files for the server, the standard client programs, and the development libraries and header files.) If you don't install the development RPM, you'll join the many Linux users who've asked, "I installed MySQL, but I cannot find the libraries or header files; where are they?"

Perl Support

General Perl information is available at:

http://www.perl.org/

Perl software can be obtained from the Comprehensive Perl Archive Network (CPAN):

http://cpan.perl.org/

To write MySQL-based Perl programs, you'll need the DBI module and the MySQL-specific DBD module, DBD::mysql.

To install these modules under Unix, it may be easiest to let Perl itself help you. For example, to install DBI and DBD::mysql, run the following commands (you'll probably need to do this as root):

# perl -MCPAN -e shell cpan> install DBI cpan> install DBD::mysql             

If the last command complains about failed tests, use force install DBD::mysql instead. Under ActiveState Perl for Windows, you can use the ppm utility:

C:\> ppm ppm> install DBI ppm> install DBD-mysql             

You can use the CPAN shell or ppm to install other Perl modules mentioned in this book as well.

Ruby Support

To obtain Ruby itself, visit:

http://www.ruby-lang.org/

The Ruby DBI module is available at RubyForge:

http://rubyforge.org/projects/ruby-dbi/

You'll need at least version 0.1.1 of Ruby DBI to be able to use all the features described in this book, such as option file support and SQLSTATE support.

The Ruby DBI driver for MySQL requires the mysql-ruby module, available from the Ruby Application Archive:

http://raa.ruby-lang.org/project/mysql-ruby/

The PageTemplate package used in Chapter 18 can be obtained from RubyForge:

http://rubyforge.org/projects/pagetemplate/

If you plan to use session support as described in Chapter 20, you'll need the mysql-session package, available from the Ruby Application Archive:

http://raa.ruby-lang.org/project/mysql-session/

For mysql-session, obtain the package, unpack it, and install its mysqlstore.rb and sqlthrow.rb files in some directory that your Ruby interpreter searches when looking for library files.

PHP Support

PHP software distributions and installation instructions are available here:

http://www.php.net/

PHP source distributions include the MySQL client library, so you need not obtain it separately. However, you'll need to enable MySQL support explicitly when you configure the distribution. If you use a binary distribution, be sure that it includes MySQL support.

PHP includes a pear command-line utility that you can run to install various PEAR modules. Run it without arguments for a help message. To install the PEAR DB module for database access support, use this command:

# pear install DB             

The Smarty template package used in Chapter 18, can be obtained from the Smarty site:

http://smarty.php.net/

Python Support

Python software distributions and installation instructions are available here:

http://www.python.org/

MySQLdb, the DB-API driver module that provides MySQL support, is available at SourceForge:

http://sourceforge.net/projects/mysql-python/

Java Support

You'll need a Java compiler to build and run Java programs. The javac and jikes compilers are two possible choices. On many systems, you'll find these installed already. Otherwise, you can get a compiler as part of the Java Software Development Kit (SDK). If no SDK is installed on your system, versions are available for Solaris, Linux, and Windows at Sun's Java site:

http://java.sun.com/j2se/

Several Java drivers are available that provide MySQL connectivity for the JDBC interface. This book assumes the use of MySQL Connector/J, which is available here:

http://dev.mysql.com/downloads/

Web Servers

In the web programming chapters, this book uses Apache for Perl, Ruby, PHP, and Python scripts, and Tomcat for JavaServer Pages scripts. Apache and Tomcat both are available from the Apache Software Group; visit the following sites:

http://httpd.apache.org/
http://tomcat.apache.org/

The Apache Jakarta Project site provides access to the Jakarta implementation of the JSP Standard Tag Library that is used in this book for writing JSP pages:

http://jakarta.apache.org/taglibs/

For information about configuring Apache and Tomcat to run MySQL-based scripts, see Recipes Section 17.2 and Section 17.3.




MySQL Cookbook
MySQL Cookbook
ISBN: 059652708X
EAN: 2147483647
Year: 2004
Pages: 375
Authors: Paul DuBois

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net