How do I deploy Firebase Database Security rules using the command line?

You can use firebase deploy --only database if you only want to update database rules. It will overwrite your existing rules.

You can check out Firebase CLI Reference for more info


You can use firebase deploy or firebase deploy --only database from the command line, BUT most important:

Please note hereunder firebase.json format: The "rules" entry is under "database" entry.

It was taken from Firebase Sample code.

{
  "database": {
    "rules": "database-rules.json"
  },
  "hosting": {
    "public": "./",
    "ignore": [
      "firebase.json",
      "database-rules.json",
    ]
  }
}