MySQL 因错误无法启动

MySQL 因错误无法启动

我正在尝试让 MySQL 在我的 ubuntu 服务器上运行。似乎我遇到了一些错误,我一直在尝试自己解决它们,但没有成功。我运行了:

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install mysql-server

安装完成后,我尝试通过执行以下操作来确保它已打开,sudo service mysql start结果显示

mysql.service 的作业失败,因为控制进程退出并显示错误代码。有关详细信息,请参阅“systemctl status mysql.service”和“journalctl -xe”。

我运行了sudo service mysql status,结果返回了以下内容:

● mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
   Active: activating (start-post) (Result: exit-code) since Tue 2017-04-04 14:15:55 EEST; 12s ago
  Process: 7451 ExecStart=/usr/sbin/mysqld (code=exited, status=1/FAILURE)
  Process: 7448 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
 Main PID: 7451 (code=exited, status=1/FAILURE);         : 7452 (mysql-systemd-s)
    Tasks: 2
   Memory: 1.0M
      CPU: 245ms
   CGroup: /system.slice/mysql.service
           └─control
             ├─7452 /bin/bash /usr/share/mysql/mysql-systemd-start post
             └─7483 sleep 1

如果有人能帮忙我将非常感激。

编辑1:

journalctl -xe这是尝试启动 MySql 后的输出:

-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mysql.service has failed.
--
-- The result is failed.
Apr 04 15:34:21 ramireini systemd[1]: mysql.service: Unit entered failed state.
Apr 04 15:34:21 ramireini systemd[1]: mysql.service: Failed with result 'exit-code'.
Apr 04 15:34:22 ramireini systemd[1]: mysql.service: Service hold-off time over, scheduling restart.
Apr 04 15:34:22 ramireini systemd[1]: Stopped MySQL Community Server.
-- Subject: Unit mysql.service has finished shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mysql.service has finished shutting down.
Apr 04 15:34:22 ramireini systemd[1]: Starting MySQL Community Server...
-- Subject: Unit mysql.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mysql.service has begun starting up.
Apr 04 15:34:22 ramireini audit[21899]: AVC apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/proc/21899/status" pid=21899 comm="mysqld" requested_mask="r" denied_mask="r" fsuid=115 ouid=115
Apr 04 15:34:22 ramireini kernel: audit: type=1400 audit(1491309262.116:1342): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/proc/21899/status" pid=21899 comm="mysqld" requested_mask="r" denied_mask="r" fsuid=115 o
Apr 04 15:34:22 ramireini kernel: audit: type=1400 audit(1491309262.116:1343): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/sys/devices/system/node/" pid=21899 comm="mysqld" requested_mask="r" denied_mask="r" fsui
Apr 04 15:34:22 ramireini kernel: audit: type=1400 audit(1491309262.116:1344): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/proc/21899/status" pid=21899 comm="mysqld" requested_mask="r" denied_mask="r" fsuid=115 o
Apr 04 15:34:22 ramireini audit[21899]: AVC apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/sys/devices/system/node/" pid=21899 comm="mysqld" requested_mask="r" denied_mask="r" fsuid=115 ouid=0
Apr 04 15:34:22 ramireini audit[21899]: AVC apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/proc/21899/status" pid=21899 comm="mysqld" requested_mask="r" denied_mask="r" fsuid=115 ouid=115
Apr 04 15:34:22 ramireini systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE
Apr 04 15:34:23 ramireini sudo[21909]:     root : TTY=pts/6 ; PWD=/ ; USER=root ; COMMAND=/usr/sbin/service mysql start
Apr 04 15:34:23 ramireini sudo[21909]: pam_unix(sudo:session): session opened for user root by root(uid=0)
Apr 04 15:34:52 ramireini systemd[1]: Failed to start MySQL Community Server.
-- Subject: Unit mysql.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mysql.service has failed.
--
-- The result is failed.
Apr 04 15:34:52 ramireini systemd[1]: mysql.service: Unit entered failed state.
Apr 04 15:34:52 ramireini sudo[21909]: pam_unix(sudo:session): session closed for user root
Apr 04 15:34:52 ramireini systemd[1]: mysql.service: Failed with result 'exit-code'.
Apr 04 15:34:52 ramireini systemd[1]: mysql.service: Service hold-off time over, scheduling restart.
Apr 04 15:34:52 ramireini systemd[1]: Stopped MySQL Community Server.
-- Subject: Unit mysql.service has finished shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mysql.service has finished shutting down.
Apr 04 15:34:52 ramireini systemd[1]: Starting MySQL Community Server...
-- Subject: Unit mysql.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mysql.service has begun starting up.
Apr 04 15:34:52 ramireini audit[22008]: AVC apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/proc/22008/status" pid=22008 comm="mysqld" requested_mask="r" denied_mask="r" fsuid=115 ouid=115
Apr 04 15:34:52 ramireini audit[22008]: AVC apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/sys/devices/system/node/" pid=22008 comm="mysqld" requested_mask="r" denied_mask="r" fsuid=115 ouid=0
Apr 04 15:34:52 ramireini audit[22008]: AVC apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/proc/22008/status" pid=22008 comm="mysqld" requested_mask="r" denied_mask="r" fsuid=115 ouid=115
Apr 04 15:34:52 ramireini kernel: audit: type=1400 audit(1491309292.625:1345): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/proc/22008/status" pid=22008 comm="mysqld" requested_mask="r" denied_mask="r" fsuid=115 o
Apr 04 15:34:52 ramireini kernel: audit: type=1400 audit(1491309292.625:1346): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/sys/devices/system/node/" pid=22008 comm="mysqld" requested_mask="r" denied_mask="r" fsui
Apr 04 15:34:52 ramireini kernel: audit: type=1400 audit(1491309292.625:1347): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/proc/22008/status" pid=22008 comm="mysqld" requested_mask="r" denied_mask="r" fsuid=115 o
Apr 04 15:34:52 ramireini systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE
lines 2046-2106/2106 (END)
[weechat] 0:WeeChat 1.4- 1:HTML  2:CSS  3:PHP  4:SQL*                      

