Utilities

MySQL ships with a set of command-line programs for running the server, checking and repairing data files, performing backup and recovery, managing security, and routing connections. On Windows, first add the MySQL binary directory to the path (run the command prompt as Administrator):

path=%path%;"c:\progra~1\MySQL\MySQL Server 8.0\bin"

Adds the MySQL bin directory to the current session's search path on Windows.

Instance & Server


Checking


Backup & Recovery


Security


InnoDB & MyISAM


MySQL Router

mysqlrouter is part of InnoDB Cluster: lightweight middleware providing transparent routing between an application and back-end MySQL servers, used for high availability and scalability by routing traffic to the appropriate back-end server.

mysqlrouter --bootstrap localhost:3310 --directory /opt/myrouter --user snoopy

Bootstraps a Router instance against a target and writes its configuration to the given directory.

mysqlrouter_keyring is a command-line application for managing MySQL Router key rings; mysqlrouter_plugin_info is a debugging tool that inspects a Router plugin for potential conflicts and general problems.

# Add MySQL's bin directory to PATH (Windows, run as Administrator)
path=%path%;"c:\progra~1\MySQL\MySQL Server 8.0\bin"

# Check the server's status and variables
mysqladmin -uroot -p status
mysqladmin -uroot -p variables

# Read a binary log in text form
mysqlbinlog mysql-bin.000001 > mysql-bin.000001.txt

# Check, repair, and optimize every table in a database
mysqlcheck --check --repair --optimize -uroot -p mydb

# Quickly inspect a database's tables/columns without a SQL client
mysqlshow mydb
mysqlshow mydb tbl

# Load test/benchmark load against a server
mysqlslap --auto-generate-sql --concurrency=50 --iterations=10

# Look up the meaning of an error code
perror 1146

# Store credentials so client tools do not need -p on every call
mysql_config_editor set --login-path=local --host=localhost --user=root --password

# Harden a fresh installation
mysql_secure_installation

# Verify InnoDB page checksums
innochecksum /var/lib/mysql/mydb/mytable.ibd

# Bootstrap MySQL Router against a target instance
mysqlrouter --bootstrap localhost:3310 --directory /opt/myrouter --user snoopy