Before I start, I'd like to state that I have tried exhausting all Stack Overflow posts asking this same question, but either none of their recommended answers apply (which is absurdly improbable), or I just wasn't able to find the right answer yet. Hence the following post:
First of all, I am not proficient at all regarding coding. However, in my job, which is managing the WordPress website of an Internet television network (meaning I schedule hourly updates of our online video content every day), I have to teach myself how to understand very basic coding in case emergencies happen. This is such an emergency. In doing advanced scheduling for our online content, I opened too many tabs and triggered a WordPress error:
Error establishing a database connection
This has happened before, and I managed to fix the error then by finding the answer sudo service mysqld start; here. However, when it reoccurred again today, simply redoing what I did before didn't work any more. Thus I tried following some other answers as much as my limited understanding of code can help me get. Some other similar queries. No answers so far were able to help me, or maybe I just don't understand how they work.
From what I gathered, my problem is
Trying the previous solution failed:
[root@li725-222 ~]# sudo service mysqld start;
MySQL Daemon failed to start.
Starting mysqld: [FAILED]
This, from my mysqld.log:
171217 05:19:05 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
171217 05:19:16 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
171217 5:19:16 [Note] /usr/libexec/mysqld (mysqld 5.5.53) starting as process 27761 ...
171217 5:19:16 [Note] Plugin 'FEDERATED' is disabled.
171217 5:19:16 InnoDB: The InnoDB memory heap is disabled
171217 5:19:16 InnoDB: Mutexes and rw_locks use GCC atomic builtins
171217 5:19:16 InnoDB: Compressed tables use zlib 1.2.3
171217 5:19:16 InnoDB: Using Linux native AIO
171217 5:19:16 InnoDB: Initializing buffer pool, size = 128.0M
InnoDB: mmap(137363456 bytes) failed; errno 12
171217 5:19:16 InnoDB: Completed initialization of buffer pool
171217 5:19:16 InnoDB: Fatal error: cannot allocate memory for the buffer pool
171217 5:19:16 [ERROR] Plugin 'InnoDB' init function returned error.
171217 5:19:16 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
171217 5:19:16 [ERROR] Unknown/unsupported storage engine: InnoDB
171217 5:19:16 [ERROR] Aborting
171217 5:19:16 [Note] /usr/libexec/mysqld: Shutdown complete
171217 05:19:16 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
Searching for InnoDB: Fatal error: cannot allocate memory for the buffer pool on Google, I found this guide. Doing this suggestion didn't yield results (maybe I did it wrong, or maybe the solution is not applicable?):
(1) Increase the physical RAM. Adding 1GB of additional RAM will solve the problem.
(2) Allocate SWAP space. Digital Ocean VPS instance is not configured to use swap space by default. By allocating 512MB of swap space, we were able to solve this problem. To add swap space to your server, please follow the following steps:
## As a root user, perform the following: # dd if=/dev/zero of=/swap.dat bs=1024 count=512M # mkswap /swap.dat # swapon /swap.dat ## Edit the /etc/fstab, and the following entry. /swap.dat none swap sw 0 0
(3) Reduce the size of MySQL buffer pool size
## Edit /etc/my.cnf, and add the following line under the [mysqld] heading. [mysqld] innodb_buffer_pool_size=64M
Restart mysql and you're good to go.
I tried some of the answers in this thread as well but I don't think any of them worked.
Our website is hosted in Linode and is running on CentOS 6.5.
P.S. I have just noticed that my mysqld.log had ballooned in size from 754kb to ~881.97mb. I don't know the reason but of course it must have something to do with my attempted fixes. I recall deleting the files /var/lib/mysql/ib_logfile0 and /var/lib/mysql/ib_logfile1 as per the advice of one of the solutions I tried (I backed them up first, of course). The difference between the mysqld.log then and now is that in the latest version, these text strings have been added:
171217 05:19:16 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
171217 05:39:42 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
171217 5:39:42 [Note] /usr/libexec/mysqld (mysqld 5.5.53) starting as process 28073 ...
171217 5:39:42 [Note] Plugin 'FEDERATED' is disabled.
171217 5:39:42 InnoDB: The InnoDB memory heap is disabled
171217 5:39:42 InnoDB: Mutexes and rw_locks use GCC atomic builtins
171217 5:39:42 InnoDB: Compressed tables use zlib 1.2.3
171217 5:39:42 InnoDB: Using Linux native AIO
171217 5:39:42 InnoDB: Initializing buffer pool, size = 64.0M
171217 5:39:42 InnoDB: Completed initialization of buffer pool
171217 5:39:42 InnoDB: Log file ./ib_logfile0 did not exist: new to be created
InnoDB: Setting log file ./ib_logfile0 size to 5 MB
InnoDB: Database physically writes the file full: wait...
171217 5:39:42 InnoDB: Log file ./ib_logfile1 did not exist: new to be created
InnoDB: Setting log file ./ib_logfile1 size to 5 MB
InnoDB: Database physically writes the file full: wait...
171217 5:39:42 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!
171217 5:39:42 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...
171217 5:39:42 InnoDB: Error: page 1 log sequence number 1118101582
InnoDB: is in the future! Current system log sequence number 580967436.
InnoDB: Your database may be corrupt or you may have copied the InnoDB
InnoDB: tablespace but not the InnoDB log files. See
InnoDB: http://dev.mysql.com/doc/refman/5.5/en/forcing-innodb-recovery.html
InnoDB: for more information.
171217 5:39:42 InnoDB: Error: page 4 log sequence number 1099567460
InnoDB: is in the future! Current system log sequence number 580967436.
InnoDB: Your database may be corrupt or you may have copied the InnoDB
InnoDB: tablespace but not the InnoDB log files. See
InnoDB: http://dev.mysql.com/doc/refman/5.5/en/forcing-innodb-recovery.html
InnoDB: for more information...
..with that last paragraph looping and looping up until the moment (maybe it is still updating).