https://hastebin.com/kayazumili.txt

我把它全部放进了 hastebin,这样无数行代码就可以放进去了 :p

编辑2:

我按照步骤进行操作,并在重新安装过程中注意到了以下几点:

AppArmor parser error for /etc/apparmor.d/usr.sbin.mysqld in /etc/apparmor.d/usr.sbin.mysqld at line 9: Could not open 'abstractions/mysql'.

E: Sub-process /usr/bin/dpkg returned an error code (1)

W: Operation was interrupted before it could finish.

MySQL 安装命令的输出:

root@ramireini:~# sudo apt-get install mysql-server
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  libaio1 libcgi-fast-perl libcgi-pm-perl libencode-locale-perl libevent-core-2.0-5 libfcgi-perl libhtml-parser-perl libhtml-tagset-perl libhtml-template-perl libhttp-date-perl libhttp-message-perl
  libio-html-perl liblwp-mediatypes-perl libtimedate-perl liburi-perl mysql-client-5.7 mysql-client-core-5.7 mysql-common mysql-server-5.7 mysql-server-core-5.7
Suggested packages:
  libdata-dump-perl libipc-sharedcache-perl libwww-perl mailx tinyca
The following NEW packages will be installed:
  libaio1 libcgi-fast-perl libcgi-pm-perl libencode-locale-perl libevent-core-2.0-5 libfcgi-perl libhtml-parser-perl libhtml-tagset-perl libhtml-template-perl libhttp-date-perl libhttp-message-perl
  libio-html-perl liblwp-mediatypes-perl libtimedate-perl liburi-perl mysql-client-5.7 mysql-client-core-5.7 mysql-common mysql-server mysql-server-5.7 mysql-server-core-5.7
0 upgraded, 21 newly installed, 0 to remove and 4 not upgraded.
Need to get 0 B/19.4 MB of archives.
After this operation, 163 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = (unset),
    LC_ALL = (unset),
    LC_TIME = "fi_FI.UTF-8",
    LC_MONETARY = "fi_FI.UTF-8",
    LC_ADDRESS = "fi_FI.UTF-8",
    LC_TELEPHONE = "fi_FI.UTF-8",
    LC_NAME = "fi_FI.UTF-8",
    LC_MEASUREMENT = "fi_FI.UTF-8",
    LC_IDENTIFICATION = "fi_FI.UTF-8",
    LC_NUMERIC = "fi_FI.UTF-8",
    LC_PAPER = "fi_FI.UTF-8",
    LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_US.UTF-8").
