sous-chefs / mysql

Development repository for the mysql cookbook
https://supermarket.chef.io/cookbooks/mysql
Apache License 2.0
338 stars 690 forks source link

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

Closed maneeshmp closed 7 years ago

maneeshmp commented 7 years ago

Cookbook version

8.2.0

Chef-client version

Chef: 12.7.2

Platform Details

Ubuntu 14.04

Scenario:

I am trying to install mysql server, but with the inital root password I can't connect mysql

Steps to Reproduce:

My recipe has the below code,

mysql_service 'default' do initial_root_password 'abc123' bind_address '0.0.0.0' port '3306' version '5.5' action [:create, :start] end

When i try below command on my instance, I get eror mysql -u root -pabc123 ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

Expected Result:

It should connect mysql

Actual Result:

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

valeriucraciun commented 7 years ago

This is not an issue. In the Readme it says:

To connect to the socket from the command line, check the socket in the relevant my.cnf file and use something like this:

mysql -S /var/run/mysql-foo/mysqld.sock -Pwhatever

Or to connect over the network, use something like this: connect over the network..

mysql -h 127.0.0.1 -Pwhatever

In your case: mysql -S /var/run/mysql-default/mysqld.sock -u root -pabc123

dirceuvjr commented 7 years ago

@maneeshmp You could also create a symlink to the .sock file: ln -s /var/run/mysql-foo/mysqld.sock /var/run/mysqld/mysqld.sock

maneeshmp commented 7 years ago

ok thanks

lock[bot] commented 5 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.