MySQL Shell plugins can be used to contain functions that are registered as MySQL Shell reports (see Section 10.1, “Reporting with MySQL Shell”), and functions that are members of extension objects that are made available by user-defined MySQL Shell global objects (see Section 10.2, “Adding Extension Objects to MySQL Shell”). A single plugin can contain and register more than one function, and can contain a mix of reports and members of extension objects. Functions that are registered as reports or members of extension objects by a MySQL Shell plugin are available immediately when MySQL has completed startup.
A MySQL Shell plugin is a folder containing an initialization
script appropriate for the language (an
file). The initialization script is the entry point for the
plugin. A plugin can only contain code in one language, so if you
are creating an extension object with a mix of members defined in
members as separate language-appropriate plugins.
For a MySQL Shell plugin to be loaded automatically at startup,
its folder must be located under the
folder in the MySQL Shell user configuration path. MySQL Shell
searches for any initialization scripts in this location.
MySQL Shell ignores any folders in the
plugins location whose name begins with a dot
(.) but otherwise the name you use for a plugin's folder is not
The default path for the
plugins folder is
~/.mysqlsh/plugins on Unix and
%AppData%\MySQL\mysqlsh\plugins in Windows.
The user configuration path can be overridden on all platforms by
defining the environment variable
MYSQLSH_USER_CONFIG_HOME. The value of this
~/.mysqlsh/ on Unix.
When an error is found while loading plugins, a warning is shown
and the error details are available in the MySQL Shell
application log. To see more details on the loading process use
--log-level=debug option when starting
When a MySQL Shell plugin is loaded, the following objects are available as global variables:
The built in global objects
The Shell API main module
The X DevAPI main module
The AdminAPI main module