RE: mysqli connection problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

I've made some tests and now I suspect that what I see is a DB package bug.

I run the following script and it works fine:

<?php

$mysqli = new mysqli("localhost", "test1", "", "testdb");

/* check connection */ 
if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit();
}

printf("Host information: %s\n", $mysqli->host_info);

if ($result = $mysqli->query("SELECT * FROM contents")) {
    printf("Select returned  %d rows", $result->num_rows);

}

while ($row = mysqli_fetch_assoc($result)) {
    print_r($row);
}

/* close connection */
$mysqli->close();

?>

While trying to connect to the same db using PEAR::DB_DataObject (connection
string: mysqli://test1@localhost/testdb)

Still gives me this error
"Can't connect to local MySQL server through socket '' (111)"

> -----Original Message-----
> From: Martin Norland [mailto:martin.norland@xxxxxxxxxx]
> Sent: Tuesday, February 08, 2005 10:19 PM
> To: php-db@xxxxxxxxxxxxx
> Cc: 'MySQL General List'; 'PHP General List'
> Subject: Re:  mysqli connection problem
> 
> My intention of setting the reply-to was not to offend, or claim you
> were wrong - merely to move the discussion to the list I felt (and still
> feel - as I've done it again) is most appropriate for the question.
> 
> anyway, back to the task at hand
> 
> ( first: I'm assuming you restarted apache after changing your php.ini -
> otherwise, that's your problem. )
> 
> Whatever the case, the error message clearly shows that it is not
> reading the value, however it's set - because the error is still showing
> a blank string for the socket.  If it were a permissions problem with
> the socket, you wouldn't be getting that exact error - at the very
> least, it would still show the correct socket path.  More likely, it
> would also error with a "cannot open socket" or equivalent.
> 
> You may wish to examine ini_get(), ini_get_all(), phpinfo(), or
> php_ini_scanned_files(), to verify if it is set, or to see if it's being
> overwritten somewhere.
> 
> Cheers,
> 
> Denis Gerasimov wrote:
> > Didn't help me. MySQL socket does exist - /var/lib/mysql/mysql.sock
> (default
> > location).
> > mysqli.default_socket is NOT set to null but to this value (manually, as
> you
> > advised)
> >
> > Again,
> >
> > 1. Connection to localhost still fails with message "Can't connect to
> local
> > MySQL server through socket '' (111)"
> >
> > 2. Connection to server's domain name fails too (!) with message "Access
> > denied for user 'user'@'example.com' (using password: YES)"
> >
> > 3. Connection to localhost through mysql shows the following config
> >
> > mysql> status
> > --------------
> > mysql  Ver 14.7 Distrib 4.1.9, for pc-linux-gnu (i686)
> >
> > Connection id:          42
> > Current database:
> > Current user:           root@localhost
> > SSL:                    Not in use
> > Current pager:          stdout
> > Using outfile:          ''
> > Using delimiter:        ;
> > Server version:         4.1.9-standard
> > Protocol version:       10
> > Connection:             Localhost via UNIX socket
> > Server characterset:    latin1
> > Db     characterset:    latin1
> > Client characterset:    latin1
> > Conn.  characterset:    latin1
> > UNIX socket:            /var/lib/mysql/mysql.sock
> > Uptime:                 1 day 3 hours 1 min 7 sec
> >
> > Threads: 3  Questions: 272  Slow queries: 0  Opens: 64  Flush tables: 1
> > Open tables: 26  Queries per second avg: 0.003
> > --------------
> >
> > Seems to be a security issue... Any more ideas about these symptoms?
> >
> >
> >>-----
> >>I can't see any reason why you wouldn't be able to use the same socket -
> >>you're connecting to the same exact server, it's just a path.  You
> >>should be perfectly able to set your mysqli.default_socket to the same
> >>as the mysql.default_socket.  I can't tell you what the default for your
> >>system is, but there are php functions to get configuration options, if
> >>you don't have it in any obvious places.
> >>
> >>Cheers,
> >>--
> >>- Martin Norland, Database / Web Developer, International Outreach x3257
> >>The opinion(s) contained within this email do not necessarily represent
> >>those of St. Jude Children's Research Hospital.
> >>
> >>
> >>
> >>--
> >>MySQL General Mailing List
> >>For list archives: http://lists.mysql.com/mysql
> >>To unsubscribe:
> >>http://lists.mysql.com/mysql?unsub=denis.gerasimov@xxxxxxxx
> >
> >
> 
> 
> --
> - Martin Norland, Database / Web Developer, International Outreach x3257
> The opinion(s) contained within this email do not necessarily represent
> those of St. Jude Children's Research Hospital.
> 
> 
> 
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:
> http://lists.mysql.com/mysql?unsub=denis.gerasimov@xxxxxxxx

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux