How to delete indexedDB?
Asked Answered
C

20

103

I'm working in a project which involves using IndexedDB. As I'm begining to know this technology, I need to be able to delete an indexedDB by hand so I can start over.

I found the way to do it in Firefox, but I can't find the way for Google Chrome.

I tried deleting the content of this folder (I'm using Mac):

{home}/Library/Application Support/Google/Chrome/Default/IndexedDB

but it seems Chrome stil have the DB anywhere so I can't start over.

Cissoid answered 21/2, 2012 at 19:48 Comment(0)
J
109

In theory, all you need to do to delete an IndexedDB in Chrome is:

  1. In Chrome, go to Options > Under the Hood > Content Settings > All cookies and Site Data > find the domain where you created the IndexedDB
  2. Hit either the "X" or click "Indexed Database" > Remove

In Windows, the file is located here:

%USERPROFILE%\AppData\Local\Google\Chrome\User Data\Default\IndexedDB

On Mac, do the following:

  1. In Chrome, go to "Settings" (or "Preferences" under the Chrome menu)
  2. Click "show advanced settings" (at the bottom of the page)
  3. Go to "Privacy" > "Content Settings" > "All cookies and Site Data" > find the domain where you created the IndexedDB
  4. Hit either the "X" or click "Indexed Database" > Remove

On Mac, the folder is located here:

/Users/[USERNAME]/Library/Application Support/Google/Chrome/Default/IndexedDB/

On Linux, the folder is located at:

/home/[USERNAME]/.config/google-chrome/Default/IndexedDB/
Johanson answered 22/2, 2012 at 4:54 Comment(5)
Chrome for OS X does not have an "Options" menu item or any reference to "Under the Hood", so this may be a confusing hint for some people.Spieler
On OS X you can get there via "Chrome > Clear Browsing Data...", close the dialog and then go to "Advanced settings" instead of "Under the Hood". After that it's ~same as above.Starinsky
I think it is easier to run indexedDB.deleteDatabase("databaseName") in the console.Paulettapaulette
On OSX Chrome v31 step: 1. Settings > Show advanced settings... > Privacy > Content settings... > Cookies > All cookies and site data... 2. Search to filter your IP. 3. Click Indexed database. 4. Remove it !Takamatsu
Maybe it's Chrome under Linux or maybe it's a newer version, but here are the steps for getting there in my experience: 1. Settings > Show advanced settings... > Content Settings > All cookies and site Data find the domain where you created the IndexedDB 2. Hit either the "X" or click "Indexed Database" > RemoveKagera
B
170

I've had success running the following in Chrome:

indexedDB.deleteDatabase('DB NAME')
Blaney answered 23/2, 2013 at 21:37 Comment(2)
This kept failing for me, then I realized I needed to close the DB first. In my success handler I keep a handy reference to the DB (e.target.result) so I can call close() on it. Only then can call deleteDatabase('DB NAME'). You will also need to right click and use 'refresh indexedDB' if you are on the chrome dev tools resources tab to see the result of the deletion.Herculean
couldn't find hostname for chrome app but this works when you inspect the app.Rickettsia
J
109

In theory, all you need to do to delete an IndexedDB in Chrome is:

  1. In Chrome, go to Options > Under the Hood > Content Settings > All cookies and Site Data > find the domain where you created the IndexedDB
  2. Hit either the "X" or click "Indexed Database" > Remove

In Windows, the file is located here:

%USERPROFILE%\AppData\Local\Google\Chrome\User Data\Default\IndexedDB

On Mac, do the following:

  1. In Chrome, go to "Settings" (or "Preferences" under the Chrome menu)
  2. Click "show advanced settings" (at the bottom of the page)
  3. Go to "Privacy" > "Content Settings" > "All cookies and Site Data" > find the domain where you created the IndexedDB
  4. Hit either the "X" or click "Indexed Database" > Remove

On Mac, the folder is located here:

/Users/[USERNAME]/Library/Application Support/Google/Chrome/Default/IndexedDB/

On Linux, the folder is located at:

/home/[USERNAME]/.config/google-chrome/Default/IndexedDB/
Johanson answered 22/2, 2012 at 4:54 Comment(5)
Chrome for OS X does not have an "Options" menu item or any reference to "Under the Hood", so this may be a confusing hint for some people.Spieler
On OS X you can get there via "Chrome > Clear Browsing Data...", close the dialog and then go to "Advanced settings" instead of "Under the Hood". After that it's ~same as above.Starinsky
I think it is easier to run indexedDB.deleteDatabase("databaseName") in the console.Paulettapaulette
On OSX Chrome v31 step: 1. Settings > Show advanced settings... > Privacy > Content settings... > Cookies > All cookies and site data... 2. Search to filter your IP. 3. Click Indexed database. 4. Remove it !Takamatsu
Maybe it's Chrome under Linux or maybe it's a newer version, but here are the steps for getting there in my experience: 1. Settings > Show advanced settings... > Content Settings > All cookies and site Data find the domain where you created the IndexedDB 2. Hit either the "X" or click "Indexed Database" > RemoveKagera
P
30

Alternarive is to do it in the developers console, using this command:

indexedDB.deleteDatabase("databaseName")
Paulettapaulette answered 25/2, 2013 at 10:40 Comment(1)
This is the easiest way. You just need to to right click on 'IndexedDB' in Resources and select 'Refresh IndexedDB' to confirm that the database has been zapped.Waltman
T
9

In Chrome webkit you can use webkitGetDatabaseNames which returns all database names

With this code, you can delete all local indexedDB:

window.indexedDB.webkitGetDatabaseNames().onsuccess = function(sender,args)
{
    var r = sender.target.result;
    for(var i in r)
        indexedDB.deleteDatabase(r[i]);
}; 
Think answered 9/5, 2015 at 8:14 Comment(1)
You should never use prefixed APIs on any live website. And you shouldn't use non standard code without feature detection.Payroll
G
6

Chrome -> Inspector Window -> Application -> look at left hand menu -> Storage -> IndexedDB

You have to be on your application's page though. Also I think Safari expires IDB data after 7 days or something.

Gredel answered 4/12, 2017 at 15:44 Comment(0)
H
5

To remove all Chrome IndexedDB databases run the following in OSX terminal emulator.

rm -rf ${HOME}/Library/Application\ Support/Google/Chrome/Default/IndexedDB/*

Now restart your browser and that's it.


Because I need to purge IndexedDB databases very often, I have set up an alias in my ~./bash_profile.

alias purge-idb="rm -rf ${HOME}/Library/Application\ Support/Google/Chrome/Default/IndexedDB/*"
Hemistich answered 9/2, 2014 at 11:21 Comment(0)
C
4

write this code segment in console

window.indexedDB.deleteDatabase(<your db name>)

Cha answered 4/3, 2017 at 7:43 Comment(0)
S
3

To delete an IndexedDB from the OS X version of Chrome:

1) In Preferences, show Advanced Settings then click the "Content Settings" button under the "Privacy" section.

2) In the "Content Settings" popup, click the "All Cookies and Site Data" button under the "Cookies" section.

3) In the "Cookies and site data" popup, use the "Search Cookies" textbox to look up the domain that is the source of the IndexedDB.

4) Click on the domain entry in the list.

5) Click on the "indexed database" tag listed under the domain.

6) Click on the "Remove" button in the drop down detail for the indexed database.

Spieler answered 17/12, 2012 at 20:3 Comment(0)
V
3

Chrome Developer tools now have an option to delete all databases for an app, under "Application/Clear Storage".

Voidance answered 23/9, 2017 at 22:53 Comment(0)
W
2

It's not possible to delete IndexedDB database (as opposed to stores and indexes) programmatically.

As for manual workarounds, this post details the location of the database on Windows systems for Firefox and Chrome.

Update: Thanks to developer Joshua Bell, Chrome implements an off-spec (but insanely useful) deleteDatabase method on the window.indexedDB object. Here's the crbug that landed this patch. Moreover, in newer versions of IE, you can delete databases via a settings panel.

Wicker answered 20/3, 2012 at 22:43 Comment(0)
T
2

In Debian GNU/Linux directory

/home/[username]/.config/google-chrome/Default/IndexedDB/chrome-xxx.indexeddb.leveldb/

contains regular files (for example):

000003.log, CURRENT, LOCK, LOG, MANIFEST-000002

Throve answered 6/2, 2013 at 23:20 Comment(0)
A
2

This is maybe overkill for your specific question, but I kept ending up here in my struggle to delete my idb.

My solution in the end was based on mozilla's documentation, but required that I first close the database.

For me, in Javascript, the code looked like this:

my_db_instance.close(function(e){console.log(e)});
var DBDeleteRequest = indexedDB.deleteDatabase("my_db_name");

// When i had the base open, the closure was blocked, so i left this here
DBDeleteRequest.onblocked = function(event) {
  console.log("Blocked");
};

DBDeleteRequest.onerror = function(event) {
    console.log("Error deleting database.");
  console.log(event);
};

DBDeleteRequest.onsuccess = function(event) {
  console.log("Database deleted successfully");
};
Apron answered 6/8, 2018 at 13:14 Comment(1)
Even if it's an old question/answer, thanks a lot!!Millionaire
E
2

To delete IndexedDB in Chrome on Android:

  1. Settings
  2. Site settings
  3. Data stored
  4. Search needed site and press
  5. Delete stored data

To delete IndexedDB in Chrome on Android

(You cannot delete IndexedDB via Settings -> Privacy and security section, what is quite misleading...)

Ellinger answered 30/5, 2022 at 20:47 Comment(0)
P
1

In order to complete @Judson's answer, based on @fullstacklife's comment; for deleting IndexedDB in chrome using javascript you should:

let currentIDB = indexedDB.open("DB_NAME", DB_VERSION_INTEGER);
    currentIDB.onblocked = function(){
        //
    };
    currentIDB.onerror = function(){
        //
    };
    currentIDB.onsuccess = function(){
        var idb = currentIDB.result;
        idb.close();
        indexedDB.deleteDatabase("DB_NAME");
    };
Procephalic answered 12/12, 2019 at 10:13 Comment(0)
D
0

Alternatively, use your web application in a new incognito window, and close it when you're done: database deleted.

Darbie answered 13/9, 2012 at 5:36 Comment(0)
S
0

In chrome OSX- /Users/user/Library/Application Support/Google/Chrome/Default/IndexedDB Firefox OSX - Users/user/Library/Application Support/Firefox/Profiles/4zaemxcn.default/indexedDB

You just need to make visible the library folder. All of the files are stored in folders(which are called as domain name) and the files use hash, but you can figure out the name of database from it. You can delete data from IDB because it is a client side database and all of the data is stored locally.

Stump answered 19/12, 2012 at 1:0 Comment(0)
W
0

In windows, you can manually delete the whole IndexedDB databases by locating the IndexedDB directory for the browser and deleting it

For Chrome:

C:\Users\user-name\AppData\Local\Google\Chrome\User Data\Profile 1\IndexedDB

You can delete every folder which clears up the indexedDB. You can start over now.

Westbrooks answered 17/9, 2014 at 6:54 Comment(0)
P
0

I needed to get rid of an indexedDB in Chrome. So I search for this lousy thing called "email assistant" on my computer using MasterSeeker. Found the thing in a bunch folders that were indexedDB in Chrome. It seemed too easy that I just delete those files. I looked up how, and ended up here. I went to chrome settings with my Windows 10 PC. I just gave it a shot at trying to clear the browsing data. Presto - all those files disappeared from indexedDB, including that dreaded "email assistant" crapola. Now when I look in the indexedDB folder all I see that has reappeared is https_mail.google.com_0.indexeddb.leveldb - which looks like a safe non-irritating thing.

Proportioned answered 9/6, 2019 at 1:7 Comment(0)
G
0
//By for loop
const deleteAllDBs=async()=>{
    const existingDBs=await indexedDB.databases()
    for (let i = 0; i < existingDBs.length; i++) {
        indexedDB.deleteDatabase(existingDBs[i].name)
    }
}

//By forEach loop
const dbs = await window.indexedDB.databases()
dbs.forEach(db => { window.indexedDB.deleteDatabase(db.name) })
Gpo answered 31/7, 2022 at 17:37 Comment(1)
Your answer could be improved by adding more information on what the code does and how it helps the OP.Thermomotor
S
0

Since most of the answers not mentioned how to find the db names:

  1. Open the site you want db to be cleared.
  2. Press F12 in Chrome, select console regime.
  3. Type indexedDB.databases().then(res => console.log(res)) to learn database names used by this website (open the result with interactive console, find the name).
  4. Finally, as mentioned above, execute in the console indexedDB.deleteDatabase('<your database name>').
Smolensk answered 15/9, 2022 at 16:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.