Skip to content

TODO: Uninstall Mathesar

The uninstall instructions vary depending on the installation method you chose. Select your installation method below to proceed.

Uninstall a Docker installation of Mathesar

Note

Depending on your Docker setup, you may need to run docker commands with sudo.

  1. Remove Mathesar internal schemas.

    If you’d like to continue using your PostgreSQL databases, you can remove the schemas created for Mathesar’s use during installation. For each database accessible through the Mathesar UI, the safe and easy way to do so is to use Mathesar’s new “Disconnect Database” functionality. When disconnecting a database, choose the “Remove Mathesar’s internal schemas” option to safely remove any Mathesar schemas.

    If that doesn’t work, or doesn’t work for all databases, you can perform the following manual steps instead:

    1. Connect to the database.

      psql -h <DB HOSTNAME> -p <DB PORT> -U <DB_USER> <DB_NAME>
      
    2. Delete the types schema.

      DROP SCHEMA mathesar_types CASCADE;
      

      Deleting this schema will also delete any database objects that depend on it. Specifically, this will delete any data using Mathesar’s custom data types.

    3. Delete the function schemas.

      DROP SCHEMA msar CASCADE;
      DROP SCHEMA __msar CASCADE;
      
  2. Remove the Mathesar container.

    docker rm -v mathesar_service
    
  3. Remove the Mathesar Image

    docker rmi mathesar_service
    
  4. Remove volumes related to Mathesar

    docker volume rm static &&
    docker volume rm media
    

Uninstall a guided script or Docker compose installation of Mathesar

  1. Remove Mathesar internal schemas.

    If you’d like to continue using your PostgreSQL databases, you can remove the schemas created for Mathesar’s use during installation. For each database accessible through the Mathesar UI, the safe and easy way to do so is to use Mathesar’s new “Disconnect Database” functionality. When disconnecting a database, choose the “Remove Mathesar’s internal schemas” option to safely remove any Mathesar schemas.

    If that doesn’t work, or doesn’t work for all databases, you can perform the following manual steps instead:

    1. Connect to the database.

      psql -h <DB HOSTNAME> -p <DB PORT> -U <DB_USER> <DB_NAME>
      
    2. Delete the types schema.

      DROP SCHEMA mathesar_types CASCADE;
      

      Deleting this schema will also delete any database objects that depend on it. Specifically, this will delete any data using Mathesar’s custom data types.

    3. Delete the function schemas.

      DROP SCHEMA msar CASCADE;
      DROP SCHEMA __msar CASCADE;
      
  2. Remove all Mathesar Docker images and containers.

    docker compose -f docker-compose.yml down --rmi all -v
    
  3. Remove configuration files.

    rm -rf xMATHESAR_INSTALLATION_DIRx  # may need sudo, depending on location
    

Uninstall a source installation of Mathesar

  1. Remove Mathesar internal schemas.

    If you’d like to continue using your PostgreSQL databases, you can remove the schemas created for Mathesar’s use during installation. For each database accessible through the Mathesar UI, the safe and easy way to do so is to use Mathesar’s new “Disconnect Database” functionality. When disconnecting a database, choose the “Remove Mathesar’s internal schemas” option to safely remove any Mathesar schemas.

    If that doesn’t work, or doesn’t work for all databases, you can perform the following manual steps instead:

    1. Connect to the database.

      psql -h <DB HOSTNAME> -p <DB PORT> -U <DB_USER> <DB_NAME>
      
    2. Delete the types schema.

      DROP SCHEMA mathesar_types CASCADE;
      

      Deleting this schema will also delete any database objects that depend on it. Specifically, this will delete any data using Mathesar’s custom data types.

    3. Delete the function schemas.

      DROP SCHEMA msar CASCADE;
      DROP SCHEMA __msar CASCADE;
      
  2. Stop Caddy service

    systemctl disable caddy.service && systemctl stop caddy.service
    
  3. Remove Caddy service file and Caddyfile (requires sudo)

    sudo rm /lib/systemd/system/caddy.service
    sudo rm /etc/caddy/Caddyfile
    
  4. Stop Gunicorn

    systemctl disable gunicorn.service
    systemctl stop gunicorn.service
    
  5. Remove Gunicorn service file

    sudo rm /lib/systemd/system/gunicorn.service
    
  6. Remove your Mathesar installation directory

    rm -r xMATHESAR_INSTALLATION_DIRx  # May need sudo, depending on location
    

    Your installation directory might be customized

    It’s possible that Mathesar could have been installed into a different directory than shown above. Use caution when deleting this directory.

  7. Remove Django database

    1. Connect to the psql terminal.

      sudo -u postgres psql
      
    2. Drop the Django database.

      DROP DATABASE mathesar_django;