How to access mysql command line?

Problems with the Linux version of XAMPP, questions, comments, and anything related.

How to access mysql command line?

Postby esender » 16. February 2009 07:51

I just installed XAMPP 1.70 for linux Ubuntu 8.10 32bit.

Phpmysadmin works fine and I do see all the active databases.

However, I need to be able to use the command line, but I get the following error when trying to do so:
Code: Select all
eric@eric-lunix32:~/Desktop$ mysql -u root
The program 'mysql' is currently not installed.  You can install it by typing:
sudo apt-get install mysql-client-5.0
bash: mysql: command not found


So I did the "sudo apt-get install mysql-client-5.0" command to manually install. (Or I think I did it through synaptic?)

Then I started getting this error:
Code: Select all
eric@eric-lunix32:/$ mysql -u root
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)


So I went into Synaptic and uninstalled mysql-client.

Now I get this error:
Code: Select all
eric@eric-lunix32:/$ mysql -u root
bash: /usr/bin/mysql: No such file or directory



So how do I access mysql through the command line?
Thanks
esender
 
Posts: 10
Joined: 15. January 2009 00:40

Re: How to access mysql command line?

Postby Wiedmann » 16. February 2009 08:05

I need to be able to use the command line

Start with reading the manual for your "command line" (bash). Especially chapter 3.7.2:
http://www.gnu.org/software/bash/manual ... -Execution

So how do I access mysql through the command line?

Start the client with its full pathname. (Because you want the XAMPP one, not some from your system.)
Wiedmann
AF Moderator
 
Posts: 17102
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Re: How to access mysql command line?

Postby esender » 16. February 2009 09:39

Wiedmann wrote:
I need to be able to use the command line

Start with reading the manual for your "command line" (bash). Especially chapter 3.7.2:
http://www.gnu.org/software/bash/manual ... -Execution

So how do I access mysql through the command line?

Start the client with its full pathname. (Because you want the XAMPP one, not some from your system.)


Thanks... but after reading it I am a bit confused still.

I am brand new to linux (I actually spent the full day yesterday setting up my VirtualBox, trying to figure out things like how to install a basic problem haha).

Anyway, could you or someone break it down into simpler steps---To be honest, I am actually unsure if that guide you sent me addresses my specific issue. The guide you sent me seems to be about how to execute a command, in general.

Thanks
esender
 
Posts: 10
Joined: 15. January 2009 00:40

Re: How to access mysql command line?

Postby esender » 16. February 2009 10:27

Wiedmann wrote:Start the client with its full pathname. (Because you want the XAMPP one, not some from your system.)


Do you mean I should perform the "mysql -u root" command while I am located inside the "mysql" directory?

I believe it did that (unless I was in the wrong mysql directory). It didn't work. Same thing.
Code: Select all
eric@eric-lunix32:/opt/lampp/var/mysql$ mysql -u root
The program 'mysql' is currently not installed.  You can install it by typing:
sudo apt-get install mysql-client-5.0
bash: mysql: command not found
eric@eric-lunix32:/opt/lampp/var/mysql$
esender
 
Posts: 10
Joined: 15. January 2009 00:40

Re: How to access mysql command line?

Postby Wiedmann » 16. February 2009 10:30

I am brand new to linux

It's the same like in Windows... Only one difference:
"." (the current directory) is not part of the search path in Linux.

I am actually unsure if that guide you sent me addresses my specific issue.

I'm sure ;-)

The guide you sent me seems to be about how to execute a command, in general.

I think that's a good starting point for you:
--> If you just type "command param" in the shell, nobody (the shell) knows, that there is such a command somewhere in the XAMPP directories. And the shell is not searching in the XAMPP directorys.

You don't know how your shell is searching and starting commands, and that's the reason you can't start "mysql" with the above command. If you understand that chapter, you know the answer for your question.

could you or someone break it down into simpler steps

It's the same like with the command you start "lampp".

a) put "/opt/lampp/bin" in your "$PATH"
b) or use "cd /opt/lampp/bin && ./mysql -u root"
c) or use "/opt/lampp/bin/mysql -u root"
Wiedmann
AF Moderator
 
Posts: 17102
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Re: How to access mysql command line?

Postby esender » 16. February 2009 10:34

Wiedmann wrote:a) put "/opt/lampp/bin" in your "$PATH"
b) or use "cd /opt/lampp/bin && ./mysql -u root"
c) or use "/opt/lampp/bin/mysql -u root"


Sweet!

Thanks. Linux sure has quite a learning curve, but I am excited to see the powerful new options it gives me over windows. Honestly, I can't stand how apache just crashes every 2 seconds on vista.

Much appreciated!
esender
 
Posts: 10
Joined: 15. January 2009 00:40

Re: How to access mysql command line?

Postby Wiedmann » 16. February 2009 10:41

but I am excited to see the powerful new options it gives me over windows

Oh, with Windows you must also use one of these three...:
a) put "C:\xampp\mysql\bin" in your "%PATH%"
b) or use "cd C:\xampp\mysql\bin && .\mysql -u root"
c) or use "C:\xampp\mysql\bin\mysql -u root"

But you have a fourth method in Windows:
d) or use "cd C:\xampp\mysql\bin && mysql -u root"
Wiedmann
AF Moderator
 
Posts: 17102
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany


Return to XAMPP for Linux

Who is online

Users browsing this forum: No registered users and 23 guests