如何告诉 DBD::mysql mysql.sock 在哪里?
将 DBD::mysql 与 DBI 一起使用,尝试连接到数据库时出现以下错误。
DBI connect('database=mydb:host=localhost','someuser',...) failed: Can't connect
to local MySQL server through socket '/tmp/mysql.sock' (2) at ./myscript.pl line 97
是的,MySQL 已启动并正在运行。问题是 mysql.sock 不在 /tmp 中。
我知道 mysql.sock 的位置,并且目前已经对其进行了攻击,以便它可以正常工作,我创建了一个指向 mysql.sock 文件当前位置的软链接。我宁愿不更改 MySQL 配置,尽管这可能是最简单的事情。
有没有办法进入 DBD::mysql 并将其配置为在正确的位置查找 mysql.sock?
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',...) failed: Can't connect
to local MySQL server through socket '/tmp/mysql.sock' (2) at ./myscript.pl line 97
Yes MySQL is up and running. The problem is that mysql.sock is not in /tmp.
I know the location of mysql.sock and I currently have it hacked so that it works, I created a soft link to the current location of the mysql.sock file. I would rather not change the MySQL configuration, though this would probably be the easiest thing to do.
Is there a way to go into DBD::mysql and configure it to look for mysql.sock in the correct location?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以在 connect 方法中指定套接字的位置
有关更多信息,请查看文档 这里
You can specify the location of the socket in the connect method
For further information please have a look at the docs here
您不需要指定主机,因为您正在连接到套接字文件。
You don't need to specify host since you're connecting to a socket file.