$ tar xzf MyToBiz-version.tgz$ cd /path/to/MyToBiz |
$ /path/to/MyToBiz/ perl mtbd.pl --server-host mysql.example.net --server-port 3306 --client-port 9876Proxy launched at : Sat Jun 16 21:01:34 2007Proxy started at : Sat Jun 16 21:01:47 2007-- server-host : mysql.example.net-- server-port : 3306-- client-port : 9876 |
$ mysql -h host -u username -P 9876 -p password -b |
mysql> !about; -- DISPLAY MyToBiz ABOUT MESSAGE ; +--------------------------------------------------------------------------+ | ABOUT | +--------------------------------------------------------------------------+ | ABOUT MyToBiz | | ------------------------------------------------------------------------ | | | | MyToBiz is a Toolkit for MySQL which aims to help the DBA or developer | | of MySQL database application. Its goal is to simplify dynamic SQL | | query execution and provide a suite of modules with a comprehensive | | set of DBA and development tools. | | | | ------------------------------------------------------------------------ | | - Report bugs to <momed at users.sourceforge.net>. - | +--------------------------------------------------------------------------+ 11 rows in set (0.00 sec) mysql> !ld my%; -- SHOW DATABASES LIKE 'my%'; +-----------+ | Database | +-----------+ | mysql | | mysql_bck | +-----------+ 2 rows in set (0.00 sec) mysql> !wc -l db.tst; -- SELECT count(*) FROM db.tst; +----------+ | count(*) | +----------+ | 3 | +----------+ 1 row in set (0.00 sec) mysql> !dump db.tst; -- SELECT * FROM db.tst; +--------+-------+ | id | txt | +--------+-------+ | 100000 | col-1 | | 200000 | col-2 | | 300000 | col-3 | +--------+-------+ 3 rows in set (0.03 sec) mysql> !call getDBSize(); -- get some db, data and indexes size & stats; +-----------------------------+----------+-----------+------------+----------+-------------------------+ | base | DB (MB) | DATA (MB) | INDEX (MB) | Pourcent | Graph | +-----------------------------+----------+-----------+------------+----------+-------------------------+ | ts | 0.0010 | 0.0000 | 0.0010 | 0.00 | * | | information_schema | 0.0039 | 0.0000 | 0.0039 | 0.00 | * | | test | 0.0060 | 0.0001 | 0.0059 | 0.00 | * | | db | 0.0093 | 0.0006 | 0.0088 | 0.00 | * | | mysql | 8.6328 | 5.3349 | 3.2979 | 1.98 | ** | | mysql_bck | 9.9791 | 9.2330 | 0.7461 | 2.29 | ** | | phpmyadmin | 36.0781 | 31.2627 | 4.8154 | 8.29 | **** | | tsdb_spiderdb | 46.2438 | 41.0241 | 5.2197 | 10.62 | ***** | | ftpsearch | 55.6699 | 30.4717 | 25.1982 | 12.79 | ***** | | tm | 59.0429 | 45.5175 | 13.5254 | 13.56 | ****** | | phptracking | 92.0994 | 50.8806 | 41.2187 | 21.15 | ******** | | spiderdb1_pagelist | 92.0984 | 50.8806 | 41.2178 | 21.15 | ******** | -/- -/- -/- -/- -/- -/- -/- | NULL | 435.4264 | 290.7222 | 144.7041 | 100.00 | *********************** | +-----------------------------+----------+-----------+------------+----------+-------------------------+ 17 rows in set (1 min 18.31 sec)
|
A Sort of overview
So what's so darn interesting about all this then? Well, the key point is that MyToBiz supports "pluggable contexts". A context here means that it's a different way of interpreting the commands you type. For example:
mysql> use mysql Database changed mysql> !ls; -- ls is an alias for SHOW TABLES +---------------------------+ | Tables_in_mysql | +---------------------------+ | db | | func | | help_category | | help_keyword | | help_topic | | host | | proc | | time_zone_transition_type | | user | / / +---------------------------+ 17 rows in set (0.47 sec) mysql> !set $cmd = select Host, Db, User from db limit 2; +----------------------------------------------+ | Set | +----------------------------------------------+ | $cmd = select Host, Db, User from db limit 2 | +----------------------------------------------+ 1 row in set (0.75 sec) mysql> !e $cmd; -- e is an alias for EXPLAIN +----+-------------+-------+-------+---------------+---------+---------+------+------+-------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+-------------+-------+-------+---------------+---------+---------+------+------+-------------+ | 1 | SIMPLE | db | index | NULL | PRIMARY | 420 | NULL | 8 | Using index | +----+-------------+-------+-------+---------------+---------+---------+------+------+-------------+ 1 row in set (0.62 sec) mysql> !eq $cmd; -- eq is an alias for EXECUTE QUERRY +-----------+--------+------------+ | Host | Db | User | +-----------+--------+------------+ | localhost | moodle | moodleuser | | localhost | mysql | tmadmin | +-----------+--------+------------+ 2 rows in set (0.86 sec)
|
The "!" prefix introduce text that's in a different context; The interpretation of the text depends on the context.
However, it gets clever in that MyToBiz has several different futures (and more can be added).
Built-ins Stuff
1 – LS:
MYTOBIZ_BUILTINS
Usage: ls [OPTION]... [DATABASE.TABLE]...
List information about database or tables: (the current database by default).
mysql> !ls -help; +-----------------------------------------------------------------------------------+ | HELP LS | +-----------------------------------------------------------------------------------+ | HELP LS | | --------------------------------------------------------------------------------- | | Usage: ls [OPTION]... [DATABASE.TABLE]... | | List information about the database or tables (the current database by default). | | | | --help show this help | | -d show databases | | -t show tables (the current database by default). | | -v show variables | | -s show status | | -e show errors | | -w show WARNINGS | | -p show PRIVILEGES | | -pl show PROCESSLIST | | -fpl show FULL PROCESSLIST | | -cd show CREATE DATABASE | | -ct show CREATE TABLE | | -ls show list script | | -bi show list built-ins | | -gv show list global vars | | -cfg show config | | --------------------------------------------------------------------------------- | | - Report bugs to <momed at users.sourceforge.net>. - | +-----------------------------------------------------------------------------------+ 23 rows in set (0.50 sec) |
mysql> !ls; -- IF no database select, ls will list all databases on server +-----------------------------+ | Database | +-----------------------------+ | information_schema | | test | | cdcol | | wordpress | | xoops2013 | / / | xtab | +-----------------------------+ 58 rows in set (1.83 sec) mysql> use test; Database changed mysql> !ls; -- IF an database select, ls will list tables +----------------+ | Tables_in_test | +----------------+ | sales | | t1 | | t2 | | tst | +----------------+ |
2 - ALIAS:
MYTOBIZ_BUILTINS
Alias [-p] [name [=value] ...]
Alias with no arguments or with the -p option prints the list of aliases in the form alias name=value on standard output.
When arguments are supplied, an alias is defined for each name whose value is given. A trailing space in value causes the next word to be checked for alias sub-stitution when the alias is expanded. For each name in the argument list for which no value is supplied, the name and value of the alias is printed. Alias returns true unless a name is given for which no alias has been defined.
mysql> !alias; +-------------------------------------+ | Alias | +-------------------------------------+ | ls -se='eq SHOW STORAGE ENGINES' | | dump='eq SELECT * FROM' | | le='ls -e' | | ls -ml='eq SHOW MASTER LOGS' | | ls -pl='eq SHOW PROCESSLIST' | | lv='ls -v' | | lp='ls -p' | | ls -p='eq SHOW PRIVILEGES' | | ls -bl='eq SHOW BINLOG EVENTS' | | ls -ms='eq SHOW MASTER STATUS' | | eq='exec_query' | | ls -fpl='eq SHOW FULL PROCESSLIST' | | e='eq EXPLAIN' | | ls -sh='eq SHOW SLAVE HOSTS' | | lt='ls -t' | | ld='ls -d' | | lss='ls -s' | | wc -l='eq SELECT COUNT(*) FROM' | | lw='ls -w' | | ls -ss='eq SHOW SLAVE STATUS' | +-------------------------------------+ |
To add an alias:
mysql> !alias ll='exec ls -l' -> -- exec is an mytobiz builtin to execute system command -> -- on Proxy host -> ; +---------------------+ | Alias | +---------------------+ | ll = 'exec ls -l' | +---------------------+ 1 row in set (0.55 sec) mysql> !ll; -- run the new Alias +-------------------------------------------------------+ | Exec | +-------------------------------------------------------+ | total 28 | | -rwxr-xr-x+ 1 User2 Aucun 10007 Jun 17 02:40 README | | drwxr-xr-x+ 2 User2 Aucun 0 Jun 17 13:34 doc | | drwxr-xr-x+ 6 User2 Aucun 0 Jun 16 13:34 lib | | drwxr-xr-x+ 2 User2 Aucun 0 Jun 16 23:14 log | | -rwxr-xr-x+ 1 User2 Aucun 4108 Jun 17 13:27 mtb.conf | | -rwxr-xr-x+ 1 User2 Aucun 4578 Jun 17 00:23 mtbd.pl | | -rwxr-xr-x+ 1 User2 Aucun 0 Jun 15 23:52 t.pl | +-------------------------------------------------------+ 8 rows in set (1.42 sec) |
4 - HELP:
2 - SET:
3 – EXECUTE QUERRY:
5 - EXPLAIN:
6 - EVAL:
7 - EXEC: