DBI Mysql socket problems

I'm trying to get a simple perl script to connect to a MySQL database
via DBI:DBI.  When I attempt to connect however I get the following
error:

DBI->connect(albatross) failed: Can't connect to local MySQL server
through socket '/tmp/mysql.sock' (111) at ./test.pl line 71
Can't connect to local MySQL server through socket '/tmp/mysql.sock'
(111) at ./test.pl line 71.

  What confuses me is that /tmp/mysql.sock is NOT the socket that I have
mysqld running on.  When I do a 'mysqladmin variables' it shows that the
socket is /var/lib/mysql/mysql.sock
  Why is the DBI interface attempted to connect to a non-existant socket
when the actual daemon specifies the correct one?  Any help would be
greatly appriciated.

  Jason
0
jscharlach
6/5/2001 7:28:53 PM
perl.dbi.users 11100 articles. 1 followers. Follow

4 Replies
793 Views

Similar Articles

[PageSpeed] 10

Are you running the server on a different host?  What does your connect
string look like?

Jason Scharlach wrote:
> 
> I'm trying to get a simple perl script to connect to a MySQL database
> via DBI:DBI.  When I attempt to connect however I get the following
> error:
> 
> DBI->connect(albatross) failed: Can't connect to local MySQL server
> through socket '/tmp/mysql.sock' (111) at ./test.pl line 71
> Can't connect to local MySQL server through socket '/tmp/mysql.sock'
> (111) at ./test.pl line 71.
> 
>   What confuses me is that /tmp/mysql.sock is NOT the socket that I have
> mysqld running on.  When I do a 'mysqladmin variables' it shows that the
> socket is /var/lib/mysql/mysql.sock
>   Why is the DBI interface attempted to connect to a non-existant socket
> when the actual daemon specifies the correct one?  Any help would be
> greatly appriciated.
> 
>   Jason
0
paul
6/5/2001 7:59:02 PM
I'm running the test app on the same host as the MySQL server.  My
connect string looks like so:

    $dbh = DBI->connect( "DBI:mysql:albatross", "", "" ) or
            die $DBI::errstr;

  Jason

Paul Lukins wrote:
> 
> Are you running the server on a different host?  What does your connect
> string look like?
> 
> Jason Scharlach wrote:
> >
> > I'm trying to get a simple perl script to connect to a MySQL database
> > via DBI:DBI.  When I attempt to connect however I get the following
> > error:
> >
> > DBI->connect(albatross) failed: Can't connect to local MySQL server
> > through socket '/tmp/mysql.sock' (111) at ./test.pl line 71
> > Can't connect to local MySQL server through socket '/tmp/mysql.sock'
> > (111) at ./test.pl line 71.
> >
> >   What confuses me is that /tmp/mysql.sock is NOT the socket that I have
> > mysqld running on.  When I do a 'mysqladmin variables' it shows that the
> > socket is /var/lib/mysql/mysql.sock
> >   Why is the DBI interface attempted to connect to a non-existant socket
> > when the actual daemon specifies the correct one?  Any help would be
> > greatly appriciated.
> >
> >   Jason
0
jscharlach
6/5/2001 9:00:48 PM
You could try using the mysql_read_default_file class method to specify
a .cnf file (to paraphrase the docs):

$dsn = "DBI:mysql:albatross;mysql_read_default_file=/home/joe/my.cnf";
$dbh = DBI->connect($dsn, $user, $password) or die $DBI::errstr;

Or you could try specifying the socket directly using mysql_socket (also
paraphrasing the docs):

$dsn = "DBI:mysql:albatross;mysql_socket=/var/lib/mysql/mysql.sock";
$dbh = DBI->connect($dsn, $user, $password) or die $DBI::errstr;

Paul.

Jason Scharlach wrote:
> 
> I'm running the test app on the same host as the MySQL server.  My
> connect string looks like so:
> 
>     $dbh = DBI->connect( "DBI:mysql:albatross", "", "" ) or
>             die $DBI::errstr;
> 
>   Jason
> 
> Paul Lukins wrote:
> >
> > Are you running the server on a different host?  What does your connect
> > string look like?
> >
> > Jason Scharlach wrote:
> > >
> > > I'm trying to get a simple perl script to connect to a MySQL database
> > > via DBI:DBI.  When I attempt to connect however I get the following
> > > error:
> > >
> > > DBI->connect(albatross) failed: Can't connect to local MySQL server
> > > through socket '/tmp/mysql.sock' (111) at ./test.pl line 71
> > > Can't connect to local MySQL server through socket '/tmp/mysql.sock'
> > > (111) at ./test.pl line 71.
> > >
> > >   What confuses me is that /tmp/mysql.sock is NOT the socket that I have
> > > mysqld running on.  When I do a 'mysqladmin variables' it shows that the
> > > socket is /var/lib/mysql/mysql.sock
> > >   Why is the DBI interface attempted to connect to a non-existant socket
> > > when the actual daemon specifies the correct one?  Any help would be
> > > greatly appriciated.
> > >
> > >   Jason
0
paul
6/6/2001 2:13:04 AM
Here's a hunch:
You upgraded MySQL recently.

