Selected Revision
2012-03-07 07:27
Compare To
2010-08-23 13:55
Additions Deletions

Excerpt Diff [16]

Install a plugin

Answer Diff [447]

== Syntax: ¶

<<fixed>> ¶
[PLUGIN plugin_name] SONAME 'plugin_library' ¶
<</fixed>> ¶

== Description: ¶

This statement installs a plugin. ¶

<<fixed>>plugin_name<</fixed>> is the name of the plugin as defined in the ¶
plugin declaration structure contained in the library file. Plugin names are ¶
not case sensitive. For maximal compatibility, plugin names should be limited ¶
to ASCII letters, digits, and underscore, because they are used in C source ¶
files, shell command lines, M4 and Bourne shell scripts, and SQL environments.
Starting from 5.5.21, a plugin name can be omitted. It means that MariaDB will load **all** plugins from the specified ##plugin_library##.

<<fixed>>plugin_library<</fixed>> is the name of the shared library that ¶
contains the plugin code.
The nameIn MariaDB before 5.5.21 the name should includes the file name extension (for ¶
example, or ##libmyplugin.dylibll##). Starting from 5.5.21, the file name extension can be omitted (which makes the statement look the same on all architectures). ¶

The shared library must be located in the plugin directory (that is, ¶
the directory named by the plugin_dir system variable). The library ¶
must be in the plugin directory itself, not in a subdirectory. By ¶
default, plugin_dir is plugin directory under the directory named by ¶
the pkglibdir configuration variable, but it can be changed by setting ¶
the value of <<fixed>>plugin_dir<</fixed>> at server startup. For example, set ¶
its value in a my.cnf file: ¶

<<fixed>> ¶
[mysqld] ¶
plugin_dir=/path/to/plugin/directory ¶
<</fixed>> ¶

If the value of <<fixed>>plugin_dir<</fixed>> is a relative path name, it is ¶
taken to be relative to the MySQL base directory (the value of the basedir ¶
system variable). ¶

<<fixed>>INSTALL PLUGIN<</fixed>> adds a line to the mysql.plugin table that ¶
describes the plugin. This table contains the plugin name and library file ¶
name. ¶

As of MySQL 5.1.33, <<fixed>>INSTALL PLUGIN<</fixed>> causes the server to read ¶
option (my.cnf) files just as during server startup. This enables the plugin to ¶
pick up any relevant options from those files. It is possible to add plugin ¶
options to an option file even before loading a plugin (if the loose prefix is ¶
used). It is also possible to uninstall a plugin, edit my.cnf, and install the ¶
plugin again. Restarting the plugin this way enables it to the new option ¶
values without a server restart. ¶

Before MySQL 5.1.33, a plugin is started with each option set to its ¶
default value. ¶

<<fixed>>INSTALL PLUGIN<</fixed>> also loads and initializes the plugin code to ¶
make the plugin available for use. A plugin is initialized by executing its ¶
initialization function, which handles any setup that the plugin must perform ¶
before it can be used. ¶

To use <<fixed>>INSTALL PLUGIN<</fixed>>, you must have the ¶
<<fixed>>[[grant|INSERT privilege]]<</fixed>> for the mysql.plugin table. ¶

At server startup, the server loads and initializes any plugin that is ¶
listed in the mysql.plugin table. This means that a plugin is installed ¶
with <<code>>INSTALL PLUGIN<</code>> only once, not every time the server ¶
starts. Plugin loading at startup does not occur if the server is started with ¶
the <<code>>--skip-grant-tables<</code>> option. ¶

When the server shuts down, it executes the deinitialization function ¶
for each plugin that is loaded so that the plugin has a change to ¶
perform any final cleanup. ¶

If you need to load plugins for a single server startup when the ¶
<<fixed>>--skip-grant-tables<</fixed>> option is given (which tells the server ¶
not to read system tables), use the ¶
<<fixed>>--plugin-load<</fixed>> option. ¶

== Examples: ¶

<<code>> ¶
MariaDB [(none)]> INSTALL PLUGIN sphinx SONAME ''; ¶
Query OK, 0 rows affected (0.00 sec)

# starting from 5.5.21 one can also write ¶
MariaDB [(none)]> INSTALL SONAME 'ha_xtradb'; ¶
Query OK, 0 rows affected (0.00 sec)

<</code>> ¶

== See Also: ¶

* [[uninstall-plugin|UNINSTALL PLUGIN]] ¶