3

Yesterday I was working using MySQL installed on my computer.
I downloaded xampp, so I have I changed on my.cnf file the path to the socket:

 /opt/lampp/var/mysql/mysql.sock  

That file was just there. Today I wanted to keep working on it, and I found that file is not there anymore, so I am getting the following error while I am starting mysql server:

ERROR 2002 (HY000): 
Can't connect to local MySQL server through socket 
'/opt/lampp/var/mysql/mysql.sock' (2)

Here are some tests I made:

mujeresponja@ubuntu:~$ ps -fea | grep mysqld
1000     15707 15615  0 16:28 pts/1    00:00:00 grep --color=auto mysqld
mujeresponja@ubuntu:~$ ps -fea | grep mysql 
1000     15709 15615  0 16:29 pts/1    00:00:00 grep --color=auto mysql

As a possible solution I uninstalled xampp and reinstall it, and also a new MySQL server, just in case. Anyway, that file is not there anymore.

EDIT Where the mysql.sock should be, instead there are two files mysql_upgrade_info (Which contains just 5.5.8) and another binary file called ubuntu.err:

mujeresponja@ubuntu:/opt/lampp/var/mysql$ sudo cat ubuntu.err 
110403 17:28:52 mysqld_safe Starting mysqld daemon with databases from /opt/lampp/var/mysql
110403 17:28:52 [Note] Plugin 'FEDERATED' is disabled.
/opt/lampp/sbin/mysqld: Can't find file: './mysql/plugin.frm' (errno: 13)
110403 17:28:52 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
InnoDB: The InnoDB memory heap is disabled
InnoDB: Mutexes and rw_locks use InnoDB's own implementation
InnoDB: Compressed tables use zlib 1.2.3
110403 17:28:52  InnoDB: Initializing buffer pool, size = 16.0M
110403 17:28:52  InnoDB: Completed initialization of buffer pool
110403 17:28:52  InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
InnoDB: File name /opt/lampp/var/mysql/ibdata1
InnoDB: File operation call: 'create'.
InnoDB: Cannot continue operation.
110403 17:28:52 mysqld_safe mysqld from pid file /opt/lampp/var/mysql/ubuntu.pid ended
110403 17:29:22 mysqld_safe Starting mysqld daemon with databases from /opt/lampp/var/mysql
110403 17:29:22 [Note] Plugin 'FEDERATED' is disabled.
/opt/lampp/sbin/mysqld: Can't find file: './mysql/plugin.frm' (errno: 13)
110403 17:29:22 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
InnoDB: The InnoDB memory heap is disabled
InnoDB: Mutexes and rw_locks use InnoDB's own implementation
InnoDB: Compressed tables use zlib 1.2.3
110403 17:29:22  InnoDB: Initializing buffer pool, size = 16.0M
110403 17:29:22  InnoDB: Completed initialization of buffer pool
110403 17:29:22  InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
InnoDB: File name /opt/lampp/var/mysql/ibdata1
InnoDB: File operation call: 'create'.
InnoDB: Cannot continue operation.
110403 17:29:22 mysqld_safe mysqld from pid file /opt/lampp/var/mysql/ubuntu.pid ended

(Sorry, I don't know how to show terminal messages in an appropiuate way) Can anybody help me on this? Thanks in advance!

Blanca Hdez
  • 3,513
  • 19
  • 71
  • 93

5 Answers5

6

You can locate the actual socket file and create a symbolic link leading to it as follows:

# check path to socket from mysql settings  
mysqladmin | grep d.sock

# create a symbolic link
ln -s path_to_mysql_socket /opt/lampp/var/mysql/mysql.sock
Th. Ma.
  • 9,432
  • 5
  • 31
  • 46
  • the problem is that I have no mysql.sock file – Blanca Hdez Apr 03 '11 at 15:17
  • You still havent proved that mysql is currently running – BugFinder Apr 03 '11 at 15:20
  • The same error. Where the mysql.sock should be, instead there are two files mysql_upgrade_info (Which contains just 5.5.8) and another binary file called ubuntu.err – Blanca Hdez Apr 03 '11 at 15:40
  • According to the error file, you need to run mysql_upgrade first to create some missing tables "Can't open the mysql.plugin table". There is another mention about missing privileges "InnoDB: The error means mysqld does not have the access rights to InnoDB" – Th. Ma. Apr 03 '11 at 16:19
  • And how to change those privileges?? Trying to upgrade mysql I face new errors... unning 'mysqlcheck' with connection arguments: '--port=3306' '--socket=/var/run/mysqld/mysqld.sock' mysqlcheck: Got error: 2002: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) when trying to connect FATAL ERROR: Upgrade failed Always related with mysql.sock file missing. Is there anyway to get that file back?? Even reinstalling it is not there anymore... – Blanca Hdez Apr 03 '11 at 16:49
  • The presence of this file somewhere would participate in proving MySQL is running and for having it running, you need to have a proper installation of the distribution, with correct privileges applied to configuration files and binaries before launching the service. Have you tried to install MySQL only without xampp? You might save some time by installing directly Apache, PHP and MySQL from separate packets. – Th. Ma. Apr 04 '11 at 19:24
