Cognizant Designs LLC

Denver SEO, Internet Marketing & Website Design

Posts from — November 2009

Mac OSX Dev Space – Basic Commandline & MySQL Imports

This will be the first in a short series about knowing your development environment and how to make it your bitch! Now I know some of you designers out there, and you know who you are, have not a clue about where to begin when creating virtual instances on your Apache environment. You just downloaded MAMP and suddenly you think that somehow that is enough. Save me your BS encrusted psycho babel about how this is information that only the server wizards need to know. Even if you never become completely proficient in this area, it is worth breaking your install to test these tools and become more fluent in the ways of the Terminal, or shell to the UNIX crowd.

Today we start with MAMP and move to the TERMINAL. In the next article I will go over some cool commands for GIT and SVN as well as setting different editor applications to run in your TERMINAL.

Quick sob story, a few months back I forced my machine into corrupted library purgatory and had only the Install Disks and Terminal access at my command. At 3 in the morning I faced the obliteration of months of work due to my lack of diligence keeping back-ups. After examining the TERMINAL and asking it for simple information like if it could read my file library, I found that I could copy files from my dying drive to the portable entirely in command line.

TERMINAL

Simple commands that you will use day in and day out:

  • cd — change directory
  • ls -al — list all items in a table that shows ownership and permissions alphabetically ascending
  • [control key] + [C key] — cancel the command that you just entered
  • sudo ‘command’ — tell the system to overwrite all permissions and authenticate yourself as the admin
  • ln -s /path/to/item/you/are/linkingto ‘nameofalias’ — make a relative link to something, can be a folder or a file
  • rm -rf ‘filename’ — remove anything with the file name

Another neat thing in TERMINAL is the built in auto-complete feature. When entering in a path or a filename, you need to only enter up to the last unique character and then press TAB to complete the name. (eg /pa TAB results in /path/ or something like that) Also, pressing the UP or DOWN key on your keyboard will cycle through the commands you have used, super handy if you are using a lot of the same ones over and over.

MYSQL

First you need to create the database and user that will be associated with that database in your MAMP phpMyAdmin interface. Then you need to import some data. For smaller db’s you can easily accomplish this through the same web interface but for larger databases (anything over 3mb) you will need to do this entirely from command line. Crack open the terminal and run this command:

mysql -u dbuser -p yourdbname < /path/to/backup.sql

What this command does is tell mysql to use the specified database “-p ‘yourdbname’ ” and associated user “-p ‘dbuser’ ” and import the backup sql file that you have pointed it to.

  No Comments