http://bugzilla.novell.com/show_bug.cgi?id=499021
Summary: PHP PDO::mysql always connects to invalid socket Classification: openSUSE Product: openSUSE 11.1 Version: Final Platform: x86-64 OS/Version: openSUSE 11.1 Status: NEW Severity: Normal Priority: P5 - None Component: Apache AssignedTo: bnc-team-apache@forge.provo.novell.com ReportedBy: jo@feuersee.de QAContact: qa@suse.de Found By: ---
User-Agent: Mozilla/5.0 (compatible; Konqueror/3.5; Linux) KHTML/3.5.10 (like Gecko) SUSE
Using the PHP modules from the repo http://download.opensuse.org/repositories/server:/php/openSUSE_11.1/x86_64/
The PDO::mysql always tries to connect via UNIX socket /tmp/mysql.sock (unless another socket is specified). This socket does not exist due to MySQL configuration. Further, connecting via TCP with PDO using MySQL backend is not possible.
Reproducible: Always
Steps to Reproduce: $dsn = 'mysql:dbname=test'; $db = new PDO($dsn, $user, $passwd); Actual Results: Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)' in /home/wwwusers/preview.food-detektiv.de/htdocs/admin/PDO.php:13 Stack trace: #0 /home/wwwusers/preview.food-detektiv.de/htdocs/admin/PDO.php(13): PDO->__construct('mysql:localhost...', 'sqldrwatson', 'Karera1') #1 {main} thrown in /home/wwwusers/preview.food-detektiv.de/htdocs/admin/PDO.php on line 13
Expected Results: a database connection
With openSUSE 11.1 the socket for MySQL is /var/lib/mysql/mysql.sock
Specifying this socket as DSN works, however it is impossible to connect via PDO::mysql and TCP (eg. to another host)
Defaults for PDO::mysql should be: - connect via TCP - hostname is localhost
http://bugzilla.novell.com/show_bug.cgi?id=499021
User aaatoja@o2.pl added comment http://bugzilla.novell.com/show_bug.cgi?id=499021#c1
Marek Ruszkowski aaatoja@o2.pl changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |aaatoja@o2.pl Platform|x86-64 |32bit
--- Comment #1 from Marek Ruszkowski aaatoja@o2.pl 2009-08-06 04:46:02 MDT --- I think I have similar problem on Opensuse 11.0. I have moved mysql from /var/lib/mysql to /srv/mysql, modified all configs (/etc/my.cnf, /etc/init.d/mysql), socket is created under /srv/mysql/ but when trying to connect with PHP (tried mysql, mysqli, pdo_mysql) I'm getting message "Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'".
https://bugzilla.novell.com/show_bug.cgi?id=499021
https://bugzilla.novell.com/show_bug.cgi?id=499021#c2
Bruno Friedmann bruno@ioda-net.ch changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |pothibo@gmail.com
--- Comment #2 from Bruno Friedmann bruno@ioda-net.ch 2011-04-02 08:15:14 UTC --- *** Bug 505711 has been marked as a duplicate of this bug. *** http://bugzilla.novell.com/show_bug.cgi?id=505711
https://bugzilla.novell.com/show_bug.cgi?id=499021
https://bugzilla.novell.com/show_bug.cgi?id=499021#c3
Bruno Friedmann bruno@ioda-net.ch changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |bruno@ioda-net.ch Resolution| |FIXED
--- Comment #3 from Bruno Friedmann bruno@ioda-net.ch 2011-04-02 08:19:48 UTC --- openSUSE bug squash day (http://en.opensuse.org/openSUSE:Open-Bugs-Day) This has been fixed later, by upstream and packaging.
Now mysql start and run in /var/run/mysql, and rights are setted to permit any pgm to access the socket.
Can be tested with
<?php
$dsn = 'mysql:dbname=mysql'; $user= 'test'; $passwd = 'test'; try{ $dbh = new PDO($dsn, $user, $passwd); foreach($dbh->query('SELECT Host,Db from db') as $row) { print_r($row) . "<br />" . PHP_EOL; } $dbh= null; }catch (Exception $e){ echo "Error : " .$e->getTrace().PHP_EOL;
}
fixed in 11.2