# Nextcloud - Mariadb



## Ernie95 (Feb 25, 2022)

Hi All,

I am trying to install Nextcloud in a freebsd jail.

I found lot of explanations and HowTo on internet and also in this forum.

I have an issue. I tested 3 times from scratch and always the same issue. Your advice are welcome.

Context :

I installed the following packages:
apache24-2.4.52
mariadb105-server-10.5.13
php80 (several packages)
nextcloud-php80-23.0.0

in a jail with freebsd 12.3

The different HowTo is not full aligned with my wish (NC + mariadb).

But  I successful set up apache, mariadb. I can see the first page of NC for the first connexion and set up. And I have the following message for the first connexion:
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 search this warning on net but the explanations don't allow me to solve the issue.

I tried to set up again Mariadb for the ownership of nextcloud database, and I check also with relevant mysql commands the ownership. Same issue.

I tried to change localhost for the first connexion view of NC by:
localhost : port
ipadress : port
mariadb (I seen this on a docker post, last chance )

No success.

Sure I am not an expert, and I would like to have some guideline for investigation.

Perhaps the config file of mariadb doesn't contain the rigth parameters.

I setup these parameters:

Nextcloud will have been installed to /usr/local/www/nextcloud, which is not the default web root for apache (place where apache looks for index.php). This will need to be changed to the Nextcloud directory so that the Nextcloud web UI can be loaded. You can do this by editing apache’s configuration file:
$ nano /usr/local/etc/apache24/httpd.conf
Change the following two lines
DocumentRoot "/usr/local/www/apache24/data"
<Directory "/usr/local/www/apache24/data">
To
DocumentRoot "/usr/local/www/nextcloud"
<Directory "/usr/local/www/nextcloud">

Ownership: chown -R www:www /usr/local/www/nextcloud

I put in htppd.conf:
Alias /nextcloud /usr/local/www/nextcloud
    AcceptPathInfo On
    <Directory /usr/local/www/nextcloud>
        AllowOverride All
        Require all granted
    </Directory>

And in mariadb:
 mysql -u root -p
create database nextcloud_db;
create user 'nextcloud_user'@'localhost' identified by 'yourpassword';
grant all privileges on nextcloud_db.* to 'nextcloud_user'@'localhost';
flush privileges;

I change the name of database and of the user and of the password

Thanks in advance for your advice.

BR


----------



## Ernie95 (Feb 26, 2022)

Hi,
It seems that via such command in mysql environment:
*MariaDB [(none)]>* GRANT ALL ON *database_name.** to '*database_username*'@'*10.24.96.%*' IDENTIFIED BY '*database_password*';
*MariaDB [(none)]>* FLUSH PRIVILEGES;

With the name of the nextcloud database, the IP adress of local network (with % for last number) and the name of the user, it solves the point.

I will try again, it seems that localhost is not recognized for the first connexion.

BR


----------

