------------------------------------------------------------------------------- Commands in 'discovery' order... mysql --user {username} --host {network_name} --password Password: ***** show databases; What database (table sets) you have access to. use {database} Work in this database set show tables; What tables are in this database describe {table}; What columns and types are in this table show create table {table} The command to use to re-recreate the table (does not show REFERENCES comments) -------- Create Table create table {table} ({name} {type},... ); to modify you need to use alter table .... Add data to tables.... load data insert ------------------------------------------------------------------------------- Administer Creating a Database (administrator) Adding users Granting Access ------------------------------------------------------------------------------- Safe snapshots of MySQL tables (for backups) on LVM systems #!/usr/bin/perl # # On a LINUX LVM system, get mysql to flush and do a LVM snapshot # before making a backup of the mysql snapshot # # $SnapDir="/snapshots/mysql"; $SnapDev="/dev/asylum/mysql_snapshot"; $SnapSize="128M"; $MySQLDev="/dev/asylum/mysql"; $OnOff=$ARGV[0]; # Are we creating or removing a mysql table snapshot chomp $OnOff; if ($ARGV[1] eq "-v" || $ARGV[1] eq "-v\n") { $Verbose="y"; $MountParams="-v -t ext4 -o ro,noatime,nodiratime,noexec,nosuid,nodev,barrier=0"; $UMountParams="-v"; } else { $Verbose="n"; $MountParams="-t ext4 -o ro,noatime,nodiratime,noexec,nosuid,nodev,barrier=0"; $UMountParams=""; } if ($OnOff eq "on") { # connect mysql ROOT use DBI; $DB=DBI->connect("DBI:mysql:mysql" . ";mysql_read_default_file=/root/.my.cnf", root, $password) or die "Could not connect to MySQL\n"; # flush and lock all tables $DB->do("flush tables with read lock;") or die "Can't flush and lock tables: ",$DB->errstr,"\n"; # create the LVM snapshot device system ("lvcreate --size $SnapSize --snapshot --name mysql_snapshot $MySQLDev > /dev/null 2>&1") == 0 or die "Can't create snapshot: $?\n"; # unlock the tables so MySQL can continue serving clients # After this we don't have to talk to MySQL at all anymore. $DB->do("unlock tables"); $DB->disconnect; # mount up the snapshot volume system ("mount $MountParams $SnapDev $SnapDir") == 0 or die "Unable to mount snapshot: $?\n"; } elsif ($OnOff eq "off") { # Unmount the snapshot system ("umount $UMountParams $SnapDir") == 0 or die "Can't unmount snapshot: $?\n"; # Delete the snapshot volume system ("lvremove --force $SnapDev > /dev/null 2>&1") == 0 or system ("lvremove --force $SnapDev > /dev/null") == 0 or die "Can't remove the snapshot volume: $?\n"; } else { die "Invalid parameter used on command line.\n"; } -------------------------------------------------------------------------------