无法启动 MySQL 服务器 - 控制进程退出并出现错误代码

joy*_*eba 5 mysql ubuntu mysql-error-1064

我的 mysql 服务器停止后无法启动

\n

命令使用:

\n
sudo /etc/init.d/mysql restart\n
Run Code Online (Sandbox Code Playgroud)\n

错误 :

\n
\n

重新启动 mysql(通过 systemctl): mysql.serviceJob for mysql.service\n失败,因为控制进程退出并出现错误代码。

\n
\n

systemctl status mysql.service使用和检查状态journalctl -xe,没有得到任何帮助。

\n

错误日志:

\n

-

\n
\n
2020-06-23T00:11:48.882919Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use\n
Run Code Online (Sandbox Code Playgroud)\n

--explicit_defaults_for_timestamp 服务器选项(有关更多详细信息,请参阅文档)。

\n
2020-06-23T00:11:48.883135Z 0 [Warning] Can't create test file /u1/mysql/sad-swh.lower-test\n\n2020-06-23T00:11:48.883185Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.30-0ubuntu0.18.04.1) starting as process 28411 ...\n\n2020-06-23T00:11:48.886131Z 0 [Warning] Can't create test file /u1/mysql/sad-swh.lower-test\n\n2020-06-23T00:11:48.886148Z 0 [Warning] Can't create test file /u1/mysql/sad-swh.lower-test\n\n2020-06-23T00:11:48.889591Z 0 [Note] InnoDB: PUNCH HOLE support available\n\n2020-06-23T00:11:48.889612Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins\n\n2020-06-23T00:11:48.889616Z 0 [Note] InnoDB: Uses event mutexes\n\n2020-06-23T00:11:48.889620Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier\n\n2020-06-23T00:11:48.889623Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11\n\n2020-06-23T00:11:48.889627Z 0 [Note] InnoDB: Using Linux native AIO\n\n2020-06-23T00:11:48.889890Z 0 [Note] InnoDB: Number of pools: 1\n\n2020-06-23T00:11:48.890022Z 0 [Note] InnoDB: Using CPU crc32 instructions\n\n2020-06-23T00:11:48.892207Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M\n\n2020-06-23T00:11:48.900818Z 0 [Note] InnoDB: Completed initialization of buffer pool\n\n2020-06-23T00:11:48.903535Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be\n
Run Code Online (Sandbox Code Playgroud)\n

改变了。请参阅 setpriority() 的手册页。

\n
2020-06-23T00:11:48.913543Z 0 [Note] InnoDB: The first innodb_system data file 'ibdata1' did not exist. A new tablespace will\n
Run Code Online (Sandbox Code Playgroud)\n

被创造!

\n
2020-06-23T00:11:48.913858Z 0 [ERROR] InnoDB: Operating system error number 13 in a file operation.\n\n2020-06-23T00:11:48.913871Z 0 [ERROR] InnoDB: The error means mysqld does not have the access rights to the directory.\n\n2020-06-23T00:11:48.913878Z 0 [ERROR] InnoDB: Operating system error number 13 in a file operation.\n\n2020-06-23T00:11:48.913883Z 0 [ERROR] InnoDB: The error means mysqld does not have the access rights to the directory.\n\n2020-06-23T00:11:48.913889Z 0 [ERROR] InnoDB: Cannot open datafile './ibdata1'\n\n2020-06-23T00:11:48.913896Z 0 [ERROR] InnoDB: Could not open or create the system tablespace. If you tried to add new data files to\n
Run Code Online (Sandbox Code Playgroud)\n

系统表空间,并且在这里失败了,您现在应该将 my.cnf 中的 ninnodb_data_file_path 编辑回原来的状态,并删除在这次失败的尝试中创建的新 ibdata 文件 InnoDB。InnoDB 仅\n写入了那些全是零的文件,但尚未以任何方式使用它们。\n但要小心:不要删除\n包含您的宝贵数据的旧数据文件!

\n
2020-06-23T00:11:48.913903Z 0 [ERROR] InnoDB: InnoDB Database creation was aborted with error Cannot open a file. You may need to\n
Run Code Online (Sandbox Code Playgroud)\n

在尝试再次启动之前删除 ibdata1 文件。

\n
2020-06-23T00:11:49.514733Z 0 [ERROR] Plugin 'InnoDB' init function returned error.\n\n2020-06-23T00:11:49.514763Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.\n\n2020-06-23T00:11:49.514773Z 0 [ERROR] Failed to initialize builtin plugins.\n\n2020-06-23T00:11:49.514779Z 0 [ERROR] Aborting\n\n2020-06-23T00:11:49.514817Z 0 [Note] Binlog end\n\n2020-06-23T00:11:49.514889Z 0 [Note] Shutting down plugin 'CSV'\n\n2020-06-23T00:11:49.515486Z 0 [Note] /usr/sbin/mysqld: Shutdown complete\n
Run Code Online (Sandbox Code Playgroud)\n
\n
 \xe2\x97\x8f mysql.service - MySQL Community Server Loaded: loaded (/lib/systemd/system/mysql.service;\n enabled;\n vendor preset: enabled) Active: failed (Result: exit-code) since Mon 2020-06-22 16:07:36 CST;\n 9min ago Process: 26756 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pid (code=exited, status=1/FAILURE) Process: 26737 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS) Main PID: 18936 (code=exited, status=0/SUCCESS)\n
Run Code Online (Sandbox Code Playgroud)\n

Mos*_*man 5

Mysql 服务器在我的新 Ubuntu 18.04 实例上意外停止,并在尝试启动时出现相同的错误。

\n
Job for mysql.service failed because the control process exited with error code.\nSee "systemctl status mysql.service" and "journalctl -xe" for details.\n
Run Code Online (Sandbox Code Playgroud)\n

运行命令时systemctl status mysql.service

\n
\xe2\x97\x8f mysql.service - MySQL Community Server\n   Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)\n   Active: failed (Result: exit-code) since Sat 2020-08-29 17:11:53 UTC; 11s ago\n  Process: 3124 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=1/FAILURE)\n Main PID: 2557 (code=exited, status=0/SUCCESS)\n\nAug 29 17:11:53 ip-172-26-10-122 systemd[1]: mysql.service: Control process exited, code=exited status=1\nAug 29 17:11:53 ip-172-26-10-122 systemd[1]: mysql.service: Failed with result 'exit-code'.\nAug 29 17:11:53 ip-172-26-10-122 systemd[1]: Failed to start MySQL Community Server.\n
Run Code Online (Sandbox Code Playgroud)\n

经过网上搜索近6个小时终于找到了解决方案。

\n
sudo chmod -R u+rwx /etc/mysql/\nsudo chown -R mysql.mysql /etc/mysql/\n
Run Code Online (Sandbox Code Playgroud)\n