Lost Login Password for Nextcloud - no email setup

I have completed the setup with the YouTube tutorial (thanks BTW it was awesome) and I forgot my username and password to log into Nextcloud. How do I retrieve/reset it?

Welcome to the forum!

I haven’t watched the tutorial yet, I did not have time for it. But I can assume 2 things:
Case 1: nextcloud is using local linux authentication, in which case it would be just a matter of logging into the server, and using (sudo) passwd username to reset the password.
Case 2: nextcloud is using a database, like mysql, in which case you still have to login the server, but instead log into the db using the db client (like mysql or psql for postgres) and resetting the password that way.
Case 3: you’re running nextcloud in docker, in which case I have no idea how to help you lol.

If you tell under which category your server falls into, I may be able to help, but all 3 of them require that you have access to the server you are running nextcloud on.

The good news is that case 2 is what I believe is happening. Docker is definitely not the case, and Linux authentication is definitely not involved.

I do have SSH access to the server. I can log into the SQL instance. HOWEVER, I am very lost from there as to how to reset the password. I thought it was the database master password, but it did not work. At one point in the setup, we create the database and then create a user. Then set that users’ password. Give the user permissions to access all the database.

Hope this helps paint a clearer picture.

Thanks!

We don’t use Nextcloud, but I found this that might help:

https://wiki.turris.cz/doc/en/public/nextcloud_password_reset

Thank you. I do get the following error:

php-cli: command not found

You maybe can just run ‘php -f’ instad of ‘php-cli’ ? (notice theres a space between ‘php’ and ‘-f’)

Get the error:
Could not open input file: /srv/www/nextcloud/occ

Now, trying to cd to that directory, there is no such directory. I know PHP is installed and apache2 as well. any ideas where that would be hiding?

I did find the installation… it is under var/www/nextcloud

I do get the following error when I run the command:

Cannot write into “config” directory!
This can usually be fixed by giving the webserver write access to the config directory.

But, if you prefer to keep config.php file read only, set the option “config_is_read_only” to true in it.
See Configuration Parameters — Nextcloud latest Administration Manual latest documentation

Ok… so i changed the permissions. now when I run the command:

sudo -u nobody php -f /var/www/nextcloud/occ user:resetpassword USER HERE

I get:

An unhandled exception has been thrown:
OCP\HintException: [0]: Memcache \OC\Memcache\APCu not available for local cache (Is the matching PHP module installed and enabled?)

There’s this other one I saw too:

https://www.edv2.com/nxt/core/doc/admin/configuration_user/reset_admin_password.html

It has a different user with the ‘-u’ option, so maybe look and see what Linux user your Nextcloud files are woned by and use that. Like I said, we don’t run Nextcloud, so I’m just looking it up.

Thanks… basically the same thing.

I JUST got the system to allow me to reset passwords. I THINK? I did reset the password as instructed, but I can not log in with the username password combo

Any ideas?

IDK; since you just installed it, it’s probably easiest to just delete and re-install it then.

1 Like

Ok, so if it’s MySQL, MariaDB or Postgres do a

grep mysql /etc/passwd
grep mar /etc/passwd
grep postgres /etc/passwd

If they have /bin/bash at the end, it should be fine to login to those (linux) users, but if not, you have to change their login shell by

usermod -s /bin/bash mysql

Then you should be able to login as the mysql user. I’ll just use mysql from now on, but same applies to mariadb.

sudo su - mysql
mysql

Then in the mysql client

show databases ;
use database-name ;
show tables ;

If you have a users table, do

select * from users-table ;

Be mindful that the table names are case sensitive. Once you find the user do a:

alter user username identified by 'new_password' ;

If it’s postgres, do the same up to and including sudo su - postgres

psql

Then in the postgresql client:

\l ;
\c database-name
alter role username with password 'new_password' ; 
quit ;

After altering the username, do:

exit 
sudo usermod -s /sbin/nologin mysql

Now you should be good to go.

1 Like

Thank you.

I did get it to work after all. My previous post worked. The system was not letting me in because of a cookie.

I tried it directly on the server, and it worked. I tried it on an incognito window, and it worked. I flushed cookies, it worked. So the password change I did worked.

Thank you all for your input and help!

3 Likes