Can't Start MySQL Service Ubuntu - mysql

After editing /etc/mysql/mysql.conf.d/mysqld.cnf to change my bind address to allow external connections to my MySQL database, I tried restarting the MySQL service to get the following error:
ubuntu#resonance:/var/www/html$ sudo service mysql start
Job for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xe" for details.
upon typing both of those commands, I get the following:
Nov 15 17:45:06 resonance 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.
Nov 15 17:45:06 resonance 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.
Nov 15 17:45:06 resonance audit[24219]: AVC apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/proc/24219/status" pid=24219 com
Nov 15 17:45:06 resonance audit[24219]: AVC apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/sys/devices/system/node/" pid=24
Nov 15 17:45:06 resonance audit[24219]: AVC apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/proc/24219/status" pid=24219 com
Nov 15 17:45:06 resonance kernel: audit: type=1400 audit(1510767906.536:98): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="
Nov 15 17:45:06 resonance kernel: audit: type=1400 audit(1510767906.536:99): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="
Nov 15 17:45:06 resonance kernel: audit: type=1400 audit(1510767906.536:100): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name=
Nov 15 17:45:08 resonance systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE
Nov 15 17:45:26 resonance dhclient[1326]: DHCPREQUEST of 10.2.6.251 on ens3 to 10.2.11.18 port 67 (xid=0x7d5eaaff)
Nov 15 17:45:26 resonance dhclient[1326]: DHCPACK of 10.2.6.251 from 10.2.11.18
Nov 15 17:45:26 resonance root[24322]: /etc/dhcp/dhclient-enter-hooks.d/avahi-autoipd returned non-zero exit status 1
Nov 15 17:45:26 resonance dhclient[1326]: bound to 10.2.6.251 -- renewal in 53 seconds.
and
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: activating (start-post) since Wed 2017-11-15 17:46:38 UTC; 84ms ago
Process: 24586 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 24595 (mysqld); : 24596 (mysql-systemd-s)
Tasks: 3
Memory: 1.4M
CPU: 86ms
CGroup: /system.slice/mysql.service
├─24595 /usr/sbin/mysqld
└─control
├─24596 /bin/bash /usr/share/mysql/mysql-systemd-start post
└─24601 sleep 1
Nov 15 17:46:38 resonance systemd[1]: Starting MySQL Community Server...
any idea what I'm doing wrong? This is the file I changed:
https://pastebin.com/pevhYMNK
EDIT
So I tried changing the bind IP back to 127.0.0.1 and it started working again. What do I have to do to allow external connections? I really need it working.

You should comment out bind-address and skip-netwroking lines in your config and then restart.

Related

Unable to start mysql in ubuntu

I have tried the following the code to restart the MySql services
sudo service mysql restart
got the following error
Job for mysql.service failed because the control process exited with error code.
See "systemctl status mysql.service" and "journalctl -xe" for details.
ubuntu#ip-172-31-52-10:~$ journalctl -xe
And the journalctl Log says
Unit mysql.service has begun starting up.
Mar 17 15:10:55 ip-172-31-52-10 audit[4057]: AVC apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/sys/devices/system/node/" pid=4057 comm="mysqld" r
Mar 17 15:10:55 ip-172-31-52-10 kernel: audit: type=1400 audit(1552835455.957:54): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/sys/devices/syst
Mar 17 15:10:56 ip-172-31-52-10 mysql-systemd-start[4038]: ERROR: Unable to start MySQL server:
Mar 17 15:10:56 ip-172-31-52-10 mysql-systemd-start[4038]: 2019-03-17T15:10:56.000286Z 0 [ERROR] unknown variable 'bind=0.0.0.0'
Mar 17 15:10:56 ip-172-31-52-10 mysql-systemd-start[4038]: 2019-03-17T15:10:56.004319Z 0 [ERROR] Aborting
Mar 17 15:10:56 ip-172-31-52-10 mysql-systemd-start[4038]: Please take a look at https://wiki.debian.org/Teams/MySQL/FAQ for tips on fixing common upgrade issues.
Mar 17 15:10:56 ip-172-31-52-10 mysql-systemd-start[4038]: Once the problem is resolved, restart the service.
Mar 17 15:10:56 ip-172-31-52-10 systemd[1]: mysql.service: Control process exited, code=exited status=1
Mar 17 15:10:56 ip-172-31-52-10 systemd[1]: mysql.service: Failed with result 'exit-code'.
Mar 17 15:10:56 ip-172-31-52-10 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.
Mar 17 15:10:56 ip-172-31-52-10 systemd[1]: mysql.service: Service hold-off time over, scheduling restart.
Mar 17 15:10:56 ip-172-31-52-10 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.
Mar 17 15:10:56 ip-172-31-52-10 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.
Mar 17 15:10:56 ip-172-31-52-10 systemd[1]: mysql.service: Start request repeated too quickly.
Mar 17 15:10:56 ip-172-31-52-10 systemd[1]: mysql.service: Failed with result 'exit-code'.
Mar 17 15:10:56 ip-172-31-52-10 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.
how do I fix this?

