rivman / MySQL-Tools

Custom MySQL utilities created for daily work.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MySQL

Programs

Scripts


mysql_vars.sh

Purpose

Display important MySQL server variables and counters.

Uses Bash for server portability.

Output can be easily be diffed to compare servers.

Set-up

    chmod 744 mysql_vars.sh

Usage

    ./mysql_vars.sh

– prompts for host, username, and password (not echoed) of the MySQL server.

Usage on Windows

On Windows, via a PuTTY connection, the script output may exceed PuTTY's scrollback limit. I chose an interactive connection input for my usage on Linux-to-Linux machines (avoiding switches). Nevertheless, this means that stdout redirection is blocked.

Short of rewriting the command-line parsing, a workaround is:

    ./mysql_vars.sh | tee myvars.txt

mysql_varmon.sh

Purpose

Continously monitor MySQL server variables.

Uses Bash for server portability and updating ease (but possesses a flickery terminal refresh).
This directly led to mysqlmon.

Set-up

    chmod 744 mysql_varmon.sh

Usage

    ./mysql_varmon.sh

– prompts for host, username, and password (not echoed) of the MySQL server.

Ctrl + C to exit.


mysql_grants.sh

Purpose

List GRANTs.

Similar to pt-show-grants, with cleaner output.
Connect as root user.

Set-up

    chmod 744 mysql_grants.sh

Usage

    ./mysql_grants.sh

schema_cleaner.php

Purpose

PHP CLI script to reduce large schema files to just table definitions i.e. removing mysqldump comments and directives.

Usage

    php schema_tools/schema_cleaner.php <filename>

schema_summary.php

Purpose

PHP CLI script to extract a brief summary of table names and foreign keys from large unwieldy schema files.

The keyword option enables searching for keywords in table names and table contents.

Usage

    php schema_tools/schema_summary.php <filename> [keyword]

Example for querying a large schema file for user references in table names and columns:

    php schema_tools/schema_summary.php bigschema.sql user | less

schema_splitter.php

Purpose

PHP CLI script to split a large MySQL schema file by table definitions into separate .sql files.

Usage

    php schema_tools/schema_splitter.php <filename>

example:

    php schema_tools/schema_splitter.php ../schema_example/dbfilltest.sql

table_bench.php

Purpose

  • Time row inserts into a MySQL table through configuration toggles controlling transactions, prepared statements etc.
  • Provides a timing harness for altering mysqld variables.

Timings are often highly variable, and so require much averaging. Nevertheless, large time differences are noticeable for prepared statements and my.cnf variables adjusted for INSERTs.

Usage

  1. cd table_bench

  2. Set the database connection parameters in setup.php

  3. php setup.php

  4. Set the parameters in table_bench/config.php

  5. php table_bench.php

The above PHP files can also be executed through a web server.


table_sizer.php

Purpose

PHP CLI script to query MySQL table size properties, and if timestamps are available, provide an estimation of data insertion rates.

Usage

First, add the database connection and table parameters in the configuration section at the top of the script.

    php table_sizer.php

or if made executable:

    ./table_sizer.php

License

Scripts and executables released under the GPL v.3.

About

Custom MySQL utilities created for daily work.

License:GNU General Public License v3.0


Languages

Language:PHP 47.6%Language:C 28.2%Language:Shell 13.0%Language:Python 9.5%Language:Makefile 1.7%