LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   problems connecting to mysql database (https://www.linuxquestions.org/questions/linux-software-2/problems-connecting-to-mysql-database-828438/)

mark_alfred 08-25-2010 01:26 PM

problems connecting to mysql database
 
Hello. I'm having problems connecting to the mysql database on my system. I first noticed this when I was trying to set up the program anymeal. I subsequently tried using MySQL Administrator (mysql-admin), but had no luck. It gives my the following feedback:
Code:

Could not connect to host 'localhost'.
MySQL Error Nr. 2002
Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

Click the 'Ping' button to see if there is a networking problem.

I press the ping button, and it seems to connect.
Code:

64 bytes from localhost (127.0.0.1): icmp_seq=4 ttl=64 time=0.166 ms
64 bytes from localhost (127.0.0.1): icmp_seq=5 ttl=64 time=0.165 ms
64 bytes from localhost (127.0.0.1): icmp_seq=6 ttl=64 time=0.160 ms
64 bytes from localhost (127.0.0.1): icmp_seq=7 ttl=64 time=0.164 ms
64 bytes from localhost (127.0.0.1): icmp_seq=8 ttl=64 time=0.189 ms
64 bytes from localhost (127.0.0.1): icmp_seq=9 ttl=64 time=0.163 ms
64 bytes from localhost (127.0.0.1): icmp_seq=10 ttl=64 time=0.162 ms
64 bytes from localhost (127.0.0.1): icmp_seq=11 ttl=64 time=0.162 ms


bathory 08-25-2010 03:58 PM

Hi,

Ping localhost is useless, as it's already up since you're logged in it.
Check if mysqld is running and if the socket is at the location specified
Code:

lsof|grep mysqld.sock
Regards

mark_alfred 08-25-2010 06:15 PM

I figured it out. Turns out I did not have the server installed. Why this wasn't a dependency of the AnyMeal program, I'm not sure, but anyway, I now got it working. Also, for the AnyMeal program, I needed to set it to "network" from localhost, rather than running from mysqld.sock, which I couldn't get going.

joec@home 08-25-2010 07:41 PM

Quote:

Originally Posted by mark_alfred (Post 4077743)
Why this wasn't a dependency of the AnyMeal program, I'm not sure, but anyway, I now got it working.

This is confusing to beginning administrators, we were all there at one time. The reason it is not a dependency is because the MySQL server is not required to be on the local machine. You may have one MySQL server with many workstations attached to it, or you may have one workstation that attaches to many different MySQL servers.

vsurlan 08-26-2010 03:58 AM

Quote:

Originally Posted by mark_alfred (Post 4077743)
Also, for the AnyMeal program, I needed to set it to "network" from localhost, rather than running from mysqld.sock, which I couldn't get going.

When both the MySQL server and the client (AnyMeal in your case) are on the same machine it is much better to work through sockets. Especially if your data is security sensitive. It's faster and you can prevent intrusions by completely disabling networking for MySQL. The fact that you have problems setting this to work via sockets is an indicator that there is something fundamentally wrong in the settings somewhere and I would investigate that further if this is a production setup.


All times are GMT -5. The time now is 01:07 AM.