0% found this document useful (0 votes)
146 views4 pages

LinuxCBT DBMS Edition Updates Notes

This document provides information on various MySQL administration utilities including: 1. MySQLShow - Explains the 'mysqlshow' command which enumerates information about databases, tables, and columns. Various options are demonstrated to drill down into different levels of metadata. 2. MyISAMCheck - Describes how to check, repair, optimize MyISAM tables offline. Backup options are included before making changes. 3. MySQLCheck - Explains how to check and repair tables online across various storage engines including MyISAM. Options to check specific databases and tables are covered.

Uploaded by

Stephen Efange
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
146 views4 pages

LinuxCBT DBMS Edition Updates Notes

This document provides information on various MySQL administration utilities including: 1. MySQLShow - Explains the 'mysqlshow' command which enumerates information about databases, tables, and columns. Various options are demonstrated to drill down into different levels of metadata. 2. MyISAMCheck - Describes how to check, repair, optimize MyISAM tables offline. Backup options are included before making changes. 3. MySQLCheck - Explains how to check and repair tables online across various storage engines including MyISAM. Options to check specific databases and tables are covered.

Uploaded by

Stephen Efange
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

###MySQLShow###

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'

2. Use 'myisamchk' in a variety of ways


2a. 'myisamchk demos.MYI' - default check - does NOT make changes
2b. 'myisamchk -B demos.MYI' - default check, however, performs a backup (if
changes are to be made) - A simple check does NOT perform changes
2c. 'myisamchk -B -r demos.MYI' - performs a recovery and provides a backup
2d. 'myisamchk -i -B tbl_name' - checks table (-c) - returns stats about the
table
2e. 'myisamchk -i -B *.MYI' - checks all tables
2f. 'myisamchk -s -B *.MYI' - checks silently, returning errors to STDOUT
2g. 'myisamchk -r -B products' - backs-up and recovers table 'products'

3. Use 'mysqlshow -i -u root -p LCBTProdsDemos products' - enumerates 'engine'


type, amongst other useful data

###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'

2c. Check tables that have changed since last check


'mysqlcheck -u root -p -C ' - checks tables that have changed since last check
Note: Each table stores important metadat, including, but not limited to: the last
time the table was checked
2d. 'mysqlshow -u root -p -i mysql user' - returns checked status, plus
additional information

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)

3c. Check|Repair across the wire


'mysqlcheck -u lcbtproductsdemo -p -C --all-databases'

3d. Full Repair - '-r'


3e. Auto Repair - '--auto-repair'
3f. Fast check - checks tables that have not been closed properly
'--fast'

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

2. Test 'mysql*' client utilities against the forwarded port


2a. 'mysql -p -h 127.0.0.1' - attempts to connect but fails because of undefined
user
2b. 'grant all privileges on *.* to 'root'@'%' identified by 'abc123' with grant
option'

3. Setup tunnel so that it is available on ALL routable interfaces


3a. 'ssh -g -L 3306:192.168.75.50:3306 192.168.75.50'

linuxcbtbuild1 -> (clear-text) -> linuxcbtserv1 -> (SSH) -> linuxcbtsuse1 (SSH)

4. Restrict MySQL to the loopback adapter


4a. '/etc/my.cnf' - update to bind to loopback adapter
4b. reinitiate the tunnel
'ssh -g -L 3306:127.0.0.1:3306 192.168.75.50'

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)

grant all privileges on *.* to 'linuxcbt'@'%' identified by 'abc123' with grant


option;

flush privileges;

'create database LCBTProdsDemos;'

###MySQL WorkBench Utility###


Features:
1. All encompassing GUI for MySQL Management
2. Query management - SQL Editor
3. Connection management
4. Instance management
5. Database modeling & deployment
6. Table Editor - manipulates tables
7. Replaces:
a. MySQL Query Browser
b. MySQL Administrator

###Multiple Instances on Linux|Unix Systems###


Features:
1. The ability to dedicate distinct MySQL hierarchies/DBMSs to clients: ISPs
2. One way: 'mysqld_multi' - Perl script - /etc/my.cnf

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'

2d. Connect to default and 2nd instance:


'mysql -p' - connects to the default: TCP:3306 || /var/lib/mysql/mysql.sock'
'mysql -P 3307 --protocol tcp ' - forces usage of: TCP instead of Unix Domain
Sockets, which happens when you attempt to connect to MySQL via the loopback
interface

2e. Remove anonymous accounts


2f. Secure 'root' accounts with a password
2g. 'grant all privileges on *.* to 'root'@'%' identified by 'abc123' with grant
option'

3. Create a 3rd instance, similar to the 2nd instance

You might also like