<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body text="#000099" bgcolor="#FFFFCC">
<div class="moz-cite-prefix">On 3/11/19 6:04 PM, <a class="moz-txt-link-abbreviated" href="mailto:macports@raf.org">macports@raf.org</a>
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:20190311220453.jn2bjml4p5nogfha@raf.org">
<pre class="moz-quote-pre" wrap="">MacPorts wrote:
</pre>
<blockquote type="cite">
<pre class="moz-quote-pre" wrap="">On 3/11/19 1:34 AM, Andrew Udvare wrote:
</pre>
<blockquote type="cite">
<blockquote type="cite">
<pre class="moz-quote-pre" wrap="">On 2019-03-11, at 00:10, MacPorts <a class="moz-txt-link-rfc2396E" href="mailto:macports@hyperbole-software.com"><macports@hyperbole-software.com></a> wrote:
I noticed that the socket in /var/mysql is called mysql.sock while the one in /opt/local/var/run/mysql5 is called mysqld.sock (note the 'd' between 'l' and '.').
I tried using
$ sudo ln -s /var/mysql/mysql.sock /opt/local/var/run/mysql5/mysqld.sock
for some reason that also didn't work.
Then I tried:
$ sudo ln -s /var/mysql/mysql.sock /opt/local/var/run/mysql5/mysql.sock
$ sudo mv /opt/local/var/run/mysql5/mysql.sock /opt/local/var/run/mysql5/mysqld.sock
this worked. I don't know why this worked and making the link directly didn't, but at least it's working now.
</pre>
</blockquote>
<pre class="moz-quote-pre" wrap="">I ran into a similar issue a long time ago with PHP. PHP has an option to control this setting at build time and it also has a runtime option in php.ini.
The DBI port should be doing the same. I don't think users should have to add things outside of the prefix, unmanaged by port.
</pre>
</blockquote>
<pre class="moz-quote-pre" wrap="">I thought creating a link from the socket file to where Perl expects to
find it was working. It's not.
What is working is to specify the path to the socket file with
"mysql_socket=/var/mysql/mysql.sock" in the dsn when I make the
connection, but, that makes the code specific to my machine, so I'd like
to find a better solution. Still looking.
Carl.
</pre>
</blockquote>
<pre class="moz-quote-pre" wrap="">
how about putting the dsn in a config file for your application
or getting it from an environment variable rather than having
it inside the application's code?
cheers,
raf
</pre>
</blockquote>
I have<br>
[client]<br>
socket=/var/mysql/mysql.sock<br>
<br>
[mysqld]<br>
socket=/var/mysql/mysql.sock<br>
<br>
in /etc/my.cnf and /opt/local/etc/mysql57/my.cnf. I've looked for
other config files and can't find any others that apply to MySQL.<br>
<br>
I set the environment variable
DBD_MYSQL_SOCKET=/var/mysql/mysql.sock.<br>
<br>
$dbh = DBI->connect($dsn, $db_user_id, $db_password)<br>
<br>
still says: Can't connect to local MySQL server through socket
'/opt/local/var/run/mysql57/mysqld.sock<br>
<br>
<br>
<br>
Thanks for the suggestions,<br>
Carl.<br>
<br>
<br>
<br>
</body>
</html>