How do you fix Perl when you get an error Can't connect to local MySQL server through socket
Posted by Support, Last modified by Support on 22 August 2011 11:56 AM
You can fix Perl when you get an error "Can't connect to local MySQL server through socket" by doing one of the following one at a time or a combination of them:


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

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

For further information please have a look at the docs here: http://search.cpan.org/~capttofu/DBD-mysql-4.013/lib/DBD/mysql.pm


Change your database server in your configuration file from localhost to 127.0.0.1
(96 vote(s))
Helpful
Not helpful

Comments (0)