Question

Mysql server keeps stopping unexpectedly

Currently running an apache server with wordpress. Keeps bringing up database error connection after a few minutes of doing anything. Attempted to get into mysql through command line. Keep getting error:

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

Error log dump:

140124 17:29:01 [Warning] Using unique option prefix myisam-recover instead of myisam-recover-options is deprecated and will be removed in a future release. Please use the full name instead. 140124 17:29:01 [Note] Plugin ‘FEDERATED’ is disabled. 140124 17:29:01 InnoDB: The InnoDB memory heap is disabled 140124 17:29:01 InnoDB: Mutexes and rw_locks use GCC atomic builtins 140124 17:29:01 InnoDB: Compressed tables use zlib 1.2.3.4 140124 17:29:01 InnoDB: Initializing buffer pool, size = 128.0M InnoDB: mmap(137363456 bytes) failed; errno 12 140124 17:29:01 InnoDB: Completed initialization of buffer pool 140124 17:29:01 InnoDB: Fatal error: cannot allocate memory for the buffer pool 140124 17:29:01 [ERROR] Plugin ‘InnoDB’ init function returned error. 140124 17:29:01 [ERROR] Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed. 140124 17:29:01 [ERROR] Unknown/unsupported storage engine: InnoDB 140124 17:29:01 [ERROR] Aborting

140124 17:29:01 [Note] /usr/sbin/mysqld: Shutdown complete

140124 17:29:02 [Warning] Using unique option prefix myisam-recover instead of myisam-recover-options is deprecated and will be removed in a future release. Please use the full name instead. 140124 17:29:02 [Note] Plugin ‘FEDERATED’ is disabled. 140124 17:29:02 InnoDB: The InnoDB memory heap is disabled 140124 17:29:02 InnoDB: Mutexes and rw_locks use GCC atomic builtins 140124 17:29:02 InnoDB: Compressed tables use zlib 1.2.3.4 140124 17:29:02 InnoDB: Initializing buffer pool, size = 128.0M InnoDB: mmap(137363456 bytes) failed; errno 12 140124 17:29:02 InnoDB: Completed initialization of buffer pool 140124 17:29:02 InnoDB: Fatal error: cannot allocate memory for the buffer pool 140124 17:29:02 [ERROR] Plugin ‘InnoDB’ init function returned error. 140124 17:29:02 [ERROR] Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed. 140124 17:29:02 [ERROR] Unknown/unsupported storage engine: InnoDB 140124 17:29:02 [ERROR] Aborting

140124 17:29:02 [Note] /usr/sbin/mysqld: Shutdown complete

140124 17:29:50 [Warning] Using unique option prefix myisam-recover instead of myisam-recover-options is deprecated and will be removed in a future release. Please use the full name instead. 140124 17:29:50 [Note] Plugin ‘FEDERATED’ is disabled. 140124 17:29:50 InnoDB: The InnoDB memory heap is disabled 140124 17:29:50 InnoDB: Mutexes and rw_locks use GCC atomic builtins 140124 17:29:50 InnoDB: Compressed tables use zlib 1.2.3.4 140124 17:29:50 InnoDB: Initializing buffer pool, size = 128.0M InnoDB: mmap(137363456 bytes) failed; errno 12 140124 17:29:50 InnoDB: Completed initialization of buffer pool 140124 17:29:50 InnoDB: Fatal error: cannot allocate memory for the buffer pool 140124 17:29:50 [ERROR] Plugin ‘InnoDB’ init function returned error. 140124 17:29:50 [ERROR] Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed. 140124 17:29:50 [ERROR] Unknown/unsupported storage engine: InnoDB 140124 17:29:50 [ERROR] Aborting

140124 17:29:50 [Note] /usr/sbin/mysqld: Shutdown complete

140124 17:29:51 [Warning] Using unique option prefix myisam-recover instead of myisam-recover-options is deprecated and will be removed in a future release. Please use the full name instead. 140124 17:29:51 [Note] Plugin ‘FEDERATED’ is disabled. 140124 17:29:51 InnoDB: The InnoDB memory heap is disabled 140124 17:29:51 InnoDB: Mutexes and rw_locks use GCC atomic builtins 140124 17:29:51 InnoDB: Compressed tables use zlib 1.2.3.4 140124 17:29:51 InnoDB: Initializing buffer pool, size = 128.0M InnoDB: mmap(137363456 bytes) failed; errno 12 140124 17:29:51 InnoDB: Completed initialization of buffer pool 140124 17:29:51 InnoDB: Fatal error: cannot allocate memory for the buffer pool 140124 17:29:51 [ERROR] Plugin ‘InnoDB’ init function returned error. 140124 17:29:51 [ERROR] Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed. 140124 17:29:51 [ERROR] Unknown/unsupported storage engine: InnoDB 140124 17:29:51 [ERROR] Aborting