MySQL installation fails

I was having problems starting the MySQL service so I removed the packages like this:
sudo dpkg -P mysql-server mysql-server-5.7
sudo apt autoremove
sudo apt clean
sudo rm -rvf /var/lib/mysql
sudo apt install mysql-server
During installation, I was asked for the password for root and after that, the following happened:
Setting up mysql-server-5.7 (5.7.21-0ubuntu0.16.04.1) ...
Renaming removed key_buffer and myisam-recover options (if present)
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 Mo 2018-04-23 17:22:42 CEST; 6ms ago
Process: 27860 ExecStartPost=/usr/share/mysql/mysql-systemd-start post (code=exited, status=0/SUCCESS)
Process: 27859 ExecStart=/usr/sbin/mysqld (code=exited, status=1/FAILURE)
Process: 27851 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 27859 (code=exited, status=1/FAILURE)
Apr 23 17:22:42 mari systemd[1]: Failed to start MySQL Community Server.
Apr 23 17:22:42 mari systemd[1]: mysql.service: Unit entered failed state.
Apr 23 17:22:42 mari 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
Errors were encountered while processing:
mysql-server-5.7
mysql-server
Running dpkg --configure -a results in the same errors. Here's journalctl -xe:
-- 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 23 17:25:20 mari audit[28913]: AVC apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/proc/28913/status" pid=28913 comm="mysqld
Apr 23 17:25:20 mari audit[28913]: AVC apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/sys/devices/system/node/" pid=28913 comm=
Apr 23 17:25:20 mari audit[28913]: AVC apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/proc/28913/status" pid=28913 comm="mysqld
Apr 23 17:25:20 mari kernel: audit: type=1400 audit(1524497120.211:209): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/proc/28
Apr 23 17:25:22 mari systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE
Apr 23 17:25:50 mari 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 23 17:25:50 mari systemd[1]: mysql.service: Unit entered failed state.
Apr 23 17:25:50 mari systemd[1]: mysql.service: Failed with result 'exit-code'.
Apr 23 17:25:50 mari sudo[28755]: pam_unix(sudo:session): session closed for user root
Apr 23 17:25:50 mari systemd[1]: mysql.service: Service hold-off time over, scheduling restart.
Apr 23 17:25:50 mari 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 23 17:25:50 mari 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 23 17:25:50 mari audit[29041]: AVC apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/proc/29041/status" pid=29041 comm="mysqld
Apr 23 17:25:50 mari audit[29041]: AVC apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/sys/devices/system/node/" pid=29041 comm=
Apr 23 17:25:50 mari audit[29041]: AVC apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/proc/29041/status" pid=29041 comm="mysqld
Apr 23 17:25:50 mari kernel: kauditd_printk_skb: 2 callbacks suppressed
Apr 23 17:25:50 mari kernel: audit: type=1400 audit(1524497150.668:212): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/proc/29
Apr 23 17:25:50 mari kernel: audit: type=1400 audit(1524497150.668:213): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/sys/dev
Apr 23 17:25:50 mari kernel: audit: type=1400 audit(1524497150.668:214): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/proc/29
Apr 23 17:25:52 mari systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE
Others seem to have the same problem but none of the solutions I found so far worked. For example, someone said that their problem was being caused by a missing log file which is not missing for me.
Thank you to Michael O. for the comment, it helped me out tremendously. The answer to the question he linked by itself didn't solve my problem as, after whitelisting MySQL to access the files it needed, apparmor started to block MySQL from acquiring capabilities.
While searching I came across this blog post from Oracle that suggests using apparmor-utils's utility called aa-complain. This utility sets a profile to complain mode, basically letting you off with a warning.
So I installed apparmor-utils:
sudo apt install apparmor-utils
Checked where the MySQL service was located:
which mysql
And used the output to put the service on complain mode:
aa-complain /usr/bin/mysql
After restarting the computer the service started without errors.

