---
title: Getting command line access to PHP and MySQL running MAMP on OSX
description: "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"
---

[Blog ](https://www.metaltoad.com/blog)

# [Getting command line access to PHP and MySQL running MAMP on OSX](https://www.metaltoad.com/blog/getting-command-line-access-php-and-mysql-running-mamp-osx)

 Written by [Joaquin Lippincott, CEO](https://www.metaltoad.com/blog/author/joaquin-lippincott-ceo) | Jan 26, 2009 12:00:00 AM

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…](http://www.tech-recipes.com/rx/2621/os_x_change_path_environment_variable/)

[View full post](https://www.metaltoad.com/blog/getting-command-line-access-php-and-mysql-running-mamp-osx)

```json
{
  "@context" : "http://schema.org",
  "@type" : "BlogPosting",
  "author" : {
    "@type" : "Person",
    "name" : "Joaquin Lippincott, CEO"
  },
  "dateModified" : "2023-12-06T23:20:23.865Z",
  "datePublished" : "2009-01-26T00:00:00Z",
  "headline" : "Getting command line access to PHP and MySQL running MAMP on OSX",
  "image" : {
    "@type" : "ImageObject",
    "height" : 500,
    "url" : "https://6104926.fs1.hubspotusercontent-na1.net/hubfs/6104926/Imported_Blog_Media/Metal_Toad_blog_generic-Aug-11-2023-09-58-04-5554-PM.jpg",
    "width" : 870
  },
  "mainEntityOfPage" : "https://www.metaltoad.com/blog/getting-command-line-access-php-and-mysql-running-mamp-osx",
  "publisher" : {
    "@type" : "Organization",
    "logo" : {
      "@type" : "ImageObject",
      "height" : 60.0,
      "url" : "https://6104926.fs1.hubspotusercontent-na1.net/hubfs/6104926/social-suggested-images/6104926.fs1.hubspotusercontent-na1.nethub6104926hubfsMetal_Toad_Logo_orange_horizontal-50-1.jpg",
      "width" : 240.00002
    },
    "name" : "Blog"
  }
}
```