5

I'm trying to get MySQL to work on my ubuntu server. It seems I ran into some errors and I've been trying to sort them out myself but I haven't had any success. I ran:

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

After the installation I tried to make sure it was turned on by doing sudo service mysql start which ended up in it saying

Job for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xe" for details.

I ran sudo service mysql status Which returned this:

● 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

If someone could help with this I would appreciate it.

EDIT1:

Here is the output of journalctl -xe after trying to start 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

I put it all into hastebin so the gazillion lines can actually fit into there :p

EDIT2:

I went by the steps and during the re-install I noted these:

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.

Output of MySQL Install Command:

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:~#

Output of 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:/# 
  • Run this: sudo apt -o Dpkg::Options::="--force-confmiss" install --reinstall mysql-server. If this doesn't resolve all the issues and there are errors in the output, append the complete text on black screen starting with the command all the way to the last line (command prompt) to your question. – L. D. James Apr 4 '17 at 18:30
  • @L.D.James - Added the output of above command to the main question. – Frozen Apr 4 '17 at 18:45
  • Run these two commands: (1) sudo ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/usr.sbin.mysqld (2) sudo apt install --reinstall mysql-server – L. D. James Apr 4 '17 at 19:02
  • Comments are not for extended discussion; this conversation has been moved to chat. – jokerdino Apr 4 '17 at 19:02
  • Duplicate: askubuntu.com/questions/916009/… – m-arch Dec 16 '17 at 17:34
1

The problem with starting the server was a protection by Apparmor to protect against unauthorized applications running.

This remedied by added the command line:

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

Other important components were ensuring against conflicts from the installed mysql-server, but purging it and reinstalling it. Ensuring the defaults are set by removing what's failing and reinstalling what's tested from the repository, which works.

During the process of the reinstall (in this case) there was a problem with the perl script which is part of the install routine. Fixing those problems and errors assisted in the reinstall.

The details of the issues that were causing problems were presented at to the concole of which, removing each of the issues was a step by step recovery.

3

As described here after installing mysql-server using:

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

You should configure mysql:

sudo mysql_secure_installation

Afterwards tests your configuration using:

systemctl status mysql.service

If MySQL isn't running, you can start it with sudo systemctl mysql start.

For an additional check, you can try connecting to the database using the mysqladmin tool, which is a client that lets you run administrative commands. For example, this command says to connect to MySQL as root (-u root), prompt for a password (-p), and return the version.

mysqladmin -p -u root version
  • If I run "sudo mysql_secure_installation" it comes up with "Error: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) ". – Frozen Apr 4 '17 at 11:44
  • @Frozen - what happened if you execute sudo service mysql start and afterwards runs sudo mysql_secure_installation ? – Yaron Apr 4 '17 at 11:48
  • After running 'sudo service mysql start' it says 'Job for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xe" for details.' – Frozen Apr 4 '17 at 11:52
  • great :) please edit your question and add the output of sudo journalctl -xe -u mysql as previously suggested by @taifwa – Yaron Apr 4 '17 at 11:54
  • done, added it to the main post. – Frozen Apr 4 '17 at 12:10
2

Firstly, you want to stop using the service <ITEM> <COMMAND> structure and start getting used to systemctl <COMMAND> <ITEM> structure instead

Secondly, systemd can give you some better information if you check the logging via its tool journalctl:

sudo journalctl -xe -u mysql

This should give you more information about what happened. The "status" will not necessarily tell you the events leading to the error.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.