Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Sat Aug 13, 2011 5:33 pm 
Offline
Senior Member

Joined: Thu Aug 05, 2010 11:23 pm
Posts: 64
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 wp_cache_get errors.

PHP Fatal error: Call to undefined function wp_cache_get() 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.


Top
   
 Post subject:
PostPosted: Sat Aug 13, 2011 5:57 pm 
Offline
Senior Member

Joined: Thu Aug 05, 2010 11:23 pm
Posts: 64
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

?


Top
   
 Post subject:
PostPosted: Sat Aug 13, 2011 6:43 pm 
Offline
Senior Member
User avatar

Joined: Sat Aug 30, 2008 1:55 pm
Posts: 1739
Location: Rochester, New York
Is mysqld running?

Code:
$ 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.

_________________
Code:
/* TODO: need to add signature to posts */


Top
   
 Post subject:
PostPosted: Sat Aug 13, 2011 8:41 pm 
Offline
Senior Member

Joined: Thu Aug 05, 2010 11:23 pm
Posts: 64
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...
Quote:
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


Quote:
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
Quote:
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.
Quote:
Disk is full writing '/var/lib/mysql/dbname/db_yarpp_related_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 db_yarpp_related_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.

?


Top
   
 Post subject:
PostPosted: Sat Aug 13, 2011 10:14 pm 
Offline
Senior Member
User avatar

Joined: Sat Aug 30, 2008 1:55 pm
Posts: 1739
Location: Rochester, New York
superdupler wrote:
Disk is full writing '/var/lib/mysql/dbname/db_yarpp_related_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.

_________________
Code:
/* TODO: need to add signature to posts */


Top
   
 Post subject:
PostPosted: Sat Aug 13, 2011 10:54 pm 
Offline
Senior Member

Joined: Thu Aug 05, 2010 11:23 pm
Posts: 64
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.


Top
   
 Post subject:
PostPosted: Sun Aug 14, 2011 8:06 am 
Offline
Senior Member
User avatar

Joined: Sat Aug 30, 2008 1:55 pm
Posts: 1739
Location: Rochester, New York
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:

Code:
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.

_________________
Code:
/* TODO: need to add signature to posts */


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group