# Using perl script to connect to xtradb

**URL:** <https://forums.percona.com/t/using-perl-script-to-connect-to-xtradb/1836>\
**Category:** Other MySQL® Questions\
**Created:** [June 27, 2012, 3:34am UTC](https://forums.percona.com/t/using-perl-script-to-connect-to-xtradb/1836 "2012-06-27T03:34:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rei125](https://avatars.discourse-cdn.com/v4/letter/r/3da27b/32.png) [@rei125](https://forums.percona.com/u/rei125)\
**Post date:** [June 27, 2012, 3:34am UTC](https://forums.percona.com/t/using-perl-script-to-connect-to-xtradb/1836/1 "2012-06-27T03:34:01Z")

</div>

Hi,

I am trying to write a perl script to connect to xtradb (and retrieve datas later on).

When using MYSQL, we can write Perl as the following.

#!/usr/local/bin/perluse DBI;# to connect$dbh = DBI → connect (“DBI:mysql:$dbname:localhost”,$dbusername,$dbpassword)# to select$sql = “select \* from testtable”;$sth = $dbh-\>prepare($sql);$sth → execute()

In xtradb, we could use --default-files to specify where is our my.cnf  
Example:

mysql --defaults-file=/mydir/my.cnf -uroot -ppassword

Anyone knows how to imply this to the Perl script?  
Or any sample perl connection script?

Thank you.

---

<div class="post-metadata">

**Author:** ![xaprb](https://avatars.discourse-cdn.com/v4/letter/x/49beb7/32.png) [@xaprb](https://forums.percona.com/u/xaprb)\
**Post date:** [June 27, 2012, 9:15am UTC](https://forums.percona.com/t/using-perl-script-to-connect-to-xtradb/1836/2 "2012-06-27T09:15:50Z")

</div>

You can include the mysql\_read\_defaults\_file option in your connection string (the first option to DBI-\>connect() ). See the DBD::mysql perldoc for details on this and other options.
