Jupiter:docker exec -itu 33 nextcloud bash
www-data@nextcloud:~/html$ php occ db:convert-type --all-apps mysql nextcloud localhost nextcloud
What is the database password?
Creating schema in new database
In Connection.php line 140:
Failed to connect to the database: An exception occurred in the driver: SQL
STATE[HY000] [2002] No such file or directory
db:convert-type [--port PORT] [--password PASSWORD] [--clear-schema] [--all-apps] [--chunk-size CHUNK-SIZE] [--] <type> <username> <hostname> <database>
www-data@nextcloud:~/html$
Yet my mariadb container shows that there’s a nextcloud database:
Jupiter:docker exec -it mariadb mariadb -uroot -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 5
Server version: 11.1.2-MariaDB-1:11.1.2+maria~ubu2204 mariadb.org binary distribution
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)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| nextcloud |
| performance_schema |
| sys |
+--------------------+
5 rows in set (0.001 sec)
MariaDB [(none)]>
I tried changing localhost to mariadb as that is the container name of my mariadb container. It prompted for database password and I supplied “nextcloud”'s database password. it said access was denied. Thinking that perhaps I had the wrong password for the nextcloud user I tried:
Jupiter:docker exec -it mariadb mariadb -unextcloud -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 24
Server version: 11.1.2-MariaDB-1:11.1.2+maria~ubu2204 mariadb.org binary distribution
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)]>
I gave it what I know of the nextcloud user’s password and I was able to get in. So it seems like the nextcloud user did not have enough permissions to do the needful. So I tried specifying “root” as the username and gave it the MariaDB root password. This seems to have worked but I fear I may have the incorrect user permissions on the db. How do I verify and how do I fix if needed?
Hmmm… I was worried about restarting the nextcloud container and it not working because I did this as root but it seems to have worked. If there’s anything else I need to do to make sure this is correct let me know.
My best guess is when you created the nextcloud db user that the @hostname part was localhost or something like that rather than a wildcard (%) or the nextcloud container’s hostname/IP address.
Jupiter:docker exec -it mariadb mariadb -uroot -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 663
Server version: 11.1.2-MariaDB-1:11.1.2+maria~ubu2204 mariadb.org binary distribution
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)]> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
MariaDB [mysql]> select user, host from user;
+-------------+-----------+
| User | Host |
+-------------+-----------+
| root | % |
| healthcheck | 127.0.0.1 |
| healthcheck | ::1 |
| healthcheck | localhost |
| mariadb.sys | localhost |
| nextcloud | localhost |
| root | localhost |
+-------------+-----------+
7 rows in set (0.001 sec)
MariaDB [mysql]>
So is my installation incorrect? How do I correct it? I mean it seems like right now Nextcloud is using MariaDB but as the root user. Shouldn’t it be as the nextcloud user?
I had a nextcloud user and he was granted access to localhost but I’m now realizing that mariadb, running in another docker container, is like running in another host thus the requirement for ‘%’ in the hostname. Added that.