<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h4 class="title">
      <a name="multiple-windows-command-line-servers">
      </a>
      7.8.2.1 Starting Multiple MySQL Instances at the Windows Command Line
     </h4>
    </div>
   </div>
  </div>
  <p>
   The procedure for starting a single MySQL server manually from
        the command line is described in
   <a class="xref" href="windows-start-command-line.html" title="2.3.3.6 Starting MySQL from the Windows Command Line">
    Section 2.3.3.6, “Starting MySQL from the Windows Command Line”
   </a>
   . To start multiple
        servers this way, you can specify the appropriate options on the
        command line or in an option file. It is more convenient to
        place the options in an option file, but it is necessary to make
        sure that each server gets its own set of options. To do this,
        create an option file for each server and tell the server the
        file name with a
   <a class="link" href="option-file-options.html#option_general_defaults-file">
    <code class="option">
     --defaults-file
    </code>
   </a>
   option when you run it.
  </p>
  <p>
   Suppose that you want to run one instance of
   <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
    <span class="command">
     <strong>
      mysqld
     </strong>
    </span>
   </a>
   on port 3307 with a data directory of
   <code class="filename">
    C:\mydata1
   </code>
   , and another instance on port
        3308 with a data directory of
   <code class="filename">
    C:\mydata2
   </code>
   .
        Use this procedure:
  </p>
  <div class="orderedlist">
   <ol class="orderedlist" type="1">
    <li class="listitem">
     <p>
      Make sure that each data directory exists, including its own
            copy of the
      <code class="literal">
       mysql
      </code>
      database that contains
            the grant tables.
     </p>
    </li>
    <li class="listitem">
     <p>
      Create two option files. For example, create one file named
      <code class="filename">
       C:\my-opts1.cnf
      </code>
      that looks like this:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-ini"><div class="docs-select-all right" id="sa87046271"><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">datadir</span> <span class="token attr-value"><span class="token punctuation">=</span> C:/mydata1</span>
<span class="token constant">port</span> <span class="token attr-value"><span class="token punctuation">=</span> 3307</span></code></pre>
     </div>
     <p>
      Create a second file named
      <code class="filename">
       C:\my-opts2.cnf
      </code>
      that looks like this:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-ini"><div class="docs-select-all right" id="sa37026408"><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">datadir</span> <span class="token attr-value"><span class="token punctuation">=</span> C:/mydata2</span>
<span class="token constant">port</span> <span class="token attr-value"><span class="token punctuation">=</span> 3308</span></code></pre>
     </div>
    </li>
    <li class="listitem">
     <p>
      Use the
      <a class="link" href="option-file-options.html#option_general_defaults-file">
       <code class="option">
        --defaults-file
       </code>
      </a>
      option to start each server with its own option file:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa83222930"><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-terminal"><span class="token prompt">C:\&gt;</span><span class="token command"> C:\mysql\bin\mysqld</span> <span class="token constant">--defaults-file</span><span class="token attr-value"><span class="token punctuation">=</span>C:\my-opts1.cnf</span>
<span class="token prompt">C:\&gt;</span><span class="token command"> C:\mysql\bin\mysqld</span> <span class="token constant">--defaults-file</span><span class="token attr-value"><span class="token punctuation">=</span>C:\my-opts2.cnf</span></code></pre>
     </div>
     <p>
      Each server starts in the foreground (no new prompt appears
            until the server exits later), so you need to issue those
            two commands in separate console windows.
     </p>
    </li>
   </ol>
  </div>
  <p>
   To shut down the servers, connect to each using the appropriate
        port number:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa13196989"><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-terminal"><span class="token prompt">C:\&gt;</span><span class="token command"> C:\mysql\bin\mysqladmin</span> <span class="token constant">--port</span><span class="token attr-value"><span class="token punctuation">=</span>3307</span> <span class="token constant">--host</span><span class="token attr-value"><span class="token punctuation">=</span>127.0.0.1</span> <span class="token constant">--user</span><span class="token attr-value"><span class="token punctuation">=</span>root</span> <span class="token property">--password</span> shutdown
<span class="token prompt">C:\&gt;</span><span class="token command"> C:\mysql\bin\mysqladmin</span> <span class="token constant">--port</span><span class="token attr-value"><span class="token punctuation">=</span>3308</span> <span class="token constant">--host</span><span class="token attr-value"><span class="token punctuation">=</span>127.0.0.1</span> <span class="token constant">--user</span><span class="token attr-value"><span class="token punctuation">=</span>root</span> <span class="token property">--password</span> shutdown</code></pre>
  </div>
  <p>
   Servers configured as just described permit clients to connect
        over TCP/IP. If your version of Windows supports named pipes and
        you also want to permit named-pipe connections, specify options
        that enable the named pipe and specify its name. Each server
        that supports named-pipe connections must use a unique pipe
        name. For example, the
   <code class="filename">
    C:\my-opts1.cnf
   </code>
   file
        might be written like this:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-ini"><div class="docs-select-all right" id="sa89201523"><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">datadir</span> <span class="token attr-value"><span class="token punctuation">=</span> C:/mydata1</span>
<span class="token constant">port</span> <span class="token attr-value"><span class="token punctuation">=</span> 3307</span>
<span class="token constant">enable-named-pipe</span>
<span class="token constant">socket</span> <span class="token attr-value"><span class="token punctuation">=</span> mypipe1</span></code></pre>
  </div>
  <p>
   Modify
   <code class="filename">
    C:\my-opts2.cnf
   </code>
   similarly for use by
        the second server. Then start the servers as described
        previously.
  </p>
  <p>
   A similar procedure applies for servers that you want to permit
        shared-memory connections. Enable such connections by starting
        the server with the
   <a class="link" href="server-system-variables.html#sysvar_shared_memory">
    <code class="literal">
     shared_memory
    </code>
   </a>
   system variable
        enabled and specify a unique shared-memory name for each server
        by setting the
   <a class="link" href="server-system-variables.html#sysvar_shared_memory_base_name">
    <code class="literal">
     shared_memory_base_name
    </code>
   </a>
   system
        variable.
  </p>
 </div>
 <br/>
</div>
