DBI and sockets

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Don Stefani

    DBI and sockets

    I'm looking for a better way to fix my problem.

    I'm using Perl, DBI, DBD::mysql,
    I was getting this error...
    "Can't connect to local MySQL server through socket
    '/var/lib/mysql/mysql.sock' (2)"

    the default setting for looking for mysql.sock in either DBI or DBD is
    /var/lib/mysql/mysql.sock
    (at least on my install), yet the real location is /tmp/mysql.sock

    I never had a problem until I tried a simple CGI program.

    This fixed the problem by adding the mysql_socket attribute to my
    connection...
    $dbh =
    DBI->connect("DBI:m ysql:host=local host:mysql_sock et=/tmp/mysql.sock;data base=business". ..

    Do you know of a way to avoid adding this attribute to my connection string?

    Thanks,

    Don

  • Don Stefani

    #2
    Re: DBI and sockets

    Don Stefani wrote:[color=blue]
    > I'm looking for a better way to fix my problem.
    >
    > I'm using Perl, DBI, DBD::mysql,
    > I was getting this error...
    > "Can't connect to local MySQL server through socket
    > '/var/lib/mysql/mysql.sock' (2)"
    >
    > the default setting for looking for mysql.sock in either DBI or DBD is
    > /var/lib/mysql/mysql.sock
    > (at least on my install), yet the real location is /tmp/mysql.sock
    >
    > I never had a problem until I tried a simple CGI program.
    >
    > This fixed the problem by adding the mysql_socket attribute to my
    > connection...
    > $dbh =
    > DBI->connect("DBI:m ysql:host=local host:mysql_sock et=/tmp/mysql.sock;data base=business". ..
    >
    >
    > Do you know of a way to avoid adding this attribute to my connection
    > string?
    >
    > Thanks,
    >
    > Don
    >[/color]
    I also added a ln -s from /tmp/mysql.sock to /var/lib/mysql/

    But I'd sure like to fix this the right way..
    Thanks,

    Don

    Comment

    • Don Stefani

      #3
      Re: DBI and sockets

      Don Stefani wrote:[color=blue]
      > I'm looking for a better way to fix my problem.
      >
      > I'm using Perl, DBI, DBD::mysql,
      > I was getting this error...
      > "Can't connect to local MySQL server through socket
      > '/var/lib/mysql/mysql.sock' (2)"
      >
      > the default setting for looking for mysql.sock in either DBI or DBD is
      > /var/lib/mysql/mysql.sock
      > (at least on my install), yet the real location is /tmp/mysql.sock
      >
      > I never had a problem until I tried a simple CGI program.
      >
      > This fixed the problem by adding the mysql_socket attribute to my
      > connection...
      > $dbh =
      > DBI->connect("DBI:m ysql:host=local host:mysql_sock et=/tmp/mysql.sock;data base=business". ..
      >
      >
      > Do you know of a way to avoid adding this attribute to my connection
      > string?
      >
      > Thanks,
      >
      > Don
      >[/color]
      I also added a ln -s from /tmp/mysql.sock to /var/lib/mysql/

      But I'd sure like to fix this the right way..
      Thanks,

      Don

      Comment

      • Don Stefani

        #4
        Re: DBI and sockets

        Don Stefani wrote:[color=blue]
        > Don Stefani wrote:
        >[color=green]
        >> I'm looking for a better way to fix my problem.
        >>
        >> I'm using Perl, DBI, DBD::mysql,
        >> I was getting this error...
        >> "Can't connect to local MySQL server through socket
        >> '/var/lib/mysql/mysql.sock' (2)"
        >>
        >> the default setting for looking for mysql.sock in either DBI or DBD is
        >> /var/lib/mysql/mysql.sock
        >> (at least on my install), yet the real location is /tmp/mysql.sock
        >>
        >> I never had a problem until I tried a simple CGI program.
        >>
        >> This fixed the problem by adding the mysql_socket attribute to my
        >> connection...
        >> $dbh =
        >> DBI->connect("DBI:m ysql:host=local host:mysql_sock et=/tmp/mysql.sock;data base=business". ..
        >>
        >>
        >> Do you know of a way to avoid adding this attribute to my connection
        >> string?
        >>
        >> Thanks,
        >>
        >> Don
        >>[/color]
        > I also added a ln -s from /tmp/mysql.sock to /var/lib/mysql/
        >
        > But I'd sure like to fix this the right way..
        > Thanks,
        >
        > Don
        >[/color]
        OK, so I'm answering all of my own posts, sorry.

        I reinstalled both DBI and DBD::mysql by hand.
        I think I had used Yast (suse9) to install DBD originally.

        After removing the sym-link everything works fine.
        I guess I'll avoid the packages when it comes to Perl and MySQL.

        Thanks, I hope this helps someone else.

        Don

        Comment

        • Don Stefani

          #5
          Re: DBI and sockets

          Don Stefani wrote:[color=blue]
          > Don Stefani wrote:
          >[color=green]
          >> I'm looking for a better way to fix my problem.
          >>
          >> I'm using Perl, DBI, DBD::mysql,
          >> I was getting this error...
          >> "Can't connect to local MySQL server through socket
          >> '/var/lib/mysql/mysql.sock' (2)"
          >>
          >> the default setting for looking for mysql.sock in either DBI or DBD is
          >> /var/lib/mysql/mysql.sock
          >> (at least on my install), yet the real location is /tmp/mysql.sock
          >>
          >> I never had a problem until I tried a simple CGI program.
          >>
          >> This fixed the problem by adding the mysql_socket attribute to my
          >> connection...
          >> $dbh =
          >> DBI->connect("DBI:m ysql:host=local host:mysql_sock et=/tmp/mysql.sock;data base=business". ..
          >>
          >>
          >> Do you know of a way to avoid adding this attribute to my connection
          >> string?
          >>
          >> Thanks,
          >>
          >> Don
          >>[/color]
          > I also added a ln -s from /tmp/mysql.sock to /var/lib/mysql/
          >
          > But I'd sure like to fix this the right way..
          > Thanks,
          >
          > Don
          >[/color]
          OK, so I'm answering all of my own posts, sorry.

          I reinstalled both DBI and DBD::mysql by hand.
          I think I had used Yast (suse9) to install DBD originally.

          After removing the sym-link everything works fine.
          I guess I'll avoid the packages when it comes to Perl and MySQL.

          Thanks, I hope this helps someone else.

          Don

          Comment

          Working...