Quick Perl solution.
By admin on May 18, 2009 | In Daily Commute - Standard hints/tips, Highway Maintenance - DBA stuff | Send feedback »
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.
No feedback yet
Leave a comment
| « Date Issues importing from an Excel csv file | More on Variables » |