programming with mySQL on mac

Discussion in 'Mac Programming' started by snoopy531, Jul 28, 2013.

  1. macrumors newbie

    Joined:
    Sep 26, 2011
    #1
    Hi,

    I would please like to know how can I start coding with mySQL. I have the mac osx 10.6.8 and mySQL Workbench. I downloaded -MySQL Database 5.6.12 DMG and started mysql Server from preference. After the download, I entered in the terminal %mysql --console (command) and after, I got a message: no such job. After that, I entered %mysql -u root and I got also the same message. Usually from a book, I should be able to start coding and I would see mysql> after entering on of those 2 commands in the terminal. I spend hours trying to figure out why that doesn't work and I am still at the same place.

    Thank you for your help.
     
  2. kryten2, Jul 28, 2013
    Last edited: Jul 28, 2013

    macrumors 6502a

    Joined:
    Mar 17, 2012
    Location:
    Belgium
    #2
  3. macrumors 68000

    Joined:
    Mar 29, 2009
    Location:
    USA
    #3
    You aren't typing the % symbol are you? Only type what comes after that symbol.
     
  4. macrumors newbie

    Joined:
    Jul 18, 2013
    Location:
    Noida
    #4
    Programming with mySQL is really best plan for programming development. I think if you use PHP then this is the biggest plan. Magento CMS is the best for dynamic website and you can get templates via conversion of simple layout.
     
  5. macrumors member

    Joined:
    Jan 21, 2011
    Location:
    East Bay, California
    #5
  6. thread starter macrumors newbie

    Joined:
    Sep 26, 2011
    #6
    Hi again,

    I also tried without the % and I get (command not found) message. I would like to add rows in the database by using the terminal without using PHP.

    Thank you
     
  7. macrumors 68000

    Joined:
    Mar 29, 2009
    Location:
    USA
    #7
    The command:

    whereis mysql

    Will tell you where mysql is installed. You can start it by using the full path to the command.

    http://dev.mysql.com/doc/refman/5.5/en/macosx-installation-notes.html

    You might want to add aliases to your shell's resource file to make it easier to access commonly used programs such as mysql and mysqladmin from the command line. The syntax for bash is:

    alias mysql=/usr/local/mysql/bin/mysql
    alias mysqladmin=/usr/local/mysql/bin/mysqladmin

    Even better, add /usr/local/mysql/bin to your PATH environment variable. You can do this by modifying the appropriate startup file for your shell. For more information, see Section 4.2.1, “Invoking MySQL Programs”.
     
  8. macrumors member

    Joined:
    Aug 19, 2008
    #8
    Verify if mysql is really running. Check in "Activity Monitor" and search for "mysql".
     
  9. snoopy531, Aug 1, 2013
    Last edited: Aug 1, 2013

    thread starter macrumors newbie

    Joined:
    Sep 26, 2011
    #9
    Hi again,

    Thanks to you,
    -I found mysql using in the /usr/local/mysql/bin folder and I tried some commands from the mysql terminal. For exemple;
    mysql> SELECT VERSION(), CURRENT_DATE();
    mysql> SHOW DATABASE;
    and I get the right answers , but when I enter the following one, I get a mistake;
    mysql> CREATE DATABASE produce;
    the mistake is:
    ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'produce'
    Can you please tell me why this is wrong? Is it because I don't use a username and a password. I still have problems making that.

    -When I enter the following command, nothing special happens:
    mysql -u root
    and I don't get this message like I should: Welcome to the MySQL monitor. Commands end with; or g

    and SELECT_VERSION(), CURRENT_DATE; won't work anymore after that command. I get the following mistake;
    ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'mysql -u root

    -also when I enter:
    mysql> whereis mysql
    why do I get this symbol and not the location?:
    ->


    Thank you very much.
     
  10. macrumors 68000

    Joined:
    Mar 29, 2009
    Location:
    USA
    #10
    Read up on MySQL users and permissions. This page shows how to create a user and give it access

    http://dev.mysql.com/doc/refman/5.1/en/adding-users.html

    You're entering a Linux command (whereis) and not a MySQL command. You need to exit MySQL (just type 'exit') and go back to the Linux command prompt to use that command.
     
  11. snoopy531, Aug 1, 2013
    Last edited: Aug 1, 2013

    thread starter macrumors newbie

    Joined:
    Sep 26, 2011
    #11
    I don't have or use linux and I installed mysql only for Mac os x. From the MySQL users and permissions page, I can't use shell> mysql --user=root mysql . Is that specifically a Linux command? Can we use mySQL on Mac if we don't have Linux? On Mac os x, I can't find nowhere a terminal which begins with shell>. I tried to enter mysql --user=root mysql from the /usr/local/mysql/bin mysql and I only get -> symbol without any other message.

    I also tried mysql> CREATE USER 'monty'@'localhost' IDENTIFIED BY 'some_pass';
    and I had this error :
    ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'mysql --user=root mysql
    CREATE USER 'monty'@'localhost' IDENTIFIED BY 'some_pass' at line 1

    I need help on this please.
    Thank you very much.
     
  12. macrumors 68000

    Joined:
    Mar 29, 2009
    Location:
    USA
    #12
    When I said 'linux command' I meant unix command, which is fine for OS X - you're just entering the wrong command at the wrong place.

    The mysql prompt looks like this:

    >

    The reason you got the > prompt after typing in 'mysql --user=root mysql' is that it's expecting you to enter a MySQL command. You can just enter a semicolon ; by itself and it will end that command and you can enter a new one.
     
  13. macrumors newbie

    Joined:
    Nov 28, 2011
    #13
    If you want a GUI approach (which you probably don't, as the nature of your question involves the terminal), you can try using Mamp + Coda 2.
     

Share This Page