"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