Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Not sure how to fix this but here is the description. I can run the command to a Lampstack MySQL installation like this and it works:

/opt/lampstack/mysql/bin/mysql -u root -p

And my PATH variable has this path in it, but yet this command doesn't work:

mysql -u root -p

Gives this error:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

The command asks for password but then gives the error.

I should note as well that running phpMyAdmin works fine at localhost:9090 with root and correct password.

Presumably, there are two MySQL installations getting confused, because I can run each command with --version and I get two distributions: 5.5.32 and 5.5.21.

This is a problem because I'm trying to use the Lampstack MySQL installation for a Django project. I have this configuration running on Windows but in an attempt to duplicate the environment on Ubuntu I've gotten a bit mixed up.

What is the best way to resolve this issue without removing the core MySQL on the Ubuntu system (and use the Lampstack one)?

NOTE

I discovered that the /var/run/mysqld/mysqld.sock doesn't actually exist and nor does the directory /var/run/mysqld. I'm not sure how to fix this so any assistance is appreciated.

share|improve this question
2  
The order of $PATH matters. It will use the first one it finds. –  Aaron Copley Aug 7 '13 at 19:18
    
thanks, trying this now... –  nicorellius Aug 7 '13 at 19:19

2 Answers 2

up vote 3 down vote accepted

Check in which order in the PATH your /opt/lampstack/mysql/bin/. Is it before or after the native mysqlbinary? Run a

which mysql

to confirm. Make sure that /opt/lampstack/mysql/bin/ appears BEFORE the other path.

share|improve this answer
    
This seems to have worked. Thank you. I will accept the answer as soon as I can. In the meantime, I'm still getting connection errors through the server. What is the best way to flush this out so it uses the default binary in all places (still getting errors referring to /var/run/mysqld/mysqld.sock)? The command mysql -u root -p is now working... –  nicorellius Aug 7 '13 at 19:27
    
Depending on the case, I'd probably prepend the PATH in /etc/profile.d/custom_mysql.sh file, like put a line containing something like export PATH=/opt/lampstack/mysql/bin/:$PATH at the beginning of the file. Beware though that then the OS will probably default to using this new mysql aswell, which might break things, so I guess for you the best way is to have a check in there to, for example if there is a specific user only who should use this binary then add a check, or add the stanza to ~user/.bashrc (or what ever shell that user is using) –  Petter H Aug 7 '13 at 19:56
    
What I ended up doing is actually reinstalled MySQL outside my Lampstack and then just dumped the db and created a new one. This way I co uld use the default socket without worrying about it... Thanks. –  nicorellius Aug 7 '13 at 22:05

When trying to determine if something is accessible on your $PATH it's always best to use the command type.

$ type mysql

Example

$ type mysql
mysql is /usr/bin/mysql
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.