How can I restore the accidentally deleted mysql dbuser

When deleting a parallel installation, I accidentally deleted the current mysql dbuser oc_XYZ. Simply creating this dbuser in phpMyAdmin did not work. How and with what permissions can I create the dbuser oc_XYZ to access the existing Nextcloud again?

Welcome to the forum, @mfunk.

First thing to do is to learn how to ask properly for community support by providing information about your server setup, OS, web server, database and version and error logs if available for easy troubleshooting.

The information provided with your post is quite sparse thus making it difficult to provide you with the exact steps on how to recreate the “mysql dbuser oc_XYZ”.

However, the below could work for mySQL >= v.8.x.

Login to mysql as mysql-root-user:

mysql --password=mysql-root-user-password

From the mysql-CLI run:

CREATE USER 'dbuser_oc_XYZ'@'localhost' IDENTIFIED WITH mysql_native_password BY 'dbuser_oc_XYZ-password';
GRANT ALL PRIVILEGES ON nc-database.* TO 'dbuser_oc_XYZ'@'localhost';
FLUSH PRIVILEGES;
quit
1 Like

Thanks for the hint.

Our nextcloud is now up and running again. I had to enter the password in plain text in the config.php (was previously entered there as an encrypted password). Is this a serious security problem? If so, how can I set up an encrypted password again?

Server Setup: Ubuntu 20.04.1; Apache 2.4.41; MySQL 8.0.27; PHP 7.4.3; Nextcloud 21.0.4

Just make sure config.php has permission 640 (owner: read+write and group: read) and that owner and group is www-data.www-data (for Debian, Ubuntu etc.). Also make sure .htaccess is in place inside the config directory.

With this you can be sure that the content of config.php is not accessible through the web. If you have an intruder within your server its a different story though.

Nonetheless the user passwords saved in the DB itself are hashed and thus not simply readable if someone has access to mySQL on the server.

Thanks, I’ll check again and adjust if necessary.