How‌ ‌Can‌ ‌I‌ ‌Empty‌ ‌a‌ ‌MySQL‌ ‌Database?‌

What happens when a MySQL database runs out of disk space?

If you are conversant with MySQL databases, you’ll notice that the MySQL will become unresponsive, and the application will return Error 28.

When this happens, you’ve some options to clear up the disk space to enable MySQL to continue writing to the disk and resume operation. 

You could:

  • Remove unnecessary files from the database.
  • Delete old and unwanted tables from the database, and run the “OPTIMIZE TABLE” SQL query command to move the freed space to the OS.
  • Purge the binary logs; that’s if the MySQL is still responsive and you enabled the binary option in your MySQL server.
  • Add more space to the disk or partition.

Or you could even empty the entire database.

The article guides you through all you need to know on how to empty a MySQL database.

So, let’s get started.

Method‌ ‌1:‌ ‌Via‌ ‌phpMyAdmin‌ ‌

You could empty a MySQL database by dropping the tables, and luckily, the phpMyAdmin web interface makes this more effortless.

The phpMyAdmin is free software that helps in the administration of MySQL and MariaDB over the web. It’s like a control panel that streamlines MySQL management to eliminate the need to memorize and write MySQL command codes.

It helps users manage: 

  • Databases 
  • Tables
  • Columns
  • Relations
  • Indexes
  • Users
  • Permissions, etc

 To get started with phpMyAdmin, log in to your Spanel account.

How‌ ‌Can‌ ‌I‌ ‌Empty‌ ‌a‌ ‌MySQL‌ ‌Database?‌, Method‌ ‌1:‌ ‌Via‌ ‌phpMyAdmin‌ ‌

The Spanel is Scalahosting’s all-in-one control panel that enables you to manage your entire hosting account without paying any additional licensing fees.

In the Spanel dashboard, click on the phpMyAdmin tool under the Databases section.

How‌ ‌Can‌ ‌I‌ ‌Empty‌ ‌a‌ ‌MySQL‌ ‌Database?‌, Method‌ ‌1:‌ ‌Via‌ ‌phpMyAdmin‌ ‌ 2

Spanel will redirect you to the phpMyAdmin web console. On the interface, click Databases on the top menu bar.

How‌ ‌Can‌ ‌I‌ ‌Empty‌ ‌a‌ ‌MySQL‌ ‌Database?‌, Method‌ ‌1:‌ ‌Via‌ ‌phpMyAdmin‌ ‌ 3

You’ll see a list of your databases; click on the name of the database you intend to empty. Doing this will open the database, and you’ll see all its tables.

Click on Check all to select all the tables at a go.

Or, you could opt to select the tables individually if there are specific tables you don’t intend to delete.

How‌ ‌Can‌ ‌I‌ ‌Empty‌ ‌a‌ ‌MySQL‌ ‌Database?‌, Method‌ ‌1:‌ ‌Via‌ ‌phpMyAdmin‌ ‌ 4

After checking all the tables you want to drop, click on With selected below the tables and select Drop 0n the menu list.

How‌ ‌Can‌ ‌I‌ ‌Empty‌ ‌a‌ ‌MySQL‌ ‌Database?‌, Method‌ ‌1:‌ ‌Via‌ ‌phpMyAdmin‌ ‌ 5

This command will execute the “DROP TABLE” SQL query to drop the selected tables at once.

Click on the Go button in the next step to confirm and finally execute the task.

Method‌ ‌2:‌ ‌Via‌ ‌the‌ ‌Command‌ ‌Line‌ ‌

Unlike the phpMyAdmin that makes emptying a database pretty straightforward, using the command line to empty a MySQL database will require you to drop the database first and recreate it. 

Dropping a MySQL database via the command line is irreversible. So, ensure that you have the drop and create database privilege assigned to your user account. If not, you’d only drop the database but won’t be able to recreate it. 

And when you sort these out, here’s how to empty a MySQL database via the command line.

Log in to your server remotely via an SSH client to connect to the database you intend to drop. Of course, make sure to enable SSH for your hosting account. 

If you’re a Windows computer user, you could consider installing Putty.

Enter your hostname or IP address in the Host Name field, fill the Port field and select SSH as your connection type. Click on the Open button.

If you are a macOS user, you don’t have to bother installing a third-party SSH client. It comes with an in-built Terminal.

When you establish an SSH connection and access the command line, run this command to log in as the MySQL root or admin user.

$ mysql -u root -p

Or you could use this command to log in to the user assigned to the database you intend to drop.

Mysql -uUsername -pPassword

Replace Username and Password placeholder with the MySQL username and user’s password, respectively.

Now, run the DROP DATABASE query on the command prompt to drop the intended database.

mysql> DROP DATABASE dbname;

Replace the dbname placeholder with the name of the database you intend to drop.

That’s it.

Wrapping‌ ‌It‌ ‌Up‌ 

We’ve made emptying a MySQL database elementary and intuitive. Follow the outlined steps to run this task any time you feel like doing so. 

But always ensure you’ve got the “drop and create database” privileges.

You could always contact the Support team if you need help. Scalahosting provides free support for database issues.

Was this helpful?

What’s your goal today?

1. Find the right Web hosting solution

If you’re looking for industry-leading speed, ease of use and reliability Try ScalaHosting with an unconditional money-back guarantee.

2. Make your website lighting fast

We guarantee to make your WordPress site load in less than 2 seconds on a managed VPS with ScalaHosting or give your money back. Fill out the form, and we’ll be in touch.

Please enter a valid name
Please enter a valid website
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

3. Streamline your clients’ hosting experience

If you’re a web studio or development agency hosting more than 30 websites, schedule a call with Vlad, our co-founder and CTO, and see how we can deliver unmatched value to both your business and your clients.


Need a custom cluster or professional advice?

Book a meeting and get a free 30-minute consultation with Vlad, co-founder & CTO of Scala Hosting, who will help you select, design and build the right solution - from a single data center cluster to a multi-region & multi-datacenter high availability cluster with hundreds of servers.

Book a free consultation

4. Learn how to grow your website in 2024

An all-star team of SEO and web influencers are sharing their secret knowledge for the first time in years. Learn about the future of SEO, Web Design best practices and the secrets to getting the foundation for your website to thrive. Watch the exclusive webinar.

An Exclusive Insiders Look Behind The SEO and Web Development Curtain


Working in the web hosting industry for over 13 years, Rado has inevitably got some insight into the industry. A digital marketer by education, Rado is always putting himself in the client's shoes, trying to see what's best for THEM first. A man of the fine detail, you can often find him spending 10+ minutes wondering over a missing comma or slightly skewed design.