This question already has an answer here:

Ok. First. I tried to run a website on a server but it was too heavy for MySQL to handle. Apparently, it broke due to lack of RAM. So I changed the .cnf and .ini files for the server to lower the load, though I understand that it will work much slower.

Now I try to start the server back again.

$ sudo /etc/init.d/mysql start
[....] Starting mysql (via systemctl): mysql.serviceJob for mysql.service failed because the control p
rocess exited with error code.
See "systemctl status mysql.service" and "journalctl -xe" for details.


For some reason it fails. I am completely out of ideas what is wrong anymore. Here are MySQL logs, what else is I need to fix?

2019-01-31T02:10:13.714141Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2019-01-31T02:10:13.716372Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.25-0ubuntu0.18.10.2) starting as process 24740 ...
2019-01-31T02:10:13.720956Z 0 [Note] InnoDB: PUNCH HOLE support available
2019-01-31T02:10:13.720991Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2019-01-31T02:10:13.720995Z 0 [Note] InnoDB: Uses event mutexes
2019-01-31T02:10:13.720999Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2019-01-31T02:10:13.721002Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2019-01-31T02:10:13.721005Z 0 [Note] InnoDB: Using Linux native AIO
2019-01-31T02:10:13.721292Z 0 [Note] InnoDB: Number of pools: 1
2019-01-31T02:10:13.721420Z 0 [Note] InnoDB: Using CPU crc32 instructions
2019-01-31T02:10:13.725482Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2019-01-31T02:10:13.725537Z 0 [ERROR] InnoDB: mmap(137428992 bytes) failed; errno 12
2019-01-31T02:10:13.725544Z 0 [ERROR] InnoDB: Cannot allocate memory for the buffer pool
2019-01-31T02:10:13.725548Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2019-01-31T02:10:13.725558Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2019-01-31T02:10:13.725563Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2019-01-31T02:10:13.725568Z 0 [ERROR] Failed to initialize builtin plugins.
2019-01-31T02:10:13.725571Z 0 [ERROR] Aborting
2019-01-31T02:10:13.728065Z 0 [Note] Binlog end
2019-01-31T02:10:13.728148Z 0 [Note] Shutting down plugin 'CSV'
2019-01-31T02:10:13.728458Z 0 [Note] /usr/sbin/mysqld: Shutdown complete

/etc/mysql/mysql.conf.d/mysqld.cnf file:

# The MySQL database server configuration file.
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html
# This will be passed to all mysql clients
# It has been reported that passwords should be enclosed with ticks/quotes
# escpecially if they contain "#" chars...
# Remember to edit /etc/mysql/debian.cnf when changing the socket location.
# Here is entries for some specific programs
# The following values assume you have at least 32M ram
socket          = /var/run/mysqld/mysqld.sock
nice            = 0
# * Basic Settings
user            = mysql
pid-file        = /var/run/mysqld/mysqld.pid
socket          = /var/run/mysqld/mysqld.sock
port            = 3306
basedir         = /usr
datadir         = /var/lib/mysql
tmpdir          = /tmp
lc-messages-dir = /usr/share/mysql
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address            =
# * Fine Tuning
key_buffer_size         = 16M
sort_buffer_size        = 16M
read_buffer_size        = 1M
write_buffer_size       = 1M
max_allowed_packet      = 16M
thread_stack            = 192K
thread_cache_size       = 8
# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
myisam-recover-options  = BACKUP
max_connections         = 5
table_open_cache        = 32
thread_concurrency      = 6
# * Query Cache Configuration
query_cache_limit       = 1M
query_cache_size        = 16M
#thanks https://forums.cpanel.net/threads/optimizing-mysql-for-512mb-80-of-installed-ram.170278/
table_cache = 256
myisam_sort_buffer_size = 16M
thread_cache_size = 8
wait_timeout = 60
connect_timeout = 30
interactive-timeout = 50
query-cache-type = 1
query_cache_size = 8M
query_cache_limit = 1M
max_user_connections = 5
# * Logging and Replication
# Both location gets rotated by the cronjob.
# Be aware that this log type is a performance killer.
# As of 5.1 you can enable the log at runtime!
#general_log_file        = /var/log/mysql/mysql.log
#general_log             = 1
# Error log - should be very few entries.
log_error = /var/log/mysql/error.log
# Here you can see queries with especially long duration
#slow_query_log         = 1
#slow_query_log_file    = /var/log/mysql/mysql-slow.log
#long_query_time = 2
# The following can be used as easy to replay backup logs or for replication.
# note: if you are setting up a replication slave, see README.Debian about
#       other settings you may need to change.
#server-id              = 1
#log_bin                        = /var/log/mysql/mysql-bin.log
expire_logs_days        = 10
max_binlog_size   = 100M
#binlog_do_db           = include_database_name
#binlog_ignore_db       = include_database_name
# * InnoDB
# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
# Read the manual for more InnoDB related options. There are many!
# * Security Features
# Read the manual, too, if you want chroot!
# chroot = /var/lib/mysql/
# For generating SSL certificates I recommend the OpenSSL GUI "tinyca".

i feel like i broke everything...

marked as duplicate by Michael Hampton Feb 1 at 3:16

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    It still cannot call mmap(), this indicates that you still don't have enough memory or shared memory configuration is just wrong. According to your mysql config you have relatively small amounts configured for mysql (it fails allocating just 128 megs, which is a modern word for "nothing"). How much memory do you have in this server ? – drookie Jan 31 at 3:34
  • @drookie 0.6Gb of ram. It's a free GCP instance. I thought this should be enough for a test project. All I have on this server is apache, php, mysql and a website. After last crash I tried to restart only MySQL, but maybe I need to restart the whole instance though how do I make it not to crash again? – Telion Jan 31 at 14:31
  • Please attach the output of free. I'm about to conclude that your server simply lacks enough memory. You could also diminish all of your memory-related parameters for mysql by three times and try to start. Or simply start with default memory config. – drookie Jan 31 at 19:27
  • This Q probably belongs in dba.stackexchange.com – Rick James Jan 31 at 22:22

You have a tiny amount of RAM. Find the my.cnf config file for MySQL, and change innodb_buffer_pool_size down to perhaps 20M. If you still get error 12, then show us that file, and we can recommend decreasing some other things.

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