For MySQL

mysql://user:password@host[:port][,host[:port]]|[/unix/socket]/database?
   charset=value& [value must be character set name for MySQL 4.1+]
   ClientCharset=charset&
   timeout=3&
   compress=0&
   named_pipe=1&
   autocommit=1&
   local_infile=0&
   [3.4.2]
   multi_statements=0&   
[3.3.0]
   config_file=~/.my.cnf&   [3.4.6]
   
config_group=parser   [3.4.6]

Generally, there is no need to specify additional parameters for connection:
mysql://user:password@localhost/database

One can replace
hostname and port_number with path to UNIX socket in square brackets (UNIX socket is a magical set of characters (path), which your administrator may tell you, provided you yourself are not the administrator in the flesh. This socket may be used to communicate with server):

user:password@[/unix/socket]/database

charset-right after connection executes "SET NAMES value";
ClientCharset
-specifies the charset, in which Parser must communicate with SQL server. Conversion will be done by driver;
timeout-specifies value of parameter Connect timeout in seconds;
compress-mode of compressing traffic between server and client;
named_pipe-use named pipes to connect to MySQL-server, working under Windows NT;
autocommit-if set to 0 after connection executes "SET AUTOCOMMIT=0";
local_infile-if set to 1, the execution of LOAD DATA [LOCAL] INFILE command is allowed (more details);
multi_statements-if set to 1, the single SQL query can contains more then one SQL statements separated by ";" character (character ";" must be escaped by character "^");
config_file - use the specified settings file (for example the certificate for secure connection can be specified there);
config_group - read the specified settings group from the settings file.


Example: transcoding by SQL server (it works with many character sets but requires MySQL version 4.1 or higher)
MySQL server version 4.1 or higher can transcode data in different ways itself so it is recommended to use these server abilities using charset option and don't use ClientCharset option at all. With MySQL server version 4.1 or higher you can even store data in different tables using different character sets but we recommend to store it in UTF-8.

Assume, data in your database is stored in
UTF-8, while pages are in windows-1257, connect string should look like this:
mysql://user:password@host/database?charset=cp1257

In this case right after connection to the server Parser will executes command
"SET NAMES cp1257" and server will transcode received data from cp1257 to character set used for storing data in requested database/table/column and transcode it back while send response.

Note: in this case you should specify character set used for storing pages.
Note: this option executes the MySQL command so you must use MySQL server character set names which are not equal to Parser character set names, defined in configuration file.


Example: DB in win
dows-1251, pages are in koi8-r, transcoding by Parser driver (for any version of MySQL server)
In some cases it's unable to use MySQL server transcode functions. In this case you can use driver transcode functions with ClientCharset option.
Assume, data in your database is stored in
windows-1251, while pages are in koi8-r, connect string should look like this:
mysql://user:password@host/database?ClientCharset=windows-1251

For Parser code all received data will be automatically converted from
windows-1251 to $request:charset (koi8-r in this example).

Note: in this case you should specify character set used for storing data in database.
Note: in this option you must use Parser character set names, defined in configuration file.

Example: connecting to a MySQL cluster

mysql://user:password@node1,node2,node3/?timeout=1

First of all, connection will be made to server node1. If the connection won't be not established within a second (generally, this takes a short fraction of a second), then the connection will be made to server node2, and if the connection won't be not established within a second, then the connection will be made to server node3.

Example: connecting to a SphinxQL


mysql://@localhost:9306/?ClientCharset=utf-8



Copyright © 1997–2021 Art. Lebedev Studio | http://www.artlebedev.com Last updated: 25.01.2021