Mysql won't start after moving data, missing sock file

Mysql won't start after moving data, missing sock file

In fresh install of Ubuntu 16.04 and fresh install of mysql I moved my mysql data in a similar manner as this post however after it, when I try to restart/start mysql I get :

error: can't connect to local MySQL server throught socket '/var/run/mysqld/mysql.sock' (2) 
Check that mysqld is running and that the socket: '/var/run/mysqld/mysql.sock' exists!

The folder /var/run/mysqld exists, but not the file.

When I run : find / -type s the file mysql.sock is not on the list.


The result of journalctl -xe:

-- Unit mysql.service has finished shutting down.
Jun 12 11:45:16 wkssop-hev7 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.
Jun 12 11:45:16 wkssop-hev7 audit[5882]: AVC apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/proc/5882/status" pid=5882 comm="mysqld" requested_mask="r" denied_mask="r" fsuid=110 ouid=110
Jun 12 11:45:16 wkssop-hev7 audit[5882]: AVC apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/sys/devices/system/node/" pid=5882 comm="mysqld" requested_mask="r" denied_mask="r" fsuid=110 ouid=0
Jun 12 11:45:16 wkssop-hev7 audit[5882]: AVC apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/proc/5882/status" pid=5882 comm="mysqld" requested_mask="r" denied_mask="r" fsuid=110 ouid=110
Jun 12 11:45:16 wkssop-hev7 kernel: audit: type=1400 audit(1497260716.044:133): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/proc/5882/status" pid=5882 comm="mysqld" requested_mask="r" denied_mask="r" fsuid=110 ouid=110
Jun 12 11:45:16 wkssop-hev7 kernel: audit: type=1400 audit(1497260716.044:134): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/sys/devices/system/node/" pid=5882 comm="mysqld" requested_mask="r" denied_mask="r" fsuid=110 ouid=0
Jun 12 11:45:16 wkssop-hev7 kernel: audit: type=1400 audit(1497260716.044:135): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/proc/5882/status" pid=5882 comm="mysqld" requested_mask="r" denied_mask="r" fsuid=110 ouid=110
Jun 12 11:45:17 wkssop-hev7 systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE

And the result of systemctl status mysql.service is:

● mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
   Active: activating (start-post) (Result: exit-code) since Mon 2017-06-12 11:45:46 CEST; 6s ago
  Process: 5986 ExecStart=/usr/sbin/mysqld (code=exited, status=1/FAILURE)
  Process: 5978 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
 Main PID: 5986 (code=exited, status=1/FAILURE);         : 5987 (mysql-systemd-s)
    Tasks: 2
   Memory: 1.4M
      CPU: 259ms
   CGroup: /system.slice/mysql.service
           └─control
             ├─5987 /bin/bash /usr/share/mysql/mysql-systemd-start post
             └─6029 sleep 1

Jun 12 11:45:46 wkssop-hev7 systemd[1]: Starting MySQL Community Server...
Jun 12 11:45:48 wkssop-hev7 systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE

This is basically the steps I'm following:

if ! service mysql stop ; then
   echo "ignoring failure to stop mysql"
fi

cp config/my.cnf /etc/mysql/my.cnf
mkdir -p /data/mysqldata
chmod 777 /data/mysqldata
cp -R -p /var/lib/mysql/* /data/mysqldata

sed "s/\/var\/lib\/mysql/\/data\/mysqldata/g" /etc/apparmor.d/usr.sbin.mysqld > tmp
mv tmp /etc/apparmor.d/usr.sbin.mysqld
apparmor_parser -r /etc/apparmor.d/usr.sbin.mysqld
/etc/init.d/apparmor reload
service mysql restart

I get the error on the last step - restart service, which is not able to do so.

I have also added to the mysql apparmor profile the /sys/devices/system/node/ r, and /sys/devices/system/node/** r, since it seemed that it is a a bug that they are not there: https://bugs.launchpad.net/ubuntu/+source/mysql-5.7/+bug/1658233

But now I'm wondering if I should do the same with: /proc/####/status, well it would actually have to be /proc I guess? so I though I might as well try, and it still fails.

journatlctl -xe | tail -30:

-- 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.
Jun 14 13:28:50 minint-l35opp1 systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE
Jun 14 13:29:18 minint-l35opp1 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.
Jun 14 13:29:18 minint-l35opp1 systemd[1]: mysql.service: Unit entered failed state.
Jun 14 13:29:18 minint-l35opp1 systemd[1]: mysql.service: Failed with result 'exit-code'.
Jun 14 13:29:18 minint-l35opp1 systemd[1]: mysql.service: Service hold-off time over, scheduling restart.
Jun 14 13:29:18 minint-l35opp1 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.
Jun 14 13:29:18 minint-l35opp1 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.
Jun 14 13:29:20 minint-l35opp1 systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE

答え1

The last error I got led me to this: https://askubuntu.com/a/792857/693474 answer... which solved my problem. even though I don't get why these 2 parameters where in there in the first place since this was a clean install?

関連情報