Internal Server Error / An exception occurred while executing a query: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away

As you are running Debian 11 have you checked this:
apt list --installed | grep maria

libmariadb3/unbekannt,now 1:10.6.16+maria~deb11 arm64  [Installiert,automatisch]
mariadb-client-10.6/unbekannt,now 1:10.6.16+maria~deb11 arm64  [Installiert,automatisch]
mariadb-client-core-10.6/unbekannt,now 1:10.6.16+maria~deb11 arm64  [Installiert,automatisch]
mariadb-common/unbekannt,now 1:10.6.16+maria~deb11 all  [Installiert,automatisch]
mariadb-server-10.6/unbekannt,now 1:10.6.16+maria~deb11 arm64  [Installiert,automatisch]
mariadb-server-core-10.6/unbekannt,now 1:10.6.16+maria~deb11 arm64  [Installiert,automatisch]
mariadb-server/unbekannt,now 1:10.6.16+maria~deb11 all  [installiert]
mysql-common/unbekannt,now 1:10.6.16+maria~deb11 all  [Installiert,automatisch]

ok :sweat_smile:

is installed

mariadb-server-core-10.6/unbekannt,now 1:10.6.16+maria~deb11 arm64 [Installiert,automatisch]

Now make a basic backup please:

cp -r /datadir/ /backup_path/

datadir is where you mysql-data is located and /backup_path/ is your backup_path

Next step should be:
sudo mariadb-upgrade -u root -p

and after entering the password. We will see.

Reading datadir from the MariaDB server failed. Got the following error when executing the 'mysql' command line client
ERROR 2002 (HY000): Can't connect to local server through socket '/run/mysqld/mysqld.sock' (111)
FATAL ERROR: Upgrade failed

As password my root pwd has been used.

Ok, I thought so, a little bit, it is only the database.
Now as you have a backup please try to follow the instruction in one of the links, and please let me know.

@sambilanet
Both of the links contain various solution approaches. So I am not sure, what you are referring to.

What I did:

  • sudo find / -type s to find the socket file β†’ /run/mysqld/mysqld.sock
  • added socket=/run/mysqld/mysql.sock to /etc/mysql/my.cnf
  • service mysqld stop
  • /etc/init.d/mysqld stop that delivered: bash: /etc/init.d/mysqld: Datei oder Verzeichnis nicht gefunden
  • mysqladmin -u root -p shutdown that delivered mysqladmin: connect to server at 'localhost' failed error: 'Can't connect to local server through socket '/run/mysqld/mysqld.sock' (111)' Check that mariadbd is running and that the socket: '/run/mysqld/mysqld.sock' exists!
  • deleted .pid file under /var/run/mysqld/
  • checked permissions of socket file
  • service mysqld start delivered: Job for mariadb.service failed because a fatal signal was delivered to the control process. See "systemctl status mariadb.service" and "journalctl -xe" for details.

So that did not work.

The other link suggested to install mysql-server package. I already found that solution, that is why I posted earlier, that the package is not installed. Shall I also try this approach?

Please note that both of the links to stackoverflow tackle the error with the (2), but mine has the (111) β†’ ```
ERROR 2002 (HY000): Can’t connect to local server through socket β€˜/run/mysqld/mysqld.sock’ (111)

I am lost, what to do.

ok,

Please show the log after executing:

systemctl status mariadb.service
journalctl -xe

mariadb.service - MariaDB 10.6.16 database server
     Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
    Drop-In: /etc/systemd/system/mariadb.service.d
             └─migrated-from-my.cnf-settings.conf, ncp-delay-automount.conf
     Active: activating (start-pre) since Wed 2024-01-24 20:15:41 CET; 3s ago
       Docs: man:mariadbd(8)
             https://mariadb.com/kb/en/library/systemd/
    Process: 1709148 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCCESS)
    Process: 1709149 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
    Process: 1709151 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= ||   VAR=`cd /usr/bin/..; /usr/bin/galera_recovery`; [ $? -eq 0 ]   && systemctl set>
Cntrl PID: 1709231 (sleep)
      Tasks: 1 (limit: 4206)
     Memory: 180.0K
        CPU: 230ms
     CGroup: /system.slice/mariadb.service
             └─1709231 /bin/sleep 20

Jan 24 20:15:41 nextcloudpi systemd[1]: Starting MariaDB 10.6.16 database server...
lines 1-18/18 (END)
 journalctl -xe
Jan 24 20:16:28 nextcloudpi mariadbd[1709407]: 2024-01-24 20:16:28 0 [Note] InnoDB: Completed initialization of buffer pool
Jan 24 20:16:28 nextcloudpi sudo[1709405]: pam_unix(sudo:session): session closed for user www-data
Jan 24 20:16:28 nextcloudpi mariadbd[1709407]: 2024-01-24 20:16:28 0 [Note] InnoDB: Starting crash recovery from checkpoint LSN=63209452151,63209452151
Jan 24 20:16:28 nextcloudpi mariadbd[1709407]: 2024-01-24 20:16:28 0 [Note] InnoDB: 1 transaction(s) which must be rolled back or cleaned up in total 2 row operations to u>
Jan 24 20:16:28 nextcloudpi mariadbd[1709407]: 2024-01-24 20:16:28 0 [Note] InnoDB: Trx id counter is 63341608
Jan 24 20:16:28 nextcloudpi mariadbd[1709407]: 2024-01-24 20:16:28 0 [Note] InnoDB: To recover: 376 pages
Jan 24 20:16:28 nextcloudpi mariadbd[1709407]: 2024-01-24 20:16:28 0 [Note] InnoDB: 128 rollback segments are active.
Jan 24 20:16:28 nextcloudpi mariadbd[1709407]: 2024-01-24 20:16:28 0 [Note] InnoDB: Starting in background the rollback of recovered transactions
Jan 24 20:16:28 nextcloudpi mariadbd[1709407]: 2024-01-24 20:16:28 0 [Note] InnoDB: Removed temporary tablespace data file: "./ibtmp1"
Jan 24 20:16:28 nextcloudpi mariadbd[1709407]: 2024-01-24 20:16:28 0 [Note] InnoDB: Creating shared tablespace for temporary tables
Jan 24 20:16:28 nextcloudpi mariadbd[1709407]: 2024-01-24 20:16:28 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
Jan 24 20:16:28 nextcloudpi mariadbd[1709407]: 2024-01-24 20:16:28 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
Jan 24 20:16:28 nextcloudpi mariadbd[1709407]: 2024-01-24 20:16:28 0 [Note] InnoDB: 10.6.16 started; log sequence number 63223002448; transaction id 63341609
Jan 24 20:16:28 nextcloudpi mariadbd[1709407]: 2024-01-24 20:16:28 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
Jan 24 20:16:28 nextcloudpi mariadbd[1709407]: 2024-01-24 20:16:28 0 [Note] Plugin 'FEEDBACK' is disabled.
Jan 24 20:16:28 nextcloudpi mariadbd[1709407]: 2024-01-24 20:16:28 0 [Warning] 'innodb-large-prefix' was removed. It does nothing now and exists only for compatibility wit>
Jan 24 20:16:28 nextcloudpi mariadbd[1709407]: 2024-01-24 20:16:28 0 [Warning] 'innodb-file-format' was removed. It does nothing now and exists only for compatibility with>
Jan 24 20:16:28 nextcloudpi mariadbd[1709407]: 2024-01-24 20:16:28 0 [Warning] 'innodb-buffer-pool-instances' was removed. It does nothing now and exists only for compatib>
Jan 24 20:16:28 nextcloudpi mariadbd[1709407]: 2024-01-24 20:16:28 0 [Warning] You need to use --log-bin to make --expire-logs-days or --binlog-expire-logs-seconds work.
Jan 24 20:16:28 nextcloudpi mariadbd[1709407]: 2024-01-24 20:16:28 0 [Warning] InnoDB: Record in index `fs_id_storage_size` of table `nextcloud`.`oc_filecache` was not fou>
Jan 24 20:16:28 nextcloudpi mariadbd[1709407]: 2024-01-24 20:16:28 0 [Note] Server socket created on IP: '127.0.0.1'.
Jan 24 20:16:28 nextcloudpi mariadbd[1709407]: 240124 20:16:28 [ERROR] mysqld got signal 11 ;
Jan 24 20:16:28 nextcloudpi mariadbd[1709407]: Sorry, we probably made a mistake, and this is a bug.
Jan 24 20:16:28 nextcloudpi mariadbd[1709407]: Your assistance in bug reporting will enable us to fix this for the next release.
Jan 24 20:16:28 nextcloudpi mariadbd[1709407]: To report this bug, see https://mariadb.com/kb/en/reporting-bugs
Jan 24 20:16:28 nextcloudpi mariadbd[1709407]: We will try our best to scrape up some info that will hopefully help
Jan 24 20:16:28 nextcloudpi mariadbd[1709407]: diagnose the problem, but since we have already crashed,
Jan 24 20:16:28 nextcloudpi mariadbd[1709407]: something is definitely wrong and this may fail.
Jan 24 20:16:28 nextcloudpi mariadbd[1709407]: Server version: 10.6.16-MariaDB-1:10.6.16+maria~deb11 source revision: b83c379420a8846ae4b28768d3c81fa354cca056
Jan 24 20:16:28 nextcloudpi mariadbd[1709407]: key_buffer_size=134217728
Jan 24 20:16:28 nextcloudpi mariadbd[1709407]: read_buffer_size=131072
Jan 24 20:16:28 nextcloudpi mariadbd[1709407]: max_used_connections=0
Jan 24 20:16:28 nextcloudpi mariadbd[1709407]: max_threads=153
Jan 24 20:16:28 nextcloudpi mariadbd[1709407]: thread_count=1
Jan 24 20:16:28 nextcloudpi mariadbd[1709407]: It is possible that mysqld could use up to
Jan 24 20:16:28 nextcloudpi mariadbd[1709407]: key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 468013 K  bytes of memory
Jan 24 20:16:28 nextcloudpi mariadbd[1709407]: Hope that's ok; if not, decrease some variables in the equation.
Jan 24 20:16:28 nextcloudpi mariadbd[1709407]: Thread pointer: 0x0
Jan 24 20:16:28 nextcloudpi mariadbd[1709407]: Attempting backtrace. You can use the following information to find out
Jan 24 20:16:28 nextcloudpi mariadbd[1709407]: where mysqld died. If you see no messages after this, something went
Jan 24 20:16:28 nextcloudpi mariadbd[1709407]: terribly wrong...
Jan 24 20:16:28 nextcloudpi mariadbd[1709407]: stack_bottom = 0x0 thread_stack 0x49000
Jan 24 20:16:28 nextcloudpi systemd[1]: mariadb.service: Main process exited, code=killed, status=11/SEGV
β–‘β–‘ Subject: Unit process exited
β–‘β–‘ Defined-By: systemd
β–‘β–‘ Support: https://www.debian.org/support
β–‘β–‘
β–‘β–‘ An ExecStart= process belonging to unit mariadb.service has exited.
β–‘β–‘
β–‘β–‘ The process' exit code is 'killed' and its exit status is 11.
Jan 24 20:16:28 nextcloudpi systemd[1]: mariadb.service: Failed with result 'signal'.
β–‘β–‘ Subject: Unit failed
β–‘β–‘ Defined-By: systemd
β–‘β–‘ Support: https://www.debian.org/support
β–‘β–‘
β–‘β–‘ The unit mariadb.service has entered the 'failed' state with result 'signal'.
Jan 24 20:16:28 nextcloudpi systemd[1]: Failed to start MariaDB 10.6.16 database server.
β–‘β–‘ Subject: A start job for unit mariadb.service has failed
β–‘β–‘ Defined-By: systemd
β–‘β–‘ Support: https://www.debian.org/support
β–‘β–‘
β–‘β–‘ A start job for unit mariadb.service has finished with a failure.
β–‘β–‘
β–‘β–‘ The job identifier is 1302505 and the job result is failed.
Jan 24 20:16:31 nextcloudpi sudo[1709428]:     root : PWD=/ ; USER=www-data ; COMMAND=/usr/bin/php /var/www/nextcloud/occ config:system:get overwrite.cli.url
Jan 24 20:16:31 nextcloudpi sudo[1709428]: pam_unix(sudo:session): session opened for user www-data(uid=33) by (uid=0)
Jan 24 20:16:31 nextcloudpi sudo[1709428]: pam_unix(sudo:session): session closed for user www-data
Jan 24 20:16:32 nextcloudpi notify_push[1709279]: Error:
Jan 24 20:16:32 nextcloudpi notify_push[1709279]:   Γ— Failed to connect to database
Jan 24 20:16:32 nextcloudpi notify_push[1709279]:   ╰─▢ pool timed out while waiting for an open connection
Jan 24 20:16:32 nextcloudpi systemd[1]: notify_push.service: Main process exited, code=exited, status=1/FAILURE
β–‘β–‘ Subject: Unit process exited
β–‘β–‘ Defined-By: systemd
β–‘β–‘ Support: https://www.debian.org/support
β–‘β–‘
β–‘β–‘ An ExecStart= process belonging to unit notify_push.service has exited.
β–‘β–‘
β–‘β–‘ The process' exit code is 'exited' and its exit status is 1.
Jan 24 20:16:32 nextcloudpi systemd[1]: notify_push.service: Failed with result 'exit-code'.
β–‘β–‘ Subject: Unit failed
β–‘β–‘ Defined-By: systemd
β–‘β–‘ Support: https://www.debian.org/support
β–‘β–‘
β–‘β–‘ The unit notify_push.service has entered the 'failed' state with result 'exit-code'.
lines 1581-1664/1664 (END)