ERROR 2002 (HY000): Can't connect to local MySQL server thro

Error establishing a database connection

if I try mysql -u root -p, then I get

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

I checked var/run/mysqld folder… it is empty. There isnt a file called mysqld.sock

and supposedly error 2013 is related to 2002

Error no. 2013 Lost connection to MySQL server during query, which I didnt see that error anywhere on the server.

I tried to reinstall mysql, I got the same problem. Nobody has an exact solution to the problem on the net. I tried several things. I still get the same issue.

I am on ubuntu 10.04 - LAMP set up using wordpress. I also get wpcacheget errors.

PHP Fatal error: Call to undefined function wpcacheget() in /srv/www/domain.com/public_html/wp-includes/functions.php on line 346

why do I get these errors? It worked okay for three weeks with occasional hick ups. Now, it just seems to ate the dust.

6 Replies

I am really puzzled on this…

it is even suggested that it is a permission issue etc.

Why would it work for several weeks and all of a sudden will have permission issues?

cd /var/run/ ls -al

drwxr-xr-x 2 mysql root 40 2011-08-13 17:22 mysqld

?

Is mysqld running?

$ ps aux | grep mysqld
mysql     2516  0.0  6.1 139640 31232 ?        Ssl  Jul02  41:58 /usr/sbin/mysqld

If not, that would be why it isn't working. "service mysql start" should bring it back, unless it was broken during previous attempts to fix it.

Not sure why PHP is unhappy, but… well, it's Wordpress, it stuns easily.

mysql was running… however, var/run/mysqld directory was empty.

I originally did… ps -ef | grep mysql

at the moment, it is working and down below I listed the steps I took for it to work. I do want to find out why this happened though. It is just strange.

right now… > ps -ef | grep mysql

mysql 5779 1 1 18:56 ? 00:01:09 /usr/sbin/mysqld

root 26663 2231 0 20:08 pts/0 00:00:00 grep –color=auto mysql

> ps aux | grep mysqld

mysql 5779 1.6 3.3 114476 34376 ? Ssl 18:56 1:09 /usr/sbin/mysqld

root 26661 0.0 0.0 3376 752 pts/0 S+ 20:08 0:00 grep –color=auto mysqld

I found this similar problem on thread

http://forums.mysql.com/read.php?11,9689,9689#msg-9689

the info I found on the were outdated from 2004 through 2009. They were also for other distros, only a few for ubuntu.

I couldnt connect at all. It was really weird.

Most believe it was permission issue, and majority of the thread was mentioning to change permissions etc.

then I saw this thread to killall
> killall mysqlmanager AND/OR

kill any mysql process AND/OR

kill process ID (cat /var/run/mysqld/mysqld.pid, cat /var/run/mysqld/mysqlmanager.angel.pid, cat /var/run/mysqld/mysqlmanager.pid)

no socket (/var/lib/mysql/)

/etc/init.d/mysqld start

mysql -u root -p

so, I checked the error log, syslog, auth.log, mysql log, and something caught my eye on mysql log.
> Disk is full writing '/var/lib/mysql/dbname/dbyarpprelated_cache.MYI' (Errcode: 28). Waiting for someone to free space… (Expect up to 60 secs delay for server to continue after freeing disk space)

110813 5:14:17 [ERROR] /usr/sbin/mysqld: Retry in 60 secs. Message reprinted in 600 secs

110813 5:24:17 [ERROR] /usr/sbin/mysqld: Retry in 60 secs. Message reprinted in 600 secs

since I couldnt use mysql at all. I couldnt even login from the terminal. If I tried mysql -u root -p I would just get the error

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

I decided to remove it all the way.

apt-get remove mysql-*

Then, installed mysql again. I was able to mysql -u root -p

recreated the database and the user.

mysql> create database dbname;

ERROR 1007 (HY000): Can't create database 'dbname'; database exists

mysql> grant all on dbname.* to 'user' identified by 'pass';

Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

mysql> quit

Bye

Nothing.

reinstall

apt-get install php5-mysql

Nothing. Still have 500 error

I removed cache plugin.

rm -r w3tc

It worked.

I got it working now.

then, install phpmyadmin, and checked tables.

it didnt show anything about dbyarpprelated_cache.MYI table; however showed another table being corrupted.

repaired the tables.

It seems ok now. however, I still would like to figure out why this happened. I dont think table corruption would disconnect mysql and make it not work.

?

@superdupler:

Disk is full writing '/var/lib/mysql/dbname/dbyarpprelated_cache.MYI' (Errcode: 28). Waiting for someone to free space… (Expect up to 60 secs delay for server to continue after freeing disk space)

I think that's your problem right there.

how can I resolve that issue so it doesnt happen again?

I optimize tables occasionaly. Then, I read somewhere that optimizing tables can 'lock the tables.' :shock:

I am not even sure what that means.

I just want to be able to take care of it ahead of time. What is the best way to do it?

Thank you.

The "df" command will tell you how much disk space you're using. You can add the -h option and it will use "human-friendly" numbers:

rtucker@rocwiki:~$ df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/xvda              16G  5.9G  9.8G  38% /
varrun                249M   56K  249M   1% /var/run
varlock               249M     0  249M   0% /var/lock
devshm                249M     0  249M   0% /dev/shm

The 38% next to / tells me the main filesystem is 38% full. If that gets close to 100%, bad things start happening.

A common cause of this is logging… pretty much everything that happens gets logged, and the log files keep growing indefinitely. If you haven't yet, install "logrotate" -- that will switch the files out on a regular basis and delete old ones.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct