Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem: mysql_db ansible module tries to use tcp socket #46

Open
mamedin opened this issue May 19, 2020 · 5 comments
Open

Problem: mysql_db ansible module tries to use tcp socket #46

mamedin opened this issue May 19, 2020 · 5 comments

Comments

@mamedin
Copy link
Contributor

mamedin commented May 19, 2020

It is a bug related to the mysql_db module.

The workaround is:

  • Adding socket=/var/run/mysqld/mysqld.sock in /root/.my.cnf to use the unix socket.

Error:

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: OperationalError: (1044, u"Access denied for user 'root'@'127.0.0.1' to database 'gnwt_test'")
fatal: [atom-test-sites -> None]: FAILED! => {"changed": false, "msg": "error creating database: (1044, u\"Access denied for user 'root'@'127.0.0.1' to database 'gnwt_test'\")"}
@mamedin
Copy link
Contributor Author

mamedin commented Jul 9, 2020

Seems related to ansible/ansible#47736 (comment)

When using MySQLdb it works fine, but fails when python-pymysql package is installed.

This command fixes the issue on atom-test-sites:

root@atom-test-sites:~# sudo apt-get remove python-pymysql
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  grub-pc-bin guile-2.0-libs libgc1c2 libgsasl7 libkyotocabinet16v5 libmailutils5 libntlm0 mailutils-common
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
  python-pymysql
0 upgraded, 0 newly installed, 1 to remove and 18 not upgraded.
After this operation, 323 kB disk space will be freed.
Do you want to continue? [Y/n] Y
(Reading database ... 143514 files and directories currently installed.)
Removing python-pymysql (0.8.0-1) ...

The python-mysqldb should be installed.

Looking at mysql_user documentation, the only requierement is (See https://docs.ansible.com/ansible/2.3/mysql_user_module.html):

Requirements (on host that executes module)
MySQLdb

@mamedin
Copy link
Contributor Author

mamedin commented Jul 6, 2022

So:

  • Never use the pymysql packages, always use the mysqldb ones

@hakamine
Copy link
Member

hakamine commented Jul 6, 2022

Hi @mamedin , it's been a while since I did this PR: #73 but it could probably help with this issue? (the PR adds a login_unix_socket parameter to the mysql_user task)

@mamedin
Copy link
Contributor Author

mamedin commented Jul 6, 2022

This issue is fixed, but I prefer to leave it open: never use the pymysql packages

I'll try to review the molecule PR, it is very useful. Thanks!

@mamedin
Copy link
Contributor Author

mamedin commented Jul 6, 2022

Hi @mamedin , it's been a while since I did this PR: #73 but it could probably help with this issue? (the PR adds a login_unix_socket parameter to the mysql_user task)

Same change I did here this morning: artefactual-labs/ansible-atom-replication@e8db189

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants