O'Reilly logo

Sams Teach Yourself MySQL by Chris Newman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using the MySQL DBD

Any Perl script that uses DBI with the MySQL DBD module should begin with the following line:

use Mysql;

Mysql

Note the unusual capitalization of Mysql that is used in the Perl API. The name of this extension is case sensitive.

Connecting to MySQL

You establish a connection to a MySQL database by calling the connect() method on the master Mysql object. The following statement opens a new connection to the database mysql10 on a local MySQL server and assigns a database handle named $dbh.

$dbh = Mysql->connect("localhost", "mysql10", "username" "password");

Mysql->connect() should have exactly four arguments:

  • host— The hostname ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required