Scripting a MySQL InnoDB Engine Conversion

0) Backup your database.
You should probably be doing this already.  Now’s a good time to make sure that your backups ran.

1) Create the script.
You’ll need the correct permissions to query the database. Here’s the command.  Be sure to change <DATABASE_NAME> as it fits.
# mysql -p -e “show tables in <DATABASE_NAME>;” | \
tail –lines=+2 | [...]

Simple MySQL Backup with auto 3 days old file deletion

/usr/local/bin/mysql.backup.sh

#!/bin/bash
NOW=$(date +”%m-%d-%Y”)
OLD=$(date +”%m-%d-%Y” –date=”3 days ago”)
PROJECT=”project_name”
LOCATION=”/home/backup”
FILE=”$PROJECT.$NOW.sql”
FILE2=”$FILE.gz”
FILEOLD=”$PROJECT.$OLD.sql.gz”
EMAIL=”youremail@domain.com”
$SQLUSER=”username”
$SQLPASS=”password”
$SQLNAME=”database_name”
cd $LOCATION ; \
rm -f $FILEOLD ; \
mysqldump -u $SQLUSER –password=$SQLPASS $SQLNAME > \
$LOCATION/$FILE ; \
gzip $LOCATION/$FILE ; \
echo “Backup location is in $LOCATION/$FILE2″ | \
mail -s “[$PROJECT] MySQL Backup” $EMAIL

Then you can put it on your cron (background process)
Below cron will execute the script on Saturday at 12AM:

0 0 [...]

How to tune Apache and Mysql

By default, Apache comes preconfigured to serve a maximum of 256 clients simultaneously. This particular configuration setting can be found in the file /etc/httpd/conf/httpd.conf
If your server has 2 GB of RAM, and you’re sharing your server with MySQL(true in my case), you’ll want to reserve about half of it for Apache (1 GB)

MySQL Master-Slave Replication

To setup Master-Slave Replication the first thing you need to do is create a user on the Master server that allows replication.