69

I recently upgraded from the previous LTS Ubuntu to Precise and now mysql refuses to start. It complains of the following when I attempt to start it:

╰$ sudo service mysql restart
stop: Unknown instance:
start: Job failed to start

And this shows in "/var/log/mysql/error.log":

120415 23:01:09 [Note] Plugin 'InnoDB' is disabled.
120415 23:01:09 [Note] Plugin 'FEDERATED' is disabled.
120415 23:01:09 [ERROR] Unknown/unsupported storage engine: InnoDB
120415 23:01:09 [ERROR] Aborting

120415 23:01:09 [Note] /usr/sbin/mysqld: Shutdown complete

I've checked permissions on all the mysql directories to make sure it had ownership and I also renamed the previou ib_logs so that it could remake them. I'm just getting no where with this issue right now, after looking at google results for 2 hours.

frlan
  • 573
  • 1
  • 8
  • 27
Garrett
  • 823
  • 1
  • 7
  • 8

9 Answers9

72

After checking the logs I found the following error:

[ERROR] Unknown/unsupported storage engine: InnoDB

I removed these files:

rm /var/lib/mysql/ib_logfile0
rm /var/lib/mysql/ib_logfile1 

at /var/lib/mysql

This resolved my problem after restart.

Apache
  • 294
  • 6
  • 19
Vinay
  • 749
  • 5
  • 2
  • 7
    the `rm` command is used to Remove files rather than rename them as far as i know... – Itai Ganot May 21 '14 at 07:06
  • 6
    Those files contain the *actual data* for your database. You don't want to delete them. – Stefan Lasiewski Jun 02 '14 at 20:26
  • 3
    No, the `ibdata` file contains the data (unless you have file-per-table). The ib_logfile files are the replay logs that contain the data for database-altering transactions that may have been in process when/if the database crashed. If you were able to shutdown the server successfully, deleting these log files won't hurt you. If it crashed, then you need them. But this is a valid answer. If your my.cnf file changes the innodb_log_file_size option and it no longer matches those two files, you will get the error message that the OP states. Deleting/moving so new ones can be made fixes it. – Safado Jun 30 '14 at 15:28
  • 2
    Why edits can only be made for 5 minutes is beyond me... I should have stated it is a *potential* fix for the above mentioned error. As stated by the OP, it was not the fix he needed. – Safado Jun 30 '14 at 15:40
  • I could not "ignore or skip" innodb as I had at hand, over 10 years of data from a customer in that ibdata file. The only option was to keep "innodb" engine selected and make that data work with the mysql server. – Ram on Rails Sep 29 '15 at 10:06
  • 2
    This solution also worked for me. No data damaged. – TCB13 Oct 31 '15 at 16:40
  • 1
    This solution worked for me as well. +1 – Paul Carlton Jan 19 '16 at 22:32
  • 1
    Got this error after running out of free disk space during mysql (re)install. Finding & removing truncated files helped. – Dallaylaen Jan 25 '16 at 20:42
  • 2
    You can always rename them, e.g. `mv ib_logfile0 ib_logfile0.bak && mv ib_logfile1 ib_logfile1.bak`. – kenorb Apr 14 '16 at 13:58
  • 1
    This works for some people and I appreciate that. However, the lack of an explanation as to how deleting those files fixes the problem has me worried. – Peter Chaula Jan 24 '21 at 18:45
  • I found "[ERROR] InnoDB: Missing FILE_CHECKPOINT at 45142 between the checkpoint 45142 and the end 4115531." in the log not far before the "Unknown/unsupported storage engine" error. Deleting the /var/lib/mysql/ib_logfile0 (there was no ib_logfile1) indeed allowed me to run "service mysql start" without failing. But... Data was damaged. It was only only a local dev WordPress running but that needed a reinstall. Not sure if db corruption this was the cause of the error or the result of the file deletion :/ – RavanH Jan 11 '22 at 09:27
  • works like a charm. – Alex May 03 '23 at 19:49
  • Yup, simply running out of disk space can result in the same error, if you delete these two files you might free up a little disk space (enough for the server to be able to start again) but will quickly run into the same thing. This happened to me, a simple df -h will tell you what the situation is like. – John Hunt Jul 17 '23 at 20:49
22

