append data to existing tables (simple)

I have a database that no one can get to, that I want to take the newest data in that db and "publish" it to a database that everyone can get to. All the tables in the secret database have the same schema as the public database, and every table has an autoincrement column called "ID". So what this script does it query the public database tables for the highest value for the "ID" column then grab all data in the private database with a value of "ID" greater than that and insert it into the public database.

First a procedure to get the max id from the public table

Copy database from one server to another

This is a script I used to copy a database from one server to another. There are a tons of ways to do this, for MyISAM tables you can simply copy the files in the MySQL data directory. This script is one I use for a large read only database which contains both MyISAM and InnoDB tables that I have to copy to multiple machines. It assumes that either the destination tables don't exists or that the data they contain can be deleted. If the destination database does not exist, you will have to create it manually with a "CREATE DATABASE" command.

Convert InnoDB to MyIASM

A script that will go through a database and convert any InnoDB tables to MyISAM tables. It uses the MySQL specific "SHOW CREATE TABLE" command which will include the type of table in the create statement. It uses this to build an array of all InnoDB tables in the database then uses "ALTER TABLE" to change the table type from InnoDB to MyISAM.

List tables in a database

Very similar to the list databases script here is the list tables script:

List Databases in a mysql instance

A simple script to list the databases in a mysql database.

#!/usr/bin/perl
use strict;
use warnings;

use DBI qw(:sql_types);

my @dbnames;

my $dbName = "mysql";
my $dbServer = "127.0.0.1";
my $dbUser = "dbuser";
my $dbPassword = "password";

Connecting

In order to connect to our database platform you need to create connection string, which contains

Subscribe to perlmysql.com RSS