DBD-mysql

 view release on metacpan or  search on metacpan

lib/DBD/mysql.pm  view on Meta::CPAN

Should the MySQL server be running on a non-standard port number,
you may explicitly state the port number to connect to in the C<hostname>
argument, by concatenating the I<hostname> and I<port number> together
separated by a colon ( C<:> ) character or by using the  C<port> argument.

To connect to a MySQL server on localhost using TCP/IP, you must specify the
hostname as 127.0.0.1 (with the optional port).

When connecting to a MySQL Server with IPv6, a bracketed IPv6 address should be used.
Example DSN:

  my $dsn = "DBI:mysql:;host=[1a12:2800:6f2:85::f20:8cf];port=3306";


=item mysql_client_found_rows

If TRUE (Default), sets the CLIENT_FOUND_ROWS flag when connecting to MySQL.
This causes UPDATE statements to return the number of rows *matched*, not
the number of rows actually changed.

If you want the number of rows changed in response to an UPDATE statement,
specify "mysql_client_found_rows=0" in the DSN.

=item mysql_compression

If your DSN contains the option "mysql_compression", then this will be used
to set the compression algorithms for the connection.

If your DSN contains the option "mysql_compression=1", then the compression
algorithms will be set to "zlib". This is for backwards compatibility with
older versions of DBD::mysql.

=item mysql_connect_timeout

If your DSN contains the option "mysql_connect_timeout=##", the connect
request to the server will timeout if it has not been successful after
the given number of seconds.

=item mysql_write_timeout

If your DSN contains the option "mysql_write_timeout=##", the write
operation to the server will timeout if it has not been successful after
the given number of seconds.

=item mysql_read_timeout

If your DSN contains the option "mysql_read_timeout=##", the read
operation to the server will timeout if it has not been successful after
the given number of seconds.

=item mysql_init_command

If your DSN contains the option "mysql_init_command=##", then
this SQL statement is executed when connecting to the MySQL server.
It is automatically re-executed if reconnection occurs.

=item mysql_skip_secure_auth

This option is for older mysql databases that don't have secure auth set.

=item mysql_read_default_file

=item mysql_read_default_group

These options can be used to read a config file like /etc/my.cnf or
~/.my.cnf. By default MySQL's C client library doesn't use any config
files unlike the client programs (mysql, mysqladmin, ...) that do, but
outside of the C client library. Thus you need to explicitly request
reading a config file, as in

    $dsn = "DBI:mysql:test;mysql_read_default_file=/home/joe/my.cnf";
    $dbh = DBI->connect($dsn, $user, $password)

The option mysql_read_default_group can be used to specify the default
group in the config file: Usually this is the I<client> group, but
see the following example:

    [client]
    host=localhost

    [perl]
    host=perlhost

(Note the order of the entries! The example won't work, if you reverse
the [client] and [perl] sections!)

If you read this config file, then you'll be typically connected to
I<localhost>. However, by using

    $dsn = "DBI:mysql:test;mysql_read_default_group=perl;"
        . "mysql_read_default_file=/home/joe/my.cnf";
    $dbh = DBI->connect($dsn, $user, $password);

you'll be connected to I<perlhost>. Note that if you specify a
default group and do not specify a file, then the default config
files will all be read.  See the documentation of
the C function mysql_options() for details.

=item mysql_socket

It is possible to choose the Unix socket that is
used for connecting to the server. This is done, for example, with

    mysql_socket=/dev/mysql

Usually there's no need for this option, unless you are using another
location for the socket than that built into the client.

=item mysql_ssl

A true value turns on the CLIENT_SSL flag when connecting to the MySQL
server and enforce SSL encryption.  A false value (which is default)
disable SSL encryption with the MySQL server.

When enabling SSL encryption you should set also other SSL options,
at least mysql_ssl_ca_file or mysql_ssl_ca_path.

  mysql_ssl=1 mysql_ssl_verify_server_cert=1 mysql_ssl_ca_file=/path/to/ca_cert.pem

This means that your communication with the server will be encrypted.

Please note that this can only work if you enabled SSL when compiling
DBD::mysql; this is the default starting version 4.034.
See L<DBD::mysql::INSTALL> for more details.

=item mysql_ssl_ca_file

The path to a file in PEM format that contains a list of trusted SSL
certificate authorities.

When set MySQL server certificate is checked that it is signed by some
CA certificate in the list.  Common Name value is not verified unless
C<mysql_ssl_verify_server_cert> is enabled.

=item mysql_ssl_ca_path

The path to a directory that contains trusted SSL certificate authority
certificates in PEM format.

When set MySQL server certificate is checked that it is signed by some
CA certificate in the list.  Common Name value is not verified unless
C<mysql_ssl_verify_server_cert> is enabled.

Please note that this option is supported only if your MySQL client was
compiled with OpenSSL library, and not with default yaSSL library.

=item mysql_ssl_verify_server_cert

Checks the server's Common Name value in the certificate that the server
sends to the client.  The client verifies that name against the host name
the client uses for connecting to the server, and the connection fails if

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 1.663 second using v1.00-cache-2.02-grep-82fe00e-cpan-48ebf85a1963 )