MySQL数据库启动失败问题的处理【阿里云服务器CentOS7为例】
[root@iZbp106mxhd41bfj0bxhuhZ ~]# service mysqld start
Timeout error occurred trying to start MySQL Daemon.
Starting mysqld: [FAILED]
说明:
遇到MySQL数据库启动失败,千万不要急着进行“rm”或修改“my.cnf”之类的尝试,rm操作会删除数据库,非常危险,谨记!
操作思路:
打开/var/log/mysqld.log文件,可以清晰的查看到问题出现的各种原因,从而对症下药,比如我的错误是:
InnoDB: Error: auto-extending data file ./ibdata1 is of a different size
InnoDB: 320 pages (rounded down to MB) than specified in the .cnf file:
InnoDB: initial 640 pages, max 0 (relevant if non-zero) pages!
InnoDB: Could not open or create data files.
InnoDB: If you tried to add new data files, and it failed here,
InnoDB: you should now edit innodb_data_file_path in my.cnf back
InnoDB: to what it was, and remove the new ibdata files InnoDB created
InnoDB: in this failed attempt. InnoDB only wrote those files full of
InnoDB: zeros, but did not yet use them in any way. But be careful: do not
InnoDB: remove old data files which contain your precious data!
191220 10:21:33 [ERROR] Plugin ‘InnoDB’ init function returned error.
191220 10:21:33 [ERROR] Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed.
191220 10:21:33 [ERROR] /usr/libexec/mysqld: Error writing file ‘/var/run/mysqld/mysqld.pid’ (Errcode: 28)
191220 10:21:33 [ERROR] Can’t start server: can’t create PID file: No space left on device
191220 10:21:33 mysqld_safe Number of processes running now: 0
191220 10:21:33 mysqld_safe mysqld restarted
191220 10:21:34 [Warning] ‘–default-character-set’ is deprecated and will be removed in a future release. Please use ‘–character-set-server’ instead.
… …
第一行:InnoDB: Error: auto-extending data file ./ibdata1 is of a different size
说明服务器空间已满,备份并删除部分文件,如图片等
service mysqld start
即可启动成功。MySQL done!
谢谢!