MySQL Connection Not Working: 2002 No Such File or Directory

MySQL connection not working: 2002 No such file or directory

If you use Linux: the path to the mysql.sock file is wrong. This is usually because you are using (LAMPP) XAMPP and it isn't in /tmp/mysql.sock

Open the php.ini file and find this line:

mysql.default_socket

And make it

mysql.default_socket = /path/to/mysql.sock

Proprietary plug-ins for GPL programs: what about interpreted languages?

he distinction between fork/exec and dynamic linking, besides being kind of artificial,

I don't think its artificial at all. Basically they are just making the division based upon the level of integration. If the program has "plugins" which are essentially fire and forget with no API level integration, then the resulting work is unlikely to be considered a derived work. Generally speaking a plugin which is merely forked/exec'ed would fit this criteria, though there may be cases where it does not. This case especially applies if the "plugin" code would work independently of your code as well.

If, on the other hand, the code is deeply dependent upon the GPL'ed work, such as extensively calling APIs, or tight data structure integration, then things are more likely to be considered a derived work. Ie, the "plugin" cannot exist on its own without the GPL product, and a product with this plugin installed is essentially a derived work of the GPLed product.

So to make it a little more clear, the same principles could apply to your interpreted code. If the interpreted code relies heavily upon your APIs (or vice-versa) then it would be considered a derived work. If it is just a script that executes on its own with extremely little integration, then it may not.

Does that make more sense?

PDOException SQLSTATE[HY000] [2002] No such file or directory

The error message indicates that a MySQL connection via socket is tried (which is not supported).

In the context of Laravel (artisan), you probably want to use a different / the correct environment. Eg: php artisan migrate --env=production (or whatever environment). See here.

mysql_connect(): No such file or directory

Yes you can not connect like that!

@PLB and @jammypeach mysqli is after v4.1, he is using v3 :)
Guys read the specs, if you want really to help!

You can't connect, because your socket file is a bit wrong. I remember now that the old RH had this issue before.
Your socket is probably as /var/mysql/mysql.sock or /tmp/mysql.sock but one or more apps are looking for the other.

If yours is /tmp/mysql.sock but no /var/mysql/mysql.sock you should:

cd /var 
mkdir mysql
cd mysql
ln -s /tmp/mysql.sock mysql.sock

If you have /var/mysql/mysql.sock but no /tmp/mysql.sock then:

cd /tmp
ln -s /var/mysql/mysql.sock mysql.sock

You'll need permissions to make the changes. Just sudo, if needed before the commands above!

ANOTHER SOLUTION (easier):

Create file and call phpinfo(); Look for 'mysql.default_socket'; or 'pdo_mysql.default_socket';
Open My.ini or My.cnf find the socket value e.g. socket=/tmp/mysql.sock
Open your php.ini file (which is also found on your phpinfo() page as ‘Loaded Configuration File‘) and change all the occurrences of the incorrect socket location to the correct socket location from MySQL.

ANOTHER SOLUTION (easiest):
DSN for PDO:

mysql:unix_socket=/tmp/mysql.sock;dbname=...

mysql_connect:

$db = mysql_connect('localhost:/tmp/mysql.sock', ...

Your system is really scary when it comes to security, if you're hosting sensitive data, I'd upgrade to the latest versions.

---- UPDATE ----

Aaahhhh PHP 5.0 and MySQL 3.23 :)

PHP 5 has a mysql client packaged that cannot connect to a MySQL database less than version 4.1.
Starting with version 4.1, MySQL uses a new way of password hashing that is not compatible with pre-4.1 databases. The server your configuration is connecting to is version 3.23. So you need to get yourself a higher version of MySQL. Sorry, but there is no other practical solution for your case. If I was you, I'd upgrade the whole system and install the most recent OS version, if I had to I'd go with Debian and the most recent stable versions of PHP and MySQL.



Related Topics



Leave a reply



Submit