Can't connect to local MySQL server through socket '/tmp/mysql.sock' - php

I don't know what's wrong with my website since I last upgraded it to new version of PHP Melody: http://www.juraatmedia.com/
Is this some script issues or server issues? Please check and reply asap. Thanks
(I am using NetworkSolutions hosting, I don't know whether mySQL server is running or not. I tried opening phpmyadmin for the specified db, it's opening but when I am clicking on my db on the left, it's just loading and not showing anything. Does that suppose to mean that mysql is not running? I tried contact them via email but they said I have to call their technical team. This is happening since saturday, how come their server is down since 2 days)

If your db config is looking to connect on localhost, change it to 127.0.0.1 (I know it's the same but it somehow it acts differently). I've had that problem before with an upgrade. Was getting that error changed the hostname to an ip address solved my problem

Related

PHP Socket PDO SQLSTATE[HY000] [2002] No such file or directory

Introduction
For the past couple of days I’ve been messing about with PHP web sockets, in an attempt to retrieve some information in real-time for the user about the various different people connected.
I’m on Ubuntu, running the latest version of XAMPP (located under /opt/lampp/), the web socket I run using PHP which I’ve installed using apt-get install php. This opens a socket with no problem whatsoever.
The problem I’m facing has to do with establishing a connection to the database from the web socket with a little help from PDO. Whenever I attempt to establish the connection to the database located on localhost, I get the following error message:
SQLSTATE[HY000] [2002] No such file or directory
Since PHP and my MySQL server isn’t aware of one another, considering MySQL is run through the instance of XAMPP and the server is run using the version of PHP (which is the same as the one as for XAMPP) I’ve installed using apt-get, one might think that this is the cause of problems. But shouldn’t the server be reachable as long as you have the correct username and password to the server configuration?
Research
I’ve been doing quite some research on the subject, and have found multiple potential solutions for the problem, but neither one appears to do the job. For example, on this question, it is suggested that you can solve this error by doing some witchery to your server software, as well as PHP—I’ve tried this with to apparent success.
On other questions, it’s instead suggested that you change this DSN PDO setup:
$dsn = "mysql:host=$host;port=$port;dbname=$name;charset=$charset";
To instead of using "localhost" for the host, you stick with 127.0.0.1—as a matter of fact, I can’t even connect unto my server if I were to do this. Doing this, my XAMPP gets stuck in some form of endless loop. A minute or so after changing from 127.0.0.1, back to localhost, it starts working again.
I can’t remember where, but I also remember seeing somebody saying it’s not at all doable (connecting to MySQL from a PHP socket), which I’d find extremely strange.
Some people also seem to suggest switching to Node.js for handling real-time connections, but I’d very much like to keep it all PHP if possible.
Furthermore
I’m probably just being a complete moron (I was ;-)), but if anybody can point me in the right direction it would be highly appreciated!
you need to specify the path of the socket
example:
$dsn = 'mysql:dbname=testdb;unix_socket=/path/to/socket';
Try to search the file mysql.sock inside the /opt/lamp

How to fix "#2003 - Can't connect to MySQL server on '127.0.0.1' (61) the server is not responding."

I am having issues connecting to MySQL server. I go to localhost:8888/phpMyAdmin/?lang=en and get the error:
"#2003 - Can't connect to MySQL server on '127.0.0.1' (61) the server
is not responding."
I've tried many different solutions however, none have worked. If anyone has any advice or ways to fix this, it would be a great help.
Ensure that MySQL is enabled in MAMP, and that you have also enabled "Allow network access to MySQL" in MAMP's MySQL settings page.
I'd recommend restarting your system, and confirming that mysql daemon start with your mamp server properly. You may also try logging into the command line mysql, and observe the configuration. You seem to suggest that you have tried many things, and I assume that you tried restarting. I know it seems ridiculous to ask you to repeat this... but, you want a clean entry point to observe the issue. There may be another mysql server running as well, or it may not be serving where you think it is. By logging into MySql as root, you should be able to determine some of the mis-configuration issues.
I went to /Applications/MAMP/bin/phpMyAdmin/config.inc.php and updated the line $cfg['Servers'][$i]['host'] = '127.0.0.1';
from 127.0.0.1 to localhost.

Bad php codes can cause this(Error:Connection timed out) type of errors in FTP?

Sometimes when i am trying to connect to my server through filezilla i am getting this error at the same time my site and phpmyadmin is also down and getting errors like this mysql error: MySQL server has gone away or some times too many connections. It was working fine for last two days. 2 days before i altered tables in my database added some code in my .inc files (ie, php code) after that only i am having this problem. But some times i can connect to server and both my site and phpadmin is also loaded. I would like to know whether bad php codes can cause this(Error:Connection timed out) type of errors in FTP? Please help me..
SOLVED
Problem was with the server and they have corrected it. Thanks a lot
to all of you who responded to my question
Seems like your code is establishing too many MySQL connections, can you add the code to your question to confirm? (Do you have a DB connection in a loop by any chance?)
Regarding post-rollback errors, as you have not stated what you have tried, here is a slew of possible solutions.
MySQL #2002 forum post - A few possible solutions here.
linuxquestions forum post - (setting 'socket = /var/lib/mysql/mysql.sock' in my.cf)
'Solve: Can’t connect to local MySQL server through socket /tmp/mysql.sock'
The basic problem is most likely that you do not have the socket set correctly, check where the .sock is and what is currently set to in your settings.
Aside: You could go for a clean install of LAMP / XAMPP / whatever, may end up being quicker if possible assuming you can't fix the issue itself.

whats meaning of "Error establishing a database connection"

i have one wordpress blog name as
http://shareprogrammingtips.com/
its hosted on hostgator and works fine. But suddendly i am getting error like
Database Error:
Error establishing a database connection
when i open my blog.
i have not done anything with php my admin of my webspace. i havent touch any setting still i am getting this.
why this error comes and how can i remove that ?
Chances are there is an issue with one of the following:
The database server is down (try connecting via a MySQL client such as PHPMyAdmin or the MySQL admin tools http://dev.mysql.com/downloads/gui-tools/5.0.html)
Incorrect username/password
Your username/password is correct however you don't have permission to connect from your current hostname (e.g. database only allows local connections).
You specified a database table that does not exist.
If you have't changed anything in the site wp-config.php or in Wordpress at all, it's probably nothing more than a temporary glitch at your webhost. Open a ticket with them.
Hostgator places a limit that database can consume only 25% of total memory assigned to a hosting account. You have mysql server going away that crashed your server.Kind of "Memory Issues" if it is repeatedly occuring the hostgator support will finally ask you to upgrade

mysql_connect returning "Can't connect to local MySQL server through socket" on remote host connection?

I have a server that's returning an unexpected, intermittent error and wondering if anyone has either experienced it before or can guess what might be going on. My search has so far has been unfruitful.
Im connecting to a remote mysql server using mysql_connect() in the usual way, but for the last 2 weeks (couple of times a day) the connection to the database fails and I get an unable to connect to socket error?
Error: 2002 - Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
Obviously this is unexpected as Im trying to connect to a remote host. Does mysql_connect default to localhost if the remote host is unavailable? I've not known it to do that, and nothing in the docs that say it does.
There doesn't seem to be any pattern to the failed connections, various files and it happens at all sorts of time of day. Im thinking it might be network traffic related, because if you refresh the page straight away it connects fine, but am confused as to why Im getting an unable to connect to socket error.
the database provider has checked and are unable to find an issue with the server itself.
anyone have any ideas?
Im sure it doesnt default to localhost, and im also pretty sure that it is the remote server sending you the error message. So it's "Local" on your mysql server, not local on "your" server.
In this case its probably due to downtime on the remote server.
Gr.
ok, facepalm moment... after this hitting me for ages I finally found why mysql_error() was reporting the socket error. in my code there was a mysql_select_db() that I didnt notice and it was that, thats reporting the socket error as there is no open connection for it to use.
actual error the mysql_connect is reporting is (2003) Can't connect to MySQL server on 'mysql.hostname.tld'. Im still leaning towards some sort of DNS lookup/network traffic issue, Im currently using the IP address to connect to see if that errors.
But as far as this question is concerned, the answer is "Im a numpty".
Have a look at this
Had a similar thing a while back.
Are you connecting from home? The reason I ask is that my ISP likes to mess around re-assinging IP addresses to my home account, and I have an IP authorization on my remote MySQL.
I think I opened up the IP connnection limitation thing to a string that was IP Addresses for my region and that solved the problem.
If you're running Windows, there might be too many connections already, if so go to http://dev.mysql.com/doc/refman/5.5/en/can-not-connect-to-server.html#can-not-connect-to-server-on-windows and have a read.
Else, perhaps someone someone may have removed the Unix socket file that mysqld uses (/tmp/mysql.sock by default). For example, you might have a cron job that removes old files from the /tmp directory.

Categories