why mysql cannot start on Ubuntu

Today when I tried to restart mysql, it showed
root#S128046:~# service mysql restart
Job for mysql.service failed because the control process exited with error
code. See "systemctl status mysql.service" and "journalctl -xe" for details.
If I try systemctl status mysql.service, it says:
root#S128046:~# systemctl status mysql.service
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: activating (start-post) (Result: exit-code) since Thu 2018-04-05 09:45:48 CST; 11s ago
Main PID: 19848 (code=exited, status=1/FAILURE); : 19849 (mysql-systemd-s)
Tasks: 2
Memory: 336.0K
CPU: 754ms
CGroup: /system.slice/mysql.service
└─control
├─19849 /bin/bash /usr/share/mysql/mysql-systemd-start post
└─19903 sleep 1
Apr 05 09:45:48 S128046.domain systemd[1]: Stopped MySQL Community Server.
Apr 05 09:45:48 S128046.domain systemd[1]: Starting MySQL Community Server...
Apr 05 09:45:51 S128046.domain systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE
And journalctl -xe says:
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mysql.service has begun starting up.
Apr 05 09:47:25 S128046.domain audit[20171]: AVC apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/proc/20171/status" pid=20171 comm="mysqld" req
Apr 05 09:47:25 S128046.domain audit[20171]: AVC apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/sys/devices/system/node/" pid=20171 comm="mysq
Apr 05 09:47:25 S128046.domain audit[20171]: AVC apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/proc/20171/status" pid=20171 comm="mysqld" req
Apr 05 09:47:25 S128046.domain kernel: audit: type=1400 audit(1522892845.214:527): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/proc/20171/s
Apr 05 09:47:25 S128046.domain kernel: audit: type=1400 audit(1522892845.214:528): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/sys/devices/
Apr 05 09:47:25 S128046.domain kernel: audit: type=1400 audit(1522892845.214:529): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/proc/20171/s
Apr 05 09:47:27 S128046.domain systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE
Apr 05 09:47:56 S128046.domain 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 05 09:47:56 S128046.domain systemd[1]: mysql.service: Unit entered failed state.
Apr 05 09:47:56 S128046.domain systemd[1]: mysql.service: Failed with result 'exit-code'.
Apr 05 09:47:56 S128046.domain systemd[1]: mysql.service: Service hold-off time over, scheduling restart.
-- Unit mysql.service has begun starting up.
Apr 05 09:47:56 S128046.domain kernel: audit: type=1400 audit(1522892876.943:530): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/proc/20273/s
Apr 05 09:47:56 S128046.domain kernel: audit: type=1400 audit(1522892876.943:531): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/sys/devices/
Apr 05 09:47:56 S128046.domain kernel: audit: type=1400 audit(1522892876.943:532): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/proc/20273/s
Apr 05 09:47:56 S128046.domain audit[20273]: AVC apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/proc/20273/status" pid=20273 comm="mysqld" req
Apr 05 09:47:56 S128046.domain audit[20273]: AVC apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/sys/devices/system/node/" pid=20273 comm="mysq
Apr 05 09:47:56 S128046.domain audit[20273]: AVC apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/proc/20273/status" pid=20273 comm="mysqld" req
Apr 05 09:47:59 S128046.domain systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE
I do not why but mysql worked well for the past months.
Any help would be appreciated, thank you in advance.
try using superuser in ubuntu
sudo service mysql restart
this may work.

