Apache Tweaks

March 15, 2006

Avoid truncated filenames in log by editing httpd.conf:
IndexOptions FancyIndexing NameWidth=*

Here is a handy Perl script to compress all Apache logs automatically called LogFlume.

Serve an additional site under same DocumentRoot:

Add new Virtual Host:

ServerName http://www.newsite.biz
ServerAdmin mike@newsite.biz
DocumentRoot /home/www/htdocs #same as other site
RewriteEngine On
RewriteRule ^/$ /home/www/htdocs/newsite/index.html
RewriteRule ^/index.html$ /home/www/htdocs/newsite/index.html


Apache Toolbox

March 15, 2006

When installing Apache, check out Apache Toolbox and this article/script.

Restore single MySQL table from large DB dump

March 15, 2006

Here’s how to restore one or more tables from a full database archive. It assumes you used mysqldump to save the database and stored it in a gz file. First create the file extract-table.pl:

#!/usr/bin/perl -wn
# extract-table.pl
BEGIN { $table = shift @ARGV }
print if /^create table $table\b/io .. /^create table (?!$table)\b/io;

Then do the following to restore the table:

zcat /path/mysqldump.date.gz | extract-table Mytable> ~/Mytable.dump
mysql  mydatabase -e "drop table Mytable"
mysql mydatabase

mtop/mkill – MySQL Monitoring Tools

March 15, 2006

mtop can be used like top in Unix. Download from HERE first.

Must start mysql with mtop user and passwd:
mysql --dbuser=monitor --password=n0tell

Useful MySQL Commands

March 15, 2006

Dump DB:mysqldump -u root -p password dbname > dbbackup.sql

Dump DB Structure:

mysqldump -u root -p password –no-data dbname > dbname.sql

Reset MySQL root Password:

*shutdown mysql, then restart as follows-

mysqld_safe –skip-grant-tables –skip-networking &

mysql -u root (no password needed)

mysql> UPDATE mysql.user SET Password=PASSWORD(‘new-password’) WHERE User=’root’;

*Logout, shutdown, and restart normally to login

Useful Debugging Commands: