0

My WordPress website often has the error Error establishing a database connection.

Previously, I used sudo chmod 755 /var/lib/mysql and sudo /etc/init.d/mysql restart to fix it. However, this time, they could not work anymore; sudo /etc/init.d/mysql returned

stop: Unknown instance: 
start: Job failed to start

And mysqld --verbose returned

180120  3:24:48 [Warning] Using unique option prefix key_buffer instead of key_buffer_size is deprecated and will be removed in a future release. Please use the full name instead.
180120  3:24:48 [Warning] Can't create test file /var/lib/mysql/chengtie.lower-test
180120  3:24:48 [Note] mysqld (mysqld 5.5.58-0ubuntu0.14.04.1) starting as process 20724 ...
180120  3:24:48 [Warning] Can't create test file /var/lib/mysql/chengtie.lower-test
180120  3:24:48 [Warning] Can't create test file /var/lib/mysql/chengtie.lower-test
180120  3:24:48 [Warning] One can only use the --user switch if running as root

180120  3:24:48 [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.
180120  3:24:48 [Note] Plugin 'FEDERATED' is disabled.
mysqld: Can't find file: './mysql/plugin.frm' (errno: 13)
180120  3:24:48 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
180120  3:24:48 InnoDB: The InnoDB memory heap is disabled
180120  3:24:48 InnoDB: Mutexes and rw_locks use GCC atomic builtins
180120  3:24:48 InnoDB: Compressed tables use zlib 1.2.8
180120  3:24:48 InnoDB: Using Linux native AIO
180120  3:24:48 InnoDB: Initializing buffer pool, size = 128.0M
InnoDB: mmap(137363456 bytes) failed; errno 12
180120  3:24:48 InnoDB: Completed initialization of buffer pool
180120  3:24:48 InnoDB: Fatal error: cannot allocate memory for the buffer pool
180120  3:24:48 [ERROR] Plugin 'InnoDB' init function returned error.
180120  3:24:48 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
180120  3:24:48 [ERROR] Unknown/unsupported storage engine: InnoDB
180120  3:24:48 [ERROR] Aborting

180120  3:24:48 [Note] mysqld: Shutdown complete

Does anyone know how to make my website back?

2
  • InnoDB: mmap(137363456 bytes) failed; errno 12 - looks like your instance is out of memory? how much memory does the droplet have and how much is available when you try starting mysql? Commented Jan 22, 2018 at 16:08
  • @Oliver the droplet has 512MB, there are other small websites running on it as well. How can I see how much memory is available when I try starting mysql? Commented Jan 24, 2018 at 18:39

1 Answer 1

1

Your droplet does not have enough memory available to start MySQL. See the error InnoDB: mmap(137363456 bytes) failed; errno 12 - MySQL is failing when trying to allocate ~130MB of memory.
Run free -m to check how much memory is available to applications.

You can address this issue in two ways:

  1. Increase the size of the droplet. This will cost you more money.
  2. Add (more) swap space to your droplet. This will most probably impact performance but saves you money.
Sign up to request clarification or add additional context in comments.

1 Comment

indeed, I increased the memory of the droplet from 512MB to 1G, it works now... thank you...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.