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.

I have mysql running in my fedora system. I have xampp setup on the system and php projects present in the webspace are working fine. PhpMyAdmin is working fine. echoing phpinfo() in a PHP script also shows mysql enabled. But running mysql connect command

mysql -u[username] -p[password]

Gives this -

bash: mysql: command not found

How do I fix that? Any pointers?

I guess I need to do some pointing (define some path in some file) so that my system knows that mysql is installed. What exactly do I have to do?

Additional Details
This system was someone else's and he is not available here. May be PHP/Mysql was setup already in the system. I just freshly extracted xampp for linux into /opt/lampp/ and have put all the above mentioned things (PHP projects and PhpMyAdmin) there. After doing that I had a socket problem (PhpMyAdmin was not working and showing this)-

#2002 - The server is not responding (or the local MySQL server's socket is not correctly configured) 

I restarted lampp using ./lampp restart but problem remained. Then after turning on system today, I started lampp and everything worked just fine. No project issues anymore only command line Mysql not working

share|improve this question
3  
Is the mysql client installed?? It's possible to install the server without the client. –  Chris S Jan 12 '11 at 14:00
    
@Chris - how do I check that? –  Sandeepan Nath Jan 13 '11 at 7:28

4 Answers 4

up vote 3 down vote accepted

Like Khaled said, the "command not found" issue is likely a problem with the path setup. If you try locate mysql and it comes up with something like /opt/lampp/mysql/bin/mysql, then you need to export PATH=$PATH:/opt/lampp/mysql/bin' to get a simple mysql to work. Additionally, you would probably want to add that to your ~/.bash_profile so that it will get reset the next time you login.

As for the socket issue, your my.cnf file will specify where the socket is located. The mysql client binary is going to look in whatever default location it is compiled with. In the case of Fedora, this is /var/lib/mysql/mysql.sock. If that is in an alternate location, you need to specify that alternate location on the commandline with mysql --socket=/path/to/mysql.sock. This file will also not be present if MySQL is not running, so you may want to check ps output ps -efa|grep -i mysql to verify it is running. As a side note, you will also see the "socket=" on the ps output, which is setting where the server is going to write the socket.

share|improve this answer
    
It worked! great detailed answer... thanks –  Sandeepan Nath Jan 13 '11 at 7:56
    
Just making it more clear for others - "then you need to export PATH=$PATH:/opt/lampp/mysql/bin" means run this in console. –  Sandeepan Nath Jan 13 '11 at 9:28

You need to locate the Mysql binaries folder and add that path to your $PATH variable. You can use find or locate to search for mysql binaries.

share|improve this answer

not familiar with Fedora, but looks like you installed mysql-server, but mysql-client is not installed

share|improve this answer

I am familiar with Fedora, and I think Jet is probably right. They make a distinction between mysql-server and mysql-client.

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.