Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Starting yesterday, I'm getting this error when connecting to mysql:

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

I haven't touched my setup for ~1 month so I don't believe its driven by any changes I've attempted to make to the setup. When I try to restart mysql service with

service mysqld restart

I get this error:

Stopping mysqld:                                           [  OK  ]
touch: cannot touch ‘/var/log/mysqld.log’: Permission denied
chown: changing ownership of ‘/var/log/mysqld.log’: Operation not permitted
chmod: changing permissions of ‘/var/log/mysqld.log’: Operation not permitted
chown: changing ownership of ‘/var/lib/mysql’: Operation not permitted
chmod: changing permissions of ‘/var/lib/mysql’: Operation not permitted
MySQL Daemon failed to start.

And if I try:

sudo service mysqld restart

I just get:

Stopping mysqld:                                           [  OK  ]
MySQL Daemon failed to start.
Starting mysqld:                                           [FAILED]

I think its a permissions issue based off what I've read on other server fault threads about the same error but I'm still stumped because I should have permissions to execute files in that directory:

drwxr-xr-x 6 mysql mysql 4096 Jun 21 16:42 /var/lib/mysql

Update: logs below. Looks like a memory issue but I don't know how to address:

140618 20:17:46 mysqld_safe Number of processes running now: 0
140618 20:17:46 mysqld_safe mysqld restarted
140618 20:17:47 [Note] Plugin 'FEDERATED' is disabled.
140618 20:17:47 InnoDB: The InnoDB memory heap is disabled
140618 20:17:47 InnoDB: Mutexes and rw_locks use GCC atomic builtins
140618 20:17:47 InnoDB: Compressed tables use zlib 1.2.7
140618 20:17:47 InnoDB: Using Linux native AIO
140618 20:17:47 InnoDB: Initializing buffer pool, size = 128.0M
InnoDB: mmap(137363456 bytes) failed; errno 12
140618 20:17:47 InnoDB: Completed initialization of buffer pool
140618 20:17:47 InnoDB: Fatal error: cannot allocate memory for the buffer pool
140618 20:17:47 [ERROR] Plugin 'InnoDB' init function returned error.
140618 20:17:47 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
140618 20:17:47 [ERROR] Unknown/unsupported storage engine: InnoDB
140618 20:17:47 [ERROR] Aborting

140618 20:17:47 [Note] /usr/libexec/mysqld: Shutdown complete

140618 20:17:47 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
140621 16:42:49 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
140621 16:42:49 [Note] Plugin 'FEDERATED' is disabled.
140621 16:42:49 InnoDB: The InnoDB memory heap is disabled
140621 16:42:49 InnoDB: Mutexes and rw_locks use GCC atomic builtins
140621 16:42:49 InnoDB: Compressed tables use zlib 1.2.7
140621 16:42:49 InnoDB: Using Linux native AIO
140621 16:42:50 InnoDB: Initializing buffer pool, size = 128.0M
InnoDB: mmap(137363456 bytes) failed; errno 12
140621 16:42:50 InnoDB: Completed initialization of buffer pool
140621 16:42:50 InnoDB: Fatal error: cannot allocate memory for the buffer pool
140621 16:42:50 [ERROR] Plugin 'InnoDB' init function returned error.
140621 16:42:50 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
140621 16:42:50 [ERROR] Unknown/unsupported storage engine: InnoDB
140621 16:42:50 [ERROR] Aborting

140621 16:42:50 [Note] /usr/libexec/mysqld: Shutdown complete

140621 16:42:50 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended

UPDATE: Found the answer here which was setting up a swap file. The full details I followed on how to do this can be found here: http://www.prowebdev.us/2012/05/amazon-ec2-linux-micro-swap-space.html

share|improve this question
1  
The first half of the question is simply because you are not root. For the second half, can you see if there are any logs generated in /var/log/ with more verbose details? Right now it could be many things. –  David Houde Jun 21 at 18:12
    
@DavidHoude posted logs, looks like a memory issue but don't know how to fix –  john k Jun 21 at 18:31
    
The log shows that MySQL started at 2:53, and was shut down at 20:03, that is, 17 hours 10 minutes after start-up. When did you execute the sudo service mysqld restart command? –  Tero Kilkanen Jun 21 at 18:53
    
Those logs show a normal shutdown, you need to show us the part relevant to the failed startup. –  Iain Jun 21 at 18:59
    
@lain - My bad, thought I'd pasted that in first time (updated logs above) –  john k Jun 21 at 19:15

1 Answer 1

You need to make sure all mysql files are owned by the mysql user. Verify that the mysql log files are owned by the MySQL User.

ls -l /var/log/mysql*

If not set the proper owner:

chown mysql:mysql /var/log/mysql....

Do the same for all directories listed in your my.cnf:

root# grep mysql /etc/mysql/my.cnf
[mysqld]
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
datadir = /data/mysql
log_bin=/data/mysql/binlogs/mysql-bin.log
slow_query_log_file=/var/log/mysql_slow_query.log
log-error=/var/log/mysql_error.log
innodb_data_home_dir = /data/mysql

For directories use recursive chown:

chown mysql:mysql -R /data/mysql
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.