DBI connect() failed: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'

错误代码如下:

DBI connect('database=prcasys;host=localhost','prcasys',...) failed: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) at ./installdb line 41

解决办法:

进入perl脚本,在DBI->connect函数内加入正确的sock位置,比如:

DBI->connect("DBI:mysql:database=$database;mysql_socket=/usr/local/mysql/data/mysql.sock;host=$hostname",
        $username, $password,

解决之。

原文地址:https://www.cnblogs.com/church/p/2596651.html