This documentation is for WSO2 Identity Server 5.1.0. View documentation for the latest release.
Page Comparison - Removing Unused Tokens from the Database (v.10 vs v.11) - Identity Server 5.1.0 - WSO2 Documentation

Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.


  1. Take a backup of the running database. 
  2. Set up the database dump in a test environment and test it for any issues.


    Tip: We recommend that you test the database dump before the cleanup task because the cleanup can take some time.

  3. Get the mysql token cleanup script from here and run it on the database dump. This takes a backup of the necessary tables, turns off SQL updates and removes unused tokens from the database.

  4. Once the cleanup is over, start WSO2 Identity Server, point to the cleaned-up database dump, and then test thoroughly for any issues. 
    You can also schedule a cleanup task that will automatically run after a given period. Here's an example:

    Code Block
    USE 'WSO2IS_DB';DROP EVENT IF EXISTS 'cleanup_tokens_event';
    CREATE EVENT 'cleanup_tokens_event'
          EVERY 1 WEEK STARTS '2015-01-01 00:00.00'
    -- 'Turn on the event_scheduler'
    SET GLOBAL event_scheduler = ON;