Delete data from database

Support intro

Sorry to hear you’re facing problems :slightly_frowning_face:

help.nextcloud.com is for home/non-enterprise users. If you’re running a business, paid support can be accessed via portal.nextcloud.com where we can ensure your business keeps running smoothly.

In order to help you as quickly as possible, before clicking Create Topic please provide as much of the below as you can. Feel free to use a pastebin service for logs, otherwise either indent short log examples with four spaces:

example

Or for longer, use three backticks above and below the code snippet:

longer
example
here

Some or all of the below information will be requested if it isn’t supplied; for fastest response please provide as much as you can :heart:

Nextcloud version: 16
Operating system and version: Ubuntu 18.04
Apache or nginx version : Apache 2.4.29
PHP version (eg, 7.1): 7.2.17

Dear, I’m install new Ubuntu VPS server with next cloud. I had only 50 GB space for all data.
All data is encrypted by default on my server
Yesterday I’m starting sync and today my site with nextcloud is crashed. My site on http doesnt works now but i have access via ssh
Filesystem Size Used Avail Use% Mounted on
/dev/myserwe 50G 48G 0 100% /

I know I’m used whole space on the server :frowning:

How I can delete some part of date on my nextcloud? Can I use some software or commends on Linux? Thank you guys!!

the linux command to delete files and directories is rm

rm /path/to/your/file.txt
rm -r /path/to/your/directory
rm -rf /path/to/your/directory

handle with care. delete stuff is gone forever.

do you know where the nextcloud data directory is located in your installation?

with du -h --max-depth=1 / you can find folder with a lot of data. max-depth=1 shows only one folder level. my guess that all mass data are in var so you could continue with du -h --max-depth=1 /var

if you know the good old Norton Commander try mc. May be you have to install it sudo apt install mc -y

Thx
I’m delete about 10 GB files from directory on server and still nextcloud doesn’t work.
I’m reboot system and services like apache2 and php.
What I shall check next?

the error logs of apache and your database -> /var/log
and the nextcloud log. should be in the data folder.

/var/log/apache2/error.log

Podsumowanie

[Sat May 25 22:38:14.887871 2019] [php7:error] [pid 430] [client 81.62.7.90:40251] PHP Fatal error: Uncaught Doctrine\DBAL\DBALException: Failed to connect to the database: An exception occurred in driver: SQLSTATE[HY000] [2002] No such file or directory in /var/www/html/nextcloud/lib/private/DB/Connection.php:64\nStack trace:\n#0 /var/www/html/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(448): OC\DB\Connection->connect()\n#1 /var/www/html/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(410): Doctrine\DBAL\Connection->getDatabasePlatformVersion()\n#2 /var/www/html/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(354): Doctrine\DBAL\Connection->detectDatabasePlatform()\n#3 /var/www/html/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(710): Doctrine\DBAL\Connection->getDatabasePlatform()\n#4 /var/www/html/nextcloud/lib/private/DB/Connection.php(151): Doctrine\DBAL\Connection->setTransactionIsolation(2)\n#5 /var/www/html/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DriverManager.php(181): OC\DB\Connection->__construct(Array, Object(Doctri in /var/www/html/nextcloud/lib/private/DB/Connection.php on line 64

But nextcloud.log has a lot information but i didn’t see any error information

your database file seems to gone. are you using mysql or sqlite?

MariaDB
mysql --version
mysql Ver 15.1 Distrib 10.1.38-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2

Podsumowanie

dpkg -l | grep mariadb
ii mariadb-client-10.1 1:10.1.38-0ubuntu0.18.04.2 amd64 MariaDB database client binaries
ii mariadb-client-core-10.1 1:10.1.38-0ubuntu0.18.04.2 amd64 MariaDB database core client binaries
ii mariadb-common 1:10.1.38-0ubuntu0.18.04.2 all MariaDB common metapackage
ii mariadb-server 1:10.1.38-0ubuntu0.18.04.2 all MariaDB database server (metapackage depending on the latest version)
ii mariadb-server-10.1 1:10.1.38-0ubuntu0.18.04.2 amd64 MariaDB database server binaries
ii mariadb-server-core-10.1 1:10.1.38-0ubuntu0.18.04.2 amd64 MariaDB database core server files

systemctl status mariadb --> status - failed

Podsumowanie

