# remove mysql

**URL:** <https://forum.ansible.com/t/remove-mysql/33405>\
**Category:** Ansible Project\
**Created:** [July 15, 2020, 3:38pm UTC](https://forum.ansible.com/t/remove-mysql/33405 "2020-07-15T15:38:55Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tony\_Wong](https://avatars.discourse-cdn.com/v4/letter/t/3ab097/32.png) [@Tony\_Wong](https://forum.ansible.com/u/Tony_Wong)\
**Post date:** [July 15, 2020, 3:38pm UTC](https://forum.ansible.com/t/remove-mysql/33405/1 "2020-07-15T15:38:55Z")

</div>

trying to remove mysql from a previous install

---

<div class="post-metadata">

**Author:** ![racke](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/racke/32/4767_2.png) [@racke](https://forum.ansible.com/u/racke)\
**Post date:** [July 15, 2020, 4:32pm UTC](https://forum.ansible.com/t/remove-mysql/33405/2 "2020-07-15T16:32:33Z")

</div>

> trying to remove mysql from a previous install
> 
> --  
> - hosts: all  
> become: true  
> vars\_files:  
> - vars/default.yml
> 
> tasks:  
> - name: Uninstall MySQL packages.  
> apt: name={{ item }} state=absent  
> with\_items:  
> - mysql-server  
> - mysql-client
> 
> but not working

To me it looks like it works (removing the packages), but your syntax is outdated.

It should be

&nbsp;&nbsp;&nbsp;apt:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;name:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- mysql-server  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- mysql-client

Regards  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Racke

---

<div class="post-metadata">

**Author:** ![Tony\_Wong](https://avatars.discourse-cdn.com/v4/letter/t/3ab097/32.png) [@Tony\_Wong](https://forum.ansible.com/u/Tony_Wong)\
**Post date:** [July 15, 2020, 4:55pm UTC](https://forum.ansible.com/t/remove-mysql/33405/3 "2020-07-15T16:55:44Z")

</div>

> this was the original install and I am just trying to reverse the installs

---

<div class="post-metadata">

**Author:** ![Tony\_Wong](https://avatars.discourse-cdn.com/v4/letter/t/3ab097/32.png) [@Tony\_Wong](https://forum.ansible.com/u/Tony_Wong)\
**Post date:** [July 15, 2020, 5:21pm UTC](https://forum.ansible.com/t/remove-mysql/33405/4 "2020-07-15T17:21:21Z")

</div>

I tried this pb but its not uninstalling

---

<div class="post-metadata">

**Author:** ![dan\_linder](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dan_linder/32/3833_2.png) [@dan\_linder](https://forum.ansible.com/u/dan_linder)\
**Post date:** [July 15, 2020, 7:28pm UTC](https://forum.ansible.com/t/remove-mysql/33405/5 "2020-07-15T19:28:01Z")

</div>

> I tried this pb but its not uninstalling

Can you be more specific? What version of Ansible are you using, what version of Debian/Ubuntu is the server you’re working on?

What is the output of this command when you run it on the machine you’re wanting to remove the packages from:

apt list | egrep ‘^mysql-server/|^mysql-client/|^python3-pymysql/|^php/|^libapache2-mod-php/’

Can you write a playbook with just the single task and run it with “-vvv” and paste the output in a response here?

The indenting in your previous example is slightly askew, and it is missing the “state: absent” parameter, but I’ll make the assumption that is just a copy-and-paste error.

---

<div class="post-metadata">

**Author:** ![racke](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/racke/32/4767_2.png) [@racke](https://forum.ansible.com/u/racke)\
**Post date:** [July 15, 2020, 7:34pm UTC](https://forum.ansible.com/t/remove-mysql/33405/6 "2020-07-15T19:34:16Z")

</div>

> &nbsp;&nbsp;&nbsp;&nbsp;this was the original install and I am just trying to reverse the installs

What is the distribution and the release of the target server(s)?

Regards  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Racke

---

<div class="post-metadata">

**Author:** ![Tony\_Wong](https://avatars.discourse-cdn.com/v4/letter/t/3ab097/32.png) [@Tony\_Wong](https://forum.ansible.com/u/Tony_Wong)\
**Post date:** [July 16, 2020, 1:58pm UTC](https://forum.ansible.com/t/remove-mysql/33405/7 "2020-07-16T13:58:15Z")

</div>

control server is ubuntu 19.10  
client is 20.04

ok working now

are these 2 pb doing same thing?

---

<div class="post-metadata">

**Author:** ![dan\_linder](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dan_linder/32/3833_2.png) [@dan\_linder](https://forum.ansible.com/u/dan_linder)\
**Post date:** [July 16, 2020, 3:51pm UTC](https://forum.ansible.com/t/remove-mysql/33405/8 "2020-07-16T15:51:05Z")

</div>

The actions that those two tasks perform look to be the same, but you should update the “name:” field to better reflect that the job is removing/un-installing those packages.
