Initial Commit

This commit is contained in:
Riley Schneider
2025-12-03 16:38:10 +01:00
parent c5e26bf594
commit b732d8d4b5
17680 changed files with 5977495 additions and 2 deletions

View File

@@ -0,0 +1,309 @@
package DBD::mysql::GetInfo;
########################################
# DBD::mysql::GetInfo
#
#
# Generated by DBI::DBD::Metadata
# $Author$ <-- the person to blame
# $Revision$
# $Date$
use strict;
use warnings;
use DBD::mysql;
# Beware: not officially documented interfaces...
# use DBI::Const::GetInfoType qw(%GetInfoType);
# use DBI::Const::GetInfoReturn qw(%GetInfoReturnTypes %GetInfoReturnValues);
my $sql_driver = 'mysql';
# SQL_DRIVER_VER should be formatted as dd.dd.dddd
my $dbdversion = $DBD::mysql::VERSION;
$dbdversion .= '_00' if $dbdversion =~ /^\d+\.\d+$/;
my $sql_driver_ver = sprintf("%02d.%02d.%04d", split(/[\._]/,$dbdversion));
my @Keywords = qw(
BIGINT
BLOB
DEFAULT
KEYS
LIMIT
LONGBLOB
MEDIMUMBLOB
MEDIUMINT
MEDIUMTEXT
PROCEDURE
REGEXP
RLIKE
SHOW
TABLES
TINYBLOB
TINYTEXT
UNIQUE
UNSIGNED
ZEROFILL
);
sub sql_keywords {
return join ',', @Keywords;
}
sub sql_data_source_name {
my $dbh = shift;
return "dbi:$sql_driver:" . $dbh->{Name};
}
sub sql_user_name {
my $dbh = shift;
# Non-standard attribute
return $dbh->{CURRENT_USER};
}
####################
# makefunc()
# returns a ref to a sub that calls into XS to get
# values for info types that must needs be coded in C
sub makefunk ($) {
my $type = shift;
return sub {dbd_mysql_get_info(shift, $type)}
}
our %info = (
20 => 'N', # SQL_ACCESSIBLE_PROCEDURES
19 => 'Y', # SQL_ACCESSIBLE_TABLES
0 => 0, # SQL_ACTIVE_CONNECTIONS
116 => 0, # SQL_ACTIVE_ENVIRONMENTS
1 => 0, # SQL_ACTIVE_STATEMENTS
169 => 127, # SQL_AGGREGATE_FUNCTIONS
117 => 0, # SQL_ALTER_DOMAIN
86 => 3, # SQL_ALTER_TABLE
10021 => makefunk 10021, # SQL_ASYNC_MODE
120 => 2, # SQL_BATCH_ROW_COUNT
121 => 2, # SQL_BATCH_SUPPORT
82 => 0, # SQL_BOOKMARK_PERSISTENCE
114 => 1, # SQL_CATALOG_LOCATION
10003 => 'Y', # SQL_CATALOG_NAME
41 => makefunk 41, # SQL_CATALOG_NAME_SEPARATOR
42 => makefunk 42, # SQL_CATALOG_TERM
92 => 29, # SQL_CATALOG_USAGE
10004 => '', # SQL_COLLATING_SEQUENCE
10004 => '', # SQL_COLLATION_SEQ
87 => 'Y', # SQL_COLUMN_ALIAS
22 => 0, # SQL_CONCAT_NULL_BEHAVIOR
53 => 259071, # SQL_CONVERT_BIGINT
54 => 0, # SQL_CONVERT_BINARY
55 => 259071, # SQL_CONVERT_BIT
56 => 259071, # SQL_CONVERT_CHAR
57 => 259071, # SQL_CONVERT_DATE
58 => 259071, # SQL_CONVERT_DECIMAL
59 => 259071, # SQL_CONVERT_DOUBLE
60 => 259071, # SQL_CONVERT_FLOAT
48 => 0, # SQL_CONVERT_FUNCTIONS
# 173 => undef, # SQL_CONVERT_GUID
61 => 259071, # SQL_CONVERT_INTEGER
123 => 0, # SQL_CONVERT_INTERVAL_DAY_TIME
124 => 0, # SQL_CONVERT_INTERVAL_YEAR_MONTH
71 => 0, # SQL_CONVERT_LONGVARBINARY
62 => 259071, # SQL_CONVERT_LONGVARCHAR
63 => 259071, # SQL_CONVERT_NUMERIC
64 => 259071, # SQL_CONVERT_REAL
65 => 259071, # SQL_CONVERT_SMALLINT
66 => 259071, # SQL_CONVERT_TIME
67 => 259071, # SQL_CONVERT_TIMESTAMP
68 => 259071, # SQL_CONVERT_TINYINT
69 => 0, # SQL_CONVERT_VARBINARY
70 => 259071, # SQL_CONVERT_VARCHAR
122 => 0, # SQL_CONVERT_WCHAR
125 => 0, # SQL_CONVERT_WLONGVARCHAR
126 => 0, # SQL_CONVERT_WVARCHAR
74 => 1, # SQL_CORRELATION_NAME
127 => 0, # SQL_CREATE_ASSERTION
128 => 0, # SQL_CREATE_CHARACTER_SET
129 => 0, # SQL_CREATE_COLLATION
130 => 0, # SQL_CREATE_DOMAIN
131 => 0, # SQL_CREATE_SCHEMA
132 => 1045, # SQL_CREATE_TABLE
133 => 0, # SQL_CREATE_TRANSLATION
134 => 0, # SQL_CREATE_VIEW
23 => 2, # SQL_CURSOR_COMMIT_BEHAVIOR
24 => 2, # SQL_CURSOR_ROLLBACK_BEHAVIOR
10001 => 0, # SQL_CURSOR_SENSITIVITY
2 => \&sql_data_source_name, # SQL_DATA_SOURCE_NAME
25 => 'N', # SQL_DATA_SOURCE_READ_ONLY
119 => 7, # SQL_DATETIME_LITERALS
17 => 'MySQL', # SQL_DBMS_NAME
18 => makefunk 18, # SQL_DBMS_VER
170 => 3, # SQL_DDL_INDEX
26 => 2, # SQL_DEFAULT_TRANSACTION_ISOLATION
26 => 2, # SQL_DEFAULT_TXN_ISOLATION
10002 => 'N', # SQL_DESCRIBE_PARAMETER
# 171 => undef, # SQL_DM_VER
3 => 137076632, # SQL_DRIVER_HDBC
# 135 => undef, # SQL_DRIVER_HDESC
4 => 137076088, # SQL_DRIVER_HENV
# 76 => undef, # SQL_DRIVER_HLIB
# 5 => undef, # SQL_DRIVER_HSTMT
6 => 'libmyodbc3.so', # SQL_DRIVER_NAME
77 => '03.51', # SQL_DRIVER_ODBC_VER
7 => $sql_driver_ver, # SQL_DRIVER_VER
136 => 0, # SQL_DROP_ASSERTION
137 => 0, # SQL_DROP_CHARACTER_SET
138 => 0, # SQL_DROP_COLLATION
139 => 0, # SQL_DROP_DOMAIN
140 => 0, # SQL_DROP_SCHEMA
141 => 7, # SQL_DROP_TABLE
142 => 0, # SQL_DROP_TRANSLATION
143 => 0, # SQL_DROP_VIEW
144 => 0, # SQL_DYNAMIC_CURSOR_ATTRIBUTES1
145 => 0, # SQL_DYNAMIC_CURSOR_ATTRIBUTES2
27 => 'Y', # SQL_EXPRESSIONS_IN_ORDERBY
8 => 63, # SQL_FETCH_DIRECTION
84 => 0, # SQL_FILE_USAGE
146 => 97863, # SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES1
147 => 6016, # SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2
81 => 11, # SQL_GETDATA_EXTENSIONS
88 => 3, # SQL_GROUP_BY
28 => 4, # SQL_IDENTIFIER_CASE
#29 => sub {dbd_mysql_get_info(shift,$GetInfoType {SQL_IDENTIFIER_QUOTE_CHAR})},
29 => makefunk 29, # SQL_IDENTIFIER_QUOTE_CHAR
148 => 0, # SQL_INDEX_KEYWORDS
149 => 0, # SQL_INFO_SCHEMA_VIEWS
172 => 7, # SQL_INSERT_STATEMENT
73 => 'N', # SQL_INTEGRITY
150 => 0, # SQL_KEYSET_CURSOR_ATTRIBUTES1
151 => 0, # SQL_KEYSET_CURSOR_ATTRIBUTES2
89 => \&sql_keywords, # SQL_KEYWORDS
113 => 'Y', # SQL_LIKE_ESCAPE_CLAUSE
78 => 0, # SQL_LOCK_TYPES
34 => 64, # SQL_MAXIMUM_CATALOG_NAME_LENGTH
97 => 0, # SQL_MAXIMUM_COLUMNS_IN_GROUP_BY
98 => 32, # SQL_MAXIMUM_COLUMNS_IN_INDEX
99 => 0, # SQL_MAXIMUM_COLUMNS_IN_ORDER_BY
100 => 0, # SQL_MAXIMUM_COLUMNS_IN_SELECT
101 => 0, # SQL_MAXIMUM_COLUMNS_IN_TABLE
30 => 64, # SQL_MAXIMUM_COLUMN_NAME_LENGTH
1 => 0, # SQL_MAXIMUM_CONCURRENT_ACTIVITIES
31 => 18, # SQL_MAXIMUM_CURSOR_NAME_LENGTH
0 => 0, # SQL_MAXIMUM_DRIVER_CONNECTIONS
10005 => 64, # SQL_MAXIMUM_IDENTIFIER_LENGTH
102 => 500, # SQL_MAXIMUM_INDEX_SIZE
104 => 0, # SQL_MAXIMUM_ROW_SIZE
32 => 0, # SQL_MAXIMUM_SCHEMA_NAME_LENGTH
105 => makefunk 105, # SQL_MAXIMUM_STATEMENT_LENGTH
# 20000 => undef, # SQL_MAXIMUM_STMT_OCTETS
# 20001 => undef, # SQL_MAXIMUM_STMT_OCTETS_DATA
# 20002 => undef, # SQL_MAXIMUM_STMT_OCTETS_SCHEMA
106 => makefunk 106, # SQL_MAXIMUM_TABLES_IN_SELECT
35 => 64, # SQL_MAXIMUM_TABLE_NAME_LENGTH
107 => 16, # SQL_MAXIMUM_USER_NAME_LENGTH
10022 => makefunk 10022, # SQL_MAX_ASYNC_CONCURRENT_STATEMENTS
112 => 0, # SQL_MAX_BINARY_LITERAL_LEN
34 => 64, # SQL_MAX_CATALOG_NAME_LEN
108 => 0, # SQL_MAX_CHAR_LITERAL_LEN
97 => 0, # SQL_MAX_COLUMNS_IN_GROUP_BY
98 => 32, # SQL_MAX_COLUMNS_IN_INDEX
99 => 0, # SQL_MAX_COLUMNS_IN_ORDER_BY
100 => 0, # SQL_MAX_COLUMNS_IN_SELECT
101 => 0, # SQL_MAX_COLUMNS_IN_TABLE
30 => 64, # SQL_MAX_COLUMN_NAME_LEN
1 => 0, # SQL_MAX_CONCURRENT_ACTIVITIES
31 => 18, # SQL_MAX_CURSOR_NAME_LEN
0 => 0, # SQL_MAX_DRIVER_CONNECTIONS
10005 => 64, # SQL_MAX_IDENTIFIER_LEN
102 => 500, # SQL_MAX_INDEX_SIZE
32 => 0, # SQL_MAX_OWNER_NAME_LEN
33 => 0, # SQL_MAX_PROCEDURE_NAME_LEN
34 => 64, # SQL_MAX_QUALIFIER_NAME_LEN
104 => 0, # SQL_MAX_ROW_SIZE
103 => 'Y', # SQL_MAX_ROW_SIZE_INCLUDES_LONG
32 => 0, # SQL_MAX_SCHEMA_NAME_LEN
105 => 8192, # SQL_MAX_STATEMENT_LEN
106 => 31, # SQL_MAX_TABLES_IN_SELECT
35 => makefunk 35, # SQL_MAX_TABLE_NAME_LEN
107 => 16, # SQL_MAX_USER_NAME_LEN
37 => 'Y', # SQL_MULTIPLE_ACTIVE_TXN
36 => 'Y', # SQL_MULT_RESULT_SETS
111 => 'N', # SQL_NEED_LONG_DATA_LEN
75 => 1, # SQL_NON_NULLABLE_COLUMNS
85 => 2, # SQL_NULL_COLLATION
49 => 16777215, # SQL_NUMERIC_FUNCTIONS
9 => 1, # SQL_ODBC_API_CONFORMANCE
152 => 2, # SQL_ODBC_INTERFACE_CONFORMANCE
12 => 1, # SQL_ODBC_SAG_CLI_CONFORMANCE
15 => 1, # SQL_ODBC_SQL_CONFORMANCE
73 => 'N', # SQL_ODBC_SQL_OPT_IEF
10 => '03.80', # SQL_ODBC_VER
115 => 123, # SQL_OJ_CAPABILITIES
90 => 'Y', # SQL_ORDER_BY_COLUMNS_IN_SELECT
38 => 'Y', # SQL_OUTER_JOINS
115 => 123, # SQL_OUTER_JOIN_CAPABILITIES
39 => '', # SQL_OWNER_TERM
91 => 0, # SQL_OWNER_USAGE
153 => 2, # SQL_PARAM_ARRAY_ROW_COUNTS
154 => 3, # SQL_PARAM_ARRAY_SELECTS
80 => 3, # SQL_POSITIONED_STATEMENTS
79 => 31, # SQL_POS_OPERATIONS
21 => 'N', # SQL_PROCEDURES
40 => '', # SQL_PROCEDURE_TERM
114 => 1, # SQL_QUALIFIER_LOCATION
41 => '.', # SQL_QUALIFIER_NAME_SEPARATOR
42 => 'database', # SQL_QUALIFIER_TERM
92 => 29, # SQL_QUALIFIER_USAGE
93 => 3, # SQL_QUOTED_IDENTIFIER_CASE
11 => 'N', # SQL_ROW_UPDATES
39 => '', # SQL_SCHEMA_TERM
91 => 0, # SQL_SCHEMA_USAGE
43 => 7, # SQL_SCROLL_CONCURRENCY
44 => 17, # SQL_SCROLL_OPTIONS
14 => '\\', # SQL_SEARCH_PATTERN_ESCAPE
13 => makefunk 13, # SQL_SERVER_NAME
94 => 'ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜáíóúñÑ', # SQL_SPECIAL_CHARACTERS
155 => 7, # SQL_SQL92_DATETIME_FUNCTIONS
156 => 0, # SQL_SQL92_FOREIGN_KEY_DELETE_RULE
157 => 0, # SQL_SQL92_FOREIGN_KEY_UPDATE_RULE
158 => 8160, # SQL_SQL92_GRANT
159 => 0, # SQL_SQL92_NUMERIC_VALUE_FUNCTIONS
160 => 0, # SQL_SQL92_PREDICATES
161 => 466, # SQL_SQL92_RELATIONAL_JOIN_OPERATORS
162 => 32640, # SQL_SQL92_REVOKE
163 => 7, # SQL_SQL92_ROW_VALUE_CONSTRUCTOR
164 => 255, # SQL_SQL92_STRING_FUNCTIONS
165 => 0, # SQL_SQL92_VALUE_EXPRESSIONS
118 => 4, # SQL_SQL_CONFORMANCE
166 => 2, # SQL_STANDARD_CLI_CONFORMANCE
167 => 97863, # SQL_STATIC_CURSOR_ATTRIBUTES1
168 => 6016, # SQL_STATIC_CURSOR_ATTRIBUTES2
83 => 7, # SQL_STATIC_SENSITIVITY
50 => 491519, # SQL_STRING_FUNCTIONS
95 => 0, # SQL_SUBQUERIES
51 => 7, # SQL_SYSTEM_FUNCTIONS
45 => 'table', # SQL_TABLE_TERM
109 => 0, # SQL_TIMEDATE_ADD_INTERVALS
110 => 0, # SQL_TIMEDATE_DIFF_INTERVALS
52 => 106495, # SQL_TIMEDATE_FUNCTIONS
46 => 3, # SQL_TRANSACTION_CAPABLE
72 => 15, # SQL_TRANSACTION_ISOLATION_OPTION
46 => 3, # SQL_TXN_CAPABLE
72 => 15, # SQL_TXN_ISOLATION_OPTION
96 => 0, # SQL_UNION
96 => 0, # SQL_UNION_STATEMENT
47 => \&sql_user_name, # SQL_USER_NAME
10000 => 1992, # SQL_XOPEN_CLI_YEAR
);
1;
__END__

