Monday, October 29, 2007

Excluding a directory with tar


$ tar -cvf file.tar / --exclude "/path/to/directory"


You musn't to write / character and the end of the pattern you would like to exclude.

Friday, October 26, 2007

MySQL tricks

New root password:

mysqladmin -u root password NEWPASSWORD


Change root password:

mysqladmin -u root -p oldpassword newpass


Create user account:

mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'localhost'
-> IDENTIFIED BY 'some_pass' WITH GRANT OPTION;

MySQL query to CSV

You again? uff.. well here is your reward.

select * from example into outfile '/tmp/example.csv' fields \
terminated by ',' lines terminated by '\n';


I'll see you ASAP looser.

CSV to MySQL

Have you tried to import a CSV file to your MySQL database without success ? :), ok I'll make your day (Clint Eastwood).

prompt in your mysql console as create a table with the fields of your csv file, for example:


mysql> CREATE TABLE `test` (
-> `fe` VARCHAR( 2 ),
-> `fi` VARCHAR( 2 ),
-> `fo` VARCHAR( 2 ),
-> `fum` VARCHAR( 2 )
-> );


Ok? the next step is to import the file into the recent created table:


mysql> load data LOCAL infile '/testfile' into table test \
fields terminated by ',' lines terminated by '\n';


/testfile is like this:

aa,bb,aa,rr
re,we,as,qw
ty,qw,as,as

Saturday, October 20, 2007

Duplicate a directory structure, using rsync.

You can duplicate a directory structure without duplicate the contents of these directories using 'rsync'.

$ rsync -avz --include='*/' --exclude='*' SOURCEDIR DESTDIR


Obviously login as root in the remote computer is a requirement whether you want to preserve the ownership.

Note: When I copy files to a remote computer I'm not capable of preserve the ownership of the files using this rsync options in spite of the rsync man says that.

CVS to SVN

The next note is about migrate a cvs repository to subversion. Basically you need the 'cvs2svn' command in your system to do it.

# cd
# mkdir project
# cd project
# cvs2svn --dump-only --dumpfile ./project.dump \
/cvsroot/project/
# svnadmin create /svnroot/project
# svnadmin load /svnroot/project < ./project.dump
# chown -R www-data:www-data /svnroot/project/


That's all