<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h4 class="title">
      <a name="install-component">
      </a>
      15.7.4.3 INSTALL COMPONENT Statement
     </h4>
    </div>
   </div>
  </div>
  <a class="indexterm" name="idm46045171801904">
  </a>
  <a class="indexterm" name="idm46045171800816">
  </a>
  <a class="indexterm" name="idm46045171799744">
  </a>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa64657889"><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">COMPONENT</span> <em class="replaceable">component_name</em>  <span class="token punctuation">[</span><span class="token punctuation">,</span> <em class="replaceable">component_name</em> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
     <span class="token punctuation">[</span><span class="token keyword">SET</span> <em class="replaceable">variable</em> <span class="token operator">=</span> <em class="replaceable">expr</em> <span class="token punctuation">[</span><span class="token punctuation">,</span> <em class="replaceable">variable</em> <span class="token operator">=</span> <em class="replaceable">expr</em><span class="token punctuation">]</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">]</span> 
  
  <em class="replaceable">variable</em>: {
    {<span class="token keyword">GLOBAL</span> <span class="token operator">|</span> <span class="token variable">@@GLOBAL.</span>} <span class="token punctuation">[</span><em class="replaceable">component_prefix</em><span class="token punctuation">.</span><span class="token punctuation">]</span><em class="replaceable">system_var_name</em>
  <span class="token operator">|</span> {<span class="token keyword">PERSIST</span> <span class="token operator">|</span> <span class="token variable">@@PERSIST.</span>} <span class="token punctuation">[</span><em class="replaceable">component_prefix</em><span class="token punctuation">.</span><span class="token punctuation">]</span><em class="replaceable">system_var_name</em>
}</code></pre>
  </div>
  <p>
   This statement installs one or more components, which become
        active immediately. A component provides services that are
        available to the server and other components; see
   <a class="xref" href="components.html" title="7.5 MySQL Components">
    Section 7.5, “MySQL Components”
   </a>
   .
   <a class="link" href="install-component.html" title="15.7.4.3 INSTALL COMPONENT Statement">
    <code class="literal">
     INSTALL
        COMPONENT
    </code>
   </a>
   requires the
   <a class="link" href="privileges-provided.html#priv_insert">
    <code class="literal">
     INSERT
    </code>
   </a>
   privilege for the
   <code class="literal">
    mysql.component
   </code>
   system table because it adds
        a row to that table to register the component.
  </p>
  <p>
   Example:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa95697724"><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">COMPONENT</span> <span class="token string">'file://component1'</span><span class="token punctuation">,</span> <span class="token string">'file://component2'</span><span class="token punctuation">;</span></code></pre>
  </div>
  <p>
   A component is named using a URN that begins with
   <code class="literal">
    file://
   </code>
   and indicates the base name of the
        library file that implements the component, located in 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.
        Component names do not include any platform-dependent file name
        suffix such as
   <code class="filename">
    .so
   </code>
   or
   <code class="filename">
    .dll
   </code>
   . (These naming details are subject to
        change because component name interpretation is itself performed
        by a service and the component infrastructure makes it possible
        to replace the default service implementation with alternative
        implementations.)
  </p>
  <p>
   <a class="link" href="install-component.html" title="15.7.4.3 INSTALL COMPONENT Statement">
    <code class="literal">
     INSTALL COMPONENT
    </code>
   </a>
   permits setting
        the values of component system variables when you install one or
        more components. The
   <code class="literal">
    SET
   </code>
   clause enables you
        to specify variable values precisely when they are needed,
        without the inconvenience or limitations associated with other
        forms of assignment. Specifically, you can also set component
        variables with these alternatives:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      At server startup using options on the command line or in an
            option file, but doing so involves a server restart. The
            values do not take effect until you install the component.
            You can specify an invalid variable name for a component on
            the command line without triggering an error.
     </p>
    </li>
    <li class="listitem">
     <p>
      Dynamically while the server is running by means of the
      <a class="link" href="set.html" title="13.3.6 The SET Type">
       <code class="literal">
        SET
       </code>
      </a>
      statement, which enables
            you to modify operation of the server without having to stop
            and restart it. Setting a read-only variable is not
            permitted.
     </p>
    </li>
   </ul>
  </div>
  <p>
   The optional
   <code class="literal">
    SET
   </code>
   clause applies a value, or
        values, only to the component specified in the
   <a class="link" href="install-component.html" title="15.7.4.3 INSTALL COMPONENT Statement">
    <code class="literal">
     INSTALL COMPONENT
    </code>
   </a>
   statement,
        rather than to all subsequent installations of that component.
   <code class="literal">
    SET GLOBAL|PERSIST
   </code>
   works for all types of
        variables, including read-only variables, without having to
        restart the server. A component system variable that you set
        using
   <a class="link" href="install-component.html" title="15.7.4.3 INSTALL COMPONENT Statement">
    <code class="literal">
     INSTALL COMPONENT
    </code>
   </a>
   takes
        precedence over any conflicting value coming from the command
        line or an option file.
  </p>
  <p>
   Example:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa29517664"><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">COMPONENT</span> <span class="token string">'file://component1'</span><span class="token punctuation">,</span> <span class="token string">'file://component2'</span> 
    <span class="token keyword">SET</span> <span class="token keyword">GLOBAL</span> component1<span class="token punctuation">.</span>var1 <span class="token operator">=</span> <span class="token number">12</span> <span class="token operator">+</span> <span class="token number">3</span><span class="token punctuation">,</span> <span class="token keyword">PERSIST</span> component2<span class="token punctuation">.</span>var2 <span class="token operator">=</span> <span class="token string">'strings'</span><span class="token punctuation">;</span></code></pre>
  </div>
  <p>
   Omitting
   <code class="literal">
    PERSIST
   </code>
   or
   <code class="literal">
    GLOBAL
   </code>
   is equivalent to specifying
   <code class="literal">
    GLOBAL
   </code>
   .
  </p>
  <p>
   Specifying
   <code class="literal">
    PERSIST
   </code>
   for any variable in
   <code class="literal">
    SET
   </code>
   silently executes
   <code class="literal">
    SET
        PERSIST_ONLY
   </code>
   immediately after
   <a class="link" href="install-component.html" title="15.7.4.3 INSTALL COMPONENT Statement">
    <code class="literal">
     INSTALL COMPONENT
    </code>
   </a>
   loads the
        components, but before updating the
   <code class="literal">
    mysql.component
   </code>
   table. If
   <code class="literal">
    SET
        PERSIST_ONLY
   </code>
   fails, then the server unloads all of the
        previously loaded new components without persisting anything to
   <code class="literal">
    mysql.component
   </code>
   .
  </p>
  <p>
   The
   <code class="literal">
    SET
   </code>
   clause accepts only valid variable
        names of the component being installed and emits an error
        message for all invalid names. Subqueries, stored functions, and
        aggregate functions are not permitted as part of the value
        expression. If you install a single component, it is not
        necessary to prefix the variable name with the component name.
  </p>
  <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
   <div class="admon-title">
    Note
   </div>
   <p>
    While specifying a variable value using the
    <code class="literal">
     SET
    </code>
    clause is similar to that of the
          command line—it is available immediately at variable
          registration—there is a distinct difference in how the
    <code class="literal">
     SET
    </code>
    clause handles
    <span class="emphasis">
     <em>
      invalid
          numerical
     </em>
    </span>
    values for boolean variables. For
          example, if you set a boolean variable to 11
          (
    <code class="literal">
     component1.boolvar = 11
    </code>
    ), you see the
          following behavior:
   </p>
   <div class="itemizedlist">
    <ul class="itemizedlist" style="list-style-type: disc; ">
     <li class="listitem">
      <p>
       <code class="literal">
        SET
       </code>
       clause yields true
      </p>
     </li>
     <li class="listitem">
      <p>
       Command line yields false (11 is neither ON nor 1)
      </p>
     </li>
    </ul>
   </div>
  </div>
  <p>
   If any error occurs, the statement fails and has no effect. For
        example, this happens if a component name is erroneous, a named
        component does not exist or is already installed, or component
        initialization fails.
  </p>
  <p>
   A loader service handles component loading, which includes
        adding installed components to the
   <code class="literal">
    mysql.component
   </code>
   system table that serves as a
        registry. For subsequent server restarts, any components listed
        in
   <code class="literal">
    mysql.component
   </code>
   are loaded by the loader
        service during the startup sequence. This occurs even 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.
  </p>
  <p>
   If a component depends on services not present in the registry
        and you attempt to install the component without also installing
        the component or components that provide the services on which
        it depends, an error occurs:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-none"><div class="docs-select-all right" id="sa78619415"><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-none">ERROR 3527 (HY000): Cannot satisfy dependency for service 'component_a'
required by component 'component_b'.</code></pre>
  </div>
  <p>
   To avoid this problem, either install all components in the same
        statement, or install the dependent component after installing
        any components on which it depends.
  </p>
  <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
   <div class="admon-title">
    Note
   </div>
   <p>
    For keyring components, do not use
    <a class="link" href="install-component.html" title="15.7.4.3 INSTALL COMPONENT Statement">
     <code class="literal">
      INSTALL COMPONENT
     </code>
    </a>
    . Instead,
          configure keyring component loading using a manifest file. See
    <a class="xref" href="keyring-component-installation.html" title="8.4.4.2 Keyring Component Installation">
     Section 8.4.4.2, “Keyring Component Installation”
    </a>
    .
   </p>
  </div>
 </div>
 <br/>
</div>
