sudo -u www-data php occ \
maintenance:install --database "mysql" --database-name "nextcloud" \
--database-user "user" --database-pass "password" --database-host "mysql" \
--admin-user "admin" --admin-pass "pass"
The admin user should be created.
An error message shows up:
MySQL username and/or password not valid You need to enter details of an existing account.
If you examine the database at this point, you'll see that the nextcloud database has been created according to the --database-name option.
Looking at data/nextcloud.log shows:
An exception occurred in driver: SQLSTATE[HY000] [1044] Access denied for user 'oc_admin'@'%' to database 'nextcloud'"
Looking at the actual MySQL server:
mysql> show grants for oc_admin@'%';
+--------------------------------------+
| Grants for oc_admin@% |
+--------------------------------------+
| GRANT USAGE ON *.* TO `oc_admin`@`%` |
+--------------------------------------+
1 row in set (0.01 sec)
It looks like oc_admin is somehow incorrectly created?
Operating system: Armbian Buster (armhf) + Docker
Web server: Apache (Docker image 19-apache).
Database: MySQL
PHP version: 7? Whatever the 19-apache docker image comes with
Nextcloud version: 19
Updated from an older Nextcloud/ownCloud or fresh install: Fresh
Where did you install Nextcloud from: Official docker image
Web server error log
Initializing nextcloud 19.0.0.11 ...
Initializing finished
New nextcloud instance
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.26.0.3. Set the 'ServerName' directive globally to suppress this message
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.26.0.3. Set the 'ServerName' directive globally to suppress this message
[Sun Jul 05 00:34:29.305590 2020] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.38 (Debian) PHP/7.4.6 configured -- resuming normal operations
[Sun Jul 05 00:34:29.305821 2020] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'
172.26.0.1 - - [05/Jul/2020:00:35:41 +0000] "GET / HTTP/1.1" 200 2779 "-" "Mozilla/5.0 (Windows NT 10.0; rv:78.0) Gecko/20100101 Firefox/78.0"
172.26.0.1 - - [05/Jul/2020:00:35:50 +0000] "POST /index.php HTTP/1.1" 200 3566 "-" "Mozilla/5.0 (Windows NT 10.0; rv:78.0) Gecko/20100101 Firefox/78.0"
{"reqId":"ybOctU252NILqArHuHlg","level":3,"time":"2020-07-05T00:41:15+00:00","remoteAddr":"172.26.0.1","user":"--","app":"no app in context","method":"POST","url":"/index.php","message":{"Exception":"Doctrine\\DBAL\\DBALException","Message":"Failed to connect to the database: An exception occurred in driver: SQLSTATE[HY000] [1044] Access denied for user 'oc_admin'@'%' to database 'nextcloud'","Code":0,"Trace":[{"file":"/var/www/html/lib/private/Setup/MySQL.php","line":66,"function":"connect","class":"OC\\DB\\Connection","type":"->","args":[]},{"file":"/var/www/html/lib/private/Setup.php","line":358,"function":"setupDatabase","class":"OC\\Setup\\MySQL","type":"->","args":["admin"]},{"file":"/var/www/html/core/Controller/SetupController.php","line":75,"function":"install","class":"OC\\Setup","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/lib/base.php","line":945,"function":"run","class":"OC\\Core\\Controller\\SetupController","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/index.php","line":37,"function":"handleRequest","class":"OC","type":"::","args":[]}],"File":"/var/www/html/lib/private/DB/Connection.php","Line":67,"CustomMessage":"--"},"userAgent":"Mozilla/5.0 (Windows NT 10.0; rv:78.0) Gecko/20100101 Firefox/78.0","version":"19.0.0.11"}
Possibly related: https://github.com/nextcloud/server/issues/18513
Looks like the problem is actually because the user I'm using to initialize the database doesn't have GRANT OPTIONS.
It may be a good idea to emit the message to the user. I spent half a day chasing my tails...
grant all privileges on *.* to 'user'@'localhost' with grant option; can solve this problem
This helped me, Thank you!
Most helpful comment
grant all privileges on *.* to 'user'@'localhost' with grant option;can solve this problem