Install WordPress on Mac with MAMP

Posted:

Create WordPress Database & Database User

Note: Please substitute username & password with your personal, secure values, and name the database something other than wordpress.

First, make sure MAMP is running.

Via GUI (see "Via Terminal" below if you prefer)

  1. Open MAMP. It should open your browser to http://localhost:8888 automatically. If not, in the MAMP window, click "Open start page," or just navigate your browser to http://localhost:8888.
  2. Click phpMyAdmin at the top of the page.
  3. Click Privileges at the top right.
  4. Click "Add new user." Enter the following:
    User name:
    username
    Host:
    (select Local from dropdown)
    Password:
    password
    Re-type:
    (password from line above)
  5. Under "Database for user," select "Create database with same name and grant all privileges."
  6. Click "Go" at bottom right of page.
  7. Done!

Via Terminal* (see "Via GUI" above if you prefer)

/Applications/MAMP/Library/bin/mysql -u root -proot -P 8889
CREATE DATABASE `wordpress`;
CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';
GRANT USAGE ON * . * TO 'username'@'localhost' IDENTIFIED BY 'password' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0;
GRANT ALL PRIVILEGES ON `wordpress` . * TO 'username'@'localhost';
QUIT ;

Get Code, Prepare Database, and Go!

In Terminal, type each of the following lines, one at a time:

cd ~/Projects # or wherever you store your projects
git clone git@github.com:you/example.com.git # git clone your project
cd example.com
/Applications/MAMP/Library/bin/mysql -u username -ppassword -P 8889 wordpress < wordpress.bak.sql # load backup of db
/Applications/MAMP/Library/bin/mysql -u username -ppassword -P 8889 wordpress # start mysql command prompt
UPDATE `wordpress`.`wp_options` SET `option_value` = 'http://localhost:8888' WHERE `wp_options`.`option_name` = 'siteurl' OR `wp_options`.`option_name` = 'home' ;

Navigate to http://localhost:8888/wp-admin in the browser.

Deploy

See: http://stackoverflow.com/questions/4236161/git-github-and-web-server-deployment-configuration/4281789#4281789