Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

snoopy531

macrumors newbie
Original poster
Sep 26, 2011
8
0
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.
 

robvas

macrumors 68040
Mar 29, 2009
3,240
629
USA
You aren't typing the % symbol are you? Only type what comes after that symbol.
 

sam051

macrumors newbie
Jul 18, 2013
2
0
Noida
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.
 

snoopy531

macrumors newbie
Original poster
Sep 26, 2011
8
0
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
 

robvas

macrumors 68040
Mar 29, 2009
3,240
629
USA
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”.
 

snoopy531

macrumors newbie
Original poster
Sep 26, 2011
8
0
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.
 
Last edited:

robvas

macrumors 68040
Mar 29, 2009
3,240
629
USA
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.
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

-also when I enter:
mysql> whereis mysql
why do I get this symbol and not the location?:
->
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.
 

snoopy531

macrumors newbie
Original poster
Sep 26, 2011
8
0
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.
 
Last edited:

robvas

macrumors 68040
Mar 29, 2009
3,240
629
USA
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.
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.
 

Peterk12

macrumors newbie
Nov 28, 2011
10
59
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.