PDA

View Full Version : programming with mySQL on mac




snoopy531
Jul 28, 2013, 03:09 PM
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.



kryten2
Jul 28, 2013, 05:34 PM
Try those commands in Terminal without the percent character eg

mysql --console (command)
mysql -u root

Robvas already answered this in your other thread how to download and use my sql on mac os x 10.6.8? (http://forums.macrumors.com/showthread.php?t=1611146)

robvas
Jul 28, 2013, 09:34 PM
You aren't typing the % symbol are you? Only type what comes after that symbol.

sam051
Jul 29, 2013, 06:25 AM
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.

Game64
Jul 29, 2013, 07:55 AM
Usually I'll code my work in PHP and use Sequel Pro to go ahead and handle all the Mysql Management.

Not sure what language you're looking to code it, or are you looking to code actual SQL Procedures?

http://www.sequelpro.com/

http://www.tizag.com/mysqlTutorial/

snoopy531
Jul 29, 2013, 10:34 AM
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
Jul 29, 2013, 12:27 PM
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”.

peoplevoice
Jul 29, 2013, 08:38 PM
Verify if mysql is really running. Check in "Activity Monitor" and search for "mysql".

snoopy531
Aug 1, 2013, 01:28 PM
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.

robvas
Aug 1, 2013, 01:56 PM
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
Aug 1, 2013, 05:12 PM
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.

robvas
Aug 1, 2013, 05:54 PM
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
Aug 5, 2013, 12:28 PM
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 (http://www.mamp.info/en/index.html) + Coda 2 (http://panic.com/coda/).