<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h4 class="title">
      <a name="install-plugin">
      </a>
      15.7.4.4 INSTALL PLUGIN Statement
     </h4>
    </div>
   </div>
  </div>
  <a class="indexterm" name="idm46045171738464">
  </a>
  <a class="indexterm" name="idm46045171737376">
  </a>
  <a class="indexterm" name="idm46045171736304">
  </a>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa64526415"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">INSTALL</span> <span class="token keyword">PLUGIN</span> <em class="replaceable">plugin_name</em> <span class="token keyword">SONAME</span> <span class="token string">'<em class="replaceable">shared_library_name</em>'</span></code></pre>
  </div>
  <p>
   This statement installs a server plugin. It requires the
   <a class="link" href="privileges-provided.html#priv_insert">
    <code class="literal">
     INSERT
    </code>
   </a>
   privilege for the
   <code class="literal">
    mysql.plugin
   </code>
   system table because it adds a
        row to that table to register the plugin.
  </p>
  <p>
   <em class="replaceable">
    <code>
     plugin_name
    </code>
   </em>
   is the name of the plugin
        as defined in the plugin descriptor structure contained in the
        library file (see
   <a class="ulink" href="/doc/extending-mysql/8.4/en/plugin-data-structures.html" target="_top">
    Plugin Data Structures
   </a>
   ).
        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.
  </p>
  <p>
   <em class="replaceable">
    <code>
     shared_library_name
    </code>
   </em>
   is the name of
        the shared library that contains the plugin code. The name
        includes the file name extension (for example,
   <code class="filename">
    libmyplugin.so
   </code>
   ,
   <code class="filename">
    libmyplugin.dll
   </code>
   , or
   <code class="filename">
    libmyplugin.dylib
   </code>
   ).
  </p>
  <p>
   The shared library must be located in the plugin directory (the
        directory named by the
   <a class="link" href="server-system-variables.html#sysvar_plugin_dir">
    <code class="literal">
     plugin_dir
    </code>
   </a>
   system variable).
        The library must be in the plugin directory itself, not in a
        subdirectory. By default,
   <a class="link" href="server-system-variables.html#sysvar_plugin_dir">
    <code class="literal">
     plugin_dir
    </code>
   </a>
   is the
   <code class="filename">
    plugin
   </code>
   directory under the directory named
        by the
   <code class="literal">
    pkglibdir
   </code>
   configuration variable, but
        it can be changed by setting the value of
   <a class="link" href="server-system-variables.html#sysvar_plugin_dir">
    <code class="literal">
     plugin_dir
    </code>
   </a>
   at server startup.
        For example, set its value in a
   <code class="filename">
    my.cnf
   </code>
   file:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-ini"><div class="docs-select-all right" id="sa90331524"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-ini"><span class="token selector">[mysqld]</span>