locale: Cannot set LC_ALL to default locale: No such file or directory
Preconfiguring packages ...
/usr/bin/locale: Cannot set LC_ALL to default locale: No such file or directory
Selecting previously unselected package mysql-common.
(Reading database ... 119915 files and directories currently installed.)
Preparing to unpack .../mysql-common_5.7.17-0ubuntu0.16.04.1_all.deb ...
Unpacking mysql-common (5.7.17-0ubuntu0.16.04.1) ...
Selecting previously unselected package libaio1:amd64.
Preparing to unpack .../libaio1_0.3.110-2_amd64.deb ...
Unpacking libaio1:amd64 (0.3.110-2) ...
Selecting previously unselected package mysql-client-core-5.7.
Preparing to unpack .../mysql-client-core-5.7_5.7.17-0ubuntu0.16.04.1_amd64.deb ...
Unpacking mysql-client-core-5.7 (5.7.17-0ubuntu0.16.04.1) ...
Selecting previously unselected package mysql-client-5.7.
Preparing to unpack .../mysql-client-5.7_5.7.17-0ubuntu0.16.04.1_amd64.deb ...
Unpacking mysql-client-5.7 (5.7.17-0ubuntu0.16.04.1) ...
Selecting previously unselected package mysql-server-core-5.7.
Preparing to unpack .../mysql-server-core-5.7_5.7.17-0ubuntu0.16.04.1_amd64.deb ...
Unpacking mysql-server-core-5.7 (5.7.17-0ubuntu0.16.04.1) ...
Selecting previously unselected package libevent-core-2.0-5:amd64.
Preparing to unpack .../libevent-core-2.0-5_2.0.21-stable-2ubuntu0.16.04.1_amd64.deb ...
Unpacking libevent-core-2.0-5:amd64 (2.0.21-stable-2ubuntu0.16.04.1) ...
Processing triggers for libc-bin (2.23-0ubuntu7) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up mysql-common (5.7.17-0ubuntu0.16.04.1) ...
update-alternatives: using /etc/mysql/my.cnf.fallback to provide /etc/mysql/my.cnf (my.cnf) in auto mode
Selecting previously unselected package mysql-server-5.7.
(Reading database ... 120084 files and directories currently installed.)
Preparing to unpack .../mysql-server-5.7_5.7.17-0ubuntu0.16.04.1_amd64.deb ...
locale: Cannot set LC_ALL to default locale: No such file or directory
Unpacking mysql-server-5.7 (5.7.17-0ubuntu0.16.04.1) ...
Selecting previously unselected package libhtml-tagset-perl.
Preparing to unpack .../libhtml-tagset-perl_3.20-2_all.deb ...
Unpacking libhtml-tagset-perl (3.20-2) ...
Selecting previously unselected package liburi-perl.
Preparing to unpack .../liburi-perl_1.71-1_all.deb ...
Unpacking liburi-perl (1.71-1) ...
Selecting previously unselected package libhtml-parser-perl.
Preparing to unpack .../libhtml-parser-perl_3.72-1_amd64.deb ...
Unpacking libhtml-parser-perl (3.72-1) ...
Selecting previously unselected package libcgi-pm-perl.
Preparing to unpack .../libcgi-pm-perl_4.26-1_all.deb ...
Unpacking libcgi-pm-perl (4.26-1) ...
Selecting previously unselected package libfcgi-perl.
Preparing to unpack .../libfcgi-perl_0.77-1build1_amd64.deb ...
Unpacking libfcgi-perl (0.77-1build1) ...
Selecting previously unselected package libcgi-fast-perl.
Preparing to unpack .../libcgi-fast-perl_1%3a2.10-1_all.deb ...
Unpacking libcgi-fast-perl (1:2.10-1) ...
Selecting previously unselected package libencode-locale-perl.
Preparing to unpack .../libencode-locale-perl_1.05-1_all.deb ...
Unpacking libencode-locale-perl (1.05-1) ...
Selecting previously unselected package libhtml-template-perl.
Preparing to unpack .../libhtml-template-perl_2.95-2_all.deb ...
Unpacking libhtml-template-perl (2.95-2) ...
Selecting previously unselected package libtimedate-perl.
Preparing to unpack .../libtimedate-perl_2.3000-2_all.deb ...
Unpacking libtimedate-perl (2.3000-2) ...
Selecting previously unselected package libhttp-date-perl.
Preparing to unpack .../libhttp-date-perl_6.02-1_all.deb ...
Unpacking libhttp-date-perl (6.02-1) ...
Selecting previously unselected package libio-html-perl.
Preparing to unpack .../libio-html-perl_1.001-1_all.deb ...
Unpacking libio-html-perl (1.001-1) ...
Selecting previously unselected package liblwp-mediatypes-perl.
Preparing to unpack .../liblwp-mediatypes-perl_6.02-1_all.deb ...
Unpacking liblwp-mediatypes-perl (6.02-1) ...
Selecting previously unselected package libhttp-message-perl.
Preparing to unpack .../libhttp-message-perl_6.11-1_all.deb ...
Unpacking libhttp-message-perl (6.11-1) ...
Selecting previously unselected package mysql-server.
Preparing to unpack .../mysql-server_5.7.17-0ubuntu0.16.04.1_all.deb ...
Unpacking mysql-server (5.7.17-0ubuntu0.16.04.1) ...
Processing triggers for man-db (2.7.5-1) ...
Processing triggers for systemd (229-4ubuntu16) ...
Processing triggers for ureadahead (0.100.0-19) ...
Setting up libaio1:amd64 (0.3.110-2) ...
Setting up mysql-client-core-5.7 (5.7.17-0ubuntu0.16.04.1) ...
Setting up mysql-client-5.7 (5.7.17-0ubuntu0.16.04.1) ...
Setting up mysql-server-core-5.7 (5.7.17-0ubuntu0.16.04.1) ...
Setting up libevent-core-2.0-5:amd64 (2.0.21-stable-2ubuntu0.16.04.1) ...
Setting up mysql-server-5.7 (5.7.17-0ubuntu0.16.04.1) ...
locale: Cannot set LC_ALL to default locale: No such file or directory
update-alternatives: using /etc/mysql/mysql.cnf to provide /etc/mysql/my.cnf (my.cnf) in auto mode
Renaming removed key_buffer and myisam-recover options (if present)
AppArmor parser error for /etc/apparmor.d/usr.sbin.mysqld in /etc/apparmor.d/usr.sbin.mysqld at line 9: Could not open 'abstractions/mysql'
Job for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xe" for details.
invoke-rc.d: initscript mysql, action "start" failed.
â— mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
   Active: activating (auto-restart) (Result: exit-code) since Tue 2017-04-04 19:01:59 EEST; 21ms ago
  Process: 25878 ExecStartPost=/usr/share/mysql/mysql-systemd-start post (code=exited, status=0/SUCCESS)
  Process: 25877 ExecStart=/usr/sbin/mysqld (code=exited, status=1/FAILURE)
  Process: 25872 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
 Main PID: 25877 (code=exited, status=1/FAILURE)

