Escolar Documentos
Profissional Documentos
Cultura Documentos
Features:
1. Front-end to SQL 'SHOW' statements
2. Enumerates information (metadata) about: DBs, Tables, Columns
Tasks:
1. Explore the environment
2. 'mysqlshow'
2a. 'mysqlshow' - enumerates information about the managed DBs
2b. 'mysql -u root -p --count' - returns a count of returned records
2c. 'mysql -u root -p --count mysql' - returns metadata about the 'mysql' DB,
including:
1. Tables
2. Columns
2. Total # of rows
2d. 'mysqlshow -u root -p --count mysql user' - returns info. one-level below the
DB by describing the specified table: SQL 'describe user'
Note: Default behavior is to return ALL columns if a single column is unspecified
2e. 'mysqlshow -u root -p --count mysql user Host' - drills to the column level
of the hierarchy
2f. 'mysqlshow -u root -p --count mysql user %priv' - returns columns terminating
with 'priv'
2g. 'mysqlshow -u root -p --count --keys mysql user' - dumps indexes on
'mysql.user'
2h. 'mysqlshow -u root -p -i mysql user' - dumps additional metadata: i.e.
'engine, timestamps, etc.'
###MyISAMCheck###
Features:
1. Checks, reparis, describes, optimizes 'myISAM'(default storage engine) tables
2. OFFLINE USAGE ONLY
3. Run from DB directory or via path to the DB directory/file
4. Optionally allows you to backup existing table prior to operations
Tasks:
1. Examine/explore 'myisamchk ...' utility
1a. take they MySQL instance offline
1b. Identify $datadir: 'ps -ef | grep mysql'
###MySQLCheck###
Features:
1. Checks, repairs, and optimizes tables
2. ONLINE USAGE
3. Requires Auth (-u($USER=default), -p, -h(localhost=default))
4. Checks various storage engines, however, is optimized for: MyISAM
Usages:
1. Check ALL databases:
1a. 'mysqlcheck -u root -p [-h HOST] --all-databases' - checks ALL DBs
2. Check specific databases:
2a. 'mysqlcheck -u root -p --databases mysql' - checks the 'mysql' DB
2b. 'mysqlcheck -u root -p --databases mysql LCBTProdsDemos' - checks 2 DBs:
'mysql', 'LCBTProdsDemos'
3. Repair options
3a. '-q' - quick repair - 'mysqlcheck -u root -p -q mysql' - checks ALL tables
3b. 'mysqlcheck -u root -p -q mysql user' - checks 'mysql.user' table
Note: 'mysqlcheck' runs via Unix sockets as well as TCP, whereas 'myisamchk' uses
neither, as it relies upon disk access to the table(s)
Note: Consider backing-up your tables prior to recoveries: i.e. 'mysqldump, etc.'
###SSH Tunneling###
Features:
1. Encryption security for mysql client/server communications
2. Obviates the need for SSL configuration
Tasks:
1. Setup SSH tunnel from the client (linuxcbtserv1) to the server (linuxcbtsuse1)
1a. 'ssh -L 3306:192.168.75.50:3306 192.168.75.50' - Local port forwarding syntax
Note: Optionally, consider implementing PKI, passwordless authentication
Note: By default, port forwarding does not share the port that is forwarded on a
routable interface, instead, it binds to the loopback adapter
linuxcbtbuild1 -> (clear-text) -> linuxcbtserv1 -> (SSH) -> linuxcbtsuse1 (SSH)
Note: This secure forwarding mechanism to the loopback adapter will authenticate
inbound requests as: 'user'@'localhost'
###Windows Installation/Support###
Features:
1. Windows 32|64-bit platforms: Windows 2000, 2003, 2008, XP, Vista, 7
2. Runs as a service - backgrounded like a daemon
3. Available via the following packages:
3a. Essentials - minimum server build (mysqld, and mysql client utilies) sans:
docs, instance manager, embedded server, benchmark suite
3b. Complete - Essentials plus ALL packages
3c. No-install archive - sans configuration wizard
3d. Source files - require compilation
Tasks:
1. Installation - dev.mysql.com/downloads
1a. Create 'mysql' account with 'domain admin' rights
Note: In stark contrast to the Linux|Unix model, the 'mysql' account requires full
rights. However, within *Nix environments, the user is a standard non-privileged
account.
1b. Disable anti-virus scanning of: $datadir & temporary directory (dedicate
distinct $tmpdir (my.ini) directory)
flush privileges;
Tasks:
1. '/etc/sysconfig/mysql' - set 'MYSQLD_MULTI="yes" '
2. '/etc/my.cnf' - configure with instances
2a. disable the default: [mysqld] block - and following directives
2b. Required per-instance directives/options:
distinct: port, datadir, pid-file, socket
2c. configure instance 2
Note: Each instance except the default will use a different TCP port, so be sure to
reference the correct port in your mysql clients.
'mkdir /var/lib/mysql-databases && mkdir /var/lib/mysql-databases/mysqld2 &&
chown -R mysql.mysql /var/lib/mysql-databases'