Oracle queries

-- show tables
select table_name from all_tables;

-- output parameter
set wrap off;
set pagesize 0;
set linesize 120;
column owner format a30;

-- show configuration
show parameters;

-- list users
select username from all_users

-- find constraint
select *
from all_constraints
where constraint_name = 'SYS_C00381400';

-- select a random row from table
SELECT column FROM
SELECT column FROM table
ORDER BY dbms_random.value
)
WHERE rownum = 1

-- update materialized view
begin
dbms_snapshot.refresh('SCHEMA.MATERIALIZED_VIEW_NAME');
end;

-- view sched

MySQL Queries

-- view hostname
select @@hostname;

-- view version
select version();

-- view engines
show engines;

-- list databases
show databases;

-- change database
use mysql;

-- show tables in database
show tables;

-- show table informations
show table status;

-- show engines
show engines;

-- show bin_log info
show variables like '%log_bin%';

-- list users
select user, host from mysql.user;

-- delete user
DROP USER 'USER_NAME'@'%';

-- set user password
--SET PASSWORD FOR 'USER_NAME'@'%' = PASSWORD('NEW_PASSWORD')
use mysql;
update user set password=PASSWORD(

Instal RoundCube (Webmail)

# set domU parameter
[ -z $DOMAIN_NAME ] && DOMAIN_NAME=webmail
[ -z $DOMAIN_MAC ] && DOMAIN_MAC=00:11:22:7d:7e:7f
[ -z $DOMAIN_RAM ] && DOMAIN_RAM=256Mb
[ -z $DOMAIN_HDD ] && DOMAIN_HDD=2Gb

# create domU
http://www.panticz.de/Xen-domU-ubuntu-jaunty

# add to autostart (optional)
ln -s /etc/xen/${DOMAIN_NAME} /etc/xen/auto

# start domU
xm create -c ${DOMAIN_NAME}

# install webmail
http://www.panticz.de/install_roundcube

Instal Drupal (CMS)

# create database
mysql -u root -p
create database drupal;
CREATE USER drupalo IDENTIFIED BY 'drupalp';
grant all on drupal.* to 'drupalo'@'%' identified by "drupalp";
commit;
quit;

# create installation file on your webserver
cat < /var/www/drupal-install.php
<?php
# dowload
system("/usr/local/bin/wget http://ftp.drupal.org/files/projects/drupal-6.19.tar.gz");

# extract
system("/usr/bin/tar xzf ./drupal-*.tar.gz");

# move drupal files to current dir
system("/bin/mv drupal-*/* .");
system("/bin/mv drupal-*/.* .");

# configure
system("/bin/cp ./sites/default/defa

MySQL: export and import

DB_HOST=localhost
DB_NAME=db1
DB_USER=root
DB_PASS=pass1234
TARGET=/tmp

# export DB
mysqldump --host=${DB_HOST} --password=${DB_PASS} --user=${DB_USER} ${DB_NAME} | bzip2 --best > ${TARGET}/$(hostname -f)_${DB_NAME}_$(date -I).sql.bz2

# import DB
bzcat /tmp/db_dump_${DB_NAME}.sql.bz2 | mysql --host=localhost --user=${DB_USER} --password=${DB_PASS} ${DB_NAME}
mysql --host=localhost --user=${DB_USER} --password=${DB_PASS} ${DB_NAME} < dump.sql

# import bzip2 compressed file
bzip2 -dc dump.sql.bz2 | mysql --user=${DB_USER} --password=${DB_PASS} ${DB_NAME}