- From: Ameya Savale <
>
- To:
- Subject: [chef] executing mysql command error
- Date: Wed, 5 Feb 2014 15:56:46 -0800
Sorry the last email was sent by mistake,
I've been having some trouble executing a mysql command. So in my recipe I enable the mysql service using the runit cookbook which works fine, however in my next resource when I try to run a mysql command I get a socket error. When I try to run the exact command directly from the command line it works fine, why does this happen?
Here is my runit resource
runit_service "Enable service mysql-#{setup_instance_node['node']}" do
sv_bin "/usr/bin/sv"
sv_dir "/var/services"
service_dir "/service"
service_name "mysql-#{setup_instance_node['name']}"
sv_templates false
sv_verbose true
action :nothing
end
runit_service "Restart service mysql-#{setup_instance_node['node']}" do
sv_bin "/usr/bin/sv"
sv_dir "/var/services"
service_dir "/service"
service_name "mysql-#{setup_instance_node['name']}"
sv_templates false
sv_verbose true
action :nothing
end
at this point it says that the mysql service is already up and then this is the next resource which I am running:
ruby_block "Set root password and set global users" do
block do
socket = "/var/lib/mysql/#{setup_instance_node['name']}/mysql.sock"
exec = ::Chef::Resource::Execute.new("Readonly users", run_context)
exec.command %Q{ mysql --socket=#{socket} -u root -e "grant select, usage on *.* to 'readonly'@'%%' identified by 'readonly';" }
exec.run_action(:run)
end
action :nothing
end
it is in this resource that I am getting the error: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/test/mysql.sock' (2)
but when I run the command from the command line it works fine, is this a problem with my actual command or with the way chef is converging the resources.
- Thank You
Ameya
Archive powered by MHonArc 2.6.16.