Skip to main content
Inspiring
August 8, 2007
Answered

Can't connect to local mysql

  • August 8, 2007
  • 6 replies
  • 1728 views
What could be causing the mysql socket to refuse connections---I'm getting the following error:

MySQL Error 2002
Can't connect to local MYSQL server through socket '/var/mysql/mysql.sock' (2)

I'm using Connection name: con1
Sever localhost
Username mysql ---and several other attempts
Password mysql ---and several other attempts
Database (browse for that)

I'm running Mac OSX 10.4.10, using Dreamweaver 8.
I've changed my config file to run PHP and it works fine; I've been able to set up tables in mysql using Terminal. So what else should I be looking for? My Local Info, Remote Info and Testing Server Info all point to my local Sites directory. URL prefix is http://127.0.0.1/~myname/

Thanks for any help.
This topic has been closed for replies.
Correct answer tharring
David, your answer was most helpful. Figuring out how to make the symbolic link was my next challenge, but I got it and it works! In Terminal I found there was a /tmp/mysql.sock but nothing at /var/mysql/ Not even a directory for mysql. So I had to create one and then make the -s link. I also had to use super user permissions to do it.

On a Mac 10.4.10, here's what you do--In Terminal
cd /var/
sudo mkdir mysql
cd (to get back to root)
sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock

At any time you can run the ls command to see all the files and directories within the current directory, so you can keep track of where you are. Always hit cd (enter) to go back to home (root).

Now when I go back to Deamweaver, I can set a connection to my databases and see them in the list!

Thanks again for your help, David. I'm going to be checking out your PHP books too!
Tedra

6 replies

Inspiring
August 9, 2007
tharring wrote:
> David, your answer was most helpful. Figuring out how to make the symbolic link
> was my next challenge, but I got it and it works!

Great! I've made a copy of your instructions in case I come across
anyone else with the same problem. The only difficulty will be
remembering where I've saved your instructions. :-)

--
David Powers, Adobe Community Expert
Author, "The Essential Guide to Dreamweaver CS3" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
tharringAuthorCorrect answer
Inspiring
August 9, 2007
David, your answer was most helpful. Figuring out how to make the symbolic link was my next challenge, but I got it and it works! In Terminal I found there was a /tmp/mysql.sock but nothing at /var/mysql/ Not even a directory for mysql. So I had to create one and then make the -s link. I also had to use super user permissions to do it.

On a Mac 10.4.10, here's what you do--In Terminal
cd /var/
sudo mkdir mysql
cd (to get back to root)
sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock

At any time you can run the ls command to see all the files and directories within the current directory, so you can keep track of where you are. Always hit cd (enter) to go back to home (root).

Now when I go back to Deamweaver, I can set a connection to my databases and see them in the list!

Thanks again for your help, David. I'm going to be checking out your PHP books too!
Tedra
Inspiring
August 9, 2007
tharring wrote:
> More news... I've found that MysqlAdmin says the socket is at /tmp/mysql.sock,
> but Dreamweaver says it can't locate the socket at /var/mysql/mysql.sock. How
> do I get these two working together? Sorry for all the questions.

I'm not a Mac expert, but other people have reported a similar problem.
The way they got round it was to create an alias so that
/var/mysql/mysql.sock points to /tmp/mysql.sock.

--
David Powers, Adobe Community Expert
Author, "The Essential Guide to Dreamweaver CS3" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
tharringAuthor
Inspiring
August 9, 2007
More news... I've found that MysqlAdmin says the socket is at /tmp/mysql.sock, but Dreamweaver says it can't locate the socket at /var/mysql/mysql.sock. How do I get these two working together? Sorry for all the questions.
Thanks,
Tedra

tharringAuthor
Inspiring
August 9, 2007
The MysqlAdmin does work when I use the password that I added in Terminal, so that's okay. Also looking at that utility I see the Mysql server IS RUNNING. It says the socket is at /tmp/mysql.sock. So I wonder why I can't set a connection to a database using php. Any other ideas?
Thanks,
Tedra
Inspiring
August 8, 2007
tharring wrote:
> What could be causing the mysql socket to refuse connections---I'm getting the
> following error:
>
> MySQL Error 2002
> Can't connect to local MYSQL server through socket '/var/mysql/mysql.sock' (2)

It means either that MySQL isn't running, or that the socket has been
created in the wrong place. Begin by checking that MySQL is actually
running (you should be able to do this in System Prefs). If it is, and
you still can't connect, try restarting your computer.

--
David Powers, Adobe Community Expert
Author, "The Essential Guide to Dreamweaver CS3" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
tharringAuthor
Inspiring
August 8, 2007
I don't see how to check this in System Preferences. Is there a utility that starts Mysql or do I have to start it in Terminal every time? I was setting up databases using an open source copy of MysqlAdmin, but now that I've started using mysql in Terminal, the MysalAdmin utility doesn't work. How would I check to see where I've set up the socket? I've restarted my computer several times and that didn't help either.
Thanks,
Tedra