If you really need skip-innodb (use case: low memory footprint), then of course you don't have to comment it out. However, if InnoDB is the default storage engine, the server will fail to start until you tell it which storage engine to use instead, e.g. default-storage-engine=myisam for MyISAM.

So, try this:

$ sudo -u mysql mysqld --skip-innodb --default-storage-engine=myisam
11

If you're using MySQL 5.6+ and want to disable InnoDB, don't forget "--default-tmp-storage" or it won't work:

To disable InnoDB, use --innodb=OFF or --skip-innodb. In this case, because the default storage engine is InnoDB, the server will not start unless you also use --default-storage-engine and --default-tmp-storage-engine to set the default to some other engine for both permanent and TEMPORARY tables.

http://dev.mysql.com/doc/refman/5.6/en/innodb-parameters.html#option_mysqld_ignore-builtin-innodb

You can add this to your my.cnf:

[mysqld] 
innodb=OFF 
ignore-builtin-innodb 
skip-innodb
default-storage-engine=myisam 
default-tmp-storage-engine=myisam

just to make sure it'll work.

Juan
  • 119
  • 1
  • 2
  • +1, Never notice the official document. it should set `default-storage-engine` and `default-tmp-storage-engine`, thanks. – Giberno Nov 07 '14 at 08:48
9

Check your mysql error log.

tail -100 /var/log/mysql/error.log

If your log says (like mine did):

InnoDB: Initializing buffer pool, size = 128.0M
InnoDB: mmap(137363456 bytes) failed; errno 12
[ERROR] InnoDB: Cannot allocate memory for the buffer pool

You don't have enough memory to use the default buffer size of 128M

Edit the config file /etc/mysql/my.cnf adding a line to specify a smaller innodb_buffer_pool_size.

# make the buffer pool smaller than 128M since we only have 1 GB of total RAM
innodb_buffer_pool_size = 16M

Save the config file, and start mysql

sudo service mysql start
user2219975
  • 205
  • 2
  • 4
  • Is spot on here. But could also be hanging processes of the webserver or something eating up the RAM, do check that, too. – sjas May 08 '17 at 14:17
0

I got this error on a modern MariaDB 10.5 system, because I forgot to units on the innodb control lines;

innodb_buffer_pool_size = 4096
innodb_log_file_size    = 1024

instead of

innodb_buffer_pool_size = 4096MB
innodb_log_file_size    = 1024MB

So, if you get this one, check there

Kirrus
  • 482
  • 2
  • 11
0

Check that you have enough free space on the disk.

Run this command to view available free space

df -h

I had this same error message but, once I provisioned more space mysql service was able to start normally

elijahbee
  • 1
  • 1
0

I had this problem, when reloading the /var/lib/mysql/ folder into a fresh install of Debian 12.

I had to remove the logfile with

mv /var/lib/mysql/ib_logfile0 /var/lib/mysql/ib_logfile0-bak

and create a new empty file with

echo ""> /var/lib/mysql/ib_logfile0

Now the service starts, but you see a lot of errors like

Aug 30 15:15:31 test mariadbd[40673]: 2023-08-30 15:15:31 0 [ERROR] InnoDB: Page [page id: space=9154, page number=3] log sequence number 258766592934 is in the future! Current system log sequence number 254569578017.
Aug 30 15:15:31 test mariadbd[40673]: 2023-08-30 15:15:31 0 [ERROR] InnoDB: Your database may be corrupt or you may have copied the InnoDB tablespace but not the InnoDB log files. Please refer to https://mariadb.com/kb/en/library/innodb-recovery-modes/ for information about forcing recovery.

I use 10.11.3-MariaDB, so I guess, I have to set in /etc/mysql/mariadb.conf.d/50-server.cnf

[mariadb]
innodb_force_recovery=4

and restart with

systemctl restart mysql 
rubo77
  • 2,469
  • 4
  • 34
  • 66
0

I got this error when I deleted the location I use for tmpdir. If you've recently changed your tmpdir, you might want to check that it's a valid, writable location.

Jeff
  • 119
  • 7
-1

Try 2 more things. 1. Lower the innodb buffer pool size. 2. Edit mysql initial script and add --innodb option.

I wonder also if your package is buggy. Could you try a different minor version?

Also, I assume your mysql server got upgraded as well? Maybe that version is broken? Precise is not final yet.

johnshen64
  • 5,865
  • 24
  • 17