maatkitdsn.3pm

Langue: en

Version: 2008-12-29 (fedora - 05/07/09)

Section: 3 (Bibliothèques de fonctions)

NAME

maatkitdsn - Data Source Names for maatkit

SYNOPSIS

  h=host,u=user,p=password,...
 
 

DESCRIPTION

This document describes how to specify a Data Source Name (DSN) for maatkit. Maatkit uses DSNs to specify how to create a DBD connection to a MySQL server. The maatkit tools that have command-line arguments such as -u or -p use them to create a DSN behind the scenes, then use the DSN to connect to MySQL.

A DSN is a string of key=value parts separated by commas. The possible keys are shown later in this document. You can also get a quick synopsis from the --help output of many of the maatkit tools.

PARTS

Many of the tools add more parts to DSNs for special purposes, and sometimes override parts to make them do something slightly different. However, all the tools support at least the following:
A
Specifies the default character set for the connection.

Enables character set settings in Perl and MySQL. If the value is "utf8", sets Perl's binmode on STDOUT to utf8, passes the "mysql_enable_utf8" option to DBD::mysql, and runs "SET NAMES UTF8" after connecting to MySQL. Any other value sets binmode on STDOUT without the utf8 layer, and runs "SET NAMES" after connecting to MySQL.

Unfortunately, there is no way from within Perl itself to specify the client library's character set. "SET NAMES" only affects the server; if the client library's settings don't match, there could be problems. You can use the defaults file to specify the client library's character set, however.

D
Specifies the connection's default database.
F
Specifies a defaults file the client library should read. The maatkit tools all read the [mysql] section within the defaults file. If you omit this, the standard defaults files will be read in the usual order. ``Standard'' varies from system to system, because the filenames to read are compiled into the client library. On Debian systems, for example, it's usually /etc/mysql/my.cnf, ~/.my.cnf, and then /usr/etc/my.cnf. If you place the following into ~/.my.cnf, maatkit will Do The Right Thing:
  [mysql]
  user=your_user_name
  pass=secret
 
 

Omitting this part is usually the right thing to do. As long as you have configured your ~/.my.cnf correctly, that will result in maatkit connecting automatically without needing a username or password.

You can also specify a default character set in the defaults file. Unlike the ``A'' part described above, this will actually instruct the client library (DBD::mysql) to change the character set it uses internally, which cannot be accomplished any other way as far as I know, except for "utf8".

P
Port number to use for the connection. Note that the usual special-case behaviors apply: if you specify "localhost" as your hostname on Unix systems, the connection actually uses a socket file, not a TCP/IP connection, and thus ignores the port.
S
Socket file to use for the connection (on Unix systems).
h
Hostname or IP address for the connection.
p
Password to use when connecting.
u
User for login if not current user.

BAREWORD

Many of the tools will let you specify a DSN as a single word, without any key=value syntax. This is called a 'bareword'. How this is handled is tool-specific, but it is usually interpreted as the ``h'' part.

DEFAULT PROPAGATION

Many tools will let you propagate values from one DSN to the next, so you don't have to specify all the parts for each DSN. For example, if you want to specify a username and password for each DSN, you can connect to three hosts as follows:
  h=host1,u=fred,p=wilma host2 host3
 
 

This is tool-specific.