Apr 04 19:01:59 ramireini systemd[1]: Failed to start MySQL Community Server.
Apr 04 19:01:59 ramireini systemd[1]: mysql.service: Unit entered failed state.
Apr 04 19:01:59 ramireini systemd[1]: mysql.service: Failed with result 'exit-code'.
dpkg: error processing package mysql-server-5.7 (--configure):
 subprocess installed post-installation script returned error exit status 1
Setting up libhtml-tagset-perl (3.20-2) ...
Setting up liburi-perl (1.71-1) ...
Setting up libhtml-parser-perl (3.72-1) ...
Setting up libcgi-pm-perl (4.26-1) ...
Setting up libfcgi-perl (0.77-1build1) ...
Setting up libcgi-fast-perl (1:2.10-1) ...
Setting up libencode-locale-perl (1.05-1) ...
Setting up libhtml-template-perl (2.95-2) ...
Setting up libtimedate-perl (2.3000-2) ...
Setting up libhttp-date-perl (6.02-1) ...
Setting up libio-html-perl (1.001-1) ...
Setting up liblwp-mediatypes-perl (6.02-1) ...
Setting up libhttp-message-perl (6.11-1) ...
dpkg: dependency problems prevent configuration of mysql-server:
 mysql-server depends on mysql-server-5.7; however:
  Package mysql-server-5.7 is not configured yet.

dpkg: error processing package mysql-server (--configure):
 dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
                                                                                                          Processing triggers for libc-bin (2.23-0ubuntu7) ...