Can't connect to local MySQL server through socket after system crashed

My laptop suddenly crashed with a BSD and after a restart and logging back in, mysql is causing me problems.
I am using vagrant with mysql inside on UBUNTU.
root#dev:/var/lib/mysql# service mysql start
Job for mysql.service failed because the control process exited with
error code. See "systemctl status mysql.service" and "journalctl -xe"
for details.
Running systemctl status mysql.service shows the following
* mysql.service - LSB: Start and stop the mysql database server daemon
Loaded: loaded (/etc/init.d/mysql; bad; vendor preset: enabled)
Active: failed (Result: exit-code) since Thu 2018-01-04 11:08:55 GMT;
14s ago
Docs: man:systemd-sysv-generator(8)
Process: 19954 ExecStart=/etc/init.d/mysql start (code=exited,
status=1/FAILURE)
Jan 04 11:08:55 dev /etc/init.d/mysql[20425]: 0 processes alive and
'/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf ping'
resulted in
Jan 04 11:08:55 dev /etc/init.d/mysql[20425]: [61B blob data]
Jan 04 11:08:55 dev /etc/init.d/mysql[20425]: error: 'Can't connect to
local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)'
Jan 04 11:08:55 dev /etc/init.d/mysql[20425]: Check that mysqld is
running and that the socket: '/var/run/mysqld/mysqld.sock' exists!
Jan 04 11:08:55 dev /etc/init.d/mysql[20425]:
Jan 04 11:08:55 dev mysql[19954]: ...fail!
Jan 04 11:08:55 dev systemd[1]: mysql.service: Control process exited,
code=exited status=1
Jan 04 11:08:55 dev systemd[1]: Failed to start LSB: Start and stop the
mysql database server daemon.
Jan 04 11:08:55 dev systemd[1]: mysql.service: Unit entered failed
state.
Jan 04 11:08:55 dev systemd[1]: mysql.service: Failed with result
'exit-code'.
Running journalctl -xe shows the following
Jan 04 11:08:53 dev kernel: audit: type=1400 audit(1515064133.370:391): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/etc/mysql/my.cnf.fallback" pid=20386 comm="mysqld" requested_ma
Jan 04 11:08:54 dev audit[20397]: AVC apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/etc/my.cnf" pid=20397 comm="mysqld" requested_mask="r" denied_mask="r" fsuid=0 ouid=0
Jan 04 11:08:54 dev audit[20397]: AVC apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/etc/mysql/my.cnf.fallback" pid=20397 comm="mysqld" requested_mask="r" denied_mask="r" fsuid=0 oui
Jan 04 11:08:54 dev kernel: audit: type=1400 audit(1515064134.382:392): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/etc/my.cnf" pid=20397 comm="mysqld" requested_mask="r" denied_m
Jan 04 11:08:54 dev kernel: audit: type=1400 audit(1515064134.382:393): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/etc/mysql/my.cnf.fallback" pid=20397 comm="mysqld" requested_ma
Jan 04 11:08:55 dev audit[20408]: AVC apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/etc/my.cnf" pid=20408 comm="mysqld" requested_mask="r" denied_mask="r" fsuid=0 ouid=0
Jan 04 11:08:55 dev audit[20408]: AVC apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/etc/mysql/my.cnf.fallback" pid=20408 comm="mysqld" requested_mask="r" denied_mask="r" fsuid=0 oui
Jan 04 11:08:55 dev kernel: audit: type=1400 audit(1515064135.398:394): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/etc/my.cnf" pid=20408 comm="mysqld" requested_mask="r" denied_m
Jan 04 11:08:55 dev kernel: audit: type=1400 audit(1515064135.398:395): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/etc/mysql/my.cnf.fallback" pid=20408 comm="mysqld" requested_ma
Jan 04 11:08:55 dev audit[20418]: AVC apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/etc/my.cnf" pid=20418 comm="mysqld" requested_mask="r" denied_mask="r" fsuid=0 ouid=0
Jan 04 11:08:55 dev audit[20418]: AVC apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/etc/mysql/my.cnf.fallback" pid=20418 comm="mysqld" requested_mask="r" denied_mask="r" fsuid=0 oui
Jan 04 11:08:55 dev kernel: audit: type=1400 audit(1515064135.410:396): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/etc/my.cnf" pid=20418 comm="mysqld" requested_mask="r" denied_m
Jan 04 11:08:55 dev kernel: audit: type=1400 audit(1515064135.410:397): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/etc/mysql/my.cnf.fallback" pid=20418 comm="mysqld" requested_ma
Jan 04 11:08:55 dev /etc/init.d/mysql[20425]: 0 processes alive and '/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf ping' resulted in
Jan 04 11:08:55 dev /etc/init.d/mysql[20425]: [61B blob data]
Jan 04 11:08:55 dev /etc/init.d/mysql[20425]: error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)'
Jan 04 11:08:55 dev /etc/init.d/mysql[20425]: Check that mysqld is running and that the socket: '/var/run/mysqld/mysqld.sock' exists!
Jan 04 11:08:55 dev /etc/init.d/mysql[20425]:
Jan 04 11:08:55 dev mysql[19954]: ...fail!
Jan 04 11:08:55 dev systemd[1]: mysql.service: Control process exited, code=exited status=1
Jan 04 11:08:55 dev systemd[1]: Failed to start LSB: Start and stop the mysql database server daemon.
-- 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.
Jan 04 11:08:55 dev systemd[1]: mysql.service: Unit entered failed state.
Jan 04 11:08:55 dev systemd[1]: mysql.service: Failed with result 'exit-code'.
Jan 04 11:09:01 dev CRON[20427]: pam_unix(cron:session): session opened for user root by (uid=0)
Jan 04 11:09:01 dev CRON[20428]: (root) CMD ( [ -x /usr/lib/php/sessionclean ] && if [ ! -d /run/systemd/system ]; then /usr/lib/php/sessionclean; fi)
Jan 04 11:09:01 dev CRON[20427]: pam_unix(cron:session): session closed for user root
Jan 04 11:09:02 dev systemd[1]: Starting Clean php session files...
-- Subject: Unit phpsessionclean.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit phpsessionclean.service has begun starting up.
Jan 04 11:09:02 dev sessionclean[20429]: Cannot load Xdebug - it was already loaded
Jan 04 11:09:02 dev sessionclean[20429]: Cannot load Xdebug - it was already loaded
Jan 04 11:09:02 dev sessionclean[20429]: Cannot load Xdebug - it was already loaded
Jan 04 11:09:02 dev systemd[1]: Started Clean php session files.
-- Subject: Unit phpsessionclean.service has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit phpsessionclean.service has finished starting up.
--
-- The start-up result is done.
I cannot see any mysqld.sock file and i have tried to start in safe mode with recovery options etc but i have no success. Any help would be very much appreciated.

