0

So this is the first time using mySQL. I recently installed mySQL server a few hours ago and XAMPP a few days ago, although only launched XAMPP for the first time today. I'm not sure I need both do I? I can run the server from either mysql or XAMPP.

I'm trying to connect to the database via bluehost (webdomain) using phpmyadmin.

I have the mySQL server running but still get the error Can't connect to local MySQL server through socket /var/lib/mysql/mysql.sock . I tried to locate the file inside /var/lib/ but only see a postfix folder inside, not mySQL.

If somehow I need to put the file there, how do I do so?

EDIT: I ran netstat -ln | grep -o -m 1 -E '\S*mysqld?\.sock' in terminal while mysql is running and this come up: /tmp/mysql.sock. I believe this is where the file is and I need to move it somehow.

EDIT2: I opened up my.cnf file and changed the socket to /var/lib/mysql/mysql.sock and then run the server from XAMPP. when I do netstat -ln | grep -o -m 1 -E '\S*mysqld?\.sock' in terminal now it comes back with /var/lib/mysql/mysql.sock. Nevertheless, the problem still occurs.

luke
  • 2,743
  • 4
  • 19
  • 43
  • 1
    Try looking at these : http://stackoverflow.com/questions/4448467/cant-connect-to-local-mysql-server-through-socket-var-lib-mysql-mysql-sock or http://stackoverflow.com/questions/5376427/cant-connect-to-local-mysql-server-through-socket-var-mysql-mysql-sock-38 or http://dba.stackexchange.com/questions/98467/how-to-solve-cant-connect-to-local-mysql-server-through-socket-error – PaulF May 17 '16 at 08:39
  • Ensure that your mysql service is running ? – JYoThI May 17 '16 at 08:46
  • yes it is running. – luke May 17 '16 at 08:49

1 Answers1

0

So, you should change your mysql.default_socket in php.ini to /tmp/mysql.sock and restart your web server.

Taras
  • 572
  • 3
  • 15
  • Went into php.ini and changed the line `pdo_mysql.default_socket=/tmp/mysql.sock` - didn't do anything – luke May 17 '16 at 08:50
  • Please also check all places in php.ini where mysql socket is set to /var/lib/mysql/mysql.sock and change these to /tmp/mysql.sock Make sure your MySQL also has socket variable set to /tmp/mysql.sock. Restart both MySQL & web server services – Taras May 17 '16 at 09:12
  • when i command f to try find whats been set to there i find nothing. above setting the socket it states `Default socket name for local MySQL connects. If empty, uses the built-in MySQL defaults.` I have changed the socket for pdo_mysql, mysql and mysqli. – luke May 17 '16 at 09:24
  • Could you check for the value of socket variable in MySQL? mysql> show variables like '%socket%'; – Taras May 17 '16 at 09:59
  • it this done in terminal or? I only have mySQL server installed – luke May 17 '16 at 10:05
  • It does not matter how. I'm using mysql client program in terminal but you can use phpMyAdmin or any other program which allows you to run SQL queries e.g. MySQL Workbench – Taras May 18 '16 at 08:35