How to remove all data from a Firebase database?

26,709

Solution 1

I think there missing some hint - why missing delete button on root level or how can we do it and quickly anyway.

Alvin at Firebase Support was very helpful:

Record or node has too much data, which makes the data viewer switch to a read-only/non real time mode to increase the browser's performance.

Solution is very simply, just use REST. By their documentation Removing Data but they don't show how can I remove all.

For remove all data you can use by Alvin this:

curl -X DELETE "https://{{project_id}}.firebaseio.com/.json"

and it means you can do this with every generated URL node in console only by adding JSON extension:

https://{{project_id}}.firebaseio.com/{{path}}/{{path}}/{{path}}/.json

I hope this helps someone.

Solution 2

You can manually create a JSON file that contains a single empty entry and import it, which will remove all existing entries.

Solution 3

A simple way to remove all data from a firebase database is to use the Firebase CLI.

Once the CLI is setted up you just need to use this command and your data will be removed :

firebase database:remove /

Solution 4

Solution 1: console From your project, click on the x button at the top level of the database.

enter image description here

then click delete

enter image description here

Solution 2: Programmatic

whatever the language you are using , call something like:

database.set('/', null)

Solution 3: Firebase CLI from your project folder (you already installed the firebase-tools) write the following in the terminal then hit Enter :

database:remove /    

firebase CLI remove all data

N.B:

Kindly consider to backup your data first.

Solution 5

I used

curl -X DELETE "https://<prject name>.firebaseio.com/.json?auth=<Firebase Database secret>"

This deletes the database also with the data which is blocked from firebase UI. Hope this helps. Thank you

FYI :

Your get Web API key is in https://console.firebase.google.com/project/<database name>/settings/serviceaccounts/databasesecrets

else you can go to Project overview settings >> project settings >> Service Accounts >> Database Secrets

Also I am wanted to comment it on the comments section but due to lack of stackoverflow point I am writing it as answer

Share:
26,709
BGBRUNO
Author by

BGBRUNO

BG BRUNO IT Lifeguard / IT Záchranár bgbruno.com

Updated on September 08, 2021

Comments

  • BGBRUNO
    BGBRUNO almost 3 years

    I started using a code that using Firebase realtime database. I implemented it to my solution. Connection and control was perfect, so I used it for the production environment.

    After a while I was doing upgrade and I need remove all data again - but wait, there are no delete buttons in console anymore at highest root level and only allowed in one selected item at once:

    https://console.firebase.google.com/project/{{project_name}}/database/data
    

    In last update shown only this message and no steps what next:

    Read-only & non-realtime mode activated to improve browser performance Select a key with fewer records to edit or view in realtime

    Q how can I remove all data at once?