I installed phpmyadmin on both systems. I then exported the nextcloud database from the source host and imported it on the target host. I copied over the nextcloud/config/config.php file.
However, when I run the occ script, it canât authenticate:
/var/www/nextcloud#
su -m www-data -c "php ./occ upgrade"
An unhandled exception has been thrown:
Doctrine\DBAL\DBALException: Failed to connect to the database: An exception occurred in driver: SQLSTATE[HY000] [1044] Access denied for user 'nextcloud'@'localhost' to database 'nextcloud' in /var/www/nextcloud/lib/private/DB/Connection.php:64
The database username and password are both ânextcloudâ. I can log in manually with these credentials:
/var/www/nextcloud# mysql -u nextcloud -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 210
Server version: 10.3.18-MariaDB-0+deb10u1 Debian 10
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>
What could be going wrong when the occ script tries to connect? Here is the relevant part of my config:
after you import the db-dumpfile, you have to create the user for the imported db; as mysql-root do sth. like grant whatever on nextcloud-db.* to 'your nc-user'@'localhost' identified by 'strong password';
(please look up exact syntax, rights, names etc. in documentation)
GOOD LUCK!
When you export database, does it contain the corresponding user credentials? Or are these stored in a separate database?
I ask because after I exported and imported my nextcloud database using phpmyadmin, I checked to see that the user rights were imported as well, and that seemed to be the case, at least as far as I could see via the phpmyadmin web interface. But I may have been mistaken.
You have to differentiate between Nextcloud users and general database users. If youâre going to export the Nextcloud database, only these user login accounts are exported. If the database users should also be exported, you have to export the internal databases too.
The information_schema , mysql , performance_schema , and sys databases are created at installation time and they are storing information about all other databases, system configuration, users, permission and other important data. These databases are necessary for the proper functionality of the MySQL installation.
sorry for getting back so late - you could also have checked with:
log into mysql as root
type:
select user from mysql.user;
MariaDB [(none)]> select user from mysql.user;
±---------+
| user |
±---------+
| ncuser | -> my nextcloud-user
âŠ
| root |
±---------+
6 rows in set (0.000 sec)
then you can see if your nextcloud user exists in mariadb/mysql.
GOOD LUCK!