Skip to content
master
Go to file
Code

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 

README.md

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 posesses 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_summary.php

Purpose

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

The optional keyword enables the script to search a large schema for keywords in table names (and table contents).

Usage

    php schema_summary.php <filename> [keyword]

example for querying a large schema file for user references in table names and table fields / keys:

    php 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_splitter.php <filename>

example:

    php schema_splitter.php schema_example/dbfilltest.sql

table_bench.php

Purpose

  • Time row inserts into a MySQL table through configuration toggles controlling connection API, transactions etc.

  • Provides a timing harness for altering mysqld variables.

Timings are often highly variable, 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

innodb_status_parser.py

Purpose

Extract and highlight some of the important items of the InnoDB monitor output.

Requirements

Python 2 or Python 3.

Set-up

Check CONFIG section parameters, and edit if required.

Usage

    python innodb_status_parser.py

or

    chmod 744 innodb_status_parser.py
    ./innodb_status_parser.py

prompts for the password (not echoed) of the MySQL server.

If USE_FILE in the top configuration section is set to True, the script will attempt to parse a previous file dump (FILENAME default is example.txt) of the InnoDB monitor output.


License

Scripts and executables released under the GPL v.3.

About

Random MySQL utilities created for daily work.

Resources

License

Packages

No packages published
You can’t perform that action at this time.