mysql export import

August 6th, 2007

This show you how to backup and restore mysql db.

Export
mysqldump -u root -h localhost -p db_name > db_name

Import
mysql -u mysql_account-p -h localhost db_name< db_name

Creating Mysql DB user

July 3rd, 2007


CREATE USER 'xxx'@'%' IDENTIFIED BY 'yyy';

GRANT USAGE ON * . * TO 'xxx'@'%' IDENTIFIED BY 'yyy' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ;

CREATE DATABASE IF NOT EXISTS `xxx` ;

GRANT ALL PRIVILEGES ON `xxx` . * TO 'xxx'@'%';

SSH Auto Login

June 25th, 2007

On the client that requires to login to the remote, execute the following command to generate the public and private keys.

[root@localhost ~]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
3e:b1:6d:44:73:e6:ca:af:3c:06:48:f1:f2:c1:5a:b6 root@localhost.localdomain

append the public key to the remote server
on the client
cat ~/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAABIwA3AQEAsr8DueNT........... root@localhost.localdomain

on the server
echo "ssh-rsa AAAAB3NzaC1yc2EAAAABIwA3AQEAsr8DueNT........... root@localhost.localdomain"
>> ~/.ssh/authorized_keys2

You may need to change root@localhost.localdomain to suit your need.

Adding Static Route on Startup

June 2nd, 2007

Create if /etc/sysconfig/static-routes does not exist.

# Routing to HK
eth0 net 192.168.2.0 netmask 255.255.255.0 gw 172.16.1.6
eth0 net 192.168.1.8 netmask 255.255.255.248 gw 172.16.1.6
# Routing to Japan
eth0 net 192.168.3.0 netmask 255.255.255.0 gw 172.16.1.1
eth0 net 192.168.4.0 netmask 255.255.255.0 gw 172.16.1.1

set the hardware clock to the current system time

June 2nd, 2007


hwclock --systohc

ClamAV Module: was infected: Oversized.Zip

May 3rd, 2007

If your email is blocked by ClamAV with Virus oversized.zip, you are hitting a bug in Mail::ClamAV perl module. To fix this, you will need to install the latest ClamAV module

perl -MCPAN -eshell

install Mail::ClamAV

Booting to Single User Mode

April 17th, 2007

If it’s LILO, just type “linux single” and that should do it (assuming that “linux” is the lilo label).
If GRUB, hit ‘e”, then select the “kernel” line, hit “e” again, and add ” single” (or just ” 1″) to the end of the line. Press ENTER, and then “b” to boot. (More modern grub uses “a” to append to the boot line)

e.g.
kernel /boot/vmlinuz-2.2.17 root=/dev/hda8 video=matrox:vesa:261 single

Installing Perl Module from CLI

March 22nd, 2007

perl -MCPAN -eshell

Installing Apache 2.x and PHP5

March 10th, 2007

Installing Apache 2.x

./configure \
--prefix=/usr/local/apache \
--enable-info \
--enable-rewrite \
--enable-ssl \
--enable-unique-id \
--enable-deflate \
--enable-usertrack \
--enable-so

make
make install


cp build/rpm/httpd.init /etc/init.d/httpd
chkconfig --add httpd
chkconfig --level 3456 httpd on

Installing PHP required Libraries
http://www.ijg.org/files/jpegsrc.v6b.tar.gz
./configure --enable-shared
mkdir -p /usr/local/man/man1
make
make install

http://www.libpng.org/pub/png/libpng.html
./configure
make
make install

http://voxel.dl.sourceforge.net/sourceforge/freetype/freetype-2.1.9.tar.gz
./configure
make
make test
make install

Install LibMCrypt
http://sourceforge.net/projects/mcrypt
./configure
make
make install

Installing PHP5

./configure \
--with-apxs2=/usr/local/apache/bin/apxs \
--with-openssl \
--with-gd \
--with-jpeg-dir \
--with-png-dir \
--with-zlib-dir \
--with-freetype-dir \
--with-ttf \
--with-mysql=/usr/local/mysql \
--with-mysqli=/usr/local/mysql/bin/mysql_config \
--with-mcrypt \
--enable-mbstring \
--enable-bcmath

make
make install

Configuring Apache for PHP
vi /usr/local/apache/conf/httpd.conf

add
AddType application/x-httpd-php .php

change
DirectoryIndex index.php index.html index.html.var

php.ini
copy php.ini-development or php.ini-production to /usr/local/lib/php.ini

edit /usr/local/lib/php.ini
timezone = Asia/HongKong

PostgreSQL installation

March 10th, 2007

This is a guide to show step-by-step PostgreSQL installation.


./configure
make
su
make install
adduser postgres
mkdir /usr/local/pgsql/data
chown postgres /usr/local/pgsql/data
su - postgres
/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
/usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data >logfile 2>&1 &
/usr/local/pgsql/bin/createdb test
/usr/local/pgsql/bin/psql test