Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 15 of 15
  1. #1
    Regular Coder low tech's Avatar
    Join Date
    Dec 2009
    Posts
    852
    Thanks
    173
    Thanked 94 Times in 94 Posts

    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
    "The greatest revenge is to accomplish what others say you cannot do."
    ~ Unknown

    I used to be indecisive, but now I'm not so sure.

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,542
    Thanks
    77
    Thanked 4,381 Times in 4,346 Posts
    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.

  • Users who have thanked Old Pedant for this post:

    low tech (12-07-2011)

  • #3
    Regular Coder low tech's Avatar
    Join Date
    Dec 2009
    Posts
    852
    Thanks
    173
    Thanked 94 Times in 94 Posts
    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
    "The greatest revenge is to accomplish what others say you cannot do."
    ~ Unknown

    I used to be indecisive, but now I'm not so sure.

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,542
    Thanks
    77
    Thanked 4,381 Times in 4,346 Posts
    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.

  • #5
    Regular Coder low tech's Avatar
    Join Date
    Dec 2009
    Posts
    852
    Thanks
    173
    Thanked 94 Times in 94 Posts
    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
    "The greatest revenge is to accomplish what others say you cannot do."
    ~ Unknown

    I used to be indecisive, but now I'm not so sure.

  • #6
    Regular Coder low tech's Avatar
    Join Date
    Dec 2009
    Posts
    852
    Thanks
    173
    Thanked 94 Times in 94 Posts
    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
    "The greatest revenge is to accomplish what others say you cannot do."
    ~ Unknown

    I used to be indecisive, but now I'm not so sure.

  • #7
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,542
    Thanks
    77
    Thanked 4,381 Times in 4,346 Posts
    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.

  • #8
    Regular Coder low tech's Avatar
    Join Date
    Dec 2009
    Posts
    852
    Thanks
    173
    Thanked 94 Times in 94 Posts
    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
    Last edited by low tech; 12-07-2011 at 08:18 AM.
    "The greatest revenge is to accomplish what others say you cannot do."
    ~ Unknown

    I used to be indecisive, but now I'm not so sure.

  • #9
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,542
    Thanks
    77
    Thanked 4,381 Times in 4,346 Posts
    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.

  • #10
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,542
    Thanks
    77
    Thanked 4,381 Times in 4,346 Posts
    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.

  • #11
    Regular Coder low tech's Avatar
    Join Date
    Dec 2009
    Posts
    852
    Thanks
    173
    Thanked 94 Times in 94 Posts
    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
    "The greatest revenge is to accomplish what others say you cannot do."
    ~ Unknown

    I used to be indecisive, but now I'm not so sure.

  • #12
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,634
    Thanks
    4
    Thanked 148 Times in 139 Posts
    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.

  • The Following 2 Users Say Thank You to guelphdad For This Useful Post:

    GotToBTru (12-07-2011), low tech (12-07-2011)

  • #13
    Regular Coder low tech's Avatar
    Join Date
    Dec 2009
    Posts
    852
    Thanks
    173
    Thanked 94 Times in 94 Posts
    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
    "The greatest revenge is to accomplish what others say you cannot do."
    ~ Unknown

    I used to be indecisive, but now I'm not so sure.

  • #14
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,634
    Thanks
    4
    Thanked 148 Times in 139 Posts
    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.

  • #15
    Regular Coder low tech's Avatar
    Join Date
    Dec 2009
    Posts
    852
    Thanks
    173
    Thanked 94 Times in 94 Posts
    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
    "The greatest revenge is to accomplish what others say you cannot do."
    ~ Unknown

    I used to be indecisive, but now I'm not so sure.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •