Developer / Entrepreneur Of The Internet Type

terminal

I’ve been throwing together a few useful mac terminal os x shell scripts lately and this was another one of those cases today. It’s not completely finished just yet but it will do a job the first time round. I’m not sure just yet how best to have lots of different symlinks to different Library bases and how to code that so that it happens.

The below code and it’s paths are relevant to me and my setup with MAMP. You can easily edit this function to include different paths as you require.

Sometimes staying on top of the latest version of WordPress can be quite annoying when your testing things locally or rolling out regular wordpress sites. I normally install with .svn but this is a neat little bash script function I threw together to grab the latest version of WordPress and unzip into the current directory through Mac OS X Terminal command.

When working on your server with ssh access, you tend to get very used to doing everything you need to do via the terminal window. Sometimes you may come accross problems which unless you have the know how you will be puzzled as to why somethings not working.

Today I came across a small problem in that a few commands which would normally work on my local os x machine were not working on my server machine.
Im going to use the ‘zip’ function as my guinea pig. If this function is not installed or enabled in your servers configuration/installation you will see a message like this:

-bash: zip: command not found

This is easy to fix simply by running the following command:

yum install zip

Now if you try the zip command again you will notice its worked or at least should work. You can also if you wish check to see if its installed first by viewing the install list on your server with the following command.

I decided today to take a backup of a database in the usual way using phpmyadmins export facility. I exported it to a zip file and called it topgame.zip i then ftp’d it to the location on the server i wanted.

I then decided that i wanted to mysqldump this database using the terminal, which ive never done before but which is much quicker and more reliable than using phpmyadmins built in import function.

So here we go……………..

Step 1 : Unzip the file that you ftp’d to the server which contains your backup database

unzip myuser_db_sometable.zip

Step 2: Login into your mysql database using terminal

mysql -u mysql_username -p

Step 3: You will be prompted for your password for mysql, enter it and hit enter, note(you will not see any characters going in).

Step 4: Enter the database name that you want to add the backup into or create a new database

Step 5 (optional): Create a database from command line

mysqladmin create db_name

Step 6: Once the table is there select the table:

use db_name

Step 7: Once the table is there select the table:

. myuser_db_sometable.zip

Step 8: then simply quit out of the mysql console using

q

Step 9: For help using the mysql console:

h

I hope someone finds this useful, its very simple and can save loads of time.