"Username is invalid because files already exist for this user" during fresh install

Iā€™m performing a fresh install of NC v18.0.3 on a totally new instance, and am attempting to automate the process. Iā€™m using the documented occ maintenance:install method, but regardless of which admin user name I try to use, Iā€™m gettingā€¦

Username is invalid because files already exist for this user

The command (with private info removed) that Iā€™m issuing is:

sudo -u ###APACHE-USER### /usr/bin/php -d memory_limit=512M occ maintenance:install --database="mysql" --database-name="nextcloud" --database-user="nextcloud" --database-pass="###PASSWORD###" --database-host="127.0.0.1" --database-port="3306" --admin-user="admin@example.com" --admin-pass="###ADMIN-PASSWORD###" --data-dir="###NC-DATA-DIR"

In the example above I used an email for the admin name, but Iā€™ve also used simply ā€œadminā€ (the default apparently) which also fails with exactly the same error.

Each time I attempt this, I delete ALL nc related files, DB database, DB user, etc. and start the install fresh right from downloading the NC files all over again. Since this is pre-install, Iā€™m not seeing anything out of the ordinary in the logs either.


EDIT: Just tried with v18.0.4 just in case, no difference, same error.


EDIT 2: Attempted with username ā€œadmin-otherā€ and it finally accepted it. So it seems the issue is specifically with using the user admin or an email starting with admin@.....

email address as user name is not a good idea.

btw: you should not use 127.0.0.1 as database host. thatā€™s the network address and therefore network stack is use. i believe. if you use localhost the unix socket is used. https://stackoverflow.com/questions/3715925/localhost-vs-127-0-0-1-in-mysql-connect/3715946

@Reiner_Nippes

email address as user name is not a good idea.

Do you have a specific reason to state this beyond predictability? And regardless, I indicated in my problem that admin was also not accepted and resulted in the same error.

you should not use 127.0.0.1 as database host

I appreciate your effort to educate me, however there are a number of reasons I may very well want to specifically use TCP rather than a socket.

I donā€™t want to come across as confrontational, because Iā€™m still in need of help, but neither of your comments have anything to do with my issue. Do you have something constructive you could point me toward that will help with the issue Iā€™ve outlined?

To add a little confusion, the occ install seems to fail on whichever username I choose to install with first, but then as soon as I switch to another it works. In the mean time, Iā€™ve had to validate the install/init first, and if the install hasnā€™t been initialized, it deletes any existing user folder using that name in the data directory. That seems to have gotten things moving, but it doesnā€™t answer the question, why is that directory being created before the init?

1 Like

Try to delete all files from nextcloud data directory.