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

前端 未结 2 1367
攒了一身酷
攒了一身酷 2021-02-20 10:23

Using DBD::mysql with DBI, I am getting the following error when attempting to connect to the database.

DBI connect(\'database=mydb:host=localhost\',\'someuser\'         


        
2条回答
  •  一生所求
    2021-02-20 10:42

    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

提交回复
热议问题