Go Back   CodingForums.com > :: Server side development > MySQL

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-07-2011, 05:40 AM   PM User | #1
low tech
Regular Coder

 
low tech's Avatar
 
Join Date: Dec 2009
Posts: 740
Thanks: 149
Thanked 67 Times in 67 Posts
low tech is on a distinguished road
mysql command line -- where?

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
__________________
Ask not what can I do for myself, but what can I do for others

"The greatest revenge is to accomplish what others say you cannot do."
~ Unknown
low tech is offline   Reply With Quote
Old 12-07-2011, 06:08 AM   PM User | #2
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,200
Thanks: 59
Thanked 3,996 Times in 3,965 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
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
Code:
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.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote
Users who have thanked Old Pedant for this post:
low tech (12-07-2011)
Old 12-07-2011, 06:30 AM   PM User | #3
low tech
Regular Coder

 
low tech's Avatar
 
Join Date: Dec 2009
Posts: 740
Thanks: 149
Thanked 67 Times in 67 Posts
low tech is on a distinguished road
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

Quote:
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
__________________
Ask not what can I do for myself, but what can I do for others

"The greatest revenge is to accomplish what others say you cannot do."
~ Unknown
low tech is offline   Reply With Quote
Old 12-07-2011, 06:38 AM   PM User | #4
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,200
Thanks: 59
Thanked 3,996 Times in 3,965 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
Quote:
Originally Posted by low tech View Post
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.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote
Old 12-07-2011, 06:55 AM   PM User | #5
low tech
Regular Coder

 
low tech's Avatar
 
Join Date: Dec 2009
Posts: 740
Thanks: 149
Thanked 67 Times in 67 Posts
low tech is on a distinguished road
Hi Old Pedant

Quote:
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
__________________
Ask not what can I do for myself, but what can I do for others

"The greatest revenge is to accomplish what others say you cannot do."
~ Unknown
low tech is offline   Reply With Quote
Old 12-07-2011, 07:23 AM   PM User | #6
low tech
Regular Coder

 
low tech's Avatar
 
Join Date: Dec 2009
Posts: 740
Thanks: 149
Thanked 67 Times in 67 Posts
low tech is on a distinguished road
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
__________________
Ask not what can I do for myself, but what can I do for others

"The greatest revenge is to accomplish what others say you cannot do."
~ Unknown
low tech is offline   Reply With Quote
Old 12-07-2011, 07:56 AM   PM User | #7
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,200
Thanks: 59
Thanked 3,996 Times in 3,965 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
Chto vy govoritye? Pochemu dumaayete stranitsya?

Normal me for perfectly looks it.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote
Old 12-07-2011, 08:15 AM   PM User | #8
low tech
Regular Coder

 
low tech's Avatar
 
Join Date: Dec 2009
Posts: 740
Thanks: 149
Thanked 67 Times in 67 Posts
low tech is on a distinguished road
Quote:
Originally Posted by Old Pedant View Post
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
__________________
Ask not what can I do for myself, but what can I do for others

"The greatest revenge is to accomplish what others say you cannot do."
~ Unknown

Last edited by low tech; 12-07-2011 at 08:18 AM..
low tech is offline   Reply With Quote
Old 12-07-2011, 08:28 AM   PM User | #9
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,200
Thanks: 59
Thanked 3,996 Times in 3,965 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
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!
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote
Old 12-07-2011, 08:34 AM   PM User | #10
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,200
Thanks: 59
Thanked 3,996 Times in 3,965 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
Off to bed. After midnight.

g'night
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote
Old 12-07-2011, 09:44 AM   PM User | #11
low tech
Regular Coder

 
low tech's Avatar
 
Join Date: Dec 2009
Posts: 740
Thanks: 149
Thanked 67 Times in 67 Posts
low tech is on a distinguished road
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
__________________
Ask not what can I do for myself, but what can I do for others

"The greatest revenge is to accomplish what others say you cannot do."
~ Unknown
low tech is offline   Reply With Quote
Old 12-07-2011, 08:26 PM   PM User | #12
guelphdad
Super Moderator


 
guelphdad's Avatar
 
Join Date: Mar 2006
Location: St. Catharines, Ontario Canada
Posts: 2,629
Thanks: 4
Thanked 147 Times in 138 Posts
guelphdad will become famous soon enoughguelphdad will become famous soon enough
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.
guelphdad is offline   Reply With Quote
The Following 2 Users Say Thank You to guelphdad For This Useful Post:
GotToBTru (12-07-2011), low tech (12-07-2011)
Old 12-07-2011, 11:10 PM   PM User | #13
low tech
Regular Coder

 
low tech's Avatar
 
Join Date: Dec 2009
Posts: 740
Thanks: 149
Thanked 67 Times in 67 Posts
low tech is on a distinguished road
Hi guelphdad

Quote:
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
__________________
Ask not what can I do for myself, but what can I do for others

"The greatest revenge is to accomplish what others say you cannot do."
~ Unknown
low tech is offline   Reply With Quote
Old 12-08-2011, 12:34 PM   PM User | #14
guelphdad
Super Moderator


 
guelphdad's Avatar
 
Join Date: Mar 2006
Location: St. Catharines, Ontario Canada
Posts: 2,629
Thanks: 4
Thanked 147 Times in 138 Posts
guelphdad will become famous soon enoughguelphdad will become famous soon enough
Quote:
Originally Posted by low tech View Post
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.
guelphdad is offline   Reply With Quote
Old 12-08-2011, 01:22 PM   PM User | #15
low tech
Regular Coder

 
low tech's Avatar
 
Join Date: Dec 2009
Posts: 740
Thanks: 149
Thanked 67 Times in 67 Posts
low tech is on a distinguished road
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
__________________
Ask not what can I do for myself, but what can I do for others

"The greatest revenge is to accomplish what others say you cannot do."
~ Unknown
low tech is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:38 AM.


Advertisement
Log in to turn off these ads.