问题
The system was running fine, but all of a sudden got this error 'Database connection failed', what might be the possible issues, how can I fix this error forever. Thank you.
System Information: Ubuntu 16.04.3 x64 2 GB Memory / 50 GB Disk
I checked with 'df -h' in the terminal,
I did error log check:
2018-07-31T10:10:04.751870Z 0 [Note] /usr/sbin/mysqld: Shutdown complete
2018-07-31T10:10:34.438715Z 0 [Warning] Changed limits: max_open_files: 1024 (requested 5000)
2018-07-31T10:10:34.438807Z 0 [Warning] Changed limits: table_open_cache: 431 (requested 2000)
2018-07-31T10:10:34.613317Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-07-31T10:10:34.615293Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.23-0ubuntu0.16.04.1) starting as process 14674 ...
2018-07-31T10:10:34.620666Z 0 [Note] InnoDB: PUNCH HOLE support available
2018-07-31T10:10:34.620694Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2018-07-31T10:10:34.620699Z 0 [Note] InnoDB: Uses event mutexes
2018-07-31T10:10:34.620703Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2018-07-31T10:10:34.620706Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.8
2018-07-31T10:10:34.620710Z 0 [Note] InnoDB: Using Linux native AIO
2018-07-31T10:10:34.621008Z 0 [Note] InnoDB: Number of pools: 1
2018-07-31T10:10:34.621153Z 0 [Note] InnoDB: Using CPU crc32 instructions
2018-07-31T10:10:34.623069Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2018-07-31T10:10:34.634597Z 0 [Note] InnoDB: Completed initialization of buffer pool
2018-07-31T10:10:34.637277Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2018-07-31T10:10:34.647303Z 0 [Note] InnoDB: The first innodb_system data file 'ibdata1' did not exist. A new tablespace will be created!
2018-07-31T10:10:34.647393Z 0 [ERROR] InnoDB: redo log file './ib_logfile0' exists. Creating system tablespace with existing redo log files is not recommended. Please delete all redo log files before creating new system tablespace.
2018-07-31T10:10:34.647403Z 0 [ERROR] InnoDB: InnoDB Database creation was aborted with error Generic error. You may need to delete the ibdata1 file before trying to start up again.
2018-07-31T10:10:35.248139Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2018-07-31T10:10:35.248186Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2018-07-31T10:10:35.248195Z 0 [ERROR] Failed to initialize builtin plugins.
2018-07-31T10:10:35.248201Z 0 [ERROR] Aborting
2018-07-31T10:10:35.248222Z 0 [Note] Binlog end
2018-07-31T10:10:35.248304Z 0 [Note] Shutting down plugin 'MyISAM'
2018-07-31T10:10:35.248323Z 0 [Note] Shutting down plugin 'CSV'
2018-07-31T10:10:35.248824Z 0 [Note] /usr/sbin/mysqld: Shutdown complete
回答1:
Did you change ib_logfile size in the process? the error The first innodb_system data file 'ibdata1' did not exist. A new tablespace will be created!
shows that it cannot find your ibdata file. Did you try the suggested Please delete all redo log files before creating new system tablespace
?
回答2:
solved it by following these steps for the error:
InnoDB: Unable to lock ./ibdata1, error: 11
commands are:
# cd /var/lib/mysql
# mkdir bak
# mv ibdata1 bak/.
# mv ib_logfile* bak/.
# cp -a bak/ibdata1 ibdata1
# cp -a bak/ib_logfile* .
# service mysql restart
Read the source
and then I was getting the error regarding 'restarting mysql service'
find the error post here
and then followed these steps:
lsof -i:3306
Then kill it (the process number)
kill -9 PROCESS
e.g. kill -9 13498
Then try to restart MySQL again.
Read the Source
thanks to @Evgeniy and @Quiron.
回答3:
It should be helpfull if you tell us if your moodle is hosted using LAMP, a MAMP, a WAMP, a WIMP, a XAMPP, remote hosted...
Also if you check the error log it should have more info about the problem. I had the same error time ago, the DB was overloaded so changing the value of max_execution_time solved the error. Into config.php search:upload_max_filesize = 2M or the value yo need.
max_execution_time = 60 or the value you need, the value are seconds.
After see your log I search for your error and I hope this will works:
Decrease the value of innodb-buffer-pool size in the config file/etc/mysql/my.cnf:innodb_buffer_pool_size = 10M
After save my.cnf, restart mysql service.
SOURCE: Getting error "Plugin 'InnoDB' registration as a STORAGE ENGINE failed" when starting MySQL来源:https://stackoverflow.com/questions/51610011/moodle-database-overload-error