A very quick entry this time. I was having problems getting Perl to use the DBI module with Mysql. I kept getting this error message:
Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’
Well, after doing quite a bit of googling I found the answer. My database is set up on a Apache server, which means the mysqld socket is located in a different place. To find out where it is located, you go into Mysql and run the following command:
Code:
show variables like 'socket%'; |
It seems that the location on my machine was /opt/lampp/var/mysql/mysqld.sock
so, I then changed my Data Source connect line in the Perl program to read:
Code:
$dsn = "DBI:mysql:$database:localhost:3306:mysql_socket=/opt/lampp/var/mysql/mysqld.sock"; |
It seems it’s a common stumbling block, so I hope this helps others to continue with their Perl programming.
Original post blogged on b2evolution.




Ningún usuario enviaron comentarios sobre " Quick Perl solution. "
Follow-up comment rss e enví un Trackback