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
Best Answer
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.
If not set the proper owner:
Do the same for all directories listed in your my.cnf:
For directories use recursive chown: