"The username is already being used" after reinstalling Nextcloud version 20.0.7.1

I needed to delete my whole installation and reinstall nextcloud. Upon opening /SERVERNAME/nextcloud it gives me the default starting screen where I entered the username AdminNextcloud. This is the same name I had used before I cleared all previous data (see Details below), yet I get stuck with the message “The username is already being used”. Where does Nextcloud keep finding that name? How do I delete ALL the previous installation without deleting maybe Apache and PHP?
Details:
I followed a great tutorial at https://pimylifeup.com/raspberry-pi-nextcloud-server/ to install nextcloud. After moving the installation to my external hard drive the dashboard came up, but no longer displayed even the default .jpg images. I decided to delete the installation and start again by using rm -r /var/www/nextcloud/* , rmdir nextcloud, removing the MariaDB nextcloud database (using DROP), clearing my browser cache and cookies, and unmounting my external hard drive. I then downloaded and reinstalled from the tarball, again following the initial tutorial.
Upon opening http://SERVERNAME/nextcloud it gives me the default setup screen where I entered the username AdminNextcloud as I had used before (all files containing that name should be gone, right?), yet I get stuck with the message “The username is already being used”. Where does Nextcloud keep finding that name? How do I delete ALL the previous installation so I can start again clean without maybe deleting Apache and PHP? I’d prefer not to just use a different admin name and would really like to find the answer to where this data remains on my system. Thanks!

@mworth Have you delete the data directory of nextcloud ?
if not, rename the directory nammed " AdminNextcloud" or delete it

Hello Mageunic, thanks for responding.
Yes, I deleted the entire /var/www/nextcloud/* directory, all files, and all subdirectories (including /var/www/nextcloud/data) before I reinstalled Nextcloud.
Any other thoughts?

This is really strange …
I suppose you have no log on it.

Correct. I searched through /var/www/nextcloud/data/nextcloud.log and there is no mention of AdminNextcloud. I couldn’t even find the error phrase “The username is already being used” in that log. I would think it should show up using the default logging level of 2. It’s strange.

Are you sure that you correctly cleared the db ? I had this very same error when the db wasn’t removed. You dropped the DB but maybe not the user in the db

Hi Berthou. I only dropped the DB. Perhaps I don’t understand enough about MariaDB, but I always thought that dropping a database (e.g. DROP DATABASE nextclouddb; ) would remove everything about it. Where else would the name be stored? I also deleted the entire nextcloud directory and all files from the filesystem, thinking all traces would be gone.

BTW, as a workaround, I just created a new admin user to complete installation. Once I got in I found that nextcloud still showed my previous admin user. Any ideas why that had been retained? Thanks for your help.

Hi Mworth,

The same kept happening to me, and I believe I’ve found what was causing this. Are you use REDIS in your docker setup? If so, turn it off, drop the DB (again, yes ;)), and then try again (of course after creating a new DB).

If you’re not having the issue anymore, hopefully this info might save someone else a couple of days ;(

Cheers.

Are you sure you have droped the nextcloud database in mariadb/mysql?
In my case the problem was that in mariadb/mysql, in database nextcloud in table oc_users (where ‘oc_’ is the tableprefix in config/config.php) the admin user (‘AdminNextcloud’ in your case) already existed. So, running on mariadb/mysql something like command
DELETE FROM nextcloud.oc_users WHERE uid='AdminNextcloud';
fixed it, the next time I reinstalled.

I hope this helps anyone still having this problem.

2 Likes

This means that the nextcloud/owncloud login user is already existent, so not be confused about the database user its just the login user for nextcloud and same appears on owncloud. ive had it running on kubernetes and everytime i deleted the pod and it relaunched it appeared that the username was already in use. All you need to do is to delete the user you log into the cloud.

For example if you use “admin” as user to login to nextcloud or owncloud then do this:

(you might need to replace owncloud with nextcloud and oc_ with nc_ just double check the database name, prefix and tables)

Check Databases:
SHOW DATABASES;

Select the Database you need to edit:
USE owncloud;

Self explanatory:
SHOW TABLES;

Select all from table oc_users or nc_users if nextcloud:
SELECT * FROM oc_users;

Delete the admin user inside table oc_users or nc_users depending on installation, also deleting from accounts and groups:

DELETE FROM oc_users
where uid = ‘admin’;

DELETE FROM oc_accounts
where user_id = ‘admin’;

DELETE FROM oc_group_user
where gid = ‘admin’;