...

View Full Version : mysql command line -- where?



low tech
12-07-2011, 05:40 AM
Hi all

This is probably a dumb question but still here goes.

I'm using xampp and I can use php admin ok

but the book i'm learning from has many examples that refer to using the mysql command line

for example

mysql> describe test_table;

where do I enter this type of command?

I opened 'shell' from xampp and entered it from there but that didn't work.

I've entered it from C:\ prompt and that didn't work.

The whole chapter has examples that begin with enter mysql> whatever.

Where do I find this elusive mysql prompt?

any help appreciated

LT

Old Pedant
12-07-2011, 06:08 AM
You probably just don't have mysql set up in your system path. If the xampp installation doesn't do that, it's a *HUGE* oversight.

First thing to do is figure out where in the heck xampp installed MySQL.

I installed MySQL "standalone" (as you know, I don't use PHP, so I'm using it with ASP and ASP.NET code). And all the ".exe" files for me are in
C:\Program Files\MySQL\MySQL Server 5.5\bin

If you can't find it any other way, just ask Windows to search for "mysql.exe". If there's more than one, look for the one that's in the same directory as many other mysql executables, such as "mysqldump.exe" and "mysqlcheck.exe".

Once you find it, remember the path to it

Now, you *could* then run it from the DOS command window by typing

C:\Program Files\MySQL\MySQL Server 5.5\bin\mysql

That is, give the full path to the executable.

But a better way is to change the environment variable "PATH" on your machine.

How you do that depends on what version of Windows you are using.

I'll show you how to do it on Vista:

(a) Bring up your Control Panel
(b) Click on the SYSTEM control panel icon
(c) Find "Advanced System Settings" (usually on the left side) and click on it
(d) Find the button labeled "Environment Variables" and click on it.
(e) You should see both "User variables for [your user name" and "System variables". You can modify PATH in either, but better is to do it in "System Variables".
(f) So scroll down to PATH in the "Variable" column and then click on the "EDIT" button.
(g) The current path will appear in a very tiny text box. I recommend that you copy what is there into a NOTEPAD window, so you can see what is there now.
(h) If the path to your MySQL "bin" directory isn't there, add it. Then copy/paste back into the silly text box.
(i) Click OK.

YOu are done. Next time you bring up a command window, you should indeed be able to type just "mysql".

FWIW, my own PATH variable right now contains this:
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\Python;C:\Program Files\QuickTime\QTSystem\;C:\Program Files\MySQL\MySQL Server 5.5\bin;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\

And as you can see, there is the path to the MyQL bin directory.

p.s.: Unless your system is configured weirdly, %SystemRoot% is of course just "c:\windows". If you care.

low tech
12-07-2011, 06:30 AM
Hi Old Pedant

I did indeed find the command line tool here

C:\Program Files\xampp\mysql\bin

all the other mysql files are there too such mysql_config etc (around 28 files in total)

anyway


a better way is to change the environment variable "PATH" on your machine.

I'll have a go at this.

I'm guessing that using the command line is the better way to manipulate a database?


Thanks for detailed explanation

LT

Old Pedant
12-07-2011, 06:38 AM
I'm guessing that using the command line is the better way to manipulate a database?

Define "better"?

Yes, I think so. You have complete control. You can do anything the MySQL is capable of, not just the things that the person who created whatever tool you are using thought you might need.

When I use SQL Server, even though I have MS's nice fancy interface to play with, 90% of the time I just use the command window (see? MS at least gives me one of those, right in the fancy tool, so I don't have to go back and forth). But there are times when a tool is handy. Maybe tomorrow I'll think of a couple.

low tech
12-07-2011, 06:55 AM
Hi Old Pedant


Define "better"?

Accepts all mysql commands such as CONSTRAINT which if I remember correctly phpadmn doesn't accept.

Extra options that phpmyadmin doesn't have I guess.

I've got a couple of chapters on it so there must be something to it hahha

oh done the PATH btw time to try it out.

LT

low tech
12-07-2011, 07:23 AM
Hi Old Pedant

Ah ha

Using the shell form xampp I entered mysql -h hostname -u username -p -D database

and eventually I got

mysql>

prompt

from there I did SHOW databases;

and success -- similar output to book

feels foreign at the moment though

LT

Old Pedant
12-07-2011, 07:56 AM
Chto vy govoritye? Pochemu dumaayete stranitsya?

Normal me for perfectly looks it.

low tech
12-07-2011, 08:15 AM
Chto vy govoritye? Pochemu dumaayete stranitsya?

Normal me for perfectly looks it.


hahahahah what?

Do you mean (to translate)

it's perfectly normal for me (you) because I (you) always look at it ?

what language is that? Russian?

LT

Old Pedant
12-07-2011, 08:28 AM
Da. But in English letters. Phonetic.

"What are you saying? Why do you think [it is] strange?"

I'm not sure I got "strange" right. I learned Russian 45+ years ago, and I just don't get much chance to use it nowadays.

Hmmm...just checked it with "Babelfish" and I think it might be right. Maybe my word means more like "a stranger" (noun) than "strange" the adjective. But that's not too bad for 45 years!

Old Pedant
12-07-2011, 08:34 AM
Off to bed. After midnight.

g'night

low tech
12-07-2011, 09:44 AM
Hi Old Pedant

Prastite, ya ne savsem ponyal, chto vy skazali.

Kak eto skazat' paangliyski?

Dobroy nochi!


The last time I accessed anything from the prompt I'm pretty sure I did some damage to my old pc hahhaa It was dangerous for me to learn a few ms dos commands hahahhaa

LT

guelphdad
12-07-2011, 08:26 PM
If you look at phpmyadmin you will see a tab marked SQL. there you can enter any command that you can enter at the mysql prompt. no exceptions.

you will find though that in phpmyadmin (because you are essentially in the mysql shell already) that you can't run mysqldump. you can run that from your windows/unix shell because you are technically at the command line. So instead of running mysql to bring up the mysql client, you can run mysqldump to run that program.

I do find that phpmyadmin has other shortfalls though, importing files to be one example, that are much easier in other programs.

low tech
12-07-2011, 11:10 PM
Hi guelphdad


If you look at phpmyadmin you will see a tab marked SQL. there you can enter any command that you can enter at the mysql prompt. no exceptions.

Thanks. yeh I've used that tab before to make tables. I think I was using it wrongly when I was looking for the command line prompt. I entered commands that were incorrect but I think I understand now.

Anyway my system was not configured correctly (see post 2) but it's ok now so I can follow as the book instructs now and obviously compare the result I get.

I'm pretty sure phpadmin can do all need at my level but it's good to know all ways.

LT

guelphdad
12-08-2011, 12:34 PM
I'm pretty sure phpadmin can do all need at my level but it's good to know all ways.

LT

oh yes absolutely, i was just letting you know that phpmyadmin does offer the sql tab where you have a bit more "freedom" when coding, rather than the point and click or form fill out of one of the other tabs.

Learning the command line is good, don't want to sway you from it.

low tech
12-08-2011, 01:22 PM
Hi guelphdad

Yeh, I appreciate you drawing my attention to the sql tab and in fact it did help to expand my understanding of choices available.

Thanks

LT



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum