How do I tell DBD::mysql where mysql.sock is?

爷,独闯天下 提交于 2019-12-05 04:20:29

You can specify the location of the socket in the connect method

my $dbh = DBI->connect("DBI:mysql:database=dbname;host=localhost;mysql_socket=/path/to/mysql.sock","someuser","somepassword", {'RaiseError' => 1});

For further information please have a look at the docs here

xyz
$dbh=DBI->connect("DBI:mysql:database=dbname;mysql_socket=/var/lib/mysql/mysql.sock;user=username;password=password");

You don't need to specify host since you're connecting to a socket file.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!