I can’t install NC because it can’t connect to MySQL. When attempting to use the installation wizard, I get this error:
MySQL username and/or password not valid You need to enter details of an existing account.
And after playing around with the source code, I see the underlying error:
Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [1045] Access denied for user ‘<user>’@‘localhost’ (using password: YES)"
System Info
OS: TurrisOS
OS version: 6.2.3
NextCloud version: 23.0.11-2
NextCloud Data folder location: /srv/www/nextcloud/data
.
MariaDB server version: 10.4.26
My original thread on the Turris forum. This thread provides more background info:
Original Thread
Hello,
I’m trying to initialize NextCloud, but NC can’t seem to connect to the MySQL DB.
I get this error on the initialization page:
Error while trying to create admin user: Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [2002] No such file or directory
I’ve tried to re-install NC via the CLI with nextcloud_install
, following the instructions to delete the config.php
file, drop the nextcloud
DB, and drop the nextcloud@localhost
and nextcloud@127.0.0.1
users.
I have tried miska’s solution in a similar thread. Miska writes:
There is also /srv/mysql that has to has correct owner - mysql:mysql. I think we might be running webserver as nobody - try that one for the Nextcloud directory.
This solution also doesn’t seem to resolve my particular issue.
As a side note, I can connect to MySQL via mysql -u root
, so the service is running.
Another important detail: I had previously installed NC on my device, and it worked perfectly fine. However, I made the mistake of installing NC it before initializing my external storage. I then rolled my device back to an earlier snapshot so I could set up my external storage and install NC in the proper order. It was after this that I began experiencing this issue.
Any help on this issue would be greatly appreciated!
Additional info:
Device: Omnia
TurrisOS version: 6.2.3
NextCloud Data folder location: /srv/www/nextcloud/data
.
MariaDB server version: 10.4.26
NextCloud-related packages installed on device:
Package Name | Version |
---|---|
nextcloud |
23.0.11-2 |
nextcloud-install |
23.0.11-2 |
foris-controller-nextcloud-module |
0.2.0-3.9-1 |
reforis-nextcloud-plugin |
0.1.0-3.9-1 |
turris-webapps-nextcloud |
1.0-6 |
Update: Still not working, but getting closer.
Using 127.0.0.1
as my DB host (instead of localhost
) in the NC installation wizard seems to get me closer to a solution. This was discovered on this StackOverflow answer.
Additionally, I discovered I needed to append the correct port to the host address, e.g. 127.0.0.1:3306
.
I created a nextcloud
database in MySQL.
CREATE DATABASE nextcloud;
I then created a new DB user and granted the user access to the DB.
CREATE USER '<user>'@'127.0.0.1' IDENTIFIED BY '<password>';
GRANT ALL ON nextcloud.* TO '<user>'@'127.0.0.1';
Even after running the query, though, I get this error in the NC initialization wizard:
MySQL username and/or password not valid You need to enter details of an existing account.
Update: Access denied for ‘<user>’@‘localhost’.
After modifying the /srv/www/nextcloud/lib/private/Setup/MySQL.php
file to var_dump()
the exception object, I can see this error is occurring behind the scenes:
Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [1045] Access denied for user ‘<user>’@‘localhost’ (using password: YES)"
Note, <user>
is the same DB user account that I had already created for NC.