140124 17:29:51 [Note] /usr/sbin/mysqld: Shutdown complete

140124 17:29:52 [Warning] Using unique option prefix myisam-recover instead of myisam-recover-options is deprecated and will be removed in a future release. Please use the full name instead. 140124 17:29:52 [Note] Plugin ‘FEDERATED’ is disabled. 140124 17:29:52 InnoDB: The InnoDB memory heap is disabled 140124 17:29:52 InnoDB: Mutexes and rw_locks use GCC atomic builtins 140124 17:29:52 InnoDB: Compressed tables use zlib 1.2.3.4 140124 17:29:52 InnoDB: Initializing buffer pool, size = 128.0M InnoDB: mmap(137363456 bytes) failed; errno 12 140124 17:29:52 InnoDB: Completed initialization of buffer pool 140124 17:29:52 InnoDB: Fatal error: cannot allocate memory for the buffer pool 140124 17:29:52 [ERROR] Plugin ‘InnoDB’ init function returned error. 140124 17:29:52 [ERROR] Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed. 140124 17:29:52 [ERROR] Unknown/unsupported storage engine: InnoDB 140124 17:29:52 [ERROR] Aborting

140124 17:29:52 [Note] /usr/sbin/mysqld: Shutdown complete

140124 17:30:16 [Warning] Using unique option prefix myisam-recover instead of myisam-recover-options is deprecated and will be removed in a future release. Please use the full name instead. 140124 17:30:16 [Note] Plugin ‘FEDERATED’ is disabled. 140124 17:30:16 InnoDB: The InnoDB memory heap is disabled 140124 17:30:16 InnoDB: Mutexes and rw_locks use GCC atomic builtins 140124 17:30:16 InnoDB: Compressed tables use zlib 1.2.3.4 140124 17:30:16 InnoDB: Initializing buffer pool, size = 128.0M InnoDB: mmap(137363456 bytes) failed; errno 12 140124 17:30:16 InnoDB: Completed initialization of buffer pool 140124 17:30:16 InnoDB: Fatal error: cannot allocate memory for the buffer pool 140124 17:30:16 [ERROR] Plugin ‘InnoDB’ init function returned error. 140124 17:30:16 [ERROR] Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed. 140124 17:30:16 [ERROR] Unknown/unsupported storage engine: InnoDB 140124 17:30:16 [ERROR] Aborting

140124 17:30:16 [Note] /usr/sbin/mysqld: Shutdown complete

140124 17:30:17 [Warning] Using unique option prefix myisam-recover instead of myisam-recover-options is deprecated and will be removed in a future release. Please use the full name instead. 140124 17:30:17 [Note] Plugin ‘FEDERATED’ is disabled. 140124 17:30:17 InnoDB: The InnoDB memory heap is disabled 140124 17:30:17 InnoDB: Mutexes and rw_locks use GCC atomic builtins 140124 17:30:17 InnoDB: Compressed tables use zlib 1.2.3.4 140124 17:30:17 InnoDB: Initializing buffer pool, size = 128.0M InnoDB: mmap(137363456 bytes) failed; errno 12 140124 17:30:17 InnoDB: Completed initialization of buffer pool 140124 17:30:17 InnoDB: Fatal error: cannot allocate memory for the buffer pool 140124 17:30:17 [ERROR] Plugin ‘InnoDB’ init function returned error. 140124 17:30:17 [ERROR] Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed. 140124 17:30:17 [ERROR] Unknown/unsupported storage engine: InnoDB 140124 17:30:17 [ERROR] Aborting

140124 17:30:17 [Note] /usr/sbin/mysqld: Shutdown complete

140124 17:30:18 [Warning] Using unique option prefix myisam-recover instead of myisam-recover-options is deprecated and will be removed in a future release. Please use the full name instead. 140124 17:30:18 [Note] Plugin ‘FEDERATED’ is disabled. 140124 17:30:18 InnoDB: The InnoDB memory heap is disabled 140124 17:30:18 InnoDB: Mutexes and rw_locks use GCC atomic builtins 140124 17:30:18 InnoDB: Compressed tables use zlib 1.2.3.4 140124 17:30:18 InnoDB: Initializing buffer pool, size = 128.0M InnoDB: mmap(137363456 bytes) failed; errno 12 140124 17:30:18 InnoDB: Completed initialization of buffer pool 140124 17:30:18 InnoDB: Fatal error: cannot allocate memory for the buffer pool 140124 17:30:18 [ERROR] Plugin ‘InnoDB’ init function returned error. 140124 17:30:18 [ERROR] Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed. 140124 17:30:18 [ERROR] Unknown/unsupported storage engine: InnoDB 140124 17:30:18 [ERROR] Aborting

140124 17:30:18 [Note] /usr/sbin/mysqld: Shutdown complete

140124 17:30:58 [Warning] Using unique option prefix myisam-recover instead of myisam-recover-options is deprecated and will be removed in a future release. Please use the full name instead. 140124 17:30:58 [Note] Plugin ‘FEDERATED’ is disabled. 140124 17:30:58 InnoDB: The InnoDB memory heap is disabled 140124 17:30:58 InnoDB: Mutexes and rw_locks use GCC atomic builtins 140124 17:30:58 InnoDB: Compressed tables use zlib 1.2.3.4 140124 17:30:58 InnoDB: Initializing buffer pool, size = 128.0M 140124 17:30:58 InnoDB: Completed initialization of buffer pool 140124 17:30:58 InnoDB: highest supported file format is Barracuda. InnoDB: The log sequence number in ibdata files does not match InnoDB: the log sequence number in the ib_logfiles! 140124 17:30:58 InnoDB: Database was not shut down normally! InnoDB: Starting crash recovery. InnoDB: Reading tablespace information from the .ibd files… InnoDB: Restoring possible half-written data pages from the doublewrite InnoDB: buffer… 140124 17:30:59 InnoDB: Waiting for the background threads to start 140124 17:31:00 InnoDB: 5.5.34 started; log sequence number 20123319 140124 17:31:00 [Note] Server hostname (bind-address): ‘127.0.0.1’; port: 3306 140124 17:31:00 [Note] - ‘127.0.0.1’ resolves to ‘127.0.0.1’; 140124 17:31:00 [Note] Server socket created on IP: ‘127.0.0.1’. 140124 17:31:00 [Note] Event Scheduler: Loaded 0 events 140124 17:31:00 [Note] /usr/sbin/mysqld: ready for connections. Version: ‘5.5.34-0ubuntu0.12.04.1’ socket: ‘/var/run/mysqld/mysqld.sock’ port: 3306 (Ubuntu) 140124 17:35:14 [Warning] Using unique option prefix myisam-recover instead of myisam-recover-options is deprecated and will be removed in a future release. Please use the full name instead. 140124 17:35:14 [Note] Plugin ‘FEDERATED’ is disabled. 140124 17:35:14 InnoDB: The InnoDB memory heap is disabled 140124 17:35:14 InnoDB: Mutexes and rw_locks use GCC atomic builtins 140124 17:35:14 InnoDB: Compressed tables use zlib 1.2.3.4 140124 17:35:14 InnoDB: Initializing buffer pool, size = 128.0M InnoDB: mmap(137363456 bytes) failed; errno 12 140124 17:35:14 InnoDB: Completed initialization of buffer pool 140124 17:35:14 InnoDB: Fatal error: cannot allocate memory for the buffer pool 140124 17:35:14 [ERROR] Plugin ‘InnoDB’ init function returned error. 140124 17:35:14 [ERROR] Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed. 140124 17:35:14 [ERROR] Unknown/unsupported storage engine: InnoDB 140124 17:35:14 [ERROR] Aborting

140124 17:35:14 [Note] /usr/sbin/mysqld: Shutdown complete

140124 17:35:15 [Warning] Using unique option prefix myisam-recover instead of myisam-recover-options is deprecated and will be removed in a future release. Please use the full name instead. 140124 17:35:15 [Note] Plugin ‘FEDERATED’ is disabled. 140124 17:35:15 InnoDB: The InnoDB memory heap is disabled 140124 17:35:15 InnoDB: Mutexes and rw_locks use GCC atomic builtins 140124 17:35:15 InnoDB: Compressed tables use zlib 1.2.3.4 140124 17:35:15 InnoDB: Initializing buffer pool, size = 128.0M InnoDB: mmap(137363456 bytes) failed; errno 12 140124 17:35:15 InnoDB: Completed initialization of buffer pool 140124 17:35:15 InnoDB: Fatal error: cannot allocate memory for the buffer pool 140124 17:35:15 [ERROR] Plugin ‘InnoDB’ init function returned error. 140124 17:35:15 [ERROR] Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed. 140124 17:35:15 [ERROR] Unknown/unsupported storage engine: InnoDB 140124 17:35:15 [ERROR] Aborting

140124 17:35:15 [Note] /usr/sbin/mysqld: Shutdown complete

root@Nostalgia:/var/log/mysql# tail /var/log/mysql/error.log InnoDB: mmap(137363456 bytes) failed; errno 12 140124 17:35:15 InnoDB: Completed initialization of buffer pool 140124 17:35:15 InnoDB: Fatal error: cannot allocate memory for the buffer pool 140124 17:35:15 [ERROR] Plugin ‘InnoDB’ init function returned error. 140124 17:35:15 [ERROR] Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed. 140124 17:35:15 [ERROR] Unknown/unsupported storage engine: InnoDB 140124 17:35:15 [ERROR] Aborting

140124 17:35:15 [Note] /usr/sbin/mysqld: Shutdown complete

root@Nostalgia:/var/log/mysql# mysql -u root -p Enter password: ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (111) root@Nostalgia:/var/log/mysql# tail /var/log/mysql/error.log InnoDB: mmap(137363456 bytes) failed; errno 12 140124 17:35:15 InnoDB: Completed initialization of buffer pool 140124 17:35:15 InnoDB: Fatal error: cannot allocate memory for the buffer pool 140124 17:35:15 [ERROR] Plugin ‘InnoDB’ init function returned error. 140124 17:35:15 [ERROR] Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed. 140124 17:35:15 [ERROR] Unknown/unsupported storage engine: InnoDB 140124 17:35:15 [ERROR] Aborting

140124 17:35:15 [Note] /usr/sbin/mysqld: Shutdown complete

Help would be nice :)

Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

This is happening to me on a WordPress droplet. I’ve done two things, one suggested by another answer here. In the [mysqld] section I’ve added innodb_buffer_pool_size = 16M. Note, this is really small, but this is on a small droplet, so it is what it is. Additionally, when mysql eventually crashed I noticed apache having a LOT of processes. It’s likely hogging up all the system memory. Again, this is for a small site, so I tuned down apache by editing /etc/apache2/mods-enabled/mpm_prefork.conf to this:

<IfModule mpm_prefork_module>
	StartServers		3
	MinSpareServers		3
	MaxSpareServers		5
	MaxRequestWorkers	25
	MaxConnectionsPerChild  0
</IfModule>

Updating innodb_buffer_pool_size stabilized the system for a lot longer than before, but apache eventually hogged all the memory. I’m hoping my problem goes away limiting the number of Apache processes that can exist.

After applying the mysql and apache tweaks in my previous post I stressed the system using ab. Below are my results. Long story short, the system was able to successfully process 5000 requests across 20 concurrent connections. The system remained stable and no mysql issues.

I’m running this on a 1G droplet, might be tight, but this config seems like it would work on a 512MB as well.

Hope this helps!

root@KavanaKava:~# time ab -l -n 5000 -c 20 http://example.com/
This is ApacheBench, Version 2.3 <$Revision: 1528965 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 45.55.159.118 (be patient)
Completed 500 requests
Completed 1000 requests
Completed 1500 requests
Completed 2000 requests
Completed 2500 requests
Completed 3000 requests
Completed 3500 requests
Completed 4000 requests
Completed 4500 requests
Completed 5000 requests
Finished 5000 requests


Server Software:        Apache/2.4.7
Server Hostname:        example.com
Server Port:            80

Document Path:          /
Document Length:        Variable

Concurrency Level:      20
Time taken for tests:   508.491 seconds
Complete requests:      5000
Failed requests:        0
Total transferred:      115833214 bytes
HTML transferred:       113373214 bytes
Requests per second:    9.83 [#/sec] (mean)
Time per request:       2033.964 [ms] (mean)
Time per request:       101.698 [ms] (mean, across all concurrent requests)
Transfer rate:          222.46 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.3      0       6
Processing:   957 2033 184.2   1966    3450
Waiting:      544  897 142.7    858    2746
Total:        957 2033 184.2   1966    3450

Percentage of the requests served within a certain time (ms)
  50%   1966
  66%   2012
  75%   2082
  80%   2163
  90%   2270
  95%   2421
  98%   2566
  99%   2675
 100%   3450 (longest request)

real	8m28.506s
user	0m0.319s
sys	0m1.003s
root@KavanaKava:~#

I’ve encountered similar issue, and adding 1GB swap solved my problem. See this: http://www.webtrafficexchange.com/solved-mysql-crash-fatal-error-cannot-allocate-memory-buffer-pool