# Leftover users in database

**URL:** <https://help.nextcloud.com/t/leftover-users-in-database/177192>\
**Category:** ℹ️ Support\
**Tags:** snap, reverseproxy, redis, nginx, apache\
**Created:** [December 21, 2023, 9:00am UTC](https://help.nextcloud.com/t/leftover-users-in-database/177192 "2023-12-21T09:00:23Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![Various\_69](https://help.nextcloud.com/user_avatar/help.nextcloud.com/various_69/32/55664_2.png) [@Various\_69](https://help.nextcloud.com/u/Various_69)\
**Post date:** [December 21, 2023, 9:00am UTC](https://help.nextcloud.com/t/leftover-users-in-database/177192/1 "2023-12-21T09:00:24Z")

</div>

> **Support intro**
>
> Sorry to hear you’re facing problems 🙁
> 
> _**[help.nextcloud.com](http://help.nextcloud.com) is for home/non-enterprise users. If you’re running a business, paid support can be accessed via [portal.nextcloud.com](http://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:
> 
> ```auto
> 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 ❤

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!):

```auto
<?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' => ***** ,
);
...
```

---

<div class="post-metadata">

**Author:** ![wwe](https://help.nextcloud.com/user_avatar/help.nextcloud.com/wwe/32/72963_2.png) [@wwe](https://help.nextcloud.com/u/wwe)\
**Post date:** [December 23, 2023, 5:50pm UTC](https://help.nextcloud.com/t/leftover-users-in-database/177192/2 "2023-12-23T17:50:08Z")

</div>

hi @Various_69 welcome to the forum 🤝

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.

---

<div class="post-metadata">

**Author:** ![Various\_69](https://help.nextcloud.com/user_avatar/help.nextcloud.com/various_69/32/55664_2.png) [@Various\_69](https://help.nextcloud.com/u/Various_69)\
**Post date:** [December 27, 2023, 7:22am UTC](https://help.nextcloud.com/t/leftover-users-in-database/177192/3 "2023-12-27T07:22:39Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![wwe](https://help.nextcloud.com/user_avatar/help.nextcloud.com/wwe/32/72963_2.png) [@wwe](https://help.nextcloud.com/u/wwe)\
**Post date:** [December 27, 2023, 9:01am UTC](https://help.nextcloud.com/t/leftover-users-in-database/177192/4 "2023-12-27T09:01:26Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Various\_69](https://help.nextcloud.com/user_avatar/help.nextcloud.com/various_69/32/55664_2.png) [@Various\_69](https://help.nextcloud.com/u/Various_69)\
**Post date:** [December 28, 2023, 8:15am UTC](https://help.nextcloud.com/t/leftover-users-in-database/177192/5 "2023-12-28T08:15:47Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![bb77](https://help.nextcloud.com/letter_avatar/bb77/32/6_449c533f586939b6e5f246632a46421f.png) [@bb77](https://help.nextcloud.com/u/bb77)\
**Post date:** [December 28, 2023, 8:53am UTC](https://help.nextcloud.com/t/leftover-users-in-database/177192/6 "2023-12-28T08:53:00Z")

</div>

> [@Various\_69](#):
>
> i try to connect in example with terminal mysql -u -p blah blah blah

Try…

```
sudo nextcloud.mysql-client

```

[https://github.com/nextcloud-snap/nextcloud-snap/wiki/Included-CLI-utilities](https://github.com/nextcloud-snap/nextcloud-snap/wiki/Included-CLI-utilities)

> [@Various\_69](#):
>
> I dont need to know why engine in car works to drive a car.

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

---

<div class="post-metadata">

**Author:** ![Various\_69](https://help.nextcloud.com/user_avatar/help.nextcloud.com/various_69/32/55664_2.png) [@Various\_69](https://help.nextcloud.com/u/Various_69)\
**Post date:** [December 28, 2023, 11:50am UTC](https://help.nextcloud.com/t/leftover-users-in-database/177192/7 "2023-12-28T11:50:06Z")

</div>

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.

> [@bb77](#):
>
> No, but to maintain or repair a car you need to know a few things.

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.

---

<div class="post-metadata">

**Author:** ![wwe](https://help.nextcloud.com/user_avatar/help.nextcloud.com/wwe/32/72963_2.png) [@wwe](https://help.nextcloud.com/u/wwe)\
**Post date:** [December 28, 2023, 3:46pm UTC](https://help.nextcloud.com/t/leftover-users-in-database/177192/8 "2023-12-28T15:46:54Z")

</div>

> [@Various\_69](#):
>
> I know how thinks works, php, mysql, nginx/apache.

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.

---

<div class="post-metadata">

**Author:** ![Various\_69](https://help.nextcloud.com/user_avatar/help.nextcloud.com/various_69/32/55664_2.png) [@Various\_69](https://help.nextcloud.com/u/Various_69)\
**Post date:** [December 29, 2023, 2:17pm UTC](https://help.nextcloud.com/t/leftover-users-in-database/177192/9 "2023-12-29T14:17:50Z")

</div>

> [@wwe](#):
>
> 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.

> [@Various\_69](#):
>
> 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”.

That was “real issue”

> [@wwe](#):
>
> and fiddling with DB files is an exact opposite of “knowing how it works”.

I think you point to this

> [@Various\_69](#):
>
> 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.

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.

---

<div class="post-metadata">

**Author:** ![wwe](https://help.nextcloud.com/user_avatar/help.nextcloud.com/wwe/32/72963_2.png) [@wwe](https://help.nextcloud.com/u/wwe)\
**Post date:** [December 29, 2023, 3:05pm UTC](https://help.nextcloud.com/t/leftover-users-in-database/177192/10 "2023-12-29T15:05:17Z")

</div>

> [@Various\_69](#):
>
> it was only option that i find in that moment.

Maybe I miss something but what is wrong using regular ways of [user management](https://docs.nextcloud.com/server/latest/admin_manual/configuration_user/index.html) like WebUI, [occ user](https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/occ_command.html#user-commands-label) command and API?

---

<div class="post-metadata">

**Author:** ![Various\_69](https://help.nextcloud.com/user_avatar/help.nextcloud.com/various_69/32/55664_2.png) [@Various\_69](https://help.nextcloud.com/u/Various_69)\
**Post date:** [January 2, 2024, 11:23am UTC](https://help.nextcloud.com/t/leftover-users-in-database/177192/11 "2024-01-02T11:23:27Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![wwe](https://help.nextcloud.com/user_avatar/help.nextcloud.com/wwe/32/72963_2.png) [@wwe](https://help.nextcloud.com/u/wwe)\
**Post date:** [January 2, 2024, 9:02pm UTC](https://help.nextcloud.com/t/leftover-users-in-database/177192/12 "2024-01-02T21:02:43Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Mornsgrans](https://help.nextcloud.com/user_avatar/help.nextcloud.com/mornsgrans/32/40386_2.png) [@Mornsgrans](https://help.nextcloud.com/u/Mornsgrans)\
**Post date:** [January 3, 2024, 4:11pm UTC](https://help.nextcloud.com/t/leftover-users-in-database/177192/13 "2024-01-03T16:11:16Z")

</div>

@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.

---

<div class="post-metadata">

**Author:** ![wwe](https://help.nextcloud.com/user_avatar/help.nextcloud.com/wwe/32/72963_2.png) [@wwe](https://help.nextcloud.com/u/wwe)\
**Post date:** [January 3, 2024, 4:36pm UTC](https://help.nextcloud.com/t/leftover-users-in-database/177192/14 "2024-01-03T16:36:23Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Mornsgrans](https://help.nextcloud.com/user_avatar/help.nextcloud.com/mornsgrans/32/40386_2.png) [@Mornsgrans](https://help.nextcloud.com/u/Mornsgrans)\
**Post date:** [January 3, 2024, 5:03pm UTC](https://help.nextcloud.com/t/leftover-users-in-database/177192/15 "2024-01-03T17:03:01Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![wwe](https://help.nextcloud.com/user_avatar/help.nextcloud.com/wwe/32/72963_2.png) [@wwe](https://help.nextcloud.com/u/wwe)\
**Post date:** [January 16, 2025, 9:02am UTC](https://help.nextcloud.com/t/leftover-users-in-database/177192/16 "2025-01-16T09:02:30Z")

</div>


