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

Cannot connect through socket #671

Open
whyte624 opened this issue Jul 7, 2021 · 1 comment
Open

Cannot connect through socket #671

whyte624 opened this issue Jul 7, 2021 · 1 comment

Comments

@whyte624
Copy link

whyte624 commented Jul 7, 2021

πŸ‘» Brief Description

Error:

FATAL: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/run/mysqld/mysqld.sock'

πŸ₯ž Cookbook version

10.1.3

πŸ‘©β€πŸ³ Chef-Infra Version

17.2.29

🎩 Platform details

Ubuntu 18.04
Vagrant

Steps To Reproduce

Steps to reproduce the behavior:

It is not full example, but I hope it will be enough.

.kitchen.yml

driver:
    name: vagrant

provisioner:
    name: chef_zero
    log_level: info
    data_bags_path: ./test/data_bags
    client_rb:
        chef_license: accept

platforms:
    - name: ubuntu-18.04

suites:
    - name: default
mysql_service 'default' do
    instance 'default'
    charset 'utf8'
    version '5.7'
    initial_root_password 'root_password'
    data_dir '/var/lib/mysql'
    action [:create, :start]
end

mysql_user 'me' do
    ctrl_user 'root'
    ctrl_password 'root_password'
    password 'my_password'
    host '%'
    privileges [:all]
    action [:create, :grant]
end

πŸš“ Expected behavior

Expecting mysql and user me

βž• Additional context

I understand that root uses auth_socket plugin.
I assume if I change plugin to mysql_native_password it would work. But I do know want to change plugin. Also it requires other recipes to be used. I would like to solve mysql server installation with this cookbook only.

If I could specify shell user who executes mysql_user resource, then I would set root (from ubuntu). However, there is no such option.

For now I solved it with execute shell script doing the same thing, but as root.

@tr3pan
Copy link

tr3pan commented Aug 23, 2024

I don't know if this is the same issue I have, but for me the issue was the socket was missing. It takes some time mysql to start and create it. If chef waits a bit chef_sleep '10' worked for me for most cases, the user creation will work.

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

No branches or pull requests

2 participants