Lakshmikant Deshpande
Lakshmikant Deshpande

Reputation: 844

Use independent MySQL installation with PHP that came with XAMPP 1.6.2

I have installed XAMPP 1.6.2 (need this use this specific version) at /opt/lampp in Ubuntu 16.0.4. I have installed Mysql 5.7.18-0ubuntu0.16.04.1 using apt-get. I need to use the installed version of MySQL with PHP that came with XAMPP.

When I try to connect PHP with MySQL (independent installation), I get this error:

Can't connect to local MySQL server through socket '/opt/lampp/var/mysql/mysql.sock'

I am still getting this error after trying the following things:

  1. Replaced all occurrences of '/opt/lampp/var/mysql/mysql.sock' with '/var/run/mysqld/mysqld.sock' in /opt/lampp directory.
  2. Restarted Apache, MySQL.
  3. Rebooted system.
  4. Searched on Stackoverflow, and tried existing solutions (eg. edit my.cnf)

Please help me out; Thanks.

Upvotes: 1

Views: 137

Answers (1)

Lakshmikant Deshpande
Lakshmikant Deshpande

Reputation: 844

I solved this issue simply by replacing localhost with 127.0.0.1 in my.cnf file.
As Fmashiro pointed out, this could have happened due to missing / corrupted socket file.

Upvotes: 0

Related Questions