Help with terminal in os x (Trying to run MySQL)

Discussion in 'macOS' started by whitespaces, Jul 28, 2009.

  1. whitespaces macrumors newbie

    Jun 23, 2009
    Hello all,

    I've just bought a Mac from being a PC user for 15yrs+ and I've been trying to get mySQL to work with much frustration.

    I'm an expert user in MS DOS but never used UNIX/Terminal etc. before so I'm a newby here. Basically all I'm trying to do is RUN A PROGRAM from terminal!!! I've installed MySQL and want to simply open it. I go to folder with :
    cd /usr/local/mysql/bin/

    No probs. I can EVEN open it using:
    open mysql

    but all the guides tell me I need to be using arguments - which by using open the terminal thinks I'm trying to use the OPEN command arguments?? Surely I should just be able to type
    mysql --user=root

    blah blah but I always get the following error:
    -bash: mysql: command not found

    Am I doing something wrong?? And what is bash anyway??

    Many thanks for any help!
    (This is just the beginning (and I'm sure not the end) of the problems I've been having getting mySQL to work - it was so simple on PC arrghhhh)
  2. parapup macrumors 65816


    Oct 31, 2006
    Just like MS-DOG UNIX has the concept of PATH. Depending on which shell you are using you need to use a command to tell the shell to put a directory in the PATH in order to be able to invoke programs/scripts from that folder from anywhere.

    Assuming you are using standard OSX bash prompt -
    export PATH=/usr/local/mysql/bin:$PATH 
    should allow you to do that. Notice that directories are separated by a ":".
  3. whitespaces thread starter macrumors newbie

    Jun 23, 2009
    Thanks Parap, the problem is not that I can't invoke the mysql program from another directory though, it's that I can't even invoke it when I'm in THAT directory. I'm not bothered about setting it up in the PATH yet - until I can get it to work from within the working folder.

    I did try your export command which appeared to work, but then still nothing happens.

    Many thanks for any help
  4. parapup macrumors 65816


    Oct 31, 2006
    If you are in that directory, and cannot invoke a command, you need to do it thusly -

    Notice the ./ before the command - it tells the shell to execute it from current path. ( . is current directory and it is not in PATH by default for good reasons)

    Also what do you mean when you say "nothing happens" when you try the export and then run mysql? Some programs need to run as root, some disappear to background after being run - so even though the command is running it will go background and do it's job or it may error out if it wasn't run as root. You need to check mysql documentation for OSX to sort that one out.
  5. plinden macrumors 68040


    Apr 8, 2004
    Did you install the MySQL preference pane? You can start and stop it from there if that's all you want to do.

    Edit: have you actually started the mysql server? The mysql command is the client command. You start the server as an admin user with:
    sudo /user/local/mysql/mysql_safe

    ... or use the pref pane.
  6. whitespaces thread starter macrumors newbie

    Jun 23, 2009
    Woohoo Parap, you're a star. The following worked a treat:
    It's bizarre why you have to do that though to me (though I am a unix numbty at the moment)

    The other thing I was on about was just about the export command - not to worry. This is just what I needed Parap - thanks. I know it prob sounds v easy just putting ./mysql but I have skimmed through unix/os x terminal tutorials and found nothing explaining this.

    (I'm just too used to DOS.. On a side note - which is better DOS or Mac OS X Terminal/bash/unix or whatever it is?)

  7. parapup macrumors 65816


    Oct 31, 2006
    Don't feel bad - the use of ./ is a very common problem new UNIX users face.

    The reason you have to use ./ is that UNIX normally does not put "." in the PATH environment variable for security reasons. Since "." denotes current directory - it can take form of any directory you are in - which is dangerous.

    See this link if you are further interested on the topic.

    On the question of DOS vs UNIX - that's not even a question I am afraid :D - as I don't consider DOS a OS and it is far too outdated. A better question would be what is better Windows or UNIX - that's a matter of personal taste, but I find UNIX to be better.
  8. whitespaces thread starter macrumors newbie

    Jun 23, 2009
    ahh many thanks parapup. It all makes sense now.

    I'm going to have to invest in a UNIX book to become ah fait with this I think.

    thanks for your help parapup.

Share This Page