Skip to content

Commit 7a6dd73

Browse files
committed
Merge pull request geerlingguy#29 from BlackMesh/remove-anonymous-users
Fixes geerlingguy#26: Remove all anonymous users (not just the 'localhost' anonymous user).
2 parents e8575a7 + 75cf220 commit 7a6dd73

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

tasks/secure-installation.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,17 @@
2121
group: root
2222
mode: 0600
2323

24+
- name: Get list of hosts for anonymous user
25+
command: mysql -NBe 'SELECT Host from mysql.user WHERE User = ""'
26+
register: mysql_anonymous_hosts
27+
changed_when: false
28+
2429
- name: Remove anonymous MySQL user.
25-
mysql_user: "name='' state=absent"
30+
mysql_user:
31+
name: ""
32+
host: "{{ item }}"
33+
state: absent
34+
with_items: mysql_anonymous_hosts.stdout_lines
2635

2736
- name: Remove MySQL test database.
2837
mysql_db: "name='test' state=absent"

0 commit comments

Comments
 (0)