-
Notifications
You must be signed in to change notification settings - Fork 7
Connect to MySQL
yuki-kimoto edited this page Sep 4, 2012
·
1 revision
Connect to MySQL server by connect
method.
my $dbi = DBIx::Custom->connect(
dsn => "dbi:mysql:database=bookshop",
user => 'ken',
password => '!LFKD%$&',
option => {mysql_enable_utf8 => 1}
);
set dsn
to data source name, user
to user name, password
to password, and option
to DBI options. Return value is DBIx::Custom object.
mysql_enable_utf8
option set to 1
, Perl internal string is automatically converted to UTF-8 byte string.
Data source can contain host name and port number to connect remote MySQL server.
my $dbi = DBIx::Custom->connect(
dsn => "dbi:mysql:database=bookshop;host=somehost.com;port=3306",
user => 'ken',
password => '!LFKD%$&',
);