-1

I am trying to connect to a mysql server running on a Fedora machine listening on port 3306 at the socket /var/lib/mysql/mysql.sock

The mysql client is an ROR application which has been launched on a ubuntu machine using vagrant. From within the client the error occurs.

Mysql2::Error at / Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

I have tried the following

  1. Added in the fedora machine, socket="/var/lib/mysql/mysql.sock" in the my.cnf file and checked. It didnt work.
  2. Added in the database.yml file, socket="/var/lib/mysql/mysql.sock". It gives the similar error. Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (13)
  3. I have tried doing the chown mysql:mysql /var/lib/mysql/. Also chown mysql:mysql /var/run/mysqld/. Earlier the mysqld.sock was not present in the Ubuntu machine. I created one and did chown. But didnt work.
  4. I have tried disk clean since in some forums it has been told that this can be due to disk space crunch. But this also didnt help.

I have been stuck on this problem and have tried all possible ways for the last 2 days. This is the only road-block for the project. Please help me get out of this situation as I am going crazy figuring out how this can be resolved. Any quick help is very highly appreciated. Thanks in advance.

MrTux
  • 32,350
  • 30
  • 109
  • 146
sams
  • 1
  • 3
  • do you have daemon running? – hrust Dec 30 '15 at 12:40
  • daemon here means mysqld right? Yes it is running – sams Dec 30 '15 at 12:43
  • ># systemctl status mysqld mysqld.service - MySQL database server Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled) Active: active (running) since Wed 2015-12-30 15:02:33 IST; 3h 10min ago – sams Dec 30 '15 at 12:43

1 Answers1

1

socks (sockets) are file-like objects sitting locally. If you have an Ubuntu machine attempting to connect to the Fedora machine, the Ubuntu machine running the application, and the Fedora machine running the database, then socks are not an option.

You will need to use TCP ports (3306) to connect. Making changes to the Fedora machine will not enable the Ubuntu machine to connect to it (excepting the firewall, if that turns out to be an issue).

Configure the application to attempt to use TCP port rather than SOCKS.

Andy Gauge
  • 1,428
  • 2
  • 14
  • 25