Leftover users in database

Support intro

Sorry to hear you’re facing problems :slightly_frowning_face:

help.nextcloud.com is for home/non-enterprise users. If you’re running a business, paid support can be accessed via portal.nextcloud.com where we can ensure your business keeps running smoothly.

In order to help you as quickly as possible, before clicking Create Topic please provide as much of the below as you can. Feel free to use a pastebin service for logs, otherwise either indent short log examples with four spaces:

example

Or for longer, use three backticks above and below the code snippet:

longer
example
here

Some or all of the below information will be requested if it isn’t supplied; for fastest response please provide as much as you can :heart:

Nextcloud version : 27.1.4
Operating system and version: Ubuntu server 22.04.03
Apache or nginx version: Dont know
PHP version: 8.1.25

The issue you are facing:
Nextcloud instance is preinstalled with ubuntu server installation (on last step there is window where you can chose what to install with ubuntu and nextcloud is installed with snap)
When i remove user from admin panel there are still leftovers in database
I found it when i tried to rename user login accounts in database.
I found that database is located in var/snap/nextcloud/current/mysql/nextcloud and is in multiple files like “oc_accounts.ibd”, “oc_activity.ibd” etc.
When i open for example oc_accounts.ibd in nano or notepad++ i found that there are still entries with old users who were deleted.
How can i “clear” database from old users? I had problem with creating user with same login as previously removed where i got error “user already exist”.
The user folder is removed from /var/snap/nextcloud/common/nextcloud/data/.

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

<?php
$CONFIG = array (
  'apps_paths' =>
  array (
    0 =>
    array (
      'path' => '/snap/nextcloud/current/htdocs/apps',
      'url' => '/apps',
      'writable' => false,
    ),
    1 =>
    array (
      'path' => '/var/snap/nextcloud/current/nextcloud/extra-apps',
      'url' => '/extra-apps',
      'writable' => true,
    ),
  ),
  'supportedDatabases' =>
  array (
    0 => 'mysql',
  ),
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'memcache.local' => '\\OC\\Memcache\\Redis',
  'redis' =>
  array (
    'host' => '/tmp/sockets/redis.sock',
    'port' => 0,
  ),
  'log_type' => 'file',
  'logfile' => '/var/snap/nextcloud/current/logs/nextcloud.log',
  'logfilemode' => 416,
  'passwordsalt' => *****,
  'secret' => *****,
  'trusted_domains' =>
  array (
    0 => 'localhost',
    1 => *****,
  ),
  'trusted_proxies' =>
  array (
    0 => *****,
  ),
  'force_language' => 'pl',
  'skeletondirectory' => '',
  'datadirectory' => '/var/snap/nextcloud/common/nextcloud/data',
  'dbtype' => 'mysql',
  'version' => '27.1.4.1',
  'overwrite.cli.url' => 'http://localhost',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost:/tmp/sockets/mysql.sock',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'nextcloud',
  'dbpassword' => *****,
  'installed' => true,
  'instanceid' => 'ociowfy3l9yw',
  'maintenance' => false,
  'loglevel' => 2,
  'mail_smtpmode' => 'smtp',
  'mail_sendmailmode' => 'smtp',
  'mail_from_address' => *****,
  'mail_smtpauth' => 1,
  'mail_smtpname' => *****,
  'mail_smtppassword' => *****,
  'mail_domain' => *****,
  'mail_smtpport' => '587',
  'mail_smtphost' => *****,
);
...

hi @Various_69 welcome to the forum :handshake:

I don’t ink there is any value in looking into database files directly, database storage formats could be pretty complex. I would recommend you check the contents of the database using supported tool e.g. mysql command line utility.

Yea i know but when i try to connect in example with terminal mysql -u -p blah blah blah i get error that sock do not exist, i think there is problem that database and everythink is in snap (i dont get yet how snap works).

then you should familiarize yourself with tools and concepts of technology you are using.

Great answer…
I dont need to know why engine in car works to drive a car.

Try…

sudo nextcloud.mysql-client

https://github.com/nextcloud-snap/nextcloud-snap/wiki/Included-CLI-utilities

No, but to maintain or repair a car you need to know a few things.

1 Like

Yea thanks but that didnt really resolve the problem with clearing leftovers from database, removing by hand all entries that in my opinion are wrong is risky. There isnt a command or somethink that do this automatically?

In last few days i tinker a little in database and when i create account for example test and remove it from database and file folder{yes i know how mysql database work}, i can still see user in WebUi, when i run command
sudo nextcloud.occ files:scan --all
i get error that files from user test exist in cache but not on disk.
And i didnt find way to clean cache.

I know how thinks works, php, mysql, nginx/apache. I didnt had time yet to acknowledge snap thats why im asking for help. And only what i get is “go to school” responses.

there is no way people in the forum know you know how it works until you show this knowledge… and fiddling with DB files is an exact opposite of “knowing how it works”.

the community is happy to help if you have real issues an explain it. random string living in the DB file is not a problem until you can show the users really remain in the DB using the right tool or keep trying to solve the problem yourself.

That was “real issue”

I think you point to this

It was example how i managed to find what is wrong, im not saying that it was good approach to it but it was only option that i find in that moment.

Maybe I miss something but what is wrong using regular ways of user management like WebUI, occ user command and API?

Nothink.
Like i said, i had error when creating user with same login as previously removed
“user account already exist” but he didnt.
Then i was looking in database and i found that entries about that user exist but do not appear in WebUI users section.

you didn’t provide any valuable information how it happened. In the past I often re-created users with same username without issues. Please provide details of the issue.

@wwe,
I can follow the issue, @Various_69 described:

I have the same problem. I deleted some unused users in Nextcloud and if I do a occ users:list they become not displayed.
If I do a occ users:info < deleted user name > the user still becomes listed in status “enabled” and I additionally needed to do a occ users:delete < username >.

But you cannot be sure, the all users really have been removed from Nextcloud database tables, which sometimes may cause error messages in Nextcloud.log.

I’m sorry I can’t repro this issue. I created 2 users from UI and removed the one in the UI and one using occ user:delete - both users didn’t show in occ user:list and occ user:info maybe you can show how you created and removed the users, maybe if the users are created by another backend like LDAP or SAML/OIDC and if this users used any specific apps which might result in some artifacts not deleted by default.

Thank you for pointing me to “LDAP”, @wwe.
In my case that might be the reason, as I use Nextcloud as an Univention app on my UCS.
Maybe @Various_69 can let us know, whether the user(s) have been created via LDAP or SAML/OIDC, too.

On Univention server the Nextcloud users will be created via LDAP in the user management, if you activate the item “Nextcloud” in the account-settings.

If you delete a user there, the user will remain in Nextcloud partially. But I cannot reproduce it exactly anymore, because that happened a few months ago after deleting the user a few weeks before i noticed the issue.

One remain in the Nextcloud database was the email-address in the email table, but the corresponding user was removed from user table.

My posting is not intended to search for a solution, but to show, that after deleting a user a few data may remain in Nextcloud database, which also may lead to log-error entries.

1 Like