尝试启动 MySQL 时出现错误

尝试启动 MySQL 时出现错误

我已经被这个问题困扰好几天了。当我运行时,service mysql start 它返回以下内容:

matthew@matthewserver:~$ service mysql start
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to start 'mysql.service'.
Authenticating as: matthew tranmer (matthew)
Password:
==== AUTHENTICATION COMPLETE ===
Job for mysql.service failed because the control process exited with error code.
See "systemctl status mysql.service" and "journalctl -xe" for details.

当我跑步时journalctl -xe

-- Unit mysql.service has begun starting up.
Oct 02 16:32:27 matthewserver mysql-systemd-start[31599]: ERROR: Unable to start MySQL server:
Oct 02 16:32:27 matthewserver mysql-systemd-start[31599]: 2018-10-02T16:32:27.849609Z 0 [ERROR] unknown variable 'key_buffer=16M'
Oct 02 16:32:27 matthewserver mysql-systemd-start[31599]: 2018-10-02T16:32:27.857580Z 0 [ERROR] Aborting
Oct 02 16:32:27 matthewserver mysql-systemd-start[31599]: Please take a look at https://wiki.debian.org/Teams/MySQL/FAQ for tips on fixing common upgrade issues.
Oct 02 16:32:27 matthewserver mysql-systemd-start[31599]: Once the problem is resolved, restart the service.
Oct 02 16:32:27 matthewserver systemd[1]: mysql.service: Control process exited, code=exited status=1
Oct 02 16:32:27 matthewserver systemd[1]: mysql.service: Failed with result 'exit-code'.
Oct 02 16:32:27 matthewserver systemd[1]: Failed to start MySQL Community Server.
-- Subject: Unit mysql.service has failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- Unit mysql.service has failed.
--
-- The result is RESULT.
Oct 02 16:32:28 matthewserver systemd[1]: mysql.service: Service hold-off time over, scheduling restart.
Oct 02 16:32:28 matthewserver systemd[1]: mysql.service: Scheduled restart job, restart counter is at 5.
-- Subject: Automatic restarting of a unit has been scheduled
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- Automatic restarting of the unit mysql.service has been scheduled, as the result for
-- the configured Restart= setting for the unit.
Oct 02 16:32:28 matthewserver systemd[1]: Stopped MySQL Community Server.
-- Subject: Unit mysql.service has finished shutting down
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- Unit mysql.service has finished shutting down.
Oct 02 16:32:28 matthewserver systemd[1]: mysql.service: Start request repeated too quickly.
Oct 02 16:32:28 matthewserver systemd[1]: mysql.service: Failed with result 'exit-code'.
Oct 02 16:32:28 matthewserver systemd[1]: Failed to start MySQL Community Server.
-- Subject: Unit mysql.service has failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- Unit mysql.service has failed.
--
-- The result is RESULT.

当我运行时systemctl status mysql.service我得到:

● mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Tue 2018-10-02 16:32:28 UTC; 2min 33s ago
  Process: 28760 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pid (code=exited, status=1/FAILURE)
  Process: 31599 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=1/FAILURE)

Oct 02 16:32:27 matthewserver mysql-systemd-start[31599]: Once the problem is resolved, restart the service.
Oct 02 16:32:27 matthewserver systemd[1]: mysql.service: Control process exited, code=exited status=1
Oct 02 16:32:27 matthewserver systemd[1]: mysql.service: Failed with result 'exit-code'.
Oct 02 16:32:27 matthewserver systemd[1]: Failed to start MySQL Community Server.
Oct 02 16:32:28 matthewserver systemd[1]: mysql.service: Service hold-off time over, scheduling restart.
Oct 02 16:32:28 matthewserver systemd[1]: mysql.service: Scheduled restart job, restart counter is at 5.
Oct 02 16:32:28 matthewserver systemd[1]: Stopped MySQL Community Server.
Oct 02 16:32:28 matthewserver systemd[1]: mysql.service: Start request repeated too quickly.
Oct 02 16:32:28 matthewserver systemd[1]: mysql.service: Failed with result 'exit-code'.
Oct 02 16:32:28 matthewserver systemd[1]: Failed to start MySQL Community Server.

当我跑步时发生这种情况sudo mysql

matthew@matthewserver:~$ sudo mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

我不知道该怎么做才能让它工作,这有点像最后的手段。

答案1

journalctl 的输出中有一行:

2018-10-02T16:32:27.849609Z 0 [错误] 未知变量 'key_buffer=16M'

此系统变量不存在。您尝试设置的变量可能是key_buffer_size。在my.cnf通常位于的文件中/etc,删除该key_buffer条目并添加以下条目:

密钥缓冲区大小 = 16M

答案2

mysqld 配置有错误:

10月02日 16:32:27 matthewserver mysql-systemd-start [31599]:2018-10-02T16:32:27.849609Z 0 [错误]未知变量'key_buffer = 16M'

您应该使用key_buffer_size=16M,而不是key_buffer=16M

相关内容