
Getting command line access to PHP and MySQL running MAMP on OSX
If you have MAMP installed on your Mac OS X box, you're probably going to want command line access to those applications at some point. Assuming you're running a default install you'll run into difficulty when you type php or mysql without logging into the appropriate directory. In MAMP the directories are as follows:
/Applications/MAMP/bin/php5/bin/php /Applications/MAMP/Library/bin/mysql
Rather than referencing those full paths every time you'll probably want to include them in the PATH. You can do this by editing your .profile file. (You can get to the directory where this lives by typing cd).
Use a text editor to open up .profile and change the following line:
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
To include the additions to the $PATH like so:
export PATH=/Applications/MAMP/Library/bin/:/Applications/MAMP/bin/php5/bin/:/opt/local/bin:/opt/local/sbin:$PATH
You'll probably need to make the shell reload your profile like so:
. ./.profile
Also if you have any problems connecting to mysql you may need to run the following command:
sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /tmp/mysql.sock
Thanks to the following blog entries:
http://www.tech-recipes.com/rx/2621/os_x_change_path_environment_variab…
Comments
Thnxs :) That helped!
Thu, 09/17/2009 - 16:01
Thanks for the post on CLI access with MAMP. Saved me some time.
Take care,
Bruce
Fri, 12/18/2009 - 05:11
Thanks this is also work for me and save me a lot of time.
Sun, 12/27/2009 - 21:51
I am unable to find .profile under Snow Leopard. Upon opening Terminal, I have tried the command "open .profile" Telnet replies, "The file /Users/Matthew/.profile does not exist." Any suggestions?
Mon, 12/28/2009 - 15:50
Hmm... I'm not running Snow Leopard, but you should be able to get to your home directory by typing:
cd
Once there try typing:
ls -al
That will give you a list of all of the files in that directory, including files that start with the . character that are otherwise hidden.
Thu, 01/07/2010 - 18:38
To anyone who is having problems getting Zend_Tool working on their MAC OS X (10.6) in Terminal, this is how to solve the problem.
Step 1
---
Download the Zend Framework to your downloads folder. Once downloaded, rename the folder ZendFramework
Step 2
---
Open Terminal and type: sudo cp -r ~/Downloads/ZendFramework /usr/local/ZendFrameworkCli
Step 3
---
In Terminal, type: open ~/.bash_profile
Note: If file is not found...
---
Open the application TextEdit. Create a new file and make sure you are typing in plain text only. Type the following: alias zf=/usr/local/ZendFrameworkCli/bin/zf.sh
Save and exit TextEdit
Step 4
---
In Terminal, type: zf show version
Done!
Wed, 08/11/2010 - 12:25
Thought I would update the instructions here for MAMP 1.9
The path has changed to
/Applications/MAMP/bin/php5.3
/Applications/MAMP/bin/php5.2
First, make MAMP's php executablechmod +x /Applications/MAMP/bin/php5.2/bin/php
then edit your path for the version of PHP you want to use:export PATH=/Applications/MAMP/Library/bin/:/Applications/MAMP/bin/php5.2/bin/:/opt/local/bin:/opt/local/sbin:$PATH
Fri, 08/13/2010 - 02:07
Thanks, Andrew!
Thu, 02/28/2013 - 22:03
Looks like it may have changed again. I'm running MAMP v2.1.1 and I had to change the PATH to:
export PATH=/Applications/MAMP/Library/bin/:/Applications/MAMP/\ bin/php/php5.4.4/bin/:/opt/local/bin:/opt/local/sbin:$PATH
Thu, 03/10/2011 - 23:15
This was exactly what I was searching for, that symlink saved my - thank you!
Wed, 04/06/2011 - 21:44
thanks to all of the above !!
Tue, 05/01/2012 - 03:27
I changed the password when I was in phpMyAdmin, the root by accident, then I got the following message:
/Applications/MAMP/Library/bin/mysqlcheck: Got error: 1045: Access denied for user 'root'@'localhost' (using password: YES) when trying to connect
How do I fix the root password in the terminal so that I can access the phpMyAdmin again.
Sat, 07/07/2012 - 23:32
hi I am trying to access mysql through the terminal and I keep getting this :Last login: Sat Jul 7 16:17:44 on ttys000
Diane-Friersons-MacBook-Pro:~ dianefrierson$ mysql -u root --password=admin-bash: mysql: command not found
Diane-Friersons-MacBook-Pro:~ dianefrierson$
I know that I'm connected because I use XAMPP and I can access mysql through the admin but I too am following a tutorial and would like to know both ways. please help thanks in advance.. Peace and Blessings
Thu, 10/04/2012 - 11:20
/Applications/MAMP/bin/php/php5.4.4/bin/php
-c /Applications/MAMP/bin/php/php5.4.4/conf/php.ini
cron.php
(one line)
Tue, 03/13/2018 - 10:35
Just another post by admin. Your posts are really good for user.
Wed, 03/25/2009 - 10:38