Mysql_connect (): There is no such file or directory in / opt / lampp / htdocs /

I installed XAMPP on my Ubuntu 14.0.04, and I try to connect to my MySQL server from a PHP file, but I get an error:

Warning : mysql_connect (): no such file or directory in /opt/lampp/htdocs/value.php on line 3 is
not connected

My value.phpfile contains

<?php

$con = mysql_connect('localhost:3307', 'root', '');
if ($con) echo 'Connected';
else echo 'not connected';
---
?>

and my MySQL server is running and my server is also running.

+4
source share
2 answers

What version of mysql are you using?

try it

 127.0.0.1:your-port-number

as

$con = mysql_connect('127.0.0.1:3307', 'root', ''); // or 3306 whatever your port number is

instead localhost

I had this problem too, but this link helped me Warning: mysql_connect ()

+5
source

, mysql ; , .

( ) /tmp/mysql.sock, /var/mysql/mysql.sock. , , .

cd /var 
sudo mkdir mysql
sudo chmod 755 mysql
cd mysql
ln -s /tmp/mysql.sock mysql.sock
0

All Articles