{
    "content": [
        {
            "type": "text",
            "text": "# DBD::mysql (perldoc)\n\n## NAME\n\nDBD::mysql - MySQL driver for the Perl5 Database Interface (DBI)\n\n## SYNOPSIS\n\nuse DBI;\nmy $dsn = \"DBI:mysql:database=$database;host=$hostname;port=$port\";\nmy $dbh = DBI->connect($dsn, $user, $password);\nmy $sth = $dbh->prepare(\n'SELECT id, firstname, lastname FROM authors WHERE lastname = ?')\nor die \"prepare statement failed: $dbh->errstr()\";\n$sth->execute('Eggers') or die \"execution failed: $dbh->errstr()\";\nprint $sth->rows . \" rows found.\\n\";\nwhile (my $ref = $sth->fetchrowhashref()) {\nprint \"Found a row: id = $ref->{'id'}, fn = $ref->{'firstname'}\\n\";\n}\n$sth->finish;\n\n## DESCRIPTION\n\nDBD::mysql is the Perl5 Database Interface driver for the MySQL database. In other words:\nDBD::mysql is an interface between the Perl programming language and the MySQL programming API\nthat comes with the MySQL relational database management system. Most functions provided by this\nprogramming API are supported. Some rarely used functions are missing, mainly because no-one\never requested them. :-)\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **EXAMPLE**\n- **DESCRIPTION** (2 subsections)\n- **DATABASE HANDLES** (2 subsections)\n- **STATEMENT HANDLES**\n- **TRANSACTION SUPPORT**\n- **MULTIPLE RESULT SETS** (1 subsections)\n- **MULTITHREADING**\n- **ASYNCHRONOUS QUERIES**\n- **INSTALLATION**\n- **AUTHORS**\n- **CONTRIBUTIONS**\n- **COPYRIGHT**\n- **LICENSE**\n- **MAILING LIST SUPPORT**\n- **ADDITIONAL DBI INFORMATION**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "DBD::mysql",
        "section": "",
        "mode": "perldoc",
        "summary": "DBD::mysql - MySQL driver for the Perl5 Database Interface (DBI)",
        "synopsis": "use DBI;\nmy $dsn = \"DBI:mysql:database=$database;host=$hostname;port=$port\";\nmy $dbh = DBI->connect($dsn, $user, $password);\nmy $sth = $dbh->prepare(\n'SELECT id, firstname, lastname FROM authors WHERE lastname = ?')\nor die \"prepare statement failed: $dbh->errstr()\";\n$sth->execute('Eggers') or die \"execution failed: $dbh->errstr()\";\nprint $sth->rows . \" rows found.\\n\";\nwhile (my $ref = $sth->fetchrowhashref()) {\nprint \"Found a row: id = $ref->{'id'}, fn = $ref->{'firstname'}\\n\";\n}\n$sth->finish;",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [
            "#!/usr/bin/perl",
            "use strict;",
            "use warnings;",
            "use DBI;",
            "# Connect to the database.",
            "my $dbh = DBI->connect(\"DBI:mysql:database=test;host=localhost\",",
            "\"joe\", \"joe's password\",",
            "{'RaiseError' => 1});",
            "# Drop table 'foo'. This may fail, if 'foo' doesn't exist",
            "# Thus we put an eval around it.",
            "eval { $dbh->do(\"DROP TABLE foo\") };",
            "print \"Dropping foo failed: $@\\n\" if $@;",
            "# Create a new table 'foo'. This must not fail, thus we don't",
            "# catch errors.",
            "$dbh->do(\"CREATE TABLE foo (id INTEGER, name VARCHAR(20))\");",
            "# INSERT some data into 'foo'. We are using $dbh->quote() for",
            "# quoting the name.",
            "$dbh->do(\"INSERT INTO foo VALUES (1, \" . $dbh->quote(\"Tim\") . \")\");",
            "# same thing, but using placeholders (recommended!)",
            "$dbh->do(\"INSERT INTO foo VALUES (?, ?)\", undef, 2, \"Jochen\");",
            "# now retrieve data from the table.",
            "my $sth = $dbh->prepare(\"SELECT * FROM foo\");",
            "$sth->execute();",
            "while (my $ref = $sth->fetchrowhashref()) {",
            "print \"Found a row: id = $ref->{'id'}, name = $ref->{'name'}\\n\";",
            "$sth->finish();",
            "# Disconnect from the database.",
            "$dbh->disconnect();"
        ],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 15,
                "subsections": []
            },
            {
                "name": "EXAMPLE",
                "lines": 38,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 50,
                "subsections": [
                    {
                        "name": "Class Methods",
                        "lines": 344
                    },
                    {
                        "name": "Private MetaData Methods",
                        "lines": 11
                    }
                ]
            },
            {
                "name": "DATABASE HANDLES",
                "lines": 13,
                "subsections": [
                    {
                        "name": "mysql_insert_id",
                        "lines": 1
                    },
                    {
                        "name": "mysql_thread_id",
                        "lines": 173
                    }
                ]
            },
            {
                "name": "STATEMENT HANDLES",
                "lines": 124,
                "subsections": []
            },
            {
                "name": "TRANSACTION SUPPORT",
                "lines": 55,
                "subsections": []
            },
            {
                "name": "MULTIPLE RESULT SETS",
                "lines": 47,
                "subsections": [
                    {
                        "name": "Issues with multiple result sets",
                        "lines": 3
                    }
                ]
            },
            {
                "name": "MULTITHREADING",
                "lines": 9,
                "subsections": []
            },
            {
                "name": "ASYNCHRONOUS QUERIES",
                "lines": 22,
                "subsections": []
            },
            {
                "name": "INSTALLATION",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "AUTHORS",
                "lines": 18,
                "subsections": []
            },
            {
                "name": "CONTRIBUTIONS",
                "lines": 10,
                "subsections": []
            },
            {
                "name": "COPYRIGHT",
                "lines": 12,
                "subsections": []
            },
            {
                "name": "LICENSE",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "MAILING LIST SUPPORT",
                "lines": 10,
                "subsections": []
            },
            {
                "name": "ADDITIONAL DBI INFORMATION",
                "lines": 28,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "DBD::mysql - MySQL driver for the Perl5 Database Interface (DBI)\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "use DBI;\n\nmy $dsn = \"DBI:mysql:database=$database;host=$hostname;port=$port\";\nmy $dbh = DBI->connect($dsn, $user, $password);\n\nmy $sth = $dbh->prepare(\n'SELECT id, firstname, lastname FROM authors WHERE lastname = ?')\nor die \"prepare statement failed: $dbh->errstr()\";\n$sth->execute('Eggers') or die \"execution failed: $dbh->errstr()\";\nprint $sth->rows . \" rows found.\\n\";\nwhile (my $ref = $sth->fetchrowhashref()) {\nprint \"Found a row: id = $ref->{'id'}, fn = $ref->{'firstname'}\\n\";\n}\n$sth->finish;\n",
                "subsections": []
            },
            "EXAMPLE": {
                "content": "#!/usr/bin/perl\n\nuse strict;\nuse warnings;\nuse DBI;\n\n# Connect to the database.\nmy $dbh = DBI->connect(\"DBI:mysql:database=test;host=localhost\",\n\"joe\", \"joe's password\",\n{'RaiseError' => 1});\n\n# Drop table 'foo'. This may fail, if 'foo' doesn't exist\n# Thus we put an eval around it.\neval { $dbh->do(\"DROP TABLE foo\") };\nprint \"Dropping foo failed: $@\\n\" if $@;\n\n# Create a new table 'foo'. This must not fail, thus we don't\n# catch errors.\n$dbh->do(\"CREATE TABLE foo (id INTEGER, name VARCHAR(20))\");\n\n# INSERT some data into 'foo'. We are using $dbh->quote() for\n# quoting the name.\n$dbh->do(\"INSERT INTO foo VALUES (1, \" . $dbh->quote(\"Tim\") . \")\");\n\n# same thing, but using placeholders (recommended!)\n$dbh->do(\"INSERT INTO foo VALUES (?, ?)\", undef, 2, \"Jochen\");\n\n# now retrieve data from the table.\nmy $sth = $dbh->prepare(\"SELECT * FROM foo\");\n$sth->execute();\nwhile (my $ref = $sth->fetchrowhashref()) {\nprint \"Found a row: id = $ref->{'id'}, name = $ref->{'name'}\\n\";\n}\n$sth->finish();\n\n# Disconnect from the database.\n$dbh->disconnect();\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "DBD::mysql is the Perl5 Database Interface driver for the MySQL database. In other words:\nDBD::mysql is an interface between the Perl programming language and the MySQL programming API\nthat comes with the MySQL relational database management system. Most functions provided by this\nprogramming API are supported. Some rarely used functions are missing, mainly because no-one\never requested them. :-)\n\nIn what follows we first discuss the use of DBD::mysql, because this is what you will need the\nmost. For installation, see the separate document DBD::mysql::INSTALL. See \"EXAMPLE\" for a\nsimple example above.\n\nFrom perl you activate the interface with the statement\n\nuse DBI;\n\nAfter that you can connect to multiple MySQL database servers and send multiple queries to any\nof them via a simple object oriented interface. Two types of objects are available: database\nhandles and statement handles. Perl returns a database handle to the connect method like so:\n\n$dbh = DBI->connect(\"DBI:mysql:database=$db;host=$host\",\n$user, $password, {RaiseError => 1});\n\nOnce you have connected to a database, you can execute SQL statements with:\n\nmy $query = sprintf(\"INSERT INTO foo VALUES (%d, %s)\",\n$number, $dbh->quote(\"name\"));\n$dbh->do($query);\n\nSee DBI for details on the quote and do methods. An alternative approach is\n\n$dbh->do(\"INSERT INTO foo VALUES (?, ?)\", undef,\n$number, $name);\n\nin which case the quote method is executed automatically. See also the bindparam method in DBI.\nSee \"DATABASE HANDLES\" below for more details on database handles.\n\nIf you want to retrieve results, you need to create a so-called statement handle with:\n\n$sth = $dbh->prepare(\"SELECT * FROM $table\");\n$sth->execute();\n\nThis statement handle can be used for multiple things. First of all you can retrieve a row of\ndata:\n\nmy $row = $sth->fetchrowhashref();\n\nIf your table has columns ID and NAME, then $row will be hash ref with keys ID and NAME. See\n\"STATEMENT HANDLES\" below for more details on statement handles.\n\nBut now for a more formal approach:\n",
                "subsections": [
                    {
                        "name": "Class Methods",
                        "content": "connect\nuse DBI;\n\n$dsn = \"DBI:mysql:$database\";\n$dsn = \"DBI:mysql:database=$database;host=$hostname\";\n$dsn = \"DBI:mysql:database=$database;host=$hostname;port=$port\";\n\n$dbh = DBI->connect($dsn, $user, $password);\n\nThe \"database\" is not a required attribute, but please note that MySQL has no such thing as\na default database. If you don't specify the database at connection time your active\ndatabase will be null and you'd need to prefix your tables with the database name; i.e.\n'SELECT * FROM mydb.mytable'.\n\nThis is similar to the behavior of the mysql command line client. Also, 'SELECT DATABASE()'\nwill return the current database active for the handle.\n\nhost\nport\nThe hostname, if not specified or specified as '' or 'localhost', will default to a\nMySQL server running on the local machine using the default for the UNIX socket. To\nconnect to a MySQL server on the local machine via TCP, you must specify the loopback IP\naddress (127.0.0.1) as the host.\n\nShould the MySQL server be running on a non-standard port number, you may explicitly\nstate the port number to connect to in the \"hostname\" argument, by concatenating the\n*hostname* and *port number* together separated by a colon ( \":\" ) character or by using\nthe \"port\" argument.\n\nTo connect to a MySQL server on localhost using TCP/IP, you must specify the hostname as\n127.0.0.1 (with the optional port).\n\nWhen connecting to a MySQL Server with IPv6, a bracketed IPv6 address should be used.\nExample DSN:\n\nmy $dsn = \"DBI:mysql:;host=[1a12:2800:6f2:85::f20:8cf];port=3306\";\n\nmysqlclientfoundrows\nEnables (TRUE value) or disables (FALSE value) the flag CLIENTFOUNDROWS while\nconnecting to the MySQL server. This has a somewhat funny effect: Without\nmysqlclientfoundrows, if you perform a query like\n\nUPDATE $table SET id = 1 WHERE id = 1;\n\nthen the MySQL engine will always return 0, because no rows have changed. With\nmysqlclientfoundrows however, it will return the number of rows that have an id 1, as\nsome people are expecting. (At least for compatibility to other engines.)\n\nmysqlcompression\nIf your DSN contains the option \"mysqlcompression=1\", then the communication between\nclient and server will be compressed.\n\nmysqlconnecttimeout\nIf your DSN contains the option \"mysqlconnecttimeout=##\", the connect request to the\nserver will timeout if it has not been successful after the given number of seconds.\n\nmysqlwritetimeout\nIf your DSN contains the option \"mysqlwritetimeout=##\", the write operation to the\nserver will timeout if it has not been successful after the given number of seconds.\n\nmysqlreadtimeout\nIf your DSN contains the option \"mysqlreadtimeout=##\", the read operation to the\nserver will timeout if it has not been successful after the given number of seconds.\n\nmysqlinitcommand\nIf your DSN contains the option \"mysqlinitcommand=##\", then this SQL statement is\nexecuted when connecting to the MySQL server. It is automatically re-executed if\nreconnection occurs.\n\nmysqlskipsecureauth\nThis option is for older mysql databases that don't have secure auth set.\n\nmysqlreaddefaultfile\nmysqlreaddefaultgroup\nThese options can be used to read a config file like /etc/my.cnf or ~/.my.cnf. By\ndefault MySQL's C client library doesn't use any config files unlike the client programs\n(mysql, mysqladmin, ...) that do, but outside of the C client library. Thus you need to\nexplicitly request reading a config file, as in\n\n$dsn = \"DBI:mysql:test;mysqlreaddefaultfile=/home/joe/my.cnf\";\n$dbh = DBI->connect($dsn, $user, $password)\n\nThe option mysqlreaddefaultgroup can be used to specify the default group in the\nconfig file: Usually this is the *client* group, but see the following example:\n\n[client]\nhost=localhost\n\n[perl]\nhost=perlhost\n\n(Note the order of the entries! The example won't work, if you reverse the [client] and\n[perl] sections!)\n\nIf you read this config file, then you'll be typically connected to *localhost*.\nHowever, by using\n\n$dsn = \"DBI:mysql:test;mysqlreaddefaultgroup=perl;\"\n. \"mysqlreaddefaultfile=/home/joe/my.cnf\";\n$dbh = DBI->connect($dsn, $user, $password);\n\nyou'll be connected to *perlhost*. Note that if you specify a default group and do not\nspecify a file, then the default config files will all be read. See the documentation of\nthe C function mysqloptions() for details.\n\nmysqlsocket\nIt is possible to choose the Unix socket that is used for connecting to the server. This\nis done, for example, with\n\nmysqlsocket=/dev/mysql\n\nUsually there's no need for this option, unless you are using another location for the\nsocket than that built into the client.\n\nmysqlssl\nA true value turns on the CLIENTSSL flag when connecting to the MySQL server and\nenforce SSL encryption. A false value (which is default) disable SSL encryption with the\nMySQL server.\n\nWhen enabling SSL encryption you should set also other SSL options, at least\nmysqlsslcafile or mysqlsslcapath.\n\nmysqlssl=1 mysqlsslverifyservercert=1 mysqlsslcafile=/path/to/cacert.pem\n\nThis means that your communication with the server will be encrypted.\n\nPlease note that this can only work if you enabled SSL when compiling DBD::mysql; this\nis the default starting version 4.034. See DBD::mysql::INSTALL for more details.\n\nmysqlsslcafile\nThe path to a file in PEM format that contains a list of trusted SSL certificate\nauthorities.\n\nWhen set MySQL server certificate is checked that it is signed by some CA certificate in\nthe list. Common Name value is not verified unless \"mysqlsslverifyservercert\" is\nenabled.\n\nmysqlsslcapath\nThe path to a directory that contains trusted SSL certificate authority certificates in\nPEM format.\n\nWhen set MySQL server certificate is checked that it is signed by some CA certificate in\nthe list. Common Name value is not verified unless \"mysqlsslverifyservercert\" is\nenabled.\n\nPlease note that this option is supported only if your MySQL client was compiled with\nOpenSSL library, and not with default yaSSL library.\n\nmysqlsslverifyservercert\nChecks the server's Common Name value in the certificate that the server sends to the\nclient. The client verifies that name against the host name the client uses for\nconnecting to the server, and the connection fails if there is a mismatch. For encrypted\nconnections, this option helps prevent man-in-the-middle attacks.\n\nVerification of the host name is disabled by default.\n\nmysqlsslclientkey\nThe name of the SSL key file in PEM format to use for establishing a secure connection.\n\nmysqlsslclientcert\nThe name of the SSL certificate file in PEM format to use for establishing a secure\nconnection.\n\nmysqlsslcipher\nA list of permissible ciphers to use for connection encryption. If no cipher in the list\nis supported, encrypted connections will not work.\n\nmysqlsslcipher=AES128-SHA\nmysqlsslcipher=DHE-RSA-AES256-SHA:AES128-SHA\n\nmysqlssloptional\nSetting \"mysqlssloptional\" to true disables strict SSL enforcement and makes SSL\nconnection optional. This option opens security hole for man-in-the-middle attacks.\nDefault value is false which means that \"mysqlssl\" set to true enforce SSL encryption.\n\nThis option was introduced in 4.043 version of DBD::mysql. Due to The BACKRONYM\n<http://backronym.fail/> and The Riddle <http://riddle.link/> vulnerabilities in\nlibmysqlclient library, enforcement of SSL encryption was not possbile and therefore\n\"mysqlssloptional=1\" was effectively set for all DBD::mysql versions prior to 4.043.\nStarting with 4.043, DBD::mysql with \"mysqlssl=1\" could refuse connection to MySQL\nserver if underlaying libmysqlclient library is vulnerable. Option \"mysqlssloptional\"\ncan be used to make SSL connection vulnerable.\n\nmysqlserverpubkey\nPath to the RSA public key of the server. This is used for the sha256password and\ncachingsha2password authentication plugins.\n\nmysqlgetserverpubkey\nSetting \"mysqlgetserverpubkey\" to true requests the public RSA key of the server.\n\nmysqllocalinfile\nThe LOCAL capability for LOAD DATA may be disabled in the MySQL client library by\ndefault. If your DSN contains the option \"mysqllocalinfile=1\", LOAD DATA LOCAL will be\nenabled. (However, this option is *ineffective* if the server has also been configured\nto disallow LOCAL.)\n\nmysqlmultistatements\nSupport for multiple statements separated by a semicolon (;) may be enabled by using\nthis option. Enabling this option may cause problems if server-side prepared statements\nare also enabled.\n\nmysqlserverprepare\nThis option is used to enable server side prepared statements.\n\nTo use server side prepared statements, all you need to do is set the variable\nmysqlserverprepare in the connect:\n\n$dbh = DBI->connect(\n\"DBI:mysql:database=test;host=localhost;mysqlserverprepare=1\",\n\"\",\n\"\",\n{ RaiseError => 1, AutoCommit => 1 }\n);\n\nor:\n\n$dbh = DBI->connect(\n\"DBI:mysql:database=test;host=localhost\",\n\"\",\n\"\",\n{ RaiseError => 1, AutoCommit => 1, mysqlserverprepare => 1 }\n);\n\nThere are many benefits to using server side prepare statements, mostly if you are\nperforming many inserts because of that fact that a single statement is prepared to\naccept multiple insert values.\n\nTo make sure that the 'make test' step tests whether server prepare works, you just need\nto export the env variable MYSQLSERVERPREPARE:\n\nexport MYSQLSERVERPREPARE=1\n\nPlease note that mysql server cannot prepare or execute some prepared statements. In\nthis case DBD::mysql fallbacks to normal non-prepared statement and tries again.\n\nmysqlserverpreparedisablefallback\nThis option disable fallback to normal non-prepared statement when mysql server does not\nsupport execution of current statement as prepared.\n\nUseful when you want to be sure that statement is going to be executed as server side\nprepared. Error message and code in case of failure is propagated back to DBI.\n\nmysqlembeddedoptions\nThe option <mysqlembeddedoptions> can be used to pass 'command-line' options to\nembedded server.\n\nExample:\n\nuse DBI;\n$testdsn=\"DBI:mysqlEmb:database=test;mysqlembeddedoptions=--help,--verbose\";\n$dbh = DBI->connect($testdsn,\"a\",\"b\");\n\nThis would cause the command line help to the embedded MySQL server library to be\nprinted.\n\nmysqlembeddedgroups\nThe option <mysqlembeddedgroups> can be used to specify the groups in the config\nfile(*my.cnf*) which will be used to get options for embedded server. If not specified\n[server] and [embedded] groups will be used.\n\nExample:\n\n$testdsn=\"DBI:mysqlEmb:database=test;mysqlembeddedgroups=embeddedserver,common\";\n\nmysqlconnattrs\nThe option <mysqlconnattrs> is a hash of attribute names and values which can be used\nto send custom connection attributes to the server. Some attributes like 'os',\n'platform', 'clientname' and 'clientversion' are added by libmysqlclient and\n'programname' is added by DBD::mysql.\n\nYou can then later read these attributes from the performance schema tables which can be\nquite helpful for profiling your database or creating statistics. You'll have to use a\nMySQL 5.6 server and libmysqlclient or newer to leverage this feature.\n\nmy $dbh= DBI->connect($dsn, $user, $password,\n{ AutoCommit => 0,\nmysqlconnattrs => {\nfoo => 'bar',\nwiz => 'bang'\n},\n});\n\nNow you can select the results from the performance schema tables. You can do this in\nthe same session, but also afterwards. It can be very useful to answer questions like\n'which script sent this query?'.\n\nmy $results = $dbh->selectallhashref(\n'SELECT * FROM performanceschema.sessionconnectattrs',\n'ATTRNAME'\n);\n\nThis returns:\n\n$result = {\n'foo' => {\n'ATTRVALUE'       => 'bar',\n'PROCESSLISTID'   => '3',\n'ATTRNAME'        => 'foo',\n'ORDINALPOSITION' => '6'\n},\n'wiz' => {\n'ATTRVALUE'       => 'bang',\n'PROCESSLISTID'   => '3',\n'ATTRNAME'        => 'wiz',\n'ORDINALPOSITION' => '3'\n},\n'programname' => {\n'ATTRVALUE'       => './foo.pl',\n'PROCESSLISTID'   => '3',\n'ATTRNAME'        => 'programname',\n'ORDINALPOSITION' => '5'\n},\n'clientname' => {\n'ATTRVALUE'       => 'libmysql',\n'PROCESSLISTID'   => '3',\n'ATTRNAME'        => 'clientname',\n'ORDINALPOSITION' => '1'\n},\n'clientversion' => {\n'ATTRVALUE'       => '5.6.24',\n'PROCESSLISTID'   => '3',\n'ATTRNAME'        => 'clientversion',\n'ORDINALPOSITION' => '7'\n},\n'os' => {\n'ATTRVALUE'       => 'osx10.8',\n'PROCESSLISTID'   => '3',\n'ATTRNAME'        => 'os',\n'ORDINALPOSITION' => '0'\n},\n'pid' => {\n'ATTRVALUE'       => '59860',\n'PROCESSLISTID'   => '3',\n'ATTRNAME'        => 'pid',\n'ORDINALPOSITION' => '2'\n},\n'platform' => {\n'ATTRVALUE'       => 'x8664',\n'PROCESSLISTID'   => '3',\n'ATTRNAME'        => 'platform',\n'ORDINALPOSITION' => '4'\n}\n};\n"
                    },
                    {
                        "name": "Private MetaData Methods",
                        "content": "ListDBs\nmy $drh = DBI->installdriver(\"mysql\");\n@dbs = $drh->func(\"$hostname:$port\", 'ListDBs');\n@dbs = $drh->func($hostname, $port, 'ListDBs');\n@dbs = $dbh->func('ListDBs');\n\nReturns a list of all databases managed by the MySQL server running on $hostname, port\n$port. This is a legacy method. Instead, you should use the portable method\n\n@dbs = DBI->datasources(\"mysql\");\n"
                    }
                ]
            },
            "DATABASE HANDLES": {
                "content": "The DBD::mysql driver supports the following attributes of database handles (read only):\n\n$errno = $dbh->{'mysqlerrno'};\n$error = $dbh->{'mysqlerror'};\n$info = $dbh->{'mysqlhostinfo'};\n$info = $dbh->{'mysqlinfo'};\n$insertid = $dbh->{'mysqlinsertid'};\n$info = $dbh->{'mysqlprotoinfo'};\n$info = $dbh->{'mysqlserverinfo'};\n$info = $dbh->{'mysqlstat'};\n$threadId = $dbh->{'mysqlthreadid'};\n\nThese correspond to mysqlerrno(), mysqlerror(), mysqlgethostinfo(), mysqlinfo(),",
                "subsections": [
                    {
                        "name": "mysql_insert_id",
                        "content": ""
                    },
                    {
                        "name": "mysql_thread_id",
                        "content": "mysqlclientinfo\nList information of the MySQL client library that DBD::mysql was built against:\n\nprint \"$dbh->{mysqlclientinfo}\\n\";\n\n5.2.0-MariaDB\n\nmysqlclientversion\nprint \"$dbh->{mysqlclientversion}\\n\";\n\n50200\n\nmysqlserverversion\nprint \"$dbh->{mysqlserverversion}\\n\";\n\n50200\n\nmysqldbdstats\n$infohashref = $dbh->{mysqldbdstats};\n\nDBD::mysql keeps track of some statistics in the mysqldbdstats attribute. The following\nstats are being maintained:\n\nautoreconnectsok\nThe number of times that DBD::mysql successfully reconnected to the mysql server.\n\nautoreconnectsfailed\nThe number of times that DBD::mysql tried to reconnect to mysql but failed.\n\nThe DBD::mysql driver also supports the following attributes of database handles (read/write):\n\nmysqlautoreconnect\nThis attribute determines whether DBD::mysql will automatically reconnect to mysql if the\nconnection be lost. This feature defaults to off; however, if either the GATEWAYINTERFACE\nor MODPERL environment variable is set, DBD::mysql will turn mysqlautoreconnect on.\nSetting mysqlautoreconnect to on is not advised if 'lock tables' is used because if\nDBD::mysql reconnect to mysql all table locks will be lost. This attribute is ignored when\nAutoCommit is turned off, and when AutoCommit is turned off, DBD::mysql will not\nautomatically reconnect to the server.\n\nIt is also possible to set the default value of the \"mysqlautoreconnect\" attribute for the\n$dbh by passing it in the \"\\%attr\" hash for \"DBI-\"connect>.\n\n$dbh->{mysqlautoreconnect} = 1;\n\nor\n\nmy $dbh = DBI->connect($dsn, $user, $password, {\nmysqlautoreconnect => 1,\n});\n\nNote that if you are using a module or framework that performs reconnections for you (for\nexample DBIx::Connector in fixup mode), this value must be set to 0.\n\nmysqluseresult\nThis attribute forces the driver to use mysqluseresult rather than mysqlstoreresult. The\nformer is faster and less memory consuming, but tends to block other processes.\nmysqlstoreresult is the default due to that fact storing the result is expected behavior\nwith most applications.\n\nIt is possible to set the default value of the \"mysqluseresult\" attribute for the $dbh via\nthe DSN:\n\n$dbh = DBI->connect(\"DBI:mysql:test;mysqluseresult=1\", \"root\", \"\");\n\nYou can also set it after creation of the database handle:\n\n$dbh->{mysqluseresult} = 0; # disable\n$dbh->{mysqluseresult} = 1; # enable\n\nYou can also set or unset the \"mysqluseresult\" setting on your statement handle, when\ncreating the statement handle or after it has been created. See \"STATEMENT HANDLES\".\n\nmysqlenableutf8\nThis attribute determines whether DBD::mysql should assume strings stored in the database\nare utf8. This feature defaults to off.\n\nWhen set, a data retrieved from a textual column type (char, varchar, etc) will have the\nUTF-8 flag turned on if necessary. This enables character semantics on that string. You will\nalso need to ensure that your database / table / column is configured to use UTF8. See for\nmore information the chapter on character set support in the MySQL manual:\n<http://dev.mysql.com/doc/refman/5.7/en/charset.html>\n\nAdditionally, turning on this flag tells MySQL that incoming data should be treated as\nUTF-8. This will only take effect if used as part of the call to connect(). If you turn the\nflag on after connecting, you will need to issue the command \"SET NAMES utf8\" to get the\nsame effect.\n\nmysqlenableutf8mb4\nThis is similar to mysqlenableutf8, but is capable of handling 4-byte UTF-8 characters.\n\nmysqlbindtypeguessing\nThis attribute causes the driver (emulated prepare statements) to attempt to guess if a\nvalue being bound is a numeric value, and if so, doesn't quote the value. This was created\nby Dragonchild and is one way to deal with the performance issue of using quotes in a\nstatement that is inserting or updating a large numeric value. This was previously called\n\"unsafebindtypeguessing\" because it is experimental. I have successfully run the full\ntest suite with this option turned on, the name can now be simply\n\"mysqlbindtypeguessing\".\n\nCAVEAT: Even though you can insert an integer value into a character column, if this column\nis indexed, if you query that column with the integer value not being quoted, it will not\nuse the index:\n\nMariaDB [test]> explain select * from test where value0 = '3' \\G\n* 1. row *\nid: 1\nselecttype: SIMPLE\ntable: test\ntype: ref\npossiblekeys: value0\nkey: value0\nkeylen: 13\nref: const\nrows: 1\nExtra: Using index condition\n1 row in set (0.00 sec)\n\nMariaDB [test]> explain select * from test where value0 = 3\n-> \\G\n* 1. row *\nid: 1\nselecttype: SIMPLE\ntable: test\ntype: ALL\npossiblekeys: value0\nkey: NULL\nkeylen: NULL\nref: NULL\nrows: 6\nExtra: Using where\n1 row in set (0.00 sec)\n\nSee bug: https://rt.cpan.org/Ticket/Display.html?id=43822\n\n\"mysqlbindtypeguessing\" can be turned on via\n\n- through DSN\n\nmy $dbh= DBI->connect('DBI:mysql:test', 'username', 'pass',\n{ mysqlbindtypeguessing => 1})\n\n- OR after handle creation\n\n$dbh->{mysqlbindtypeguessing} = 1;\n\nmysqlbindcommentplaceholders\nThis attribute causes the driver (emulated prepare statements) will cause any placeholders\nin comments to be bound. This is not correct prepared statement behavior, but some\ndevelopers have come to depend on this behavior, so I have made it available in 4.015\n\nmysqlnoautocommitcmd\nThis attribute causes the driver to not issue 'set autocommit' either through explicit or\nusing mysqlautocommit(). This is particularly useful in the case of using MySQL Proxy.\n\nSee the bug report:\n\nhttps://rt.cpan.org/Public/Bug/Display.html?id=46308\n\n\"mysqlnoautocommitcmd\" can be turned on when creating the database handle:\n\nmy $dbh = DBI->connect('DBI:mysql:test', 'username', 'pass',\n{ mysqlnoautocommitcmd => 1});\n\nor using an existing database handle:\n\n$dbh->{mysqlnoautocommitcmd} = 1;\n\nping\nThis can be used to send a ping to the server.\n\n$rc = $dbh->ping();\n"
                    }
                ]
            },
            "STATEMENT HANDLES": {
                "content": "The statement handles of DBD::mysql support a number of attributes. You access these by using,\nfor example,\n\nmy $numFields = $sth->{NUMOFFIELDS};\n\nNote, that most attributes are valid only after a successful *execute*. An \"undef\" value will\nreturned otherwise. The most important exception is the \"mysqluseresult\" attribute, which\nforces the driver to use mysqluseresult rather than mysqlstoreresult. The former is faster\nand less memory consuming, but tends to block other processes. (That's why mysqlstoreresult is\nthe default.)\n\nTo set the \"mysqluseresult\" attribute, use either of the following:\n\nmy $sth = $dbh->prepare(\"QUERY\", { mysqluseresult => 1});\n\nor\n\nmy $sth = $dbh->prepare($sql);\n$sth->{mysqluseresult} = 1;\n\nColumn dependent attributes, for example *NAME*, the column names, are returned as a reference\nto an array. The array indices are corresponding to the indices of the arrays returned by\n*fetchrow* and similar methods. For example the following code will print a header of table\nnames together with all rows:\n\nmy $sth = $dbh->prepare(\"SELECT * FROM $table\") ||\ndie \"Error:\" . $dbh->errstr . \"\\n\";\n\n$sth->execute ||  die \"Error:\" . $sth->errstr . \"\\n\";\n\nmy $names = $sth->{NAME};\nmy $numFields = $sth->{'NUMOFFIELDS'} - 1;\nfor my $i ( 0..$numFields ) {\nprintf(\"%s%s\", $i ? \",\" : \"\", $$names[$i]);\n}\nprint \"\\n\";\nwhile (my $ref = $sth->fetchrowarrayref) {\nfor my $i ( 0..$numFields ) {\nprintf(\"%s%s\", $i ? \",\" : \"\", $$ref[$i]);\n}\nprint \"\\n\";\n}\n\nFor portable applications you should restrict yourself to attributes with capitalized or mixed\ncase names. Lower case attribute names are private to DBD::mysql. The attribute list includes:\n\nChopBlanks\nthis attribute determines whether a *fetchrow* will chop preceding and trailing blanks off\nthe column values. Chopping blanks does not have impact on the *maxlength* attribute.\n\nmysqlgtids\nReturns GTID(s) if GTID session tracking is ensabled in the server via sessiontrackgtids.\n\nmysqlinsertid\nIf the statement you executed performs an INSERT, and there is an AUTOINCREMENT column in\nthe table you inserted in, this attribute holds the value stored into the AUTOINCREMENT\ncolumn, if that value is automatically generated, by storing NULL or 0 or was specified as\nan explicit value.\n\nTypically, you'd access the value via $sth->{mysqlinsertid}. The value can also be accessed\nvia $dbh->{mysqlinsertid} but this can easily produce incorrect results in case one\ndatabase handle is shared.\n\nmysqlisblob\nReference to an array of boolean values; TRUE indicates, that the respective column is a\nblob. This attribute is valid for MySQL only.\n\nmysqliskey\nReference to an array of boolean values; TRUE indicates, that the respective column is a\nkey. This is valid for MySQL only.\n\nmysqlisnum\nReference to an array of boolean values; TRUE indicates, that the respective column contains\nnumeric values.\n\nmysqlisprikey\nReference to an array of boolean values; TRUE indicates, that the respective column is a\nprimary key.\n\nmysqlisautoincrement\nReference to an array of boolean values; TRUE indicates that the respective column is an\nAUTOINCREMENT column. This is only valid for MySQL.\n\nmysqllength\nmysqlmaxlength\nA reference to an array of maximum column sizes. The *maxlength* is the maximum physically\npresent in the result table, *length* gives the theoretically possible maximum. *maxlength*\nis valid for MySQL only.\n\nNAME\nA reference to an array of column names.\n\nNULLABLE\nA reference to an array of boolean values; TRUE indicates that this column may contain\nNULL's.\n\nNUMOFFIELDS\nNumber of fields returned by a *SELECT* or *LISTFIELDS* statement. You may use this for\nchecking whether a statement returned a result: A zero value indicates a non-SELECT\nstatement like *INSERT*, *DELETE* or *UPDATE*.\n\nmysqltable\nA reference to an array of table names, useful in a *JOIN* result.\n\nTYPE\nA reference to an array of column types. The engine's native column types are mapped to\nportable types like DBI::SQLINTEGER() or DBI::SQLVARCHAR(), as good as possible. Not all\nnative types have a meaningful equivalent, for example DBD::mysql::FIELDTYPEINTERVAL is\nmapped to DBI::SQLVARCHAR(). If you need the native column types, use *mysqltype*. See\nbelow.\n\nmysqltype\nA reference to an array of MySQL's native column types, for example\nDBD::mysql::FIELDTYPESHORT() or DBD::mysql::FIELDTYPESTRING(). Use the *TYPE* attribute,\nif you want portable types like DBI::SQLSMALLINT() or DBI::SQLVARCHAR().\n\nmysqltypename\nSimilar to mysql, but type names and not numbers are returned. Whenever possible, the ANSI\nSQL name is preferred.\n\nmysqlwarningcount\nThe number of warnings generated during execution of the SQL statement. This attribute is\navailable on both statement handles and database handles.\n",
                "subsections": []
            },
            "TRANSACTION SUPPORT": {
                "content": "The transaction support works as follows:\n\n*   By default AutoCommit mode is on, following the DBI specifications.\n\n*   If you execute\n\n$dbh->{AutoCommit} = 0;\n\nor\n\n$dbh->{AutoCommit} = 1;\n\nthen the driver will set the MySQL server variable autocommit to 0 or 1, respectively.\nSwitching from 0 to 1 will also issue a COMMIT, following the DBI specifications.\n\n*   The methods\n\n$dbh->rollback();\n$dbh->commit();\n\nwill issue the commands ROLLBACK and COMMIT, respectively. A ROLLBACK will also be issued if\nAutoCommit mode is off and the database handles DESTROY method is called. Again, this is\nfollowing the DBI specifications.\n\nGiven the above, you should note the following:\n\n*   You should never change the server variable autocommit manually, unless you are ignoring\nDBI's transaction support.\n\n*   Switching AutoCommit mode from on to off or vice versa may fail. You should always check for\nerrors when changing AutoCommit mode. The suggested way of doing so is using the DBI flag\nRaiseError. If you don't like RaiseError, you have to use code like the following:\n\n$dbh->{AutoCommit} = 0;\nif ($dbh->{AutoCommit}) {\n# An error occurred!\n}\n\n*   If you detect an error while changing the AutoCommit mode, you should no longer use the\ndatabase handle. In other words, you should disconnect and reconnect again, because the\ntransaction mode is unpredictable. Alternatively you may verify the transaction mode by\nchecking the value of the server variable autocommit. However, such behaviour isn't\nportable.\n\n*   DBD::mysql has a \"reconnect\" feature that handles the so-called MySQL \"morning bug\": If the\nserver has disconnected, most probably due to a timeout, then by default the driver will\nreconnect and attempt to execute the same SQL statement again. However, this behaviour is\ndisabled when AutoCommit is off: Otherwise the transaction state would be completely\nunpredictable after a reconnect.\n\n*   The \"reconnect\" feature of DBD::mysql can be toggled by using the mysqlautoreconnect\nattribute. This behaviour should be turned off in code that uses LOCK TABLE because if the\ndatabase server time out and DBD::mysql reconnect, table locks will be lost without any\nindication of such loss.\n",
                "subsections": []
            },
            "MULTIPLE RESULT SETS": {
                "content": "DBD::mysql supports multiple result sets, thanks to Guy Harrison!\n\nThe basic usage of multiple result sets is\n\ndo\n{\nwhile (@row = $sth->fetchrowarray())\n{\ndo stuff;\n}\n} while ($sth->moreresults)\n\nAn example would be:\n\n$dbh->do(\"drop procedure if exists someproc\") or print $DBI::errstr;\n\n$dbh->do(\"create procedure someproc() deterministic\nbegin\ndeclare a,b,c,d int;\nset a=1;\nset b=2;\nset c=3;\nset d=4;\nselect a, b, c, d;\nselect d, c, b, a;\nselect b, a, c, d;\nselect c, b, d, a;\nend\") or print $DBI::errstr;\n\n$sth=$dbh->prepare('call someproc()') ||\ndie $DBI::err.\": \".$DBI::errstr;\n\n$sth->execute || die DBI::err.\": \".$DBI::errstr; $rowset=0;\ndo {\nprint \"\\nRowset \".++$i.\"\\n---------------------------------------\\n\\n\";\nforeach $colno (0..$sth->{NUMOFFIELDS}-1) {\nprint $sth->{NAME}->[$colno].\"\\t\";\n}\nprint \"\\n\";\nwhile (@row= $sth->fetchrowarray())  {\nforeach $field (0..$#row) {\nprint $row[$field].\"\\t\";\n}\nprint \"\\n\";\n}\n} until (!$sth->moreresults)\n",
                "subsections": [
                    {
                        "name": "Issues with multiple result sets",
                        "content": "Please be aware there could be issues if your result sets are \"jagged\", meaning the number of\ncolumns of your results vary. Varying numbers of columns could result in your script crashing.\n"
                    }
                ]
            },
            "MULTITHREADING": {
                "content": "The multithreading capabilities of DBD::mysql depend completely on the underlying C libraries.\nThe modules are working with handle data only, no global variables are accessed or (to the best\nof my knowledge) thread unsafe functions are called. Thus DBD::mysql is believed to be\ncompletely thread safe, if the C libraries are thread safe and you don't share handles among\nthreads.\n\nThe obvious question is: Are the C libraries thread safe? In the case of MySQL the answer is\nyes, since MySQL 5.5 it is.\n",
                "subsections": []
            },
            "ASYNCHRONOUS QUERIES": {
                "content": "You can make a single asynchronous query per MySQL connection; this allows you to submit a\nlong-running query to the server and have an event loop inform you when it's ready. An\nasynchronous query is started by either setting the 'async' attribute to a true value in the\n\"do\" in DBI method, or in the \"prepare\" in DBI method. Statements created with 'async' set to\ntrue in prepare always run their queries asynchronously when \"execute\" in DBI is called. The\ndriver also offers three additional methods: \"mysqlasyncresult\", \"mysqlasyncready\", and\n\"mysqlfd\". \"mysqlasyncresult\" returns what do or execute would have; that is, the number of\nrows affected. \"mysqlasyncready\" returns true if \"mysqlasyncresult\" will not block, and zero\notherwise. They both return \"undef\" if that handle was not created with 'async' set to true or\nif an asynchronous query was not started yet. \"mysqlfd\" returns the file descriptor number for\nthe MySQL connection; you can use this in an event loop.\n\nHere's an example of how to use the asynchronous query interface:\n\nuse feature 'say';\n$dbh->do('SELECT SLEEP(10)', { async => 1 });\nuntil($dbh->mysqlasyncready) {\nsay 'not ready yet!';\nsleep 1;\n}\nmy $rows = $dbh->mysqlasyncresult;\n",
                "subsections": []
            },
            "INSTALLATION": {
                "content": "See DBD::mysql::INSTALL.\n",
                "subsections": []
            },
            "AUTHORS": {
                "content": "Originally, there was a non-DBI driver, Mysql, which was much like PHP drivers such as mysql and\nmysqli. The Mysql module was originally written by Andreas König <koenig@kulturbox.de> who\nstill, to this day, contributes patches to DBD::mysql. An emulated version of Mysql was provided\nto DBD::mysql from Jochen Wiedmann, but eventually deprecated as it was another bundle of code\nto maintain.\n\nThe first incarnation of DBD::mysql was developed by Alligator Descartes, who was also aided and\nabetted by Gary Shea, Andreas König and Tim Bunce.\n\nThe current incarnation of DBD::mysql was written by Jochen Wiedmann, then numerous changes and\nbug-fixes were added by Rudy Lippan. Next, prepared statement support was added by Patrick\nGalbraith and Alexy Stroganov (who also solely added embedded server support).\n\nFor the past nine years DBD::mysql has been maintained by Patrick Galbraith (*patg@patg.net*),\nand recently with the great help of Michiel Beijen (*michiel.beijen@gmail.com*), along with the\nentire community of Perl developers who keep sending patches to help continue improving\nDBD::mysql\n",
                "subsections": []
            },
            "CONTRIBUTIONS": {
                "content": "Anyone who desires to contribute to this project is encouraged to do so. Currently, the source\ncode for this project can be found at Github:\n\n<https://github.com/perl5-dbi/DBD-mysql/>\n\nEither fork this repository and produce a branch with your changeset that the maintainer can\nmerge to his tree, or create a diff with git. The maintainer is more than glad to take\ncontributions from the community as many features and fixes from DBD::mysql have come from the\ncommunity.\n",
                "subsections": []
            },
            "COPYRIGHT": {
                "content": "This module is\n\n*   Large Portions Copyright (c) 2004-2013 Patrick Galbraith\n\n*   Large Portions Copyright (c) 2004-2006 Alexey Stroganov\n\n*   Large Portions Copyright (c) 2003-2005 Rudolf Lippan\n\n*   Large Portions Copyright (c) 1997-2003 Jochen Wiedmann, with code portions\n\n*   Copyright (c)1994-1997 their original authors\n",
                "subsections": []
            },
            "LICENSE": {
                "content": "This module is released under the same license as Perl itself. See\n<http://www.perl.com/perl/misc/Artistic.html> for details.\n",
                "subsections": []
            },
            "MAILING LIST SUPPORT": {
                "content": "This module is maintained and supported on a mailing list, dbi-users.\n\nTo subscribe to this list, send an email to\n\ndbi-users-subscribe@perl.org\n\nMailing list archives are at\n\n<http://groups.google.com/group/perl.dbi.users?hl=en&lr=>\n",
                "subsections": []
            },
            "ADDITIONAL DBI INFORMATION": {
                "content": "Additional information on the DBI project can be found on the World Wide Web at the following\nURL:\n\n<http://dbi.perl.org>\n\nwhere documentation, pointers to the mailing lists and mailing list archives and pointers to the\nmost current versions of the modules can be used.\n\nInformation on the DBI interface itself can be gained by typing:\n\nperldoc DBI\n\nInformation on DBD::mysql specifically can be gained by typing:\n\nperldoc DBD::mysql\n\n(this will display the document you're currently reading)\n\nBUG REPORTING, ENHANCEMENT/FEATURE REQUESTS\nPlease report bugs, including all the information needed such as DBD::mysql version, MySQL\nversion, OS type/version, etc to this link:\n\n<https://rt.cpan.org/Dist/Display.html?Name=DBD-mysql>\n\nNote: until recently, MySQL/Sun/Oracle responded to bugs and assisted in fixing bugs which many\nthanks should be given for their help! This driver is outside the realm of the numerous\ncomponents they support, and the maintainer and community solely support DBD::mysql\n",
                "subsections": []
            }
        }
    }
}