<div id="docs-body">
 <div class="chapter">
  <div class="titlepage">
   <div>
    <div>
     <h1 class="title">
      <a name="tutorial">
      </a>
      Chapter 5 Tutorial
     </h1>
    </div>
   </div>
  </div>
  <div class="toc">
   <p>
    <b>
     Table of Contents
    </b>
   </p>
   <dl class="toc">
    <dt>
     <span class="section">
      <a href="connecting-disconnecting.html">
       5.1 Connecting to and Disconnecting from the Server
      </a>
     </span>
    </dt>
    <dt>
     <span class="section">
      <a href="entering-queries.html">
       5.2 Entering Queries
      </a>
     </span>
    </dt>
    <dt>
     <span class="section">
      <a href="database-use.html">
       5.3 Creating and Using a Database
      </a>
     </span>
    </dt>
    <dd>
     <dl>
      <dt>
       <span class="section">
        <a href="creating-database.html">
         5.3.1 Creating and Selecting a Database
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="creating-tables.html">
         5.3.2 Creating a Table
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="loading-tables.html">
         5.3.3 Loading Data into a Table
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="retrieving-data.html">
         5.3.4 Retrieving Information from a Table
        </a>
       </span>
      </dt>
     </dl>
    </dd>
    <dt>
     <span class="section">
      <a href="getting-information.html">
       5.4 Getting Information About Databases and Tables
      </a>
     </span>
    </dt>
    <dt>
     <span class="section">
      <a href="batch-mode.html">
       5.5 Using mysql in Batch Mode
      </a>
     </span>
    </dt>
    <dt>
     <span class="section">
      <a href="examples.html">
       5.6 Examples of Common Queries
      </a>
     </span>
    </dt>
    <dd>
     <dl>
      <dt>
       <span class="section">
        <a href="example-maximum-column.html">
         5.6.1 The Maximum Value for a Column
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="example-maximum-row.html">
         5.6.2 The Row Holding the Maximum of a Certain Column
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="example-maximum-column-group.html">
         5.6.3 Maximum of Column per Group
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="example-maximum-column-group-row.html">
         5.6.4 The Rows Holding the Group-wise Maximum of a Certain Column
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="example-user-variables.html">
         5.6.5 Using User-Defined Variables
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="example-foreign-keys.html">
         5.6.6 Using Foreign Keys
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="searching-on-two-keys.html">
         5.6.7 Searching on Two Keys
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="calculating-days.html">
         5.6.8 Calculating Visits Per Day
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="example-auto-increment.html">
         5.6.9 Using AUTO_INCREMENT
        </a>
       </span>
      </dt>
     </dl>
    </dd>
    <dt>
     <span class="section">
      <a href="apache.html">
       5.7 Using MySQL with Apache
      </a>
     </span>
    </dt>
   </dl>
  </div>
  <a class="indexterm" name="idm46045325707536">
  </a>
  <a class="indexterm" name="idm46045325706464">
  </a>
  <a class="indexterm" name="idm46045325704976">
  </a>
  <a class="indexterm" name="idm46045325703488">
  </a>
  <p>
   This chapter provides a tutorial introduction to MySQL by showing
    how to use the
   <a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
    <span class="command">
     <strong>
      mysql
     </strong>
    </span>
   </a>
   client program to create and
    use a simple database.
   <a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
    <span class="command">
     <strong>
      mysql
     </strong>
    </span>
   </a>
   (sometimes referred
    to as the
   <span class="quote">
    “
    <span class="quote">
     terminal monitor
    </span>
    ”
   </span>
   or just
   <span class="quote">
    “
    <span class="quote">
     monitor
    </span>
    ”
   </span>
   ) is an interactive program that enables you
    to connect to a MySQL server, run queries, and view the results.
   <a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
    <span class="command">
     <strong>
      mysql
     </strong>
    </span>
   </a>
   may also be used in batch mode: you place
    your queries in a file beforehand, then tell
   <a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
    <span class="command">
     <strong>
      mysql
     </strong>
    </span>
   </a>
   to execute the contents of the file. Both
    ways of using
   <a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
    <span class="command">
     <strong>
      mysql
     </strong>
    </span>
   </a>
   are covered here.
  </p>
  <p>
   To see a list of options provided by
   <a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
    <span class="command">
     <strong>
      mysql
     </strong>
    </span>
   </a>
   ,
    invoke it with the
   <a class="link" href="mysql-command-options.html#option_mysql_help">
    <code class="option">
     --help
    </code>
   </a>
   option:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa10502551"><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">$&gt; </span><span class="token command">mysql</span> <span class="token property">--help</span></code></pre>
  </div>
  <p>
   This chapter assumes that
   <a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
    <span class="command">
     <strong>
      mysql
     </strong>
    </span>
   </a>
   is installed on
    your machine and that a MySQL server is available to which you can
    connect. If this is not true, contact your MySQL administrator. (If
   <span class="emphasis">
    <em>
     you
    </em>
   </span>
   are the administrator, you need to consult
    the relevant portions of this manual, such as
   <a class="xref" href="server-administration.html" title="Chapter 7 MySQL Server Administration">
    Chapter 7,
    <i>
     MySQL Server Administration
    </i>
   </a>
   .)
  </p>
  <p>
   This chapter describes the entire process of setting up and using a
    database. If you are interested only in accessing an existing
    database, you may want to skip the sections that describe how to
    create the database and the tables it contains.
  </p>
  <p>
   Because this chapter is tutorial in nature, many details are
    necessarily omitted. Consult the relevant sections of the manual for
    more information on the topics covered here.
  </p>
 </div>
 <br/>
</div>
