Cannot connect to localhost MySQL - mysql.sock error - ERROR 2002 (HY000) - php

I'm using a brew php mysql config for my localhost and after trying to switch from php71 to php56, I am now unable to connect to my localhost and get this error:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
My services running:
I am researching this for quite some time now and I can't seem to be able to fix it. Please can someone help me? I'm going crazy.

Related

MySQL server has gone away and Error while reading greeting packet [duplicate]

This question already has answers here:
ERROR 2006 (HY000): MySQL server has gone away
(24 answers)
Closed 3 years ago.
I don't know why this :
$dbh = new PDO('mysql:host=127.0.0.1:1812;dbname=nde_oldy-pn', 'root', '');
throw this exception :
PDO::__construct(): MySQL server has gone away
PDO::__construct(): Error while reading greeting packet
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [2006] MySQL server has gone away'
PDOException: SQLSTATE[HY000] [2006] MySQL server has gone away
YEAH !! I understand ! MySQL decided to go on a trip without me on his own command ! Grrrr!
I've tried everything on this page : MySQL Documentation (.5.2.9 MySQL server has gone away)
Context :
It run with WAMP 3.0.6
(Apache 2.4.23; PHP 7.0.10; MySQL 5.7.14)
Url like this :
localhost:1812/NDEfiveYEARSproject/index.php
httpd.conf like this :
Listen 12.34.56.78:1812
Listen 0.0.0.0:1812
Listen [::0]:1812
ServerName localhost:1812
my.ini like this :
port = 3306
key_buffer_size = 64M
max_allowed_packet = 200M
Yes 1812 and 3306 ports are open.
Yes Incoming and outbound traffic rules for each port (1812 and 3306) have been created
IIS is not running
Same for Skype and Teamviewer...
Change the port no. to 3306
$dbh = new PDO('mysql:host=127.0.0.1;port=3306;dbname=nde_oldy-pn', 'root', '');
Encountered this MySQL server error today, have tried various solutions.
Uninstalling and re-installing XAMPP worked for me. :D

Mongodb:Failed to connect

I am new to MongoDB.I installed mongodb and used with Laravel framework.Its had been worked for a long time without any issues.But currently while i try to acess my website it shows:
Failed to connect to: localhost:27017: Connection refused
when i try to acces mongodb via command line,it shows:
warning: Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused
Error: couldn't connect to server 127.0.0.1:27017 (127.0.0.1), connection attempt failed at src/mongo/shell/mongo.js:146 exception: connect failed
when i try to access it via rock tool,it shows:
Unable to connect MongoDB, please check your configurations. MongoDB said:Failed to connect to: 127.0.0.1:27017: Connection refused.
what i will do? I can't figure what's wrong from my part since its working after the past months.I do nothing since the last days.Thanks in advance..
After a short break, I can find out the solution.
The origin of that issue is the unexpected shutdown of the system.So i run the below code in command prompt:
sudo rm /var/lib/mongodb/mongod.lock
mongod --repair
sudo service mongodb start
then after the above code run, its working fine :)

Failed to connect to: localhost:27017: Connection refused

I have installed MongoDB in xampp on Ubuntu using Laravel 5.1. But I always get this error
MongoConnectionException in TestController.php line 19: Failed to
connect to: localhost:27017: Connection refused
Nor I'm able
I have gone through a lot of questions, but all proved to be trivial solution.
Please help me with this as I'm stuck on it.
I think that first thing to do is to ssh on that server and check that mongod process is alive, then try open mongo shell using command - mongo . If all works try telnet on this server and port from your machine ,if there is no errors , read mongo logs

Unable to connect SQL SERVER 2008 R2

i have one page for register ... all my config is right but my register.php can't connect to my sql server..
Error
Warning: mssql_connect() [function.mssql-connect]: Unable to connect to server: x.x.x.x in C:\xampp\htdocs\rfweb\regis.php on line 81
code in line 81 is
$connectsql=mssql_connect($db_host, $db_user, $db_pass) or die('<center><b>'.$lang_error_cant_connect1.'</b><br>'.$lang_error_cant_connect2.'<br><br>Back</center>');
spesification :
SQL SERVER 2008 R2 and xampp 1.6
i've try to setting ODBC, Restart SQL, ect
anyone help me to fix it?
Try sqlsrv queries instead of mssql, and make sure you properly configured the ports of your xampp. Another thing, try to check whether you have IIS, maybe it's blocking your xampp.

Symfony PHP 5.5 : ErrorException: Notice: Memcache::connect(): failed

I am getting error while configuring Memcache with Symfony. Can anyone suggest on this. I have installed Memcache on wamp server using PHP 5.5
ErrorException: Notice: Memcache::connect(): Server localhost (tcp 11211, udp 0) failed with: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
(10060)
Your memcached server is not running. You need to start it.
If you're running Ubuntu, it's as simple as sudo service memcached start. For other operating systems, you may want to consult the manual. If you are having problems getting memcached set up, go to Server Fault and ask for help there.

Categories