MAMP, MySQL, TextMate snakepit

I’ve battled my way so far and I’m sure the answer is staring me in the face — but I need your help! Using MAMP, I can’t get connected to MySQL.

I’ve purchased "PHP and MySQL Web Development (4th ed.) by Welling & Thomson and set up MAMP. Got through the first section of the book on PHP quite well (not the monster I had envisioned). To help me with my syntax, I adopted TextMate. I’m learning to write clean PHP code. So far, so good.

Moving into the next section of the book (MySQL), I’ve hit a roadblock that I can’t seem to get around. MySQL is running as is evidence by the fact that I used phpMyAdmin to create the tutorial database (rather than writing lines of code). Thinking I was being clever in saving time with phpMyAdmin (which I’ll have to use with my ISP), I skipped over what I thought would be an easy connection to MySQL. Well for me, not so easy (so far) — arg!

I launched Terminal and attempted to put in the log in sequence the book suggests: “To log in to MySQL, go to a command-line interface on your machine and type the following:”
mysql -h hostname - u username -p

My understanding of MAMP is that the “hostname” would be “localhost” or “localhost:8889” and the “username” would be “root.” Errr — the feedback I receive from Terminal is
-bash: mysql: command not found

I tried using the suggestions found on MAMP’s “Welcome to MAMP” page to connect to the MySQL server using either my own scripts or a UNIX socket. They don’t seem to work either.

Anybody have any suggestions for what it is I’m doing (or have set) wrong?


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

At 21:14 -0500 29/12/08, James Brouwer wrote:

I launched Terminal and attempted to put in the log in sequence the
book suggests: “To log in to MySQL, go to a command-line interface
on your machine and type the following:”
mysql -h hostname - u username -p

My understanding of MAMP is that the “hostname” would be “localhost”
or “localhost:8889” and the “username” would be “root.” Errr ‹ the
feedback I receive from Terminal is
-bash: mysql: command not found

In Terminal a command has to either exist in a folder that’s included
in the value of the PATH variable or be specified with a full
pathname. On my system (which isn’t MAMP) that would be
/usr/local/mysql/bin/mysql
so the full command would be
/usr/local/mysql/bin/mysql -h localhost -u root -p

If you’re into editing ~/.profile or ~/.bashrc and adding
:/usr/local/mysql/bin
(or wherever MAMP puts it) to the PATH setting, that would make mysql
just work. Alternatively, if you need to use the mysql command many
time in just one terminal session, entering
alias mysql=/usr/local/mysql/bin/mysql
(or wherever) on opening that terminal will also make it just work.

David


David Ledger - Freelance Unix Sysadmin in the UK.
HP-UX specialist of hpUG technical user group (www.hpug.org.uk)
email@hidden
www.ivdcs.co.uk


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

James,

Have you started mysql?

you can find it’s status using: mysql status

HTH

On Dec 30, 2008, at 2:14 AM, James Brouwer wrote:

I’ve battled my way so far and I’m sure the answer is staring me in
the face — but I need your help! Using MAMP, I can’t get connected
to MySQL.

I’ve purchased "PHP and MySQL Web Development (4th ed.) by Welling &
Thomson and set up MAMP. Got through the first section of the book
on PHP quite well (not the monster I had envisioned). To help me
with my syntax, I adopted TextMate. I’m learning to write clean PHP
code. So far, so good.

Moving into the next section of the book (MySQL), I’ve hit a
roadblock that I can’t seem to get around. MySQL is running as is
evidence by the fact that I used phpMyAdmin to create the tutorial
database (rather than writing lines of code). Thinking I was being
clever in saving time with phpMyAdmin (which I’ll have to use with
my ISP), I skipped over what I thought would be an easy connection
to MySQL. Well for me, not so easy (so far) — arg!

I launched Terminal and attempted to put in the log in sequence the
book suggests: “To log in to MySQL, go to a command-line interface
on your machine and type the following:”
mysql -h hostname - u username -p

My understanding of MAMP is that the “hostname” would be “localhost”
or “localhost:8889” and the “username” would be “root.” Errr — the
feedback I receive from Terminal is
-bash: mysql: command not found

I tried using the suggestions found on MAMP’s “Welcome to MAMP” page
to connect to the MySQL server using either my own scripts or a UNIX
socket. They don’t seem to work either.

Anybody have any suggestions for what it is I’m doing (or have set)
wrong?


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

If its any help and as an alternative to phpMyAdmin supplied with MAMP.

And a friendlier interface for general database editing especially to get you started, Try downloading Sequel Pro (free) http://code.google.com/p/sequel-pro

You can then connect to your local MAMP database with Sequel Pro using:-

Host: localhost
User: root
Password: root
Database: (name of your database)
Socket: /Applications/MAMP/tmp/mysql/mysql.sock

As Mike said, make sure that MAMP is up and running.

On 30 Dec 2008, at 2:14 am, James Brouwer wrote:

I’ve battled my way so far and I’m sure the answer is staring me in the face — but I need your help! Using MAMP, I can’t get connected to MySQL.

David Owen ::
Freeway Friendly Web Hosting and Domains
http://www.ineedwebhosting.co.uk

David & Mike,

Thanks for your suggestions (I’ll definitely check out Sequel Pro). After spending a few more hours pounding my head against my desktop (both on screen and more literally), I found an answer buried deep in another forum.

The answer appears to be putting the following into the Terminal program’s (the Apple program Terminal that is) command line:

/Applications/MAMP/Library/bin/mysql -u username -p

I had previously verified that MAMP was running (and had used phpMyAdmin). While the book’s instructions worked just fine for PHP code, I had been stuck simply getting MySQL to launch (outside of phpMyAdmin that is). Clearly, MAMP stores MySQL in a different location, hence a different path to get to it.

The frustrating part of this is that even the MAMP instructions weren’t entirely helpful for the Mac OSX. If you use the directory path and the -u prompt above (substituting your actual User: name for username), you shouldn’t have any problem. Terminal will answer back:

Enter password:

When you enter your Password (the request was prompted by the -p you entered and is easily found after launching phpMyAdmin from MAMP’s MySQL page), Terminal will respond with:

Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 5.0.41 Source distribution

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.

mysql>

You are now in MySQL running under MAMP. Seems easy — once you know how to read Sanskrit!

Thanks for your assistance and patients with a neophyte. Having spent some time digging around other support boards, I have to say posters to FreewayTalk are among the most genuinely kind, thoughtful, and helpful folks around. Have a very Happy New Year! I’m certain to be back in 2009 with some more conundrums.


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options