Connecting Tech Pros Worldwide Forums | Help | Site Map

error# 2002 can't connect to local mysql server '/var/mysql/mysql.sock' (2)

Newbie
 
Join Date: Sep 2007
Posts: 7
#1: Oct 11 '07
Hey Guys, you helped me once when I tryied to create a database : "Access denied for user ''@'localhost' ". On my Mac OS 10.4, I had no problem creating database and modifying it from the terminal. But I use Dreamweaver 8 to connect to MySQL, with its built-in feature "MySQL Connection" I write this:

Connection Name: con_test001
MySQL Server: localhost
User Name: root
Password: 55555
Database: test001 (which is a database I already createde using the terminal)


But when i click test i get this message:
MySQL Error# 2002
Can't connect to local mysql server '/var/mysql/mysql.sock' (2)

I Understand that some people have the same problem even when they aren't working with dreamweaver, only php and a text editor. I also tried to this:

cd /var
sudo mkdir mysql
cd mysql
sudo ln -s /private/tmp/mysql.sock mysql.sock


but It didn't work. i log on this way:
/usr/local/mysql/bin/mysql -u root –p

pbmods if you could help me with this again, i would appreciate it. Thank you

pbmods's Avatar
Site Moderator
 
Join Date: Apr 2007
Location: Texas
Posts: 5,435
#2: Oct 13 '07

re: error# 2002 can't connect to local mysql server '/var/mysql/mysql.sock' (2)


Heya, markodilore.

Is MySQL running? Try running this in the Terminal:

Expand|Select|Wrap|Line Numbers
  1. ps -axc | grep mysqld
  2.  
If nothing comes up, then the database server is not running.

Try running this command:
Expand|Select|Wrap|Line Numbers
  1. sudo /usr/local/mysql/bin/mysql.server start
  2.  
The mysql.server file might not be in /usr/local/mysql/bin; it might be in /usr/local/mysql/support-files instead.
Newbie
 
Join Date: Sep 2007
Posts: 7
#3: Oct 13 '07

re: error# 2002 can't connect to local mysql server '/var/mysql/mysql.sock' (2)


Hey pbmobs, thanks for aswering me, again. I wrote that command and i got this message:

Expand|Select|Wrap|Line Numbers
  1. Marko-Dilore-Computer:~ markodilore$ ps -axc | grep mysqld
  2. 252  ??  S      0:00.55 mysqld
So I guess the server is running. Should i write the second part any way. because I keep getting that error message. thanks!
pbmods's Avatar
Site Moderator
 
Join Date: Apr 2007
Location: Texas
Posts: 5,435
#4: Oct 13 '07

re: error# 2002 can't connect to local mysql server '/var/mysql/mysql.sock' (2)


Heya, markodilore.

Try restarting your MySQL server. Issue the following commands:
Expand|Select|Wrap|Line Numbers
  1. > /usr/local/mysql/bin/mysql.server stop
  2. > /usr/local/mysql/bin/mysql.server start
  3.  
As always, mysql.server might be in /usr/local/mysql/support-files instead.
Newbie
 
Join Date: Sep 2007
Posts: 7
#5: Oct 15 '07

re: error# 2002 can't connect to local mysql server '/var/mysql/mysql.sock' (2)


Hey pbmods, thanks a lot. I wrote that code and it did turn mysql off and back on, I did it inmedietely following the other one:

Expand|Select|Wrap|Line Numbers
  1. Last login: Mon Oct 14 09:34:33 on console
  2. Welcome to Darwin!
  3. Marko-Dilore-Computer:~ markodilore$ sudo /usr/local/mysql/support-files/mysql.server stop
  4. Shutting down MySQL.. SUCCESS! 
  5. Marko-Dilore-Computer:~ markodilore$ sudo /usr/local/mysql/support-files/mysql.server start
  6. Starting MySQL SUCCESS! 
  7. Marko-Dilore-Computer:~ markodilore$
But I still keep getting the error message, maybe i shouldn't have turned it back on right away, shoul I try to connect to mysql in a different way or is there something in this directory: '/var/mysql/mysql.sock' that need to be fixed. Please help me, thank you.
Newbie
 
Join Date: Nov 2007
Posts: 1
#6: Nov 10 '07

re: error# 2002 can't connect to local mysql server '/var/mysql/mysql.sock' (2)


I may be mistaken, but I believe that I fixed this by editing the /etc/my.cnf file. There are sections in there for both the mysql CLIENT and the mysql SERVER. At first I mistakenly just changed the first instance of "socket" and not the second one.

For me the fix was to change both occurrences of socket to

socket = /var/lib/mysql/mysql.sock

HTH,

wunderwood
Lives Here
 
Join Date: Sep 2006
Posts: 12,070
#7: Nov 12 '07

re: error# 2002 can't connect to local mysql server '/var/mysql/mysql.sock' (2)


Quote:

Originally Posted by wunderwood

I may be mistaken, but I believe that I fixed this by editing the /etc/my.cnf file. There are sections in there for both the mysql CLIENT and the mysql SERVER. At first I mistakenly just changed the first instance of "socket" and not the second one.

For me the fix was to change both occurrences of socket to

socket = /var/lib/mysql/mysql.sock

HTH,

wunderwood

Yep that can also do it.
Another reason could be that MySQL is looking fo the sock file in /tmp instead. Moving the mysql.sock file from /var/lib/mysql/ to /tmp would do it.
Reply