1

Although the test you did is a bit garbled, Im going to assume that the test just prove mysql isnt running.

Depending on how the mysql configured itself there should be a startup file somewhere, usually around the /etc/rc.* directories, and you would need to run the rc.mysql start (or it could be a S<nn>MySQL in an rc3.d directory for example

BugFinder
  • 17,474
  • 4
  • 36
  • 51
  • I have from rc0.d to rc6.d, but in none of them there is neither of those files. Even reinstalling again – Blanca Hdez Apr 03 '11 at 15:00
  • If theres no file in any of those directories with mysql in, then thats why its not auto starting. I dont have ubunto to hand, to see which directory mysql gets installed into, but theres probably a startup script there.. Check what files you have in the mysql directories – BugFinder Apr 03 '11 at 15:21
  • I am still looking for it, but no success. Where the mysql.sock should be, instead there are two files mysql_upgrade_info (Which contains just 5.5.8) and another binary file called ubuntu.err – Blanca Hdez Apr 03 '11 at 15:41
  • Go find the mysql binaries, Look for mysqld and mysqld_safe and see if theres a script in there for start/stop – BugFinder Apr 03 '11 at 15:50
  • I think I found it, but: ./mysql.server start Starting MySQL . * The server quit without updating PID file (/opt/lampp/var/mysql/ubuntu.pid) – Blanca Hdez Apr 03 '11 at 15:56
  • OK, so now you've found some errors to resolve. Its telling you the user mysql ran as didnt have correct permissions to the files/directories as well as to run the upgrade script. (as for displaying the terminal output, try marking it as code, that seems to at least set it as a pre formatted section) – BugFinder Apr 03 '11 at 17:13
  • Thanks, and how could I change those permissions?? – Blanca Hdez Apr 03 '11 at 17:54
  • take a look at the chmod command. This was all working yesterday right? Do you remember what happened after it was working and before you shut the machine down? – BugFinder Apr 03 '11 at 18:04
  • Yes, everything was working ok yesterday, and I didn't touch permissions or anything else. I tried also mujeresponja@ubuntu:~$ whereis mysqld.sock mysqld: /usr/sbin/mysqld /usr/share/man/man8/mysqld.8.gz and changing the routes to that path. Anyway, no success. Thank you for answering! – Blanca Hdez Apr 03 '11 at 18:20
  • As the error appeared, it disappeared today... I am afraid of having the same problem tomorrow!! – Blanca Hdez Apr 04 '11 at 18:14
1

I didn't find a certain reason for my problem. I just unisntalled and reinstalled, and then everything went Ok.
That is not a real solution, but it worked. Good luck

Blanca Hdez
  • 3,513
  • 19
  • 71
  • 93
  • Facing a similar solution, mysql was running fine for so many days now, all of a sudden the mysql.sock file went AWOL – pal4life Jun 23 '14 at 16:10
0

I came in the same situation when I made a grant to *.* to other user. Mysql tried to give permissions over the mysql database and that provoked the disaster: instantly, the mysql.sock file disappeared.

this happened with the version 5.6

Raul Luna
  • 1,945
  • 1
  • 17
  • 26
0

I had the same problem with you, and I found some useful information:

2015-08-14 10:51:17 30934 [ERROR] InnoDB: Unable to lock /opt/lampp/var/mysql/ibdata1, error: 11
2015-08-14 10:51:17 30934 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.

So, I rebooted the computer and restarted XAMPP, and the problem was resolved.

Will
  • 24,082
  • 14
  • 97
  • 108