View File

@@ -0,0 +1,754 @@
=encoding utf8
=head1 NAME
DBD::mysql::INSTALL - How to install and configure DBD::mysql
=head1 SYNOPSIS
perl Makefile.PL [options]
make
make test
make install
=head1 DESCRIPTION
This document describes the installation and configuration of
DBD::mysql, the Perl DBI driver for the MySQL database. Before
reading on, make sure that you have the prerequisites available:
Perl, MySQL and DBI. For details see the separate section
L</PREREQUISITES>.
Depending on your version of Perl, it might be possible to
use a binary distribution of DBD::mysql. If possible, this is
recommended. Otherwise you need to install from the sources.
If so, you will definitely need a C compiler. Installation
from binaries and sources are both described in separate
sections. L</BINARY INSTALLATION>. L</SOURCE INSTALLATION>.
Finally, if you encounter any problems, do not forget to
read the section on known problems L</KNOWN PROBLEMS>. If
that doesn't help, you should check the section on L</SUPPORT>.
=head1 PREREQUISITES
=over
=item Perl
Preferably a version of Perl, that comes preconfigured with
your system. For example, all Linux and FreeBSD distributions
come with Perl. For Windows, use L<ActivePerl|https://www.activestate.com/activeperl>
or L<Strawberry Perl|http://www.strawberryperl.com>.
=item MySQL
You need not install the actual MySQL database server, the
client files and the development files are sufficient. For
example, Fedora Linux distribution comes with RPM files
(using YUM) B<mysql> and B<mysql-server> (use "yum search"
to find exact package names). These are sufficient, if the MySQL
server is located on a foreign machine. You may also create client
files by compiling from the MySQL source distribution and using
configure --without-server
If you are using Windows and need to compile from sources
(which is only the case if you are not using ActivePerl or
Strawberry Perl),
then you must ensure that the header and library files are
installed. This may require choosing a "Custom installation"
and selecting the appropriate option when running the
MySQL setup program.
=item DBI
DBD::mysql is a DBI driver, hence you need DBI. It is available
from the same source where you got the DBD::mysql distribution
from.
=item C compiler
A C compiler is only required if you install from source. In
most cases there are binary distributions of DBD::mysql
available. However, if you need a C compiler, make sure, that
it is the same C compiler that was used for compiling Perl and
MySQL! Otherwise you will almost definitely encounter problems
because of differences in the underlying C runtime libraries.
In the worst case, this might mean to compile Perl and MySQL
yourself. But believe me, experience shows that a lot of problems
are fixed this way.
=item Gzip libraries
Late versions of MySQL come with support for compression. Thus
it B<may> be required that you have install an RPM package like
libz-devel, libgz-devel or something similar.
=back
=head1 BINARY INSTALLATION
Binary installation is possible in the most cases, depending
on your system.
=head2 Windows
=head3 Strawberry Perl
Strawberry Perl comes bundled with DBD::mysql and the needed
client libraries.
=head3 ActiveState Perl
ActivePerl offers a PPM archive of DBD::mysql. All you need to
do is typing in a cmd.exe window:
ppm install DBD-mysql
This will fetch the module via HTTP and install them. If you
need to use a WWW proxy server, the environment variable
HTTP_proxy must be set:
set HTTP_proxy=http://myproxy.example.com:8080/
ppm install DBD-mysql
Of course you need to replace the host name C<myproxy.example.com>
and the port number C<8080> with your local values.
If the above procedure doesn't work, please upgrade to the latest
version of ActivePerl. ActiveState has a policy where it only
provides access free-of-charge for the PPM mirrors of the last
few stable Perl releases. If you have an older perl, you'd either
need to upgrade your perl or contact ActiveState about a subscription.
=head2 Red Hat Enterprise Linux (RHEL), CentOS and Fedora
Red Hat Enterprise Linux, its community derivatives such as
CentOS, and Fedora come with MySQL and DBD::mysql.
Use the following command to install DBD::mysql:
yum install "perl(DBD::mysql)"
=head2 Debian and Ubuntu
On Debian, Ubuntu and derivatives you can install DBD::mysql from
the repositories with the following command:
sudo apt-get install libdbd-mysql-perl
=head2 SLES and openSUSE
On SUSE Linux Enterprise and the community version openSUSE, you
can install DBD::mysql from the repositories with the following
command:
zypper install perl-DBD-mysql
=head2 Other systems
In the case of other Linux or FreeBSD distributions it is very likely
that all you need comes with your distribution.
I just cannot give you names, as I am not using
these systems.
Please let me know if you find the files in your favorite
Linux or FreeBSD distribution so that I can extend the above list.
=head1 SOURCE INSTALLATION
So you need to install from sources. If you are lucky, the Perl
module C<CPAN> will do all for you, thanks to the excellent work
of Andreas König. Otherwise you will need to do a manual
installation.
All of these installation types have their own section:
L</CPAN installation>, L</Manual installation> and L</Configuration>.
The DBD::mysql Makefile.PL needs to know where to find your MySQL
installation. This may be achieved using command line switches
(see L</Configuration>) or automatically using the mysql_config binary
which comes with most MySQL distributions. If your MySQL distribution
contains mysql_config the easiest method is to ensure this binary
is on your path.
Typically, this is the case if you've installed the mysql library
from your systems' package manager.
e.g.
PATH=$PATH:/usr/local/mysql/bin
export PATH
As stated, to compile DBD::mysql you'll need a C compiler. This should
be the same compiler as the one used to build perl AND the mysql client
libraries. If you're on linux, this is most typically the case and you
need not worry. If you're on UNIX systems, you might want to pay
attention.
Also you'll need to get the MySQL client and development headers on
your system. The easiest is to get these from your package manager.
To run the tests that ship with the module, you'll need access to a
running MySQL server. This can be running on localhost, but it can also
be on a remote machine.
On Fedora the process is as follows. Please note that Fedora actually
ships with MariaDB but not with MySQL. This is not a problem, it
will work just as well.
In this example we install and start a local server for running the
tests against.
yum -y install make gcc mariadb-devel mariadb-libs mariadb-server
yum -y install "perl(Test::Deep)" "perl(Test::More)"
systemctl start mariadb.service
=head2 Environment Variables
For ease of use, you can set environment variables for
DBD::mysql installation. You can set any or all of the options, and
export them by putting them in your .bashrc or the like:
export DBD_MYSQL_CFLAGS=-I/usr/local/mysql/include/mysql
export DBD_MYSQL_LIBS="-L/usr/local/mysql/lib/mysql -lmysqlclient"
export DBD_MYSQL_EMBEDDED=
export DBD_MYSQL_CONFIG=mysql_config
export DBD_MYSQL_NOCATCHSTDERR=0
export DBD_MYSQL_NOFOUNDROWS=0
export DBD_MYSQL_NOSSL=
export DBD_MYSQL_TESTDB=test
export DBD_MYSQL_TESTHOST=localhost
export DBD_MYSQL_TESTPASSWORD=s3kr1+
export DBD_MYSQL_TESTPORT=3306
export DBD_MYSQL_TESTUSER=me
The most useful may be the host, database, port, socket, user, and password.
Installation will first look to your mysql_config, and then your
environment variables, and then it will guess with intelligent defaults.
=head2 CPAN installation
Installation of DBD::mysql can be incredibly easy:
cpan DBD::mysql
Please note that this will only work if the prerequisites are
fulfilled, which means you have a C-compiler installed, and you
have the development headers and mysql client libraries available
on your system.
If you are using the CPAN module for the first time, just answer
the questions by accepting the defaults which are fine in most
cases.
If you cannot get the CPAN module working, you might try manual
installation. If installation with CPAN fails because the your local
settings have been guessed wrong, you need to ensure MySQL's
mysql_config is on your path (see L</SOURCE INSTALLATION>) or
alternatively create a script called C<mysql_config>. This is
described in more details later. L</Configuration>.
=head2 Manual installation
For a manual installation you need to fetch the DBD::mysql
source distribution. The latest version is always available
from
https://metacpan.org/module/DBD::mysql
The name is typically something like
DBD-mysql-4.025.tar.gz
The archive needs to be extracted. On Windows you may use a tool
like 7-zip, on *nix you type
tar xf DBD-mysql-4.025.tar.gz
This will create a subdirectory DBD-mysql-4.025. Enter this
subdirectory and type
perl Makefile.PL
make
make test
(On Windows you may need to replace "make" with "dmake" or
"nmake".) If the tests seem to look fine, you may continue with
make install
If the compilation (make) or tests fail, you might need to
configure some settings.
For example you might choose a different database, the C
compiler or the linker might need some flags. L</Configuration>.
L</Compiler flags>. L</Linker flags>.
For Cygwin there is a special section below.
L</Cygwin>.
=head2 Configuration
The install script "Makefile.PL" can be configured via a lot of
switches. All switches can be used on the command line. For
example, the test database:
perl Makefile.PL --testdb=<db>
If you do not like configuring these switches on the command
line, you may alternatively create a script called C<mysql_config>.
This is described later on.
Available switches are:
=over
=item testdb
Name of the test database, defaults to B<test>.
=item testuser
Name of the test user, defaults to empty. If the name is empty,
then the currently logged in users name will be used.
=item testpassword
Password of the test user, defaults to empty.
=item testhost
Host name or IP number of the test database; defaults to localhost.
=item testport
Port number of the test database
=item ps-protcol=1 or 0
Whether to run the test suite using server prepared statements or driver
emulated prepared statements. ps-protocol=1 means use server prepare,
ps-protocol=0 means driver emulated.
=item cflags
This is a list of flags that you want to give to the C compiler.
The most important flag is the location of the MySQL header files.
For example, on Red Hat Linux the header files are in /usr/include/mysql
and you might try
-I/usr/include/mysql
On Windows the header files may be in C:\mysql\include and you might try
-IC:\mysql\include
The default flags are determined by running
mysql_config --cflags
More details on the C compiler flags can be found in the following
section. L</Compiler flags>.
=item libs
This is a list of flags that you want to give to the linker
or loader. The most important flags are the locations and names
of additional libraries. For example, on Red Hat Linux your
MySQL client libraries are in /usr/lib/mysql and you might try
-L/usr/lib/mysql -lmysqlclient -lz
On Windows the libraries may be in C:\mysql\lib and
-LC:\mysql\lib -lmysqlclient
might be a good choice. The default flags are determined by running
mysql_config --libs
More details on the linker flags can be found in a separate section.
L<Linker flags>.
=back
If a switch is not present on the command line, then the
script C<mysql_config> will be executed. This script comes
as part of the MySQL distribution. For example, to determine
the C compiler flags, we are executing
mysql_config --cflags
mysql_config --libs
If you want to configure your own settings for database name,
database user and so on, then you have to create a script with
the same name, that replies
=head2 Compiler flags
Note: the following info about compiler and linker flags, you shouldn't have
to use these options because Makefile.PL is pretty good at utilizing
mysql_config to get the flags that you need for a successful compile.
It is typically not so difficult to determine the appropriate
flags for the C compiler. The linker flags, which you find in
the next section, are another story.
The determination of the C compiler flags is usually left to
a configuration script called F<mysql_config>, which can be
invoked with
mysql_config --cflags
When doing so, it will emit a line with suggested C compiler
flags, for example like this:
-L/usr/include/mysql
The C compiler must find some header files. Header files have
the extension C<.h>. MySQL header files are, for example,
F<mysql.h> and F<mysql_version.h>. In most cases the header
files are not installed by default. For example, on Windows
it is an installation option of the MySQL setup program
(Custom installation), whether the header files are installed
or not. On Red Hat Linux, you need to install an RPM archive
F<mysql-devel> or F<MySQL-devel>.
If you know the location of the header files, then you will
need to add an option
-L<header directory>
to the C compiler flags, for example C<-L/usr/include/mysql>.
=head2 Linker flags
Appropriate linker flags are the most common source of problems
while installing DBD::mysql. I will only give a rough overview,
you'll find more details in the troubleshooting section.
L</KNOWN PROBLEMS>
The determination of the C compiler flags is usually left to
a configuration script called F<mysql_config>, which can be
invoked with
mysql_config --libs
When doing so, it will emit a line with suggested C compiler
flags, for example like this:
-L'/usr/lib/mysql' -lmysqlclient -lnsl -lm -lz -lcrypt
The following items typically need to be configured for the
linker:
=over
=item The mysqlclient library
The MySQL client library comes as part of the MySQL distribution.
Depending on your system it may be a file called
F<libmysqlclient.a> statically linked library, Unix
F<libmysqlclient.so> dynamically linked library, Unix
F<mysqlclient.lib> statically linked library, Windows
F<mysqlclient.dll> dynamically linked library, Windows
or something similar.
As in the case of the header files, the client library is typically
not installed by default. On Windows you will need to select them
while running the MySQL setup program (Custom installation). On
Red Hat Linux an RPM archive F<mysql-devel> or F<MySQL-devel> must
be installed.
The linker needs to know the location and name of the mysqlclient
library. This can be done by adding the flags
-L<lib directory> -lmysqlclient
or by adding the complete path name. Examples:
-L/usr/lib/mysql -lmysqlclient
-LC:\mysql\lib -lmysqlclient
If you would like to use the static libraries (and there are
excellent reasons to do so), you need to create a separate
directory, copy the static libraries to that place and use
the -L switch above to point to your new directory. For example:
mkdir /tmp/mysql-static
cp /usr/lib/mysql/*.a /tmp/mysql-static
perl Makefile.PL --libs="-L/tmp/mysql-static -lmysqlclient"
make
make test
make install
rm -rf /tmp/mysql-static
=item The gzip library
The MySQL client can use compression when talking to the MySQL
server, a nice feature when sending or receiving large texts over
a slow network.
On Unix you typically find the appropriate file name by running
ldconfig -p | grep libz
ldconfig -p | grep libgz
Once you know the name (libz.a or libgz.a is best), just add it
to the list of linker flags. If this seems to be causing problem
you may also try to link without gzip libraries.
=back
=head1 ENCRYPTED CONNECTIONS via SSL
Connecting to your servers over an encrypted connection (SSL) is only possible
if you enabled this setting at build time. Since version 4.034, this is the
default.
Attempting to connect to a server that requires an encrypted connection without
first having L<DBD::mysql> compiled with the C<--ssl> option will result in
an error that makes things appear as if your password is incorrect.
If you want to compile L<DBD::mysql> without SSL support, which you might
probably only want if you for some reason can't install libssl headers, you
can do this by passing the C<--nossl> option to Makefile.PL or by setting the
DBD_MYSQL_NOSSL environment variable to '1'.
=head1 MARIADB NATIVE CLIENT INSTALLATION
The MariaDB native client is another option for connecting to a MySQL·
database licensed LGPL 2.1. To build DBD::mysql against this client, you
will first need to build the client. Generally, this is done with
the following:
cd path/to/src/mariadb-native-client
cmake -G "Unix Makefiles'
make
sudo make install
Once the client is built and installed, you can build DBD::mysql against
it:
perl Makefile.PL --testuser=xxx --testpassword=xxx --testsocket=/path/to//mysqld.sock --mysql_config=/usr/local/bin/mariadb_config·
make
make test
make install
=head1 SPECIAL SYSTEMS
Below you find information on particular systems:
=head2 macOS
For installing DBD::mysql you need to have the libssl header files and the
mysql client libs. The easiest way to install these is using Homebrew
(L<https://brew.sh/>).
Once you have Homebrew set up, you can simply install the dependencies using
brew install openssl mysql-connector-c
Then you can install DBD::mysql using your cpan client.
=head2 Cygwin
If you are a user of Cygwin you already
know, it contains a nicely running perl 5.6.1, installation of
additional modules usually works like a charm via the standard
procedure of
perl makefile.PL
make
make test
make install
The Windows binary distribution of MySQL runs smoothly under Cygwin.
You can start/stop the server and use all Windows clients without problem.
But to install DBD::mysql you have to take a little special action.
Don't attempt to build DBD::mysql against either the MySQL Windows or
Linux/Unix BINARY distributions: neither will work!
You MUST compile the MySQL clients yourself under Cygwin, to get a
'libmysqlclient.a' compiled under Cygwin. Really! You'll only need
that library and the header files, you don't need any other client parts.
Continue to use the Windows binaries. And don't attempt (currently) to
build the MySQL Server part, it is unnecessary, as MySQL AB does an
excellent job to deliver optimized binaries for the mainstream
operating systems, and it is told, that the server compiled under Cygwin is
unstable.
Install a MySQL server for testing against. You can install the regular
Windows MySQL server package on your Windows machine, or you can also
test against a MySQL server on a remote host.
=head3 Build MySQL clients under Cygwin:
download the MySQL LINUX source from
L<https://www.mysql.com/downloads>,
unpack mysql-<version>.tar.gz into some tmp location and from this directory
run configure:
./configure --prefix=/usr/local/mysql --without-server
This prepares the Makefile with the installed Cygwin features. It
takes some time, but should finish without error. The 'prefix', as
given, installs the whole Cygwin/MySQL thingy into a location not
normally in your PATH, so that you continue to use already installed
Windows binaries. The --without-server parameter tells configure to
only build the clients.
make
This builds all MySQL client parts ... be patient. It should finish
finally without any error.
make install
This installs the compiled client files under /usr/local/mysql/.
Remember, you don't need anything except the library under
/usr/local/mysql/lib and the headers under /usr/local/mysql/include!
Essentially you are now done with this part. If you want, you may try
your compiled binaries shortly; for that, do:
cd /usr/local/mysql/bin
./mysql -h 127.0.0.1
The host (-h) parameter 127.0.0.1 targets the local host, but forces
the mysql client to use a TCP/IP connection. The default would be a
pipe/socket connection (even if you say '-h localhost') and this
doesn't work between Cygwin and Windows (as far as I know).
If you have your MySQL server running on some other box, then please
substitute '127.0.0.1' with the name or IP-number of that box.
Please note, in my environment the 'mysql' client did not accept a
simple RETURN, I had to use CTRL-RETURN to send commands
... strange,
but I didn't attempt to fix that, as we are only interested in the
built lib and headers.
At the 'mysql>' prompt do a quick check:
mysql> use mysql
mysql> show tables;
mysql> select * from db;
mysql> exit
You are now ready to build DBD::mysql!
=head3 compile DBD::mysql
download and extract DBD-mysql-<version>.tar.gz from CPAN
cd into unpacked dir DBD-mysql-<version>
you probably did that already, if you are reading this!
cp /usr/local/mysql/bin/mysql_config .
This copies the executable script mentioned in the DBD::mysql docs
from your just built Cywin/MySQL client directory; it knows about
your Cygwin installation, especially about the right libraries to link
with.
perl Makefile.PL --testhost=127.0.0.1
The --testhost=127.0.0.1 parameter again forces a TCP/IP connection
to the MySQL server on the local host instead of a pipe/socket
connection for the 'make test' phase.
make
This should run without error
make test
make install
This installs DBD::mysql into the Perl hierarchy.
=head1 KNOWN PROBLEMS
=head2 no gzip on your system
Some Linux distributions don't come with a gzip library by default.
Running "make" terminates with an error message like
LD_RUN_PATH="/usr/lib/mysql:/lib:/usr/lib" gcc
-o blib/arch/auto/DBD/mysql/mysql.so -shared
-L/usr/local/lib dbdimp.o mysql.o -L/usr/lib/mysql
-lmysqlclient -lm -L/usr/lib/gcc-lib/i386-redhat-linux/2.96
-lgcc -lz
/usr/bin/ld: cannot find -lz
collect2: ld returned 1 exit status
make: *** [blib/arch/auto/DBD/mysql/mysql.so] Error 1
If this is the case for you, install an RPM archive like
libz-devel, libgz-devel, zlib-devel or gzlib-devel or something
similar.
=head2 different compiler for mysql and perl
If Perl was compiled with gcc or egcs, but MySQL was compiled
with another compiler or on another system, an error message like
this is very likely when running "Make test":
t/00base............install_driver(mysql) failed: Can't load
'../blib/arch/auto/DBD/mysql/mysql.so' for module DBD::mysql:
../blib/arch/auto/DBD/mysql/mysql.so: undefined symbol: _umoddi3
at /usr/local/perl-5.005/lib/5.005/i586-linux-thread/DynaLoader.pm
line 168.
This means, that your linker doesn't include libgcc.a. You have
the following options:
The solution is telling the linker to use libgcc. Run
gcc --print-libgcc-file
to determine the exact location of libgcc.a or for older versions
of gcc
gcc -v
to determine the directory. If you know the directory, add a
-L<directory> -lgcc
to the list of C compiler flags. L</Configuration>. L</Linker flags>.
=head1 SUPPORT
Finally, if everything else fails, you are not alone. First of
all, for an immediate answer, you should look into the archives
of the dbi-users mailing list, which is available at
L<http://groups.google.com/group/perl.dbi.users?hl=en&lr=>
To subscribe to this list, send and email to
dbi-users-subscribe@perl.org
If you don't find an appropriate posting and reply in the
mailing list, please post a question. Typically a reply will
be seen within one or two days.