MySQL / MariaDB shuts down after exactly 1 minute 42 seconds

I've installed Homestead via VirtualBox and Vagrant on macOS Sierra. Everything works, except for some mysterious reason MySQL shuts itself down after the box has been up for longer than 1 minute 42 seconds...
I'm able to use MySQL without issue for the first 1 minute 42 seconds, but then suddenly the service shuts down and refuses further connections.
I tailed /var/log/syslog after the server came up, and the following syslog entries appearing:
Dec 10 20:02:25 homestead systemd[1]: mariadb.service: Start operation timed out. Terminating.
Dec 10 20:02:25 homestead mysqld[1611]: 2016-12-10 20:02:25 140574075632384 [Note] /usr/sbin/mysqld: Normal shutdown
Dec 10 20:02:25 homestead mysqld[1611]: 2016-12-10 20:02:25 140574075632384 [Note] Event Scheduler: Purging the queue. 0 events
Dec 10 20:02:25 homestead kernel: [ 100.520787] audit_printk_skb: 15 callbacks suppressed
Dec 10 20:02:25 homestead kernel: [ 100.520844] audit: type=1400 audit(1481400145.309:17): apparmor="DENIED" operation="sendmsg" info="Failed name lookup - disconnected path" error=-13 profile="/usr/sbin/mysqld" name="run/systemd/notify" pid=1611 comm="mysqld" requested_mask="w" denied_mask="w" fsuid=113 ouid=0
Dec 10 20:02:25 homestead mysqld[1611]: 2016-12-10 20:02:25 140573193234176 [Note] InnoDB: FTS optimize thread exiting.
Dec 10 20:02:25 homestead mysqld[1611]: 2016-12-10 20:02:25 140574075632384 [Note] InnoDB: Starting shutdown...
Dec 10 20:02:25 homestead systemd[1]: Started Session 4 of user vagrant.
Dec 10 20:02:26 homestead mysqld[1611]: 2016-12-10 20:02:26 140574075632384 [Note] InnoDB: Waiting for page_cleaner to finish flushing of buffer pool
Dec 10 20:02:27 homestead mysqld[1611]: 2016-12-10 20:02:27 140574075632384 [Note] InnoDB: Shutdown completed; log sequence number 1355249813
Dec 10 20:02:27 homestead mysqld[1611]: 2016-12-10 20:02:27 140574075632384 [Note] /usr/sbin/mysqld: Shutdown complete
Dec 10 20:02:27 homestead kernel: [ 102.937893] audit: type=1400 audit(1481400147.726:18): apparmor="DENIED" operation="sendmsg" info="Failed name lookup - disconnected path" error=-13 profile="/usr/sbin/mysqld" name="run/systemd/notify" pid=2030 comm="mysqld" requested_mask="w" denied_mask="w" fsuid=113 ouid=0
Dec 10 20:02:27 homestead kernel: [ 102.938561] audit: type=1400 audit(1481400147.726:19): apparmor="DENIED" operation="sendmsg" info="Failed name lookup - disconnected path" error=-13 profile="/usr/sbin/mysqld" name="run/systemd/notify" pid=1611 comm="mysqld" requested_mask="w" denied_mask="w" fsuid=113 ouid=0
Dec 10 20:02:27 homestead systemd[1]: Failed to start MariaDB database server.
Dec 10 20:02:27 homestead systemd[1]: mariadb.service: Unit entered failed state.
Dec 10 20:02:27 homestead systemd[1]: mariadb.service: Failed with result 'timeout'.
Dec 10 20:02:27 homestead systemd[1]: Reached target Multi-User System.
Dec 10 20:02:27 homestead systemd[1]: Starting Notify bootloader that boot was successful...
Dec 10 20:02:27 homestead systemd[1]: Reached target Graphical Interface.
Dec 10 20:02:27 homestead systemd[1]: Starting Update UTMP about System Runlevel Changes...
Dec 10 20:02:27 homestead systemd[1]: Started Update UTMP about System Runlevel Changes.
Dec 10 20:02:27 homestead snap[2063]: Ignoring 'booted' on classic
Dec 10 20:02:27 homestead systemd[1]: Started Notify bootloader that boot was successful.
Dec 10 20:02:27 homestead systemd[1]: Startup finished in 5.989s (kernel) + 1min 36.860s (userspace) = 1min 42.850s.
The first line, where it says mariadb.service, gets logged the moment I get kicked out of MySQL. But I have no idea why.
It looks like the logs are implying MySQL / MariaDB are still trying to start up after the box has been brought up - even though I've been able to connect to them by this point without issue. Then some mystery timeout is hit, and the whole thing shuts down.
Can anyone help me interpret this...? Thanks!
Finally figured it out - AppArmor seems to be causing the problem.
By following the steps outlined here, I was able to resolve the issue, and MySQL no longer shuts down unexpected.