title: Ubuntu 20.04 - Stopped MySQL. Now it won't start (error 13, permission denied)
body: <p>Running a DigitalOcean LAMP Stack (1GB VPS) on Ubuntu 20.04, I was getting intermittent &quot;Error establshing a database connection&quot; errors in Wordpress when uploading media files. This was throwing the following Apache error:</p>
  <p><code>WordPress database error MySQL server has gone away for query...</code></p>
  <p>While this issue was occurring, MySQL logs repeatedly printed the following and nothing else since:</p>
  <pre><code>    2020-12-19T12:14:43.708558Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
      2020-12-19T12:14:43.992793Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.22-0ubuntu0.20.04.3'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  (Ubuntu).
      2020-12-19T12:14:59.498001Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.22-0ubuntu0.20.04.3) starting as process 190645
      2020-12-19T12:14:59.512933Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
      2020-12-19T12:15:00.093514Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
      2020-12-19T12:15:00.448326Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '127.0.0.1' port: 33060, socket: /var/run/mysqld/mysqlx.sock
      2020-12-19T12:15:00.524531Z 0 [System] [MY-010229] [Server] Starting XA crash recovery...
      2020-12-19T12:15:00.543848Z 0 [System] [MY-010232] [Server] XA crash recovery finished.
      2020-12-19T12:15:00.652394Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
  </code></pre>
  <p>I tried this fix: <a href="https://stackoverflow.com/questions/15693796/wordpress-database-error-mysql-server-has-gone-away-for-query">WordPress database error MySQL server has gone away for query</a></p>
  <p>Still the website was displaying the error, so I thought I should restart MySQL, but it won't restart.</p>
  <p>With <code>sudo service MySQL start</code>, I get</p>
  <p><code>Job for mysql.service failed because the control process exited with error code. See &quot;systemctl status mysql.service&quot; and &quot;journalctl -xe&quot; for details.</code></p>
  <p>Running the first command:</p>
  <pre><code>● mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Sat 2020-12-19 12:45:50 UTC; 1min 3s ago
  Process: 192068 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
  Process: 192076 ExecStart=/usr/sbin/mysqld (code=exited, status=1/FAILURE)
  Main PID: 192076 (code=exited, status=1/FAILURE)
   Status: &quot;Server startup in progress&quot;
    Error: 13 (Permission denied)
  </code></pre>
  <p>Running the second command</p>
  <pre><code> Hint: You are currently not seeing messages from other users and the system.
    Users in groups 'adm', 'systemd-journal' can see all messages.
    Pass -q to turn off this notice.
   -- Defined-By: systems
   -- Support: http://www.ubuntu.com/support
   --
   -- A start job for unit UNIT has finished successfully.
   --
   -- The job identifier is 8.
   Dec 19 12:13:48 server systemd[189372]: Listening on REST API socket for snapd user session agent.
   -- Subject: A start job for unit UNIT has finished successfully
   -- Defined-By: systems
   -- Support: http://www.ubuntu.com/support
   --
   -- A start job for unit UNIT has finished successfully.
   --
   -- The job identifier is 11.
   Dec 19 12:13:48 server systemd[189372]: Listening on D-Bus User Message Bus Socket.
   -- Subject: A start job for unit UNIT has finished successfully
   -- Defined-By: systems
   -- Support: http://www.ubuntu.com/support
   --
   -- A start job for unit UNIT has finished successfully.
   --
   -- The job identifier is 9.
   Dec 19 12:13:48 server systemd[189372]: Reached target Sockets.
   -- Subject: A start job for unit UNIT has finished successfully
   -- Defined-By: systems
   -- Support: http://www.ubuntu.com/support
   --
   -- A start job for unit UNIT has finished successfully.
   --
   -- The job identifier is 5.
   Dec 19 12:13:48 server systemd[189372]: Reached target Basic System.
   -- Subject: A start job for unit UNIT has finished successfully
   -- Defined-By: systems
   -- Support: http://www.ubuntu.com/support
   --
   -- A start job for unit UNIT has finished successfully.
   --
   -- The job identifier is 2.
   Dec 19 12:13:48 server systemd[189372]: Reached target Main User Target.
   -- Subject: A start job for unit UNIT has finished successfully
   -- Defined-By: systems
   -- Support: http://www.ubuntu.com/support
   --
   -- A start job for unit UNIT has finished successfully.
   --
   -- The job identifier is 1.
   Dec 19 12:13:48 server systemd[189372]: Startup finished in 168ms.
   -- Subject: User manager start-up is now complete
   -- Defined-By: systems
   -- Support: http://www.ubuntu.com/support
   --
   -- The user manager instance for user 1000 has been started. All services queued
   -- for starting have been started. Note that other services might still be starting
   -- up or be started at any later time.
   --
   -- Startup of the manager took 168965 microseconds.
   Dec 19 12:15:07 server sudo[190726]: pam_unix(sudo:auth): Couldn't open /etc/securetty: No such file or directory
   Dec 19 12:15:09 server sudo[190726]: pam_unix(sudo:auth): Couldn't open /etc/securetty: No such file or directory
   Dec 19 12:30:17 server sudo[191518]: pam_unix(sudo:auth): Couldn't open /etc/securetty: No such file or directory
   Dec 19 12:30:19 server sudo[191518]: pam_unix(sudo:auth): Couldn't open /etc/securetty: No such file or directory
   Dec 19 12:32:25 server sudo[191686]: pam_unix(sudo:auth): Couldn't open /etc/securetty: No such file or directory
   Dec 19 12:32:27 server sudo[191686]: pam_unix(sudo:auth): Couldn't open /etc/securetty: No such file or directory
  </code></pre>
  <p>The first error led me to this: <a href="https://askubuntu.com/questions/1228827/mysql-error-13-permission-denied">https://askubuntu.com/questions/1228827/mysql-error-13-permission-denied</a></p>
  <p>However MySQL already owns /var/lib/mysql. The owner of /usr/sbin/mysqld is root. This is the same as on another server where MySQL works fine. Should I really change this?</p>