Archive for the ‘Server’ Category
SSH aliases
In ~/.ssh/config add the following:
Host ALIAS HostName DOMAIN User USERNAME Port PORT_NUMBER
Passwordless login with MacFusion
Put a reference to the private key file in ~/.ssh/config, for example:
IdentityFile ~/.ssh/id_rsa
Source: FAQS.org
#1064 – You have an error in your SQL syntax
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
Importing a MySQL dump file
mysql -h SERVER -uUSER -p DATABASE < DUMPFILE
Backing up my Macbook with rsync, SSH and Cron
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.
Restart Apache
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
php5-imagick error in Ubuntu 8.04
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.
Create a new MySQL-user with all privileges
GRANT ALL PRIVILEGES ON thedatabase.* TO 'theusername'@'localhost' IDENTIFIED BY 'thepassword' WITH GRANT OPTION;
UPDATE 20080916: Skip the last line if the user exists.
Backup a MySQL database with mysqldump
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
Allow cgi scripts globally
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