0

I'm a inexperienced webmaster for my Boy Scout troop. I have recently set up MAMP on my map and then tried to use MySQL PHP server for dynamic data. When testing locally, everything worked. When I uploaded everything to my web server (for which I only have FTP access) I get this message when I try to access the php page.

Fatal error: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in 

Can anyone tell me what I'm doing wrong?

More info:

  • Mac Pro 1,1 running 10.7
  • Dreamweaver CS6
  • MySQL Server 5.3.3
binarious
  • 4,568
  • 26
  • 35
  • http://stackoverflow.com/questions/5376427/cant-connect-to-local-mysql-server-through-socket-var-mysql-mysql-sock-38 – Nouphal.M Jan 30 '14 at 19:58
  • Post the code you're using to connect to the MySQL server. Mask the user name & password before you post it! –  Jan 30 '14 at 20:02
  • Make sure that the username and password you are using are the same on your remote server. Additionally, make sure the MySQL user has permission to access the database. – Dave Jan 30 '14 at 20:04
  • Mysql is either not running on your server, or you don't have proper credentials. I'm more inclined to believe it's the former, since if you are denied access, it will usually tell you that. – Jage Jan 30 '14 at 20:09
  • Sounds like your MySQL is not running. – Ant Jan 30 '14 at 20:15
  • Ok. When I say inexperienced, I mean it. I Probally didn't even set this up right. I have MAMP installed on my computer and everything works locally. It's only when I put it on the remote server that things go wrong. Do I need to install MYSQL on the server? – user3254783 Jan 30 '14 at 20:15
  • By "web server" you mean a hosted commercial service, rather than your personal PC or Mac? It's false economy to host the latter way, because hackers will eat you for breakfast. Assuming you're on a "real" server, it's likely that somewhere you have a hard coded "localhost" instead a server name or IP address. As well, the user ID and password might be different. Ask your host how to connect to your MySQL server. You _must_ have more than just FTP access (are you "borrowing" or "subletting" services from another customer?). – Phil Perry Jan 30 '14 at 20:51

2 Answers2

0

IF you are sure that the server is UP and MySQL is running, the following may be true:

When MySQL states it is trying to connect through a local socket, this typically means you are using "localhost" as the address for the MySQL server in your PHP code.

Instead try using the IP Address of the MySQL server.

If this does not fix the problem, then make sure your mysql user that your code is using has permissions to access the MySQL server from 'localhost'.

Let me know if you have any questions about any of this.

Danoweb
  • 208
  • 1
  • 2
  • 9
  • Hi. Thanks for your help. How do you find the IP of the mysql server running on my home network? – user3254783 Jan 31 '14 at 23:54
  • Sorry, I actually have figured that all out and have port fowarding set up. My question now is why do I have this error message: access denied for user'root'@' ' (using password yes) in file path – user3254783 Feb 01 '14 at 00:09
0

I solved this problem. My error was that I didn't have MAMP set up to allow connections from the outside. Google it, there are many good resources out there to help you set it up. After I did that and made sure root access from any IP was enabled, I was good to go. Thanks for everyones help.