<span class="token constant">plugin_dir</span><span class="token attr-value"><span class="token punctuation">=</span><em class="replaceable">/path/to/plugin/directory</em></span></code></pre>
  </div>
  <p>
   If the value of
   <a class="link" href="server-system-variables.html#sysvar_plugin_dir">
    <code class="literal">
     plugin_dir
    </code>
   </a>
   is a
        relative path name, it is taken to be relative to the MySQL base
        directory (the value of the
   <a class="link" href="server-system-variables.html#sysvar_basedir">
    <code class="literal">
     basedir
    </code>
   </a>
   system variable).
  </p>
  <p>
   <a class="link" href="install-plugin.html" title="15.7.4.4 INSTALL PLUGIN Statement">
    <code class="literal">
     INSTALL PLUGIN
    </code>
   </a>
   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. When the server shuts down, it executes
        the deinitialization function for each plugin that is loaded so
        that the plugin has a chance to perform any final cleanup.
  </p>
  <p>
   <a class="link" href="install-plugin.html" title="15.7.4.4 INSTALL PLUGIN Statement">
    <code class="literal">
     INSTALL PLUGIN
    </code>
   </a>
   also registers the
        plugin by adding a line that indicates the plugin name and
        library file name to the
   <code class="literal">
    mysql.plugin
   </code>
   system
        table. During the normal startup sequence, the server loads and
        initializes plugins registered in
   <code class="literal">
    mysql.plugin
   </code>
   . This means that a plugin is
        installed with
   <a class="link" href="install-plugin.html" title="15.7.4.4 INSTALL PLUGIN Statement">
    <code class="literal">
     INSTALL PLUGIN
    </code>
   </a>
   only once, not every time the server starts. If the server is
        started with the
   <a class="link" href="server-options.html#option_mysqld_skip-grant-tables">
    <code class="option">
     --skip-grant-tables
    </code>
   </a>
   option,
        plugins registered in the
   <code class="literal">
    mysql.plugin
   </code>
   table
        are not loaded and are unavailable.
  </p>
  <p>
   A plugin library can contain multiple plugins. For each of them
        to be installed, use a separate
   <a class="link" href="install-plugin.html" title="15.7.4.4 INSTALL PLUGIN Statement">
    <code class="literal">
     INSTALL
        PLUGIN
    </code>
   </a>
   statement. Each statement names a different
        plugin, but all of them specify the same library name.
  </p>
  <p>
   <a class="link" href="install-plugin.html" title="15.7.4.4 INSTALL PLUGIN Statement">
    <code class="literal">
     INSTALL PLUGIN
    </code>
   </a>
   causes the server
        to read option (
   <code class="filename">
    my.cnf
   </code>
   ) 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
   <code class="literal">
    loose
   </code>
   prefix is used). It is also possible to
        uninstall a plugin, edit
   <code class="filename">
    my.cnf
   </code>
   , and
        install the plugin again. Restarting the plugin this way enables
        it to the new option values without a server restart.
  </p>
  <p>
   For options that control individual plugin loading at server
        startup, see
   <a class="xref" href="plugin-loading.html" title="7.6.1 Installing and Uninstalling Plugins">
    Section 7.6.1, “Installing and Uninstalling Plugins”
   </a>
   . If you need to
        load plugins for a single server startup when the
   <a class="link" href="server-options.html#option_mysqld_skip-grant-tables">
    <code class="option">
     --skip-grant-tables
    </code>
   </a>
   option is
        given (which tells the server not to read system tables), use
        the
   <a class="link" href="server-options.html#option_mysqld_plugin-load">
    <code class="option">
     --plugin-load
    </code>
   </a>
   option. See
   <a class="xref" href="server-options.html" title="7.1.7 Server Command Options">
    Section 7.1.7, “Server Command Options”
   </a>
   .
  </p>
  <p>
   To remove a plugin, use the
   <a class="link" href="uninstall-plugin.html" title="15.7.4.6 UNINSTALL PLUGIN Statement">
    <code class="literal">
     UNINSTALL
        PLUGIN
    </code>
   </a>
   statement.
  </p>
  <p>
   For additional information about plugin loading, see
   <a class="xref" href="plugin-loading.html" title="7.6.1 Installing and Uninstalling Plugins">
    Section 7.6.1, “Installing and Uninstalling Plugins”
   </a>
   .
  </p>
  <p>
   To see what plugins are installed, use the
   <a class="link" href="show-plugins.html" title="15.7.7.27 SHOW PLUGINS Statement">
    <code class="literal">
     SHOW PLUGINS
    </code>
   </a>
   statement or query
        the
   <code class="literal">
    INFORMATION_SCHEMA
   </code>
   the
   <a class="link" href="information-schema-plugins-table.html" title="28.3.22 The INFORMATION_SCHEMA PLUGINS Table">
    <code class="literal">
     PLUGINS
    </code>
   </a>
   table.
  </p>
  <p>
   If you recompile a plugin library and need to reinstall it, you
        can use either of the following methods:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      Use
      <a class="link" href="uninstall-plugin.html" title="15.7.4.6 UNINSTALL PLUGIN Statement">
       <code class="literal">
        UNINSTALL PLUGIN
       </code>
      </a>
      to
            uninstall all plugins in the library, install the new plugin
            library file in the plugin directory, and then use
      <a class="link" href="install-plugin.html" title="15.7.4.4 INSTALL PLUGIN Statement">
       <code class="literal">
        INSTALL PLUGIN
       </code>
      </a>
      to install all
            plugins in the library. This procedure has the advantage
            that it can be used without stopping the server. However, if
            the plugin library contains many plugins, you must issue
            many
      <a class="link" href="install-plugin.html" title="15.7.4.4 INSTALL PLUGIN Statement">
       <code class="literal">
        INSTALL PLUGIN
       </code>
      </a>
      and
      <a class="link" href="uninstall-plugin.html" title="15.7.4.6 UNINSTALL PLUGIN Statement">
       <code class="literal">
        UNINSTALL PLUGIN
       </code>
      </a>
      statements.
     </p>
    </li>
    <li class="listitem">
     <p>
      Stop the server, install the new plugin library file in the
            plugin directory, and restart the server.
     </p>
    </li>
   </ul>
  </div>
 </div>
 <br/>
</div>
