Bug #18891 | Socket file is empty | ||
---|---|---|---|
Submitted: | 7 Apr 2006 16:07 | Modified: | 19 Oct 2006 11:07 |
Reporter: | Peter Laursen (Basic Quality Contributor) | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server | Severity: | S2 (Serious) |
Version: | 5.0.22, 5.0.19 | OS: | Linux (SuSE Linux 10) |
Assigned to: | CPU Architecture: | Any |
[7 Apr 2006 16:07]
Peter Laursen
[7 Apr 2006 19:08]
Peter Laursen
I just saw that 5.0.20 was available from FTP-mirrors. I tried to install the (dynamically linked) glibc23 RPM build this time. Same situation as before. Server runs fine, but an empty socket file!
[8 Apr 2006 21:06]
Ryan Schmidt
On my PowerBook G4 with Mac OS X 10.4.6 and MySQL 5.0.19, /tmp/mysql.sock also shows up as zero bytes in the directory listing, but connecting to this socket works fine; seems like it's supposed to be that way. So unless you know for sure that sockets are supposed to show up differently in directory listings on your OS, I don't think that's the cause of your connection difficulties...
[9 Apr 2006 17:48]
Peter Laursen
Thanks for your comment! Maybe the file is supporsed to be empty. I didn't know. But must admit then that I don't understand what an empty file can do ... the problem that I experiece occurs with various PHP based software such as phpMyAdmin and SQLyog Client when connectiong with HTTP-tunnel. If I specify 'localhost' as the host some error messages occur. See attached examples. if I specify '127.0.0.1' form SQLyog or edit the phpMdAdmin config file they connect. PHP docs ( http://www.php.net/manual/en/function.mysql-connect.php ) say: "Note: Whenever you specify "localhost" or "localhost:port" as server, the MySQL client library will override this and try to connect to a local socket (named pipe on Windows). If you want to use TCP/IP, use "127.0.0.1" instead of "localhost". If the MySQL client library tries to connect to the wrong local socket, you should set the correct path as mysql.default_host string in your PHP configuration and leave the server field blank."
[9 Apr 2006 17:49]
Peter Laursen
phpAdmin (Danish) err.msg.
Attachment: admin.jpg (image/jpeg, text), 31.22 KiB.
[9 Apr 2006 17:49]
Peter Laursen
SQLyog err.msg. with HTTP-tunnel
Attachment: yog.jpg (image/jpeg, text), 24.25 KiB.
[10 Apr 2006 11:34]
Valeriy Kravchuk
Thank you for a problem report. Size 0 for *.sock file is normal. Please, send the netstat -a | grep mysql rpm -q -a | grep -i mysql commands results.
[10 Apr 2006 18:58]
Peter Laursen
Copied from a bash shell: peter@metusalinux:~> netstat -a | grep mysql tcp 0 0 *:mysql *:* LISTEN unix 2 [ ACC ] STREAM LISTENING 12958 /var/lib/mysql/mysql.sock peter@metusalinux:~> rpm -q -a | grep -i mysql mysql-shared-4.1.13-3 mysql-connector-odbc-3.51.12-1 php4-mysql-4.4.0-6 apache2-mod_auth_mysql-2.8.1-5 MySQL-Max-5.0.20-0.glibc23 php5-mysqli-5.0.4-9 MySQL-client-5.0.20-0.glibc23 perl-DBD-mysql-3.0002-2 mysql-administrator-1.0.22a-2 qt3-mysql-3.3.4-28 mysql-connector-java-3.1.8-3 mysql-query-browser-1.1.12-2 MySQL-server-5.0.20-0.glibc23 rekall-mysql-2.2.1-11 postfix-mysql-2.2.5-5 php5-mysql-5.0.4-9 peter@metusalinux:~>
[23 Apr 2006 3:38]
Peter Laursen
No change with MySQL verseion 5.0.20a Files installed: MySQL-server-5.0.20a-0.glibc23.i386.rpm MySQL-Max-5.0.20a-0.glibc23.i386.rpm MySQL-shared-5.0.20a-0.glibc23.i386.rpm MySQL-client-5.0.20a-0.glibc23.i386.rpm
[23 Apr 2006 10:29]
Peter Laursen
Some additional info you might find useful. I am experimenting with OpenSuSE 10.1 on another computer. I just tried starting MySQL here for the first time. Te distribution includes MySQL 5.0.18, but it was far from 'ready for use'. It simply would not start. Following and adapting instructions here http://dev.mysql.com/doc/refman/5.0/en/installing-binary.html (CHOWNing and CHGRPing) I got it started with the 'mysqld_safe' command/script. But it displayed the message 'Ukendt vært' - that is Danish for 'Unknown host' - and told me that I would not be able to use hostnames, only IP's. Could that be a related problem? But actually I was able to connect from third party client SQLyog running on WINE with 'localhost' as the host. This client connect using TCP (does not support socket). I also could connect from MySQL commandline client, create a user from it a process some GRANT statements. Next I attempted installing generic RPMs from MySQL FTPs, but neither the statically or dynamically generic RPMs would install at all. 'parsing complete' it displayed .. and nothing more happened. So no success with that experiment ...
[23 Apr 2006 11:49]
Peter Laursen
Now I got Apache and PHP configured on that computer running SuSE 10.1. And with the MySQL 5.0.18 that came with the distribution I CAN connect through socket (from phpMyAdmin and SQLyog-HTTP-tunnel) As I installed and configured phpMyAdmin myself (did not use the package that came with the distribution) I am 110% sure that it connects through socket!
[25 Apr 2006 19:19]
Peter Laursen
Same situation with MySQL 5.1.9 (glic23) and SuSE 10.0: no socket connection.
[15 May 2006 21:35]
Valeriy Kravchuk
Please, send the results of: select user, host from mysql.user; from your "problematic" instances.
[15 May 2006 22:33]
Peter Laursen
very simple: select user, host from mysql.user; /* returns: user host ------ ----------- root % root localhost root metusalinux */ I have only one 'problematic instance (a SuSE 10.0). Currently it is installed with MySQL 5.0.21 (glibc23 RPM). But I have tried 5.0.19, 5.0.20 and 5.1.9 as well - both glibc23 RPM's and statically linked RPM's. I have wondered if I should try a Source RPM set? (I have the necessary dev. tools installed)
[15 May 2006 22:37]
Peter Laursen
I think that 'metusalinux' is the netbios identity of SAMBA running on that machine. But I really don't remember all details here. Better you ask questions!
[25 May 2006 10:11]
Tonci Grgin
Hi Peter. When you start MySQL server does the mysql.sock file appear in /tmp directory?
[25 May 2006 10:45]
Peter Laursen
No such file in /tmp ! Not a hidden file either! Now, I cannot tell if it is created and deleted shortly after. Was that what you meant? MySQL runs as a service and starts before user login. That is all configured by the RPM's that way. When logging on as 'root' and navigating to /tmp the file is not there. And MySQL 5.0.21 running. Does that answer your question?
[26 May 2006 6:08]
Tonci Grgin
Hi Peter. Sometimes when you mess up folder / file privileges on your Suse 10 system (like I did :)), mysqld uses /tmp folder for socket file since it's available to all, but this is not the case here obviously.
[26 May 2006 14:17]
Peter Laursen
sure that could easily happen ... I do not think I did anything like that ... The only special thing I did was installing these drivers: http://www.ntfs-linux.com/ and editing the FSTAB-file for controlling Linux Users' acces to NTFS drives (some only for root some for me personally and some for all). Ecept for that I have only installed RPM packages and a few simple programs without dependencies (and all in my own personal folder tree). I could easily take those file system drivers away, I you think? The system has had several kernel-updates (as late as yesterday) but never reported any problems with that . I have a lot of programs installed and all are fully updated from SuSE Live-update. I also can create/restore an image of the Linux partition in 15 minutes. So I can let you have SSH-access (also with graphical windowmanager like KDE - and with root privilege) anytime you like. You won't need to bother about destroying things ... And there are no personal data of any kind in this Linux. Basically it is used for testing MySQL client software and for learning. Now . is this problem not reproducable on similar systems? I did not hear the word 'confirmed' ... ?
[8 Jun 2006 16:41]
Valeriy Kravchuk
As I understood, your socket file is /var/lib/mysql/mysql.sock, not in /tmp. Please, try to connect as root with mysql command line client, and provide --socket=/var/lib/mysql/mysql.sock option, like this: mysql -uroot -p --socket=/var/lib/mysql/mysql.sock Inform about the results.
[8 Jun 2006 21:50]
Peter Laursen
Commana-line client connects through socket like: metusalinux:/usr/bin # mysql -uroot -p --socket=/var/lib/mysql/mysql.sock Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 5 to server version: 5.0.22-max Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> Currently the MySQL version intalled is 5.0.22 (server and clients) PHP still does does connect with 'host' specified as 'localhost'.
[9 Jun 2006 10:51]
Valeriy Kravchuk
So, socket file is created and it "works". Please, send small PHP script that demonstrate the behaviour you described.
[9 Jun 2006 23:29]
Peter Laursen
I hope this is small enough ... I hope this is 'minimal' enough! script example 1) ================ <?php echo "<h1>Trying to connect</h1>"; $testsock = mysql_connect("127.0.0.1","root"); mysql_close($testsock); ?> This simply displays "Trying to connect" script example 2) ================ <?php echo "<h1>Trying to connect</h1>"; $testsock = mysql_connect("localhost","root"); mysql_close($testsock); ?> This displays: "Trying to connect Warning: mysql_connect() [function.mysql-connect]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (13) in /srv/www/htdocs/test.php on line 3 Warning: mysql_close(): supplied argument is not a valid MySQL-Link resource in /srv/www/htdocs/test.php on line 4"
[3 Jul 2006 15:47]
Valeriy Kravchuk
Peter, Sorry but you provided password for root when connected in mysql command line client: metusalinux:/usr/bin # mysql -uroot -p --socket=/var/lib/mysql/mysql.sock While in your php test you just connecting without expl;icit password: $testsock = mysql_connect("localhost","root"); So, this can be a reason, really. Please, send the results of: select user, host, password from mysql.user where user='root'; select * from mysql.host; to check is there any difference among root connecting 127.0.0.1 nad localhost.
[3 Jul 2006 17:32]
Peter Laursen
to my best understanding password is empty for root@localhost and root@% as well. Your queries: select user, host, password from mysql.user where user='root'; /* returns user host password ------ ----------- -------- root localhost root metusalinux root % */ select * from mysql.host; /* returns only 'the header' Host Db Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Grant_priv References_priv Index_priv Alter_priv Create_tmp_table_priv Lock_tables_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Execute_priv ------ ------ ----------- ----------- ----------- ----------- ----------- --------- ---------- --------------- ---------- ---------- --------------------- ---------------- ---------------- -------------- ------------------- ------------------ ------------ */
[23 Jul 2006 7:03]
Valeriy Kravchuk
Please, try to use mysqli_* (http://php.net/manual/en/ref.mysqli.php) instead of mysql_* in your PHP script. Send the results of ls -l /var/lib/mysql/mysql.sock
[23 Jul 2006 15:34]
Peter Laursen
:-) mysqli is not available at this system and the SuSE/Yast configuration tool won't let me have both at the same time. And I am not going to built it myself just for this! I need php_mysql extension, as I use it with SQLyog HTTP-tunneling primarily and this one only supports php_mysql and not php_mysqli at the time. But it is no problem .. I just use "127.0.0.1" as 'host' and connect with TCP instead. I think this discussion now has totally 'run off the track'. I have no problem myself that I cannot 'work around'. I reported this as I always do when I come across an issue with some software. And as I appreciate that people do with the software that I myself is involved in (SQLyog). Now, I think that I noticed that you yourself is a SuSE 10.0 user. Did you ever try install MySQL from KDE/YAST. Just click the RPM, answer 'yes' when KDE asks if it shall be installed with YAST (Use the most 'newbie' installation method, and not the 'fancy' one that you probably do!). If you after that do not experince the same problem well then it is NOT a general issue with the RPM's distributed by MySQL. I wonder if you ever tried that? As I have written allready I can give you all kinds of remote access to this system over SSH. You can even operate this system of mine from KDE running on your own box. I have X11 forwarding enabled in SSH-configuration. I have a backup of the Linux partition that I can restore in 10 minutes, so you wont have to worry about ANYTHING. But it is your decision whether this is relevant for MySQL or not. You should do it if it is relevant to you - if it is not and if this is not reproducable on your system then let us stop here! As said: I have no issue that I cannot 'work around'.
[21 Aug 2006 10:52]
Peter Laursen
Not reprocucable on a freshly installed SuSE 10.1 and MySQL 5.1.11. On this system socket connection is OK.
[5 Sep 2006 8:31]
Sveta Smirnova
> Not reprocucable on a freshly installed SuSE 10.1 and MySQL 5.1.11. > On this system socket connection is OK. Could you please to try with MySQL 5.0.24a to be sure it is not MySQL bug?
[5 Sep 2006 21:26]
Peter Laursen
I am not sure that I understand. On SuSE 10.0 I have tried every 5.0.x and 5.1.x version that has been for abotu 4 moths now - including 5.0.24a. And still get the error. But do not on SuSE 10.1. I never claimed that this is as plain or simple as being just 'a MySQL bug'. I experienced a problem and thought that MySQL would be happy to be informed! I also think that MySQL and SuSE share an interest in solving such issue if there is one? As I have written before: Just try install any recent 5.x server on SuSE 10 using YaST from KDE. Is the problem reproducable then? There is nothing more I can do!
[19 Oct 2006 11:07]
Hartmut Holzgraefe
looks as simple as a PHP extension built against the bundled MySQL library to me, the bundled library has a different socket file path compiled in and does not read the my.cnf file so it simply doesn't find the socket file the same issue can come up if client and server binaries from different packages that were built with different socket file path settings are mixed (unless the socket path is set up in my.cnf) as now the client tries to connect on a different socket file than the one used by the server
[28 Dec 2018 11:50]
Ahmed Reda
Ubuntu Server 18.04 MySQL version 5.7.24 The Mysql service stops and when go to start it from webmin I see : MySQL is not running on your system - database list could not be retrieved. The full MySQL error message was : mysqladmin: connect to server at 'localhost' failed error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)' Check that mysqld is running and that the socket: '/var/run/mysqld/mysqld.sock' exists! netstat -a | grep mysql netstat -a | grep mysql tcp 0 0 localhost:mysql 0.0.0.0:* LISTEN tcp 0 0 ip-172-31-47-95.e:42330 ec2-52-53-54-55.u:mysql TIME_WAIT tcp 0 0 ip-172-31-47-95.e:42356 ec2-52-53-54-55.u:mysql TIME_WAIT tcp 0 0 ip-172-31-47-95.e:42396 ec2-52-53-54-55.u:mysql TIME_WAIT tcp 0 0 ip-172-31-47-95.e:42370 ec2-52-53-54-55.u:mysql TIME_WAIT tcp 0 0 ip-172-31-47-95.e:42398 ec2-52-53-54-55.u:mysql TIME_WAIT tcp 0 19 ip-172-31-47-95.e:42538 ec2-52-53-54-55.u:mysql ESTABLISHED tcp 0 0 ip-172-31-47-95.e:42310 ec2-52-53-54-55.u:mysql TIME_WAIT unix 2 [ ACC ] STREAM LISTENING 20141 /var/run/mysqld/mysqld.sock unix 3 [ ] STREAM CONNECTED 25739 /var/run/mysqld/mysqld.sock mysql -uroot -p --socket=/var/lib/mysql/mysql.sock ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) script example 1) <?php echo "<h1>Trying to connect</h1>"; $testsock = mysql_connect("127.0.0.1","root"); mysql_close($testsock); ?> Resault Trying to connect viewed in browser ls -l /var/lib/mysql/mysql.sock ls: cannot access '/var/lib/mysql/mysql.sock': No such file or directory
[31 Dec 2018 11:06]
Ahmed Reda
Hello, I wonder any on can help here?