Ubuntu – ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/thesqld/thesqld.sock’ (2) – Ubuntu 10.04

MySQLUbuntu

My VPS had a hardware failure, and I was knocked out of service for the past 24 hours. Now that it's back up, MySQL refuses to work. Please keep in mind that my VPS with these exact configurations has been running for the past 2 months without error, I have not changed any code/database settings since the hardware failure.

At the command line, simply typing "sudo mysql" returns

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

I can not login with PhpMyAdmin, I receive 2 errors:

#2002 Cannot log in to the MySQL server
Connection for controluser as defined in your configuration failed.

My web app (Codeigniter) returns the following error

A Database Error Occurred

Unable to connect to your database server using the provided settings.

Filename: core/Loader.php

Line Number: 346

I am running a typical LAMP stack on Ubuntu 10.04. I have more than enough free space on my hard disk still (over 20 gigs left), so being out of space is not an issue.

/var/log/mysql.err has nothing in it, it is an empty file. I have searched high and low on Google, but seem to be at a complete loss right now.

EDIT:

Running mysqld gave me

mysqld: Can't find file: './mysql/plugin.frm' (errno: 13)
120630 18:41:10 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
120630 18:41:10  InnoDB: Initializing buffer pool, size = 8.0M
120630 18:41:10  InnoDB: Completed initialization of buffer pool
120630 18:41:10  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 ./ibdata1
InnoDB: File operation call: 'open'.
InnoDB: Cannot continue operation.

at first, now running mysqld, I get nothing, just returns me to the prompt.

EDIT 2:
Running strace -e trace=file mysqld returns:

120630 19:17:12 [Note] Plugin 'FEDERATED' is disabled.
open("./mysql/plugin.frm", O_RDONLY)    = -1 EACCES (Permission denied)
mysqld: Can't find file: './mysql/plugin.frm' (errno: 13)
120630 19:17:12 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
open("/tmp/ibzhYSAn", O_RDWR|O_CREAT|O_EXCL, 0600) = 1
unlink("/tmp/ibzhYSAn")                 = 0
open("/tmp/ibRf9302", O_RDWR|O_CREAT|O_EXCL, 0600) = 1
unlink("/tmp/ibRf9302")                 = 0
open("/tmp/ibN6AjrI", O_RDWR|O_CREAT|O_EXCL, 0600) = 1
unlink("/tmp/ibN6AjrI")                 = 0
120630 19:17:12  InnoDB: Initializing buffer pool, size = 8.0M
120630 19:17:12  InnoDB: Completed initialization of buffer pool
open("/tmp/ibGh8aSn", O_RDWR|O_CREAT|O_EXCL, 0600) = 1
unlink("/tmp/ibGh8aSn")                 = 0
open("./ibdata1", O_RDWR|O_CREAT|O_EXCL, 0660) = -1 EEXIST (File exists)
open("./ibdata1", O_RDWR)               = -1 EACCES (Permission denied)
120630 19:17:12  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 ./ibdata1
InnoDB: File operation call: 'open'.
InnoDB: Cannot continue operation.

Best Answer

If the logfile is empty, try to start mysqld manually, literally by just running mysqld at a terminal.

It should pick up your configuration file automatically (e.g. /etc/my.cnf or /etc/mysql/my.cnf) and run with it.

After that, you should have errors in plain view for you to fix. If you put them into your original question too, we can help further. The issue could be at the host: not enough memory or even the physical disks are out of space, even though you haven't yet reached your allocation.

Also, my 2 cents: upstart is crap when stuff fails. When I had MySQL issues, I already got these "already running" messages even though there wasn't a single mysql[d] - so ignore it for now.


Can you check your data directory? Sounds like that crash has corrupted it and you've lost some files. It's normally /var/lib/mysql.

  1. Can you check the permissions (do they match your .cnf file for what they should be)?
  2. Look ibdata1, how are the permissions on that?

If you have backups, it might be a good idea to use them.