Here's why I'm thinking this. The location of mysql's socket file is a
compile time option. You installed mysql, then installed DBD::mysql (or
Msql-Mysql-modules...). When the DBD drivers are compiled against the
mysql libraries, they get the location of the socket file. Installing a
new version of MySQL updates the mysql libraries (with a brand spanking
new socket file somewhere else, I don't know why they move it) confuses
DBD, because DBD is convinced it knows where the socket file is to be
found.

Solutions are:
* Reinstall DBD::mysql,
* recompile MySQL and specify the socket file location,
* start mysqld with a runtime option to put the socket file somewhere
else,
* specify the socket location in your dsn (
DBI::connect("DBI:mysql:mysql_socket=/var/lib/mysql/mysql.sock;database=...","","")

The last one is your only option if you don't have root access.

Peace,
Jamie



Jason Scharlach wrote:
> 
> I'm trying to get a simple perl script to connect to a MySQL database
> via DBI:DBI.  When I attempt to connect however I get the following
> error:
> 
> DBI->connect(albatross) failed: Can't connect to local MySQL server
> through socket '/tmp/mysql.sock' (111) at ./test.pl line 71
> Can't connect to local MySQL server through socket '/tmp/mysql.sock'
> (111) at ./test.pl line 71.
> 
>   What confuses me is that /tmp/mysql.sock is NOT the socket that I have
> mysqld running on.  When I do a 'mysqladmin variables' it shows that the
> socket is /var/lib/mysql/mysql.sock
>   Why is the DBI interface attempted to connect to a non-existant socket
> when the actual daemon specifies the correct one?  Any help would be
> greatly appriciated.
> 
>   Jason

-- 
-[sent-from-the-office]--------------------------------------------
| Programmer                 |                                    |
| HBE Software, Inc.         | email: jamie@hbesoftware.com       |
| http://www.hbesoftware.com | AIM  : Reng8tak                    |
| (514) 876-7881 x259        | PGP  : http://people.hbe.ca/~jamie |
-------------------------------------------------------------------
      perl -le '@t=(32,73,84);print ref(sub{}).pack(c4,@t);'

0
jamie
6/6/2001 1:08:44 PM
Reply:

Similar Artilces:

mysql through dbi problem
Howdy, I'm having some serious trouble. I'm running a query and getting the data, but having problems using that data in the next query. Thus: #first query $sth = $dbh->prepare ( "select distinct hmac, hport, hsid from netdata_history" ); $sth->execute( ); $sth->bind_columns ( undef, \$hmac, \$hport, \$hsid ); while ( ( $hmac, $hport, $hsid ) = $sth->fetchrow_array ) { push @hsid, $hsid; push @hport, $hport; push @hmac, $hmac; } $sth->finish(); #now cycle through result set in next query ...

MySQL DBI Problem.
I have a Perl cron job that reads emails off a pop server once a minute and stores them in a MySQL database on a remote machine. I logged onto the MySQL server today and performed a select * from messages where received > 20030322000000; Zero records were returned. I did some more investigating and discovered that no records had been inserted in 4 days. I performed a "flush tables" (Someone suggested it, I don't know what it does) command and the records were still missing, but suddenly the Perl cron job on the other machine, without any changes, was po...

DBI and mySQL problems
Hi, First, sorry for the wrap on the lines below, and my apologies if this message has been seen already- I appear to be having problems sending to nntp.perl.org (I didn't realise you had to be subscribed to beginners@perl.org to send). I am trying to insert some values into a mySQL database, all of the scalars below have a value(none are undefined). I keep getting errors similar to the one below and despite being instructed to read the mySQL manual, I cannot find anything that relates to the problem I'm experiencing. Is the problem with my Perl (likely), or mySQL? C...

MySQL DBI problem
--Apple-Mail-2--747237304 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed I am trying to read email off a mail server using perl, parse it, and then store the fields in a MySQL database. I managed to write the first two parts in a couple of days, but now I've spent two weeks trying to get the fields into a the "Messages" database. I have got several fields to go in and then I ran the same script the next day with no changes and it wasn't working any longer. I have run into about every problem imaginable and I c...

Severe DBI-Oracle DBI-ODBC Problem
--part1_7d.460bcdd0.2d55394f_boundary Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Emergency assistance - This should never be so difficult! ? All day working switching between the 2 activestate binary installation versions from activestate site & DBD/DBI versions.  No headway connecting to oracle via perl DBI.  Windows 2k - new system. Everything newly installed for this PC.  I do not see an activestate 6.xx binary at the activestate site ?   Uninterested...

[perl5-dbi/DBI-Test] a2d1b2: create separate tests for DBI and DBI::Mock ...
----==_mimepart_51f946a54bb1b_2af891bd4c100430 Date: Wed, 31 Jul 2013 10:17:25 -0700 Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-ID: <51f946a54c721_2af891bd4c100582@hookshot-fe3-pe1-prd.aws.github.net.mail> Branch: refs/heads/master Home: https://github.com/perl5-dbi/DBI-Test Commit: a2d1b22d134be0ca353e0f0b312fb14da24c798e https://github.com/perl5-dbi/DBI-Test/commit/a2d1b22d134be0ca353e0f0b312fb14da24c798e Author: Jens Rehsack <sno@netbsd.org> Date: 2013-07-31 (Wed, 31 Jul 2013) Changed ...

POSSIBLE BUG IN Win32 DBI INSTALL MODULE: DBI "prepare" no work FW: List 'dbi-users' closed to public posts
I have ActiveState Win32perl running. I installed fresh DBI, DBD, etc. from perl ppm.pl> prompt. But prepare( ) doesn't work (see below). perldoc DBI/DBD/DBI-FAQ are not useful since they assume it works. Any hints? Art www.mp3.com/ArthurSulit Classical Artist recently charted above Madonna -----Original Message----- From: Art Sulit [mailto:art@prs.net] Sent: Saturday, January 20, 2001 1:51 PM To: Webmaster@ActiveState.com Subject: POSSIBLE BUG IN YOUR DBI INSTALL MODULE: DBI "prepare" no work Hello, THERE IS A POSSIBLE BUG IN YOUR DBI INSTALL M...

timestamp problem with mysql and dbi
I have a simple table as follow: mysql> describe mytest1; +--------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +--------+--------------+------+-----+---------+-------+ | mytime | timestamp(6) | YES | | NULL | | | abc | varchar(8) | YES | | NULL | | +--------+--------------+------+-----+---------+-------+ if I insert record by perl script with statement like this: my $sth = $dbh->prepare("insert into mytest1 values (\"011011\",\"test\")") or die "Can&...

Problem with DBI and MySQL Installation??
Hi, I have installed DBI and the DBD for MySql. I can't remember it very well, but I think I got some error messages when doing 'make test' during the installation of DBD. Now, I can use DBI and when asking it for the available drivers, the driver for my sql appears in the list. However, when trying to connect to a mysql database I get the following message: ld.so.1: /opt/perl5.6.1/bin/perl: fatal: relocation error: file /opt/perl5.6.1/lib/site_perl/5.6.1/sun4-solaris/auto/DBD/mysql/mysql.so: symbol mysql_init: referenced symbol not found Killed Any id...

DBI installation problem with DBI 1.20 on linux
--0-1423006610-1009486823=:14494 Content-Type: TEXT/PLAIN; charset=US-ASCII My setup: linux (2.4.10) perl 5.6.1 (output of perl -V attached) Perl works fine (insofar as I've tested it with a few scripts), and I originally tried to install DBI from CPAN: perl -MCPAN -e shell shell%> install DBI but it didn't take; I can't remember the errors. Then I downloaded the source (DBI-1.20.tar.gz) and tried to compile it, after of course reading the README's and looking at the documentation. 'perl Makefile.PL' and 'make' went ok, but 'ma...

[perl5-dbi/dbi]
----==_mimepart_515e8f3785207_523740c1306299e Date: Fri, 05 Apr 2013 01:45:43 -0700 Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-ID: <515e8f3787c27_523740c13063084@hookshot-fe5-pe1-prd.aws.github.net.mail> Branch: refs/heads/trunk Home: https://github.com/perl5-dbi/dbi ----==_mimepart_515e8f3785207_523740c1306299e-- ...

MySQL DBI on Windows problem
Hi, I'm having a problem on Windows 2k where I have a pair of scripts where the parent forks off a few processes (a second perl script) which does some database input for a period of time, and then returns to the parent. Upon the return to the parent however, I can no longer do a $sth->execute() call. When I attempt to do so, it hangs and I get no error messages. Trying to run the same scripts on Windows ME with the same perl installation I get the following error in a dialog box: Perl has caused an error in MSVCRT.DLL. Perl will now close. That file contains the run...

Still having problems with DBI and MySQL.
I upgraded to MySql v 3.23.47, DBI-1.18, Data-ShowTable-3.3 all of which compiled with out any problems. BUT when trying to compile Msql-Mysql-modules-1.2216. I am getting the same error as I got when I ran my perl test script last time: [localhost:~dwalker/src/MySQL/Msql-Mysql-modules-1.2216] root# perl Makefile.PL --debug dyld: perl Undefined symbols: _mysql_affected_rows _mysql_close _mysql_create_db ..... The database is running fine and I even managed to figure out how to back up and restore my little test database while upgrading. I am wandering if I should up...

DBI/ Mysql DBD problem
I am having trouble setting up a working DBI/ Mysql DBD installation. I get the following error on all of my test scripts: ld.so.1: /usr/bin/perl: fatal: relocation error: file /usr/local/lib/perl5/site_perl/5.6.1/sun4-solaris/auto/DBD/mysql/mysql.so: symbol mysql_init: referenced symbol not found I cannot find a solution to this problem on any FAQ's, so if you know how I can solve this one then please let me know. Thanks! James --------------------------------------------------------------- James Dove Web Developer jd@niss.ac.uk ...

Web resources about - DBI Mysql socket problems - perl.dbi.users

Is–ought problem - Wikipedia, the free encyclopedia
The is–ought problem in meta-ethics as articulated by Scottish philosopher and historian David Hume (1711–76) is that many writers make claims ...

2016 BMW M3 and M4 recalled for driveshaft problem
... Recalls , Coupe , Sedan , Performance BMW will recall just 42 examples of the 2016 M3 and M4 in the US to check for a possible driveshaft problem. ...

Problem with metrics and referee directions
Vox has a brief little informer on the relative risk of injury in high school sports. I think it is useful, but reading the definition of injury ...

Microsoft has an emoji problem
Microsoft increasingly has an emoji problem as the company's Windows 10 operating system lacks the latest set of characters. Emoji are, essentially, ...

The junk problem is bigger than oil
Some have written off the high-yield concerns as a mere effect of crude oil's slide. But that analysis appears to be badly off base.

Social media addiction is a bigger problem than you think
Social networks are massively addictive. Most people I know check and interact on social sites constantly throughout the day. And they have no ...

Problems At Snapfish Lead To Pre-Christmas Photo Scramble, Angry Customers
... reps end chats with customers before the customer is done speaking with them? Why did the customer service rep tell me there was a problem with ...

Facebook is finally fixing its ‘real name’ problem
After some controversies and embarrassing missteps, social-media giant Facebook is trying to introduce tools to let its users go by the names ...

Poll: Americans Have 99 Problems, And Terrorism Is No. 1
The number shot up from just 3 percent to 16 percent from November to December

Culture: The observer bias problem, and why you should care
... the same type of mistakes in drawing conclusions about what we observe with Islamic fundamentalism. As I wrote here , I believe that the problem ...

Resources last updated: 12/16/2015 4:45:31 AM