我的服务器是 CentOS 6.5 64 位,运行 Remi 的 MySQL 5.5.42 社区服务器。我尝试通过运行从命令行导入数据库
mysql -u root -p website_database < website_database.sql
输入密码并启动SQL后,显示以下消息:
ERROR 2013 (HY000) at line 288: Lost connection to MySQL server during query
我尝试以 root 身份重新启动 MySQL 服务器,但显示以下消息:
# service mysqld restart
Stopping mysqld: [ OK ]
MySQL Daemon failed to start.
Starting mysqld: [FAILED]
因此我验证了mysql错误日志文件,其内容如下:
150214 20:51:41 mysqld_safe Number of processes running now: 0
150214 20:51:41 mysqld_safe mysqld restarted
150214 20:51:41 [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.
150214 20:51:41 [Note] Plugin 'FEDERATED' is disabled.
150214 20:51:41 InnoDB: The InnoDB memory heap is disabled
150214 20:51:41 InnoDB: Mutexes and rw_locks use GCC atomic builtins
150214 20:51:41 InnoDB: Compressed tables use zlib 1.2.3
150214 20:51:41 InnoDB: Using Linux native AIO
150214 20:51:41 InnoDB: Initializing buffer pool, size = 128.0M
InnoDB: mmap(137363456 bytes) failed; errno 12
150214 20:51:41 InnoDB: Completed initialization of buffer pool
150214 20:51:41 InnoDB: Fatal error: cannot allocate memory for the buffer pool
150214 20:51:41 [ERROR] Plugin 'InnoDB' init function returned error.
150214 20:51:41 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
150214 20:51:41 [ERROR] Unknown/unsupported storage engine: InnoDB
150214 20:51:41 [ERROR] Aborting
150214 20:51:41 [Note] /usr/libexec/mysqld: Shutdown complete
150214 20:51:41 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
150214 20:53:29 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
150214 20:53:29 [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.
150214 20:53:29 [Note] Plugin 'FEDERATED' is disabled.
150214 20:53:29 InnoDB: The InnoDB memory heap is disabled
150214 20:53:29 InnoDB: Mutexes and rw_locks use GCC atomic builtins
150214 20:53:29 InnoDB: Compressed tables use zlib 1.2.3
150214 20:53:29 InnoDB: Using Linux native AIO
150214 20:53:29 InnoDB: Initializing buffer pool, size = 128.0M
InnoDB: mmap(137363456 bytes) failed; errno 12
150214 20:53:29 InnoDB: Completed initialization of buffer pool
150214 20:53:29 InnoDB: Fatal error: cannot allocate memory for the buffer pool
150214 20:53:29 [ERROR] Plugin 'InnoDB' init function returned error.
150214 20:53:29 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
150214 20:53:29 [ERROR] Unknown/unsupported storage engine: InnoDB
150214 20:53:29 [ERROR] Aborting
150214 20:53:29 [Note] /usr/libexec/mysqld: Shutdown complete
150214 20:53:29 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
重启 MySQL 服务器的唯一方法是重启整个服务器。我甚至查看了日志文件都没有任何线索,你知道可能发生了什么吗?谢谢。
答案1
InnoDB: mmap(137363456 bytes) failed; errno 12
此错误意味着数据库无法分配内存,所以您应该降低innodb_buffer_pool_size
值(我不推荐这样做,因为您当前的设置似乎已经很低了)或者升级您的硬件以获得更多 RAM。