Internal Server Error after Database reinstall

Nextcloud version 16.0.4
Operating system and version Ubuntu 18.04
Apache or nginx version Apache 2.4.29
PHP version 7.2.19

The issue you are facing:
I get this error when i try to go to my Nextcloud:

Internal Server Error

The server encountered an internal error and was unable to complete your request.
Please contact the server administrator if this error reappears multiple times, please include the technical details below in your report.
More details can be found in the server log.

Is this the first time you’ve seen this error? (Y/N):
Yes

I had a problem with my MariaDB so i had to remove it and reinstall it. I created the same database and database user i previously had. Then after that i tried to go to the my Nextcloud, but then the error appeared.

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'instanceid' => '***',
  'passwordsalt' => '***',
  'secret' => '***',
  'trusted_domains' => 
  array (
    0 => 'domain.example,
  ),
  'datadirectory' => '/var/www/nextcloud/nextcloud',
  'dbtype' => 'mysql',
  'version' => '16.0.3.0',
  'overwrite.cli.url' => 'https://domain.example',
  'dbname' => 'next',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'cloud',
  'dbpassword' => '******',
  'installed' => true,
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'maintenance' => false,
);

Did you do anything to backup and restore your existing database(s)? i think at least you have to give the user perms in the newly created db (try to connect with that user locally; eg mysql -u <NC-USER> -p or sth. like it.
GOOD LUCK!

Unfortunately I didn’t back up the old database because I didn’t think about it. But i have given the new user all of the permissions it needs.

so can the nc-database-user connect and “see” stuff in the db? if you connect with mysql -u <YOUR-NC-DB-USER> -p and execute an sql-statement, is your stuff in the db?
GOOD LUCK!

I executed the SHOW TABLES; and it said that it was empty. Is it supposed to be like that?

you probably created an empty database. if you still have the old database-files from before that (check in /var/lib/mysql/… ) there should be a way to recreate the contents from them. i did that once some years ago but i don’t have a standard recipe for that.
GOOD LUCK!

I don’t have the old database files. Is it possible to just reinstall Nextcloud and have the same users? I also have the files from my Nextcloud. Can i then just reinstall Nextcloud and link the folder where the original files are when setting it up?