/kb

personal knowledgebase

Archive for the ‘Server’ Category

SSH aliases

without comments

In ~/.ssh/config add the following:

Host ALIAS
HostName DOMAIN
User USERNAME
Port PORT_NUMBER

Written by hgrimelid

June 18th, 2010 at 10:02 am

Posted in Server,Shell

Tagged with ,

Passwordless login with MacFusion

without comments

Put a reference to the private key file in ~/.ssh/config, for example:

IdentityFile ~/.ssh/id_rsa

Source: FAQS.org

Written by hgrimelid

August 6th, 2009 at 9:28 am

Posted in Server

Tagged with , , , ,

#1064 – You have an error in your SQL syntax

without comments

When exporting and importing from and to different MySQL databases with diferent version numbers this error message might show up:

#1064 – You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ‘ENGINE=MyISAM DEFAULT CHARSET=utf8′

I got the message when exporting from a MySQL 5.x database and importing to a MySQL 4.x database. The solution came to me from the following blog post comment and is very easy. Just add the --compatible option:

mysqldump -u username -ppassword –compatible=mysql40 database_name > FILENAME.sql

Written by Håvard Grimelid

March 4th, 2009 at 11:28 am

Posted in Server

Tagged with ,

Importing a MySQL dump file

with one comment

mysql -h SERVER -uUSER -p DATABASE < DUMPFILE

Written by Håvard Grimelid

January 6th, 2009 at 7:58 pm

Posted in Server

Tagged with , ,

Backing up my Macbook with rsync, SSH and Cron

without comments

I’ve created a simple script which syncs my documents folder with a remote computer. The files are transferred across the SSH protocol and the backup is performed daily with assistance of cron.

My rsync script is very simple:

#!/bin/bash
rsync -avzr --delete-excluded --exclude="*.log" --exclude="*.aux" --exclude=".svn" --exclude=".classpath" --exclude=".cache" --exclude=".project" --exclude="*.class" --exclude="*.swp" --exclude=".DS_Store" --exclude=".metadata" -e "ssh -c blowfish" /Users/USERNAME/Documents USER@REMOTE_COMPUTER:REMOTE_DIRECTORY

It was quite tricky to set up the cron job until i realized that cron does know very little of the user’s system. The trick was to add SSH_AUTH_SOCK=/tmp/501/SSHKeychain.socket in front of the script refrence in crontab, so that it looks like:

55 21 * * * SSH_AUTH_SOCK=/tmp/501/SSHKeychain.socket /Users/USERNAME/etc/backup.sh

This will cause the backup script to run at 21:55 each night. For more info on cron, check out unixgeeks.org. Add the following at the end if you’d like to suppress the mail from cron: >& /dev/null.

Note that for this script to run, SSH has to be set up with keypairs authentication.

Written by Håvard Grimelid

September 13th, 2008 at 11:29 pm

Posted in Scripts,Server

Tagged with , , ,

Restart Apache

without comments

I always forget how to stop/start/restart Apache (on Ubuntu), so here it is:

sudo /etc/init.d/apache2 stop
sudo /etc/init.d/apache2 start
sudo /etc/init.d/apache2 restart

Written by Håvard Grimelid

August 12th, 2008 at 12:02 am

Posted in Server

Tagged with ,

php5-imagick error in Ubuntu 8.04

without comments

I got the following error message, caused by a bug in Ubuntu.:

PHP Warning:  PHP Startup: Unable to load dynamic library
'/usr/lib/php5/20060613+lfs/imagick.so' -
libWand.so.9: cannot open shared object file:
No such file or directory in Unknown on line 0 finished.

Here’s the solution.

Written by Håvard Grimelid

July 17th, 2008 at 1:42 pm

Posted in Server

Tagged with , , , ,

Create a new MySQL-user with all privileges

without comments

GRANT ALL PRIVILEGES ON thedatabase.* TO 'theusername'@'localhost'
	IDENTIFIED BY 'thepassword' WITH GRANT OPTION;

UPDATE 20080916: Skip the last line if the user exists.

Written by Håvard Grimelid

May 17th, 2008 at 7:26 pm

Posted in Server

Tagged with

Backup a MySQL database with mysqldump

without comments

It’s very easy, but I always have to look it up.

mysqldump --opt -u USERNAME -p -h HOST.HOST.COM DATABASE_TABLE > DUMPFILE.sql

Written by Håvard Grimelid

May 14th, 2008 at 6:29 pm

Posted in Server

Tagged with , , ,

Allow cgi scripts globally

without comments

I run Apache on my Macbook and want to be able to run my cgi scripts from everywhere. All directories I want to access are symlinked from the DocumentRoot (/Library/WebServer/Documents) and the only thing necessary is to add the following directive for this section in httpd.conf:

Options ExecCGI

Written by Håvard Grimelid

April 23rd, 2008 at 12:41 pm

Posted in Server

Tagged with , ,