mariadb.service - MariaDB 10.1.38 database server
Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sat 2019-05-25 23:56:38 UTC; 10h ago
Docs: man:mysqld(8)
https://mariadb.com/kb/en/library/systemd/
Process: 393 ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION (code=exited, stat
Process: 317 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= || VAR=/usr/bin/galera_recovery
Process: 315 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCC
Process: 296 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCCE
Main PID: 393 (code=exited, status=1/FAILURE)
Status: “MariaDB server is down”

May 25 19:46:45 sal systemd[1]: Starting MariaDB 10.1.38 database server…
May 25 19:46:46 sal mysqld[393]: 2019-05-25 19:46:46 140118753401984 [Note] /usr/sbin/mysqld (mysqld 10.1.38-Ma
May 25 19:46:49 sal systemd[1]: mariadb.service: Main process exited, code=exited, status=1/FAILURE
May 25 19:46:49 sal systemd[1]: mariadb.service: Failed with result ‘exit-code’.
May 25 19:46:49 sal systemd[1]: Failed to start MariaDB 10.1.38 database server.
May 25 23:56:34 sal systemd[1]: Starting MariaDB 10.1.38 database server…
May 25 23:56:34 sal mysqld[393]: 2019-05-25 23:56:34 140201746607232 [Note] /usr/sbin/mysqld (mysqld 10.1.38-Ma
May 25 23:56:38 sal systemd[1]: mariadb.service: Main process exited, code=exited, status=1/FAILURE
May 25 23:56:38 sal systemd[1]: mariadb.service: Failed with result ‘exit-code’.
May 25 23:56:38 sal systemd[1]: Failed to start MariaDB 10.1.38 database server.

Pls tell my is possible restore or recover database?
Is possible recover nextcloud without reinstall MariaDB and move again data to server?
For clear info I not configure yet backup database, config file ect (mariadb or apache)

that depends what you deleted. if you deleted the database files then they are gone.
from your post it’s not clear to mariadb doesn’t start. (try to add --full to the systemctl status command.

but what is stored in your database? did you have a lot of contacts, calender entries, app datas?

if you just started to upload your files you just re-install everything and move the files on the server to the new data folder and rescan everything.

I have only document without contacts, calendar ect.
i remove all connected with MariaDB (apt purge mariadb-server) and apache
and i have problem. I can’t install again this software or this not work propertly.
After instalation activity is always fail for maria db and apache2.
root@sal:~# mysql_secure_installation --> i cant put password
its crazy for new user like me :slight_smile:

Podsumowanie

root@sal:~# apt install php7.2 libapache2-mod-php7.2 php7.2-common php7.2-mbstring php7.2-xmlrpc php7.2-soap php-apcu php-smbclient php7.2-ldap php-redis php7.2-gd php7.2-xml php7.2-intl php7.2-json php-imagick php7.2-mysql php7.2-cli php7.2-ldap php7.2-zip php7.2-curl
Reading package lists… Done
Building dependency tree
Reading state information… Done
php-apcu is already the newest version (5.1.9+4.0.11-1build1).
php-imagick is already the newest version (3.4.3~rc2-2ubuntu4).
php-redis is already the newest version (3.1.6-1build1).
php-smbclient is already the newest version (0.8.0-3build2).
php7.2 is already the newest version (7.2.17-0ubuntu0.18.04.1).
php7.2-cli is already the newest version (7.2.17-0ubuntu0.18.04.1).
php7.2-common is already the newest version (7.2.17-0ubuntu0.18.04.1).
php7.2-curl is already the newest version (7.2.17-0ubuntu0.18.04.1).
php7.2-gd is already the newest version (7.2.17-0ubuntu0.18.04.1).
php7.2-json is already the newest version (7.2.17-0ubuntu0.18.04.1).
php7.2-ldap is already the newest version (7.2.17-0ubuntu0.18.04.1).
php7.2-mysql is already the newest version (7.2.17-0ubuntu0.18.04.1).
php7.2-xml is already the newest version (7.2.17-0ubuntu0.18.04.1).
php7.2-xmlrpc is already the newest version (7.2.17-0ubuntu0.18.04.1).
php7.2-intl is already the newest version (7.2.17-0ubuntu0.18.04.1).
php7.2-mbstring is already the newest version (7.2.17-0ubuntu0.18.04.1).
php7.2-soap is already the newest version (7.2.17-0ubuntu0.18.04.1).
php7.2-zip is already the newest version (7.2.17-0ubuntu0.18.04.1).
The following packages were automatically installed and are no longer required:
galera-3 libaio1 libcgi-fast-perl libcgi-pm-perl libconfig-inifiles-perl libdbd-mysql-perl libdbi-perl
libencode-locale-perl libfcgi-perl libhtml-parser-perl libhtml-tagset-perl libhtml-template-perl
libhttp-date-perl libhttp-message-perl libio-html-perl libjemalloc1 liblwp-mediatypes-perl libmysqlclient20
libreadline5 libterm-readkey-perl libtimedate-perl mariadb-client-10.1 mariadb-client-core-10.1 mariadb-common
mariadb-server-10.1 mariadb-server-core-10.1 mysql-common socat
Use ‘apt autoremove’ to remove them.
Suggested packages:
php-pear
The following NEW packages will be installed:
libapache2-mod-php7.2
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
Need to get 1350 kB of archives.
After this operation, 4793 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libapache2-mod-php7.2 amd64 7.2.17-0ubuntu0.18.04.1 [1350 kB]
Fetched 1350 kB in 1s (2155 kB/s)
(Reading database … 30881 files and directories currently installed.)
Preparing to unpack …/libapache2-mod-php7.2_7.2.17-0ubuntu0.18.04.1_amd64.deb …
Unpacking libapache2-mod-php7.2 (7.2.17-0ubuntu0.18.04.1) …
Setting up libapache2-mod-php7.2 (7.2.17-0ubuntu0.18.04.1) …
libapache2-mod-php7.2: not switching MPM - already enabled
Setting up mariadb-server-10.1 (1:10.1.38-0ubuntu0.18.04.2) …
dpkg: error processing package mariadb-server-10.1 (–configure):
installed mariadb-server-10.1 package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
mariadb-server-10.1
E: Sub-process /usr/bin/dpkg returned an error code (1)
root@sal:~# nano /etc/php/7.2/apache2/php.ini
-su: nano: command not found
root@sal:~# apt install mariadb-server
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following NEW packages will be installed:
mariadb-server
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
Need to get 12.9 kB of archives.
After this operation, 65.5 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu bionic-updates/universe amd64 mariadb-server all 1:10.1.38-0ubuntu0.18.04.2 [12.9 kB]
Fetched 12.9 kB in 0s (39.4 kB/s)
Selecting previously unselected package mariadb-server.
(Reading database … 30888 files and directories currently installed.)
Preparing to unpack …/mariadb-server_1%3a10.1.38-0ubuntu0.18.04.2_all.deb …
Unpacking mariadb-server (1:10.1.38-0ubuntu0.18.04.2) …
Setting up mariadb-server-10.1 (1:10.1.38-0ubuntu0.18.04.2) …
dpkg: error processing package mariadb-server-10.1 (–configure):
installed mariadb-server-10.1 package post-installation script subprocess returned error exit status 1
dpkg: dependency problems prevent configuration of mariadb-server:
mariadb-server depends on mariadb-server-10.1 (>= 1:10.1.38-0ubuntu0.18.04.2); however:
Package mariadb-server-10.1 is not configured yet.

dpkg: error processing package mariadb-server (–configure):
dependency problems - leaving unconfigured
Errors were encountered while processing:
mariadb-server-10.1
mariadb-server
E: Sub-process /usr/bin/dpkg returned an error code (1)
root@sal:~# mysql_secure_installation
/usr/bin/my_print_defaults: Can’t read dir of ‘/etc/mysql/conf.d/’ (Errcode: 2 “No such file or directory”)
Fatal error in defaults handling. Program aborted

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we’ll need the current
password for the root user. If you’ve just installed MariaDB, and
you haven’t set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2 “No such file or directory”)
Enter current password for root (enter for none):
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2 “No such file or directory”)
Enter current password for root (enter for none):
\ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2 “No such file or directory”)
Enter current password for root (enter for none):
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2 “No such file or directory”)

OK currently I win with my problems with database ect.
Now I have new instance of my nextcloud and I’m move some data from my backup (old my nextcloud) to /var/www/html/nextcloud/data/username/files.
What I can do for visable data on my cloud again?

https://docs.nextcloud.com/server/16/admin_manual/configuration_server/occ_command.html?highlight=occ#file-operations-label

in your case
sudo -u www-data php /var/www/html/nextcloud/occ files:scan --all