#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Location
    London
    Posts
    2
    Rep Power
    0
    All,

    Firstly, this is my first post to this group, so thanks in advance. I have searched the archive for an answer with success.

    I am trying to connect to a MySQL database from Perl, Everything works fine when I run the script locally, but as soon as I try and run the script through a server I get the follow error message:

    - Can't create IP socket (10106)

    From the DBI module. I can guess at what it means, but have no idea how to resolve it. Any help would be greatly appreciated.

    Cheers,

    Matt.
  2. #2
  3. No Profile Picture
    Carpe Diem
    Guest
    Devshed Newbie (0 - 499 posts)
    Hi

    The basic script I use is as follows :-

    #!/usr/bin/perl

    use DBI;

    $db = "test";
    $sock = "/tmp/mysql.sock";
    $user = "user";
    $pass = "password";
    $dsn = "DBI:mysql:$db;mysql_socket=$sock";

    $dbh = DBI->connect($dsn,$user,$pass);
    $sth = $dbh->prepare("SELECT * FROM Test");
    $sth->execute();
    while (my $ref = $sth->fetchrow_hashref()) {
    print "ID = $ref->{'ID'}, Name = $ref->{'Name'}n";
    }
    $sth->finish();
    $dbh->disconnect();

    ###########

    I tend to connect via the unix socket rather then an IP address style connection (Only works locally)

    Regards
    Darren http://www.php4hosting.com/ $ http://www.php4hosting.co.uk/

Similar Threads

  1. Need advice designing a usage tracking database (MySQL)
    By Randolpho in forum Database Management
    Replies: 0
    Last Post: February 13th, 2004, 04:11 PM
  2. Replies: 3
    Last Post: February 11th, 2004, 08:30 AM
  3. Replies: 14
    Last Post: February 8th, 2004, 01:28 PM
  4. Accessing a Mysql Database on a different host.
    By tekgen in forum MySQL Help
    Replies: 2
    Last Post: February 1st, 2004, 06:54 PM
  5. Replies: 0
    Last Post: January 31st, 2004, 02:15 AM

IMN logo majestic logo threadwatch logo seochat tools logo