techbits.io

How to Delete the Mastodon PostgreSQL Database

Bit of a strange title, I know. Usually it would be someone with nefarious intent trying to delete your database... why would you want to do it?

How to Delete the Mastodon PostgreSQL Database

Bit of a strange title, I know. Usually it would be someone with nefarious intent trying to delete your database… why would you want to do it?

Well, I’ve been doing a lot of Mastodon testing, which required a lot of repetition of steps. Running the Mastodon Ruby installer again throws errors because the previous database still exists, so how do you drop it?

Firstly, you need to stop Mastodon, otherwise the services still accessing the database will cause an error:

Stop Mastodon components with the following command (the asterisk is a wildcard character so will cause all matching mastodon services to be stopped):

sudo systemctl stop mastodon*

Secondly, switch to the user that runs Mastodon (if you followed the official instructions, this will be ‘mastodon’:

sudo su - mastodon

Thirdly/lastly run:

dropdb mastodon_production

You’ve dropped your database! Congratulations…maybe? If you know a better way to do this (either using the Mastodon tools, or and better way in the Postgres CLI, please leave a comment, or let me know over at @techbits@fosstodon.org.

Share this article:

Comments

Related posts

Redirect traffic with Cloudflare (Page Rules vs Redirect Rules)
#cloudflare #mastodon

Redirect traffic with Cloudflare (Page Rules vs Redirect Rules)

I wrote a few posts (and scripts) last year focused on Mastodon, how to install it, and various surrounding ideas, which were all based on what I'd…

Mastodon v4.0.0 Upgrade [v4.0.2]
#mastodon

Mastodon v4.0.0 Upgrade [v4.0.2]

What's new in Mastodon v4.0.0, and how do you upgrade? Read on for the headline features and to see how to get started with Mastodon v4.0.0.

Using Backblaze B2 (S3) Storage with Mastodon
#mastodon #backblaze

Using Backblaze B2 (S3) Storage with Mastodon

This guide will show you how to add Mastodon content to a Backblaze B2 (S3) storage bucket, and in the process, reduce your server load!