Processing triggers for systemd (229-4ubuntu16) ...
Processing triggers for ureadahead (0.100.0-19) ...
Errors were encountered while processing:
 mysql-server-5.7
 mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)
root@ramireini:~#

输出sudo apt -o Dpkg::Options::="--force-confmiss" install --reinstall mysql-server

root@ramireini:/# sudo apt -o Dpkg::Options::="--force-confmiss" install --reinstall mysql-server
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  mysql-client-5.7 mysql-client-core-5.7 mysql-common mysql-server-5.7 mysql-server-core-5.7
Suggested packages:
  mailx tinyca
The following NEW packages will be installed:
  mysql-client-5.7 mysql-client-core-5.7 mysql-common mysql-server mysql-server-5.7 mysql-server-core-5.7
0 upgraded, 6 newly installed, 0 to remove and 4 not upgraded.
Need to get 0 B/18,7 MB of archives.
After this operation, 160 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Preconfiguring packages ...
Selecting previously unselected package mysql-common.
(Reading database ... 89934 files and directories currently installed.)
Preparing to unpack .../mysql-common_5.7.17-0ubuntu0.16.04.1_all.deb ...
Unpacking mysql-common (5.7.17-0ubuntu0.16.04.1) ...
Selecting previously unselected package mysql-client-core-5.7.
Preparing to unpack .../mysql-client-core-5.7_5.7.17-0ubuntu0.16.04.1_amd64.deb ...
Unpacking mysql-client-core-5.7 (5.7.17-0ubuntu0.16.04.1) ...
Selecting previously unselected package mysql-client-5.7.
Preparing to unpack .../mysql-client-5.7_5.7.17-0ubuntu0.16.04.1_amd64.deb ...
Unpacking mysql-client-5.7 (5.7.17-0ubuntu0.16.04.1) ...
Selecting previously unselected package mysql-server-core-5.7.
Preparing to unpack .../mysql-server-core-5.7_5.7.17-0ubuntu0.16.04.1_amd64.deb ...
Unpacking mysql-server-core-5.7 (5.7.17-0ubuntu0.16.04.1) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up mysql-common (5.7.17-0ubuntu0.16.04.1) ...

Configuration file '/etc/mysql/conf.d/mysql.cnf', does not exist on system.
Installing new config file as you requested.

Configuration file '/etc/mysql/conf.d/mysqldump.cnf', does not exist on system.
Installing new config file as you requested.

Configuration file '/etc/mysql/my.cnf.fallback', does not exist on system.
Installing new config file as you requested.
update-alternatives: using /etc/mysql/my.cnf.fallback to provide /etc/mysql/my.cnf (my.cnf) in auto mode
Selecting previously unselected package mysql-server-5.7.
(Reading database ... 90091 files and directories currently installed.)
Preparing to unpack .../mysql-server-5.7_5.7.17-0ubuntu0.16.04.1_amd64.deb ...
Unpacking mysql-server-5.7 (5.7.17-0ubuntu0.16.04.1) ...
Selecting previously unselected package mysql-server.
Preparing to unpack .../mysql-server_5.7.17-0ubuntu0.16.04.1_all.deb ...
Unpacking mysql-server (5.7.17-0ubuntu0.16.04.1) ...
Processing triggers for man-db (2.7.5-1) ...
Processing triggers for systemd (229-4ubuntu16) ...
Processing triggers for ureadahead (0.100.0-19) ...
Setting up mysql-client-core-5.7 (5.7.17-0ubuntu0.16.04.1) ...
Setting up mysql-client-5.7 (5.7.17-0ubuntu0.16.04.1) ...
Setting up mysql-server-core-5.7 (5.7.17-0ubuntu0.16.04.1) ...
Setting up mysql-server-5.7 (5.7.17-0ubuntu0.16.04.1) ...

Configuration file '/etc/apparmor.d/usr.sbin.mysqld', does not exist on system.
Installing new config file as you requested.

Configuration file '/etc/init.d/mysql', does not exist on system.
Installing new config file as you requested.

Configuration file '/etc/init/mysql.conf', does not exist on system.
Installing new config file as you requested.

Configuration file '/etc/logcheck/ignore.d.paranoid/mysql-server-5_7', does not exist on system.
Installing new config file as you requested.

Configuration file '/etc/logcheck/ignore.d.server/mysql-server-5_7', does not exist on system.
Installing new config file as you requested.

Configuration file '/etc/logcheck/ignore.d.workstation/mysql-server-5_7', does not exist on system.
Installing new config file as you requested.

Configuration file '/etc/logrotate.d/mysql-server', does not exist on system.
Installing new config file as you requested.

Configuration file '/etc/mysql/debian-start', does not exist on system.
Installing new config file as you requested.

Configuration file '/etc/mysql/mysql.cnf', does not exist on system.
Installing new config file as you requested.

Configuration file '/etc/mysql/mysql.conf.d/mysqld.cnf', does not exist on system.
Installing new config file as you requested.

Configuration file '/etc/mysql/mysql.conf.d/mysqld_safe_syslog.cnf', does not exist on system.
Installing new config file as you requested.
update-alternatives: using /etc/mysql/mysql.cnf to provide /etc/mysql/my.cnf (my.cnf) in auto mode
Renaming removed key_buffer and myisam-recover options (if present)
AppArmor parser error for /etc/apparmor.d/usr.sbin.mysqld in /etc/apparmor.d/usr.sbin.mysqld at line 9: Could not open 'abstractions/mysql'
Job for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xe" for details.
invoke-rc.d: initscript mysql, action "start" failed.
● mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
   Active: activating (auto-restart) (Result: exit-code) since ti 2017-04-04 21:40:43 EEST; 16ms ago
  Process: 3090 ExecStartPost=/usr/share/mysql/mysql-systemd-start post (code=exited, status=0/SUCCESS)
  Process: 3089 ExecStart=/usr/sbin/mysqld (code=exited, status=1/FAILURE)
  Process: 3085 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
 Main PID: 3089 (code=exited, status=1/FAILURE)

huhti 04 21:40:43 ramireini systemd[1]: Failed to start MySQL Community Server.
huhti 04 21:40:43 ramireini systemd[1]: mysql.service: Unit entered failed state.
huhti 04 21:40:43 ramireini systemd[1]: mysql.service: Failed with result 'exit-code'.
dpkg: error processing package mysql-server-5.7 (--configure):
 subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of mysql-server:
 mysql-server depends on mysql-server-5.7; however:
  Package mysql-server-5.7 is not configured yet.

dpkg: error processing package mysql-server (--configure):
 dependency problems - leaving unconfigured
Processing triggers for systemd (229-4ubuntu16) ...
No apport report written because the error message indicates its a followup error from a previous failure.
                                                                                                          Processing triggers for ureadahead (0.100.0-19) ...
Errors were encountered while processing:
 mysql-server-5.7
 mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)
root@ramireini:/# 

答案1

正如所描述的这里安装 mysql-server 后使用:

sudo apt-get update
sudo apt-get install mysql-server

您应该配置mysql:

sudo mysql_secure_installation

然后使用以下命令测试您的配置:

systemctl status mysql.service

如果 MySQL 没有运行,您可以使用 启动它sudo systemctl mysql start

为了进行额外检查,您可以尝试使用 mysqladmin 工具连接到数据库,该工具是一个允许您运行管理命令的客户端。例如,此命令表示以 root 身份连接到 MySQL (-u root),提示输入密码 (-p),然后返回版本。

mysqladmin -p -u root version

答案2

首先,你要停止使用service <ITEM> <COMMAND>结构,而是开始习惯systemctl <COMMAND> <ITEM>结构

其次,如果您通过其工具检查日志,systemd 可以为您提供一些更好的信息journalctl

sudo journalctl -xe -u mysql

这应该会为您提供有关所发生情况的更多信息。“状态”不一定告诉您导致错误的事件。

答案3

启动服务器时出现的问题是由装甲以防止未经授权的应用程序运行。

通过添加命令行可以解决这个问题:

$ sudo ln -s /etc/apparmor.d/usr.sbin.mysqld

其他重要组件是确保不会与已安装的 mysql-server 发生冲突,但要清除它并重新安装它。通过删除失败的内容并重新安装存储库中经过测试的内容来确保设置了默认值,这种方法很有效。

在重新安装过程中(在本例中),安装程序中的 perl 脚本出现了问题。修复这些问题和错误有助于重新安装。

导致问题的问题的详细信息已呈现在控制台上,其中消除每个问题都是逐步恢复的过程。

相关内容