• Shopping Cart Shopping Cart
    0Shopping Cart
London App Developer
  • Courses
  • Consulting
  • Tutorials
  • About
  • Click to open the search input field Click to open the search input field Search
  • Menu Menu
MariaDB and Debian 7 logos on a pale yellow background
Databases, Linux

How to completely uninstall MariaDB from a Debian 7 server

DevOps Deployment Automation with Terraform, AWS and Docker

There are many guides about how to install and configure popular applications on Linux servers, but not much on how to remove them.

I found this out when I needed to install a MariaDB Galera cluster on a server which already had a stand-alone MariaDB server installed. Having the older version of MariaDB installed (and the older repository in the source list) meant all of the guides I was following didn’t work due to conflicting packages.

This guide will explain how to completely remove MariaDB from your system (including any databases).

Here is how you remove MariaDB from a Debian 7 Linux server.

Stop any running instanced of MariaDB

First, you need to stop any running instances of MariaDB. To do this, type the following in the console:

sudo service mysql stop

Remove all MySQL packages from the system

Warning: this will delete all databases from your server. Make sure you have backed everything up before doing this.

Run the following command. This will use apt-get to remove all packages with the name beginning with “mysql”. The –purge switch tells it to purge all configs and related files from the system.

sudo apt-get --purge remove "mysql*"

After you run this, you will see something similar to this:

Apt-get message asking user to confirm the remove of packages

This is telling you what packages will be removed. If you wish to continue uninstalling MariaDB then press Y and hit enter.

If everything has worked as expected you will see this message:

MariaDB asking user to confirm removal of all databases on uninstall

If you are happy to lose all of your databases, select yes and press enter.

MariaDB is now removed.

Remove the configs file

Now MariaDB has been completely uninstalled, the next step is to ensure all configs are gone. the –purge switch we used earlier tells apt-get to remove all configs, however it will only remove the default configs that came with the install. Any custom configs that were added after the install will still be there.

The configs are usually located at /etc/mysql/. I would not suggest just deleting them (in-case you need them later). However I would suggest moving them to a different directory. This is how you would move them to the /tmp/ directory:

sudo mv /etc/mysql/ /tmp/mysql_configs/

Warning: Some servers are configured to delete the contents of the /tmp/ directory on reboot. If you want to keep the configs safe it’s best to move them to your home directory.

Remove from the source list

The final step is to remove the old package repositories from the sources file. This is what got me stuck when trying to install MariaDB Galera before, because I had the old repositories in the source list it would cause conflicts. Here is how you remove them:

First open the sources.list file in your editor of course (I use vi in this example):

vi /etc/apt/sources.list

In this file (usually near the bottom), locate the lines which contain “MariaDB”. Comment out these lines by appending a # to the beginning of them. This is how mine looks (although yours may vary depending on the version of MariaDB you previously had installed):

# wheezy-updates, previously known as 'volatile'
deb http://ftp.uk.debian.org/debian/ wheezy-updates main
# deb http://lon1.mirrors.digitalocean.com/mariadb/repo/5.5/debian wheezy main
# deb-src http://lon1.mirrors.digitalocean.com/mariadb/repo/5.5/debian wheezy main
deb-src http://ftp.uk.debian.org/debian/ wheezy-updates main

Now save the file.

The final step, is to update apt-get by running the below line:

sudo apt-get update

That’s it. MariaDB is now completely removed from your system. In order to re-install it, (or install Galera) you must follow the instructions on https://mariadb.org/

Thank you for reading. I hope that you found this helpful. If you have any questions please write them in the comments below.

Cheers,
Mark

DevOps Deployment Automation with Terraform, AWS and Docker

Share this entry
  • Share on Facebook
  • Share on X
  • Share on WhatsApp
  • Share on Pinterest
  • Share on LinkedIn
  • Share on Tumblr
  • Share on Vk
  • Share on Reddit
  • Share by Mail
https://i0.wp.com/londonappdeveloper.com/wp-content/uploads/2015/03/How-to-completely-uninstall-MariaDB-from-a-Debian-7-server.png?fit=277%2C223&ssl=1 223 277 mark https://londonappdeveloper.com/wp-content/uploads/2018/12/lon_website_logo-300x110.png mark2015-03-30 07:23:272022-01-12 10:36:26How to completely uninstall MariaDB from a Debian 7 server
9 replies
  1. Ola
    Ola says:
    February 20, 2016 at 6:55 pm

    Your code boxes are editable.

    Reply
    • mark
      mark says:
      February 20, 2016 at 7:00 pm

      Oh strange lol. I’ll look into fixing it. Thanks for pointing it out.

      Reply
  2. Chad Taylor
    Chad Taylor says:
    June 4, 2016 at 6:45 am

    I keep getting these errors… (I am very new to servers)

    The following packages have unmet dependencies:
    mariadb-common : Depends: mysql-common but it is not going to be installed
    phpmyadmin : Depends: php5-mysql but it is not going to be installed or
    php5-mysqli but it is not installable or
    php5-mysqlnd but it is not going to be installed
    Recommends: mysql-client or
    mariadb-client but it is not going to be installed or
    virtual-mysql-client
    E: Unmet dependencies. Try ‘apt-get -f install’ with no packages (or specify a solution).

    Reply
    • Carlos Martinez
      Carlos Martinez says:
      November 10, 2016 at 6:23 pm

      Did you follow the step?

      Try ‘apt-get -f install’ with no packages

      Put on terminal: “apt-get -f install” and install those dependencies… Cheers!

      Reply
  3. Dominic
    Dominic says:
    February 3, 2017 at 5:31 am

    Life saver!!!
    Thank you for this. 🙂

    Reply
  4. Ahmed Elkoussy
    Ahmed Elkoussy says:
    September 23, 2017 at 11:04 pm

    Thank you very much , I was stuck at removing mariadb , for some reason it kept there and prevented installing mysql-server on ubuntu

    Reply
  5. GeraldBrown
    GeraldBrown says:
    April 22, 2018 at 10:21 am

    This was a life saver for me.
    I had tried to set up a Galera cluster on a 2 node system. The first node was running OK but the server on node 2 would NOT boot up. I stopped node 1 and tried to start node. Now it was NO GO on either node. Have been trying all day to get them back online but was only able to do it after reading this.
    Thanks alot.

    Reply

Trackbacks & Pingbacks

  1. Palvelinten hallinta – Harjoitus 4 – Palvelinten hallinta CT4TN022-3013 says:
    April 26, 2022 at 5:56 pm

    […] ”Loaded: loaded” sekä ”Active: active (running)”. Löysin tähän verkosta London App Developerin ohjeen ja komennolla ’sudo apt-get –purge remove ”mysql*”’ sain poistettua […]

    Reply
  2. debian linux / raspberry pi wordpress php mysql install script | Code, Game programming and artificial intelligence says:
    November 10, 2021 at 4:59 pm

    […] Here’s the shell-script (which later needed some modifications, so if you use it you will probably end up with something working, but all steps are not specified here but needed some extra work.. to uninstall maria db this might be handy https://londonappdeveloper.com/how-to-completely-uninstall-mariadb-from-a-debian-7-server/ ) […]

    Reply

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Pages

  • About
  • Consulting
  • Home
  • Tutorials

Categories

  • AI
  • Android
  • Android Studio
  • Angular
  • Aptana Studio
  • AWS
  • Bootstrap
  • Career advice
  • Celery
  • Databases
  • Deployment
  • DevOps
  • Django
  • Django REST Framework
  • Docker
  • Eclipse
  • Getting Help
  • Git
  • Git Bash
  • Git Flow
  • GitHub Actions
  • Google App Engine
  • IDE
  • Ionic Framework
  • iOS
  • JavaScript
  • Job Search
  • Links
  • Linux
  • Mac OS X
  • macOS
  • Node.JS
  • OpenAI
  • PGAdmin
  • Postgres
  • Productivity
  • Python
  • React
  • Salt Stack
  • Stack Overflow
  • Tools
  • Travis-CI
  • Tutorials
  • Ubuntu
  • Uncategorized
  • Vagrant
  • VSCode
  • WebSockets
  • Windows 10
  • WordPress

London App Developer Ltd,

71-75 Shelton Street, Covent Garden, London, United Kingdom, WC2H 9JQ

Company registration number: 09718346

© London App Developer - London App Developer Ltd, Company Registration Number: 09718346, VAT: GB224061842
  • Link to X
  • Link to Youtube
  • Link to Facebook
  • Link to Reddit
Link to: It doesn’t bloody work! 4 things to keep in mind when reporting a bug Link to: It doesn’t bloody work! 4 things to keep in mind when reporting a bug It doesn’t bloody work! 4 things to keep in mind when reporting a bugBlack outline of a bubble bee over a field of wild flowers Link to: How to install Eclipse and PyDev Link to: How to install Eclipse and PyDev Eclipse and Python software logos on a blue background imageHow to install Eclipse and PyDev
Scroll to top Scroll to top Scroll to top

This site uses cookies. By continuing to browse the site, you are agreeing to our use of cookies.

OKLearn more

Cookie and Privacy Settings



How we use cookies

We may request cookies to be set on your device. We use cookies to let us know when you visit our websites, how you interact with us, to enrich your user experience, and to customize your relationship with our website.

Click on the different category headings to find out more. You can also change some of your preferences. Note that blocking some types of cookies may impact your experience on our websites and the services we are able to offer.

Essential Website Cookies

These cookies are strictly necessary to provide you with services available through our website and to use some of its features.

Because these cookies are strictly necessary to deliver the website, refusing them will have impact how our site functions. You always can block or delete cookies by changing your browser settings and force blocking all cookies on this website. But this will always prompt you to accept/refuse cookies when revisiting our site.

We fully respect if you want to refuse cookies but to avoid asking you again and again kindly allow us to store a cookie for that. You are free to opt out any time or opt in for other cookies to get a better experience. If you refuse cookies we will remove all set cookies in our domain.

We provide you with a list of stored cookies on your computer in our domain so you can check what we stored. Due to security reasons we are not able to show or modify cookies from other domains. You can check these in your browser security settings.

Google Analytics Cookies

These cookies collect information that is used either in aggregate form to help us understand how our website is being used or how effective our marketing campaigns are, or to help us customize our website and application for you in order to enhance your experience.

If you do not want that we track your visit to our site you can disable tracking in your browser here:

Other external services

We also use different external services like Google Webfonts, Google Maps, and external Video providers. Since these providers may collect personal data like your IP address we allow you to block them here. Please be aware that this might heavily reduce the functionality and appearance of our site. Changes will take effect once you reload the page.

Google Webfont Settings:

Google Map Settings:

Google reCaptcha Settings:

Vimeo and Youtube video embeds:

Other cookies

The following cookies are also needed - You can choose if you want to allow them:

Privacy Policy

You can read about our cookies and privacy settings in detail on our Privacy Policy Page.

Privacy Policy
Accept settingsHide notification only