1

I created a MySQL user via Ansible:

- name: MySQL user has ALL THE PRIVILEGES (in order to connect remotely)
  mysql_user: name="{{ database_user }}" password="{{ database_password }}" priv="*.*:ALL,GRANT" host="%" state=present
  notify: restart MySQL

- name: restart MySQL
  service: name=mysql state=restarted

The user is created, and I am able to connect from localhost, but not from any other machines.

Interestingly, running:

mysql> GRANT ALL PRIVILEGES ON *.* TO '{{ username }}'@'%' WITH GRANT OPTION;

as the root MySQL user then allows those connections from any other machine.

I've reproduced this on a couple of Ubuntu 14.04 hosts with Ansible 1.9.4 installed via brew running on Mac OS 10.11.

How do I correctly specify mysql_user to enable connections from any host?

jeffbr13
  • 652
  • 2
  • 8
  • 13
  • on your first block of code, make database_user=broomhilda, and run that block. Then run `select user,host,password from mysql.user where user='broomhilda'` ... and make note of that info somewhere like in Notepad. Then run your "interestingly" block, and do the same. As you know, host='%' is anyhost, perhaps look at what I wrote up [Here](http://stackoverflow.com/a/33478741) today – Drew Nov 02 '15 at 21:33
  • because what you did in the "interestingly" block was to create a superuser, as seen [Here](http://stackoverflow.com/a/5016587) – Drew Nov 02 '15 at 21:40
  • so what you may have done in your first block is to create a user with host<> '%' that has access on localhost, then a 2nd user with the next chunk. Because the 2nd chunk, even though it is a Grant stmt, also creates users ! – Drew Nov 02 '15 at 21:41

1 Answers1

0

You can check what's being created on the host by looking into mysql.user table - there might be something wrong with the user name, password or host.

And it's not necessary to restart